jiazx0107@163.com
2023-11-09 1f5947ccb5b02817dbe5aaae943c0a7fcfc2cd62
Merge remote-tracking branch 'origin/igds-api-gateway' into igds-api-gateway
已修改5个文件
125 ■■■■ 文件已修改
src/main/java/com/fzzy/gateway/hx2023/service/HxGatewayRemoteServiceImpl.java 77 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/fzzy/gateway/hx2023/service/HxGatewaySyncGrainImpl.java 27 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/fzzy/gateway/service/GatewayConfService.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/fzzy/gateway/service/GatewayDeviceService.java 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/fzzy/gateway/view/GatewayConf.view.xml 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/fzzy/gateway/hx2023/service/HxGatewayRemoteServiceImpl.java
@@ -2,10 +2,7 @@
import com.alibaba.fastjson2.JSONObject;
import com.fzzy.api.data.PushProtocol;
import com.fzzy.api.utils.MyMD5Util;
import com.fzzy.api.utils.RSAUtils;
import com.fzzy.api.utils.RedisConst;
import com.fzzy.api.utils.RedisUtil;
import com.fzzy.api.utils.*;
import com.fzzy.api.view.repository.ApiLogRep;
import com.fzzy.gateway.service.GatewayConfService;
import com.fzzy.gateway.util.GatewayHttpUtil;
@@ -20,8 +17,11 @@
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.io.UnsupportedEncodingException;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Map;
import java.util.TreeMap;
@Slf4j
@@ -164,6 +164,28 @@
    public String getSign(Map<String, String> parames, String priKey) {
        //参数拼接
        String msg = "";
        parames = sortMapKey(parames);
        for (Map.Entry<String, String> param : parames.entrySet()) {
            msg += param.getKey() + "=" + param.getValue() + "&";
        }
        msg = msg.substring(0, msg.length() - 1);
        log.debug("------待加密信息-----{}", msg);
        //MD5加密
        String md5sign = MyMD5Util.getMD5(msg);
        log.debug("------md5加密-----{}", md5sign);
        //RSA加密
        String result = GatewayRSAUtils.encryptByPrivate(md5sign, priKey);
        log.debug("------RSA加密-----{}", result);
        return result;
    }
    public static String getSign2(Map<String, String> parames, String priKey) {
        //参数拼接
        String msg = "";
        parames = sortMapKey(parames);
        for (Map.Entry<String, String> param : parames.entrySet()) {
            msg += param.getKey() + "=" + param.getValue() + "&";
        }
@@ -182,7 +204,6 @@
        return result;
    }
    /**
     * @param kqdm
     * @return
@@ -197,5 +218,51 @@
    }
    private static Map<String, String> sortMapKey(Map<String, String> map){
        if(map == null || map.isEmpty()){
            return  null;
        }
        Map<String, String> sortMap = new TreeMap<>(new Comparator<String>() {
            @Override
            public int compare(String o1, String o2) {
                return o1.compareTo(o2);
            }
        });
        sortMap.putAll(map);
        return sortMap;
    }
    public static void main(String[] args) throws UnsupportedEncodingException {
        //网关心跳接口
//        Map<String, String> params = new HashMap<>();
//        //params.put("token", "");
//        params.put("gatewayId", "6e3d92ff71b911eea5e50250f2000002");
//        params.put("gatewayIp", "123");
//        params.put("gatewayMac", "123");
//        params.put("gatewayCPU","123");
//        params.put("gatewayMem", "123");
//        params.put("gatewayHardDisk", "123");
//        params.put("timestamp", "2023-10-31 12:12:12");
//        String sign = getSign2(params,"MIIBVQIBADANBgkqhkiG9w0BAQEFAASCAT8wggE7AgEAAkEA0lg35sJGRyUFEDzt\np9pWvc0JD+0+SmiZIgMbUaEM5gqBsvUJ9LnzB0rpMTbuqAxAFbUH1Nw4qXdJVnKS\nRYfPgQIDAQABAkBPkxIq2Uou9gFRYEtkGcSA70VDYjQTgDiWVmiKXAv+JkEJmOno\\nMrHYQGAiP0q4xW66F+CLNCrGPVJns2ywMxwxAiEA/vyNX5M0/t+RHAxpMp484i9T\nb5Qf+HvepOV3c0UGZx0CIQDTLj4+qgoXGOLCM9/dzVJZ04VIjK6u546z22hXFWgI\ntQIhAMWFP8JMlx3kc1UF7Cuw1jrkLD7fwJBM7CBSPODHFHmlAiEAhv4Hcf02B/+z\nbBrG3rzSCHOKvo6XV1zTvqrhLtGTOAUCIGmoaIDgTuS0ZF71+c9mYvPVNL0T02GQ\nE8Y3ExreQphx");
//        params.put("sign", sign);
//
//        System.out.println(sign);
        byte[] encryptedData = GatewayRSAUtils.decryptBase64("yx7jNj9DGS7AkH/sXo5IrwaGNCSUnAZFmjXwWovMBfvYGVQur1RELXUu4fqIMZZ/ck6CAA3ESOJCS+aCD0aVdA==");
        StringBuilder hexString = new StringBuilder();
        for (byte b : encryptedData) {
            String hex = Integer.toHexString(0xFF & b);
            if (hex.length() == 1) {
                hexString.append('0');
            }
            hexString.append(hex);
        }
        String hexStringResult = hexString.toString();
        System.out.println(hexStringResult);
        System.out.println(BytesUtil.bytesToString(GatewayRSAUtils.decryptBase64("mgtJOOn5iZBvmQI3hzvaw2J4BiZUcXhLTsgLk8++Ig2iIZcPaky7V+ylkA+BAYxIBS5ovHXjRo4w26TTEq9k7Q==")));
    }
}
src/main/java/com/fzzy/gateway/hx2023/service/HxGatewaySyncGrainImpl.java
@@ -70,8 +70,10 @@
        double tMIn = 20, tMax = 25;
        if (null != weather) {
            double tOut = Double.valueOf(weather.getTem());
            tMIn = tOut - 2;
            tMax = tOut + 3;
            tMIn = tOut - 4;
            if(tMIn < 4)tMIn = 5;
            tMax = tOut + 0;
            if(tMax< 15)tMax = 15;
        }
@@ -103,7 +105,26 @@
        double randomNumber = tMIn;
        int x = 0, y = 0, z = 0;
        for (int i = 0; i < sumNum; i++) {
            randomNumber = Math.random() * (tMax - tMIn + 1) + tMIn;
            if((i) % Integer.valueOf(cableRule[0]) == 0){
                randomNumber = Math.random() * (tMax - tMIn + 1) + tMIn;
            } else if ((i) % Integer.valueOf(cableRule[0]) == 1) {
                randomNumber = Math.random() * (tMax - tMIn + 1) + tMIn;
            }else if ((i) % Integer.valueOf(cableRule[0]) == 2) {
                randomNumber = Math.random() * (tMax - tMIn + 1) + tMIn;
            }else if ((i) % Integer.valueOf(cableRule[0]) == 3) {
                randomNumber = Math.random() * (tMax - tMIn + 1) + tMIn;
            }else if ((i) % Integer.valueOf(cableRule[0]) == 4) {
                randomNumber = Math.random() * (tMax - tMIn + 1) + tMIn;
            }else {
                randomNumber = Math.random() * (tMax - tMIn + 1) + tMIn;
            }
           // randomNumber = Math.random() * (tMax - tMIn + 1) + tMIn;
            curTemp = NumberUtil.keepPrecision(randomNumber, 1);
            position = i;
            z = i % cableZ + 1;
src/main/java/com/fzzy/gateway/service/GatewayConfService.java
@@ -49,6 +49,7 @@
        GatewayConf data = new GatewayConf();
        BeanUtils.copyProperties(entity, data);
        gatewayConfRep.save(data);
        updateCache(data);
    }
    /**
src/main/java/com/fzzy/gateway/service/GatewayDeviceService.java
@@ -24,6 +24,7 @@
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.math.RandomUtils;
import org.apache.commons.lang.time.DateFormatUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
@@ -32,10 +33,7 @@
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.stream.Collectors;
@Slf4j
@@ -126,9 +124,9 @@
     * @return
     */
    @Expose
    public String ajaxTestWeight(GateWayTestParam parameter) {
        double weigh = (double) parameter.getWeight();
        //double weigh = Double.parseDouble("3500.0");
    public String ajaxTestWeight() {
        //double weigh = (double) parameter.getWeight();
        double weigh = Math.random() * (35000 - 16000 + 1) + 16000;
        List<GatewayDevice> devices = listAll();
        if (devices == null || devices.size() <= 0) {
            return "没有设备";
@@ -203,7 +201,7 @@
            packet.setHeaders(header);
            packet.setMessageType(ScConstant.MESSAGE_TYPE_REPORT_PROPERTY);
            packet.setDeviceId(device.getDeviceId());
            packet.setMessageId(System.currentTimeMillis() + "");
            //设置信息主体
            LprData lpr = new LprData();
            lpr.setDeviceId(device.getDeviceId());
src/main/java/com/fzzy/gateway/view/GatewayConf.view.xml
@@ -170,6 +170,12 @@
        <Property name="iconClass">fa fa-search</Property>
        <Property name="exClassName">toolbar-button-push</Property>
      </ToolBarButton>
        <ToolBarButton>
            <ClientEvent name="onClick">view.get(&quot;#dialogLpr&quot;).show();</ClientEvent>
            <Property name="caption">车牌识别推送测试</Property>
            <Property name="iconClass">fa fa-search</Property>
            <Property name="exClassName">toolbar-button-push</Property>
        </ToolBarButton>
      <ToolBarButton>
        <Property name="caption">网关初始化</Property>
        <Property name="iconClass">fa fa-search</Property>