doum
5 天以前 7233f8c157e323f97a074753a2c4bd463f960b5c
新增智能电表、空调管理
已添加3个文件
已修改5个文件
1327 ■■■■■ 文件已修改
admin/.env.development 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
admin/src/views/business/deviceDianbiao.vue 39 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/visits/dmvisit_admin/src/main/java/com/doumee/device/ElectronicNotifyController.java 72 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/visits/dmvisit_admin/src/main/java/com/doumee/device/ElectronicSubscribeController.java 67 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/visits/dmvisit_admin/src/main/java/com/doumee/service/impl/HkSyncEventServiceImpl.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/visits/dmvisit_service/src/main/java/com/doumee/core/device/ElectronicToolUitl.java 1141 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/visits/dmvisit_service/src/main/java/com/doumee/dao/business/model/Device.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/visits/dmvisit_service/src/main/resources/application-dev.yml 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
admin/.env.development
@@ -3,9 +3,9 @@
# é¡¹ç›®ä¸Šä¸‹æ–‡è·¯å¾„
VUE_APP_CONTEXT_PATH = './'
#VUE_APP_API_URL  = 'http://localhost:10010'
VUE_APP_API_URL  = 'http://localhost:10010'
VUE_APP_API_URL  = 'http://192.168.1.44:10010'
#VUE_APP_API_URL  = 'http://192.168.1.44:10010'
#VUE_APP_API_URL  = 'https://zhcg.fnwtzx.com/gateway_interface'
admin/src/views/business/deviceDianbiao.vue
@@ -11,6 +11,13 @@
            <el-form-item title="设备号" prop="doorNo">
                <el-input v-model="searchForm.doorNo" placeholder="请输入设备号" @keypress.enter.native="search"></el-input>
            </el-form-item>
          <el-form-item label="运行状态" prop="status">
            <el-select v-model="searchForm.status" @keypress.enter.native="search" clearable placeholder="选择状态">
              <el-option label="合闸" value="0"></el-option>
              <el-option label="开闸" value="1"></el-option>
              <el-option label="开闸" value="2"></el-option>
            </el-select>
          </el-form-item>
            <section>
                <el-button type="primary" @click="search">搜索</el-button>
                <el-button @click="reset">重置</el-button>
@@ -19,7 +26,8 @@
        <!-- è¡¨æ ¼å’Œåˆ†é¡µ -->
        <template v-slot:table-wrap>
          <ul class="toolbar" v-permissions="['business:device:create', 'business:device:delete']">
            <li><el-button type="primary" @click="$refs.operaDeviceWindow.open('新建电表')" icon="el-icon-plus" v-permissions="['business:device:create']">新建</el-button></li>
            <li><el-button type="primary" @click="synchronousData">同步</el-button></li>
<!--            <li><el-button type="primary" @click="$refs.operaDeviceWindow.open('新建电表')" icon="el-icon-plus" v-permissions="['business:device:create']">新建</el-button></li>-->
            <li><el-button @click="deleteByIdInBatch" icon="el-icon-delete" v-permissions="['business:device:delete']">删除</el-button></li>
          </ul>
            <el-table
@@ -27,14 +35,11 @@
                :data="tableData.list"
                stripe >
              <el-table-column type="selection" width="55"></el-table-column>
              <el-table-column prop="no" label="表号" min-width="100" align="center" ></el-table-column>
              <el-table-column prop="name" label="名称" fixed min-width="150" align="center"></el-table-column>
              <el-table-column prop="no" label="电表地址域" min-width="100" align="center" ></el-table-column>
              <el-table-column prop="doorNo" label="设备号"  min-width="120" align="center" show-overflow-tooltip></el-table-column>
<!--
              <el-table-column prop="channelNo" label="开关序号" align="center" min-width="100"></el-table-column>
-->
              <el-table-column prop="doorNo" label="采集号"  min-width="120" align="center" show-overflow-tooltip></el-table-column>
              <el-table-column prop="manufature" label="厂商" align="center" min-width="100" show-overflow-tooltip></el-table-column>
              <el-table-column prop="regionPathName" align="center"  min-width="100" label="所在位置"></el-table-column>
              <el-table-column prop="regionPathName" align="center"  min-width="100" label="绑定房间"></el-table-column>
              <el-table-column prop="ip" label="IP"  min-width="150" align="center" show-overflow-tooltip ></el-table-column>
              <el-table-column prop="port" label="端口" align="center"  ></el-table-column>
              <el-table-column prop="isUsed" label="是否使用">
@@ -114,6 +119,7 @@
import Pagination from '@/components/common/Pagination'
import OperaDeviceDataListWindow from '@/components/business/OperaDianbiaoDataListWindow'
import OperaDeviceDianbiaoWindow from '@/components/business/OperaDeviceDianbiaoWindow'
import { syncDevices } from '@/api/business/device'
export default {
  name: 'DeviceDuanluqi',
  extends: BaseTable,
@@ -197,12 +203,29 @@
    },
    send (row, type) {
      this.visibleSend = true
      this.form = { id: row.id, name: row.name, cmdDate: null, status: type}
      this.form = { id: row.id, name: row.name, cmdDate: null, status: type }
    },
    sendClose () {
      this.visibleSend = false
      this.isWorkSending = false
      this.form = { id: '', name: '', status: '', cmdDate: '' }
    },
    synchronousData () {
      this.$dialog.actionConfirm('操作确认提醒', '您确认同步全部信息吗?')
        .then(() => {
          this.isWorking.delete = true
          syncDevices({ type: 6 })
            .then(res => {
              this.$tip.apiSuccess(res || '同步成功')
              this.search()
            })
            .catch(e => {
              this.$tip.apiFailed(e)
            })
            .finally(() => {
              this.isWorking.delete = false
            })
        }) .catch(() => {})
    }
  }
}
server/visits/dmvisit_admin/src/main/java/com/doumee/device/ElectronicNotifyController.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,72 @@
package com.doumee.device;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.nio.charset.StandardCharsets;
import java.security.MessageDigest;
import java.util.*;
@RestController
@RequestMapping("/electronic")
public class ElectronicNotifyController {
    @RequestMapping("/notify")
    public String notify(String response_content, String timestamp, String sign) {
        System.out.println("timestamp: " + timestamp);
        System.out.println("response_content: " + response_content);
        System.out.println("sign: " + sign);
        // éªŒç­¾
        if(!checkSign(response_content, timestamp, sign)) {
            System.out.println("sign check failed");
            return "sign check failed";
        }
        System.out.println("sign check success");
        List<Map<String, Object>> responseContent= new ArrayList<>();
        JSONArray contentArray = JSON.parseArray(response_content);
        for(int i = 0; i < contentArray.size(); ++i) {
            HashMap<String, Object> contentMap = new HashMap<>();
            JSONObject contentObject = contentArray.getJSONObject(i);
            Set<String> keySet = contentObject.keySet();
            for(String key: keySet) {
                contentMap.put(key, contentObject.getObject(key, Object.class));
            }
            responseContent.add(contentMap);
        }
        System.out.println("接收异步通知数据:" + responseContent);
        return "SUCCESS";
    }
    private boolean checkSign(String response_content, String timestamp, String sign) {
        // éšæœºå­—符串 åŽå°èŽ·å–
        String nonce = "XOfX547SeCIlhufeeBBwgZIN";
        String buf = response_content + timestamp + nonce;
        String encode = getMD5(buf);
        return encode.equals(sign);
    }
    // md5加密
    private String getMD5(String password) {
        MessageDigest md5 = null;
        try {
            md5 = MessageDigest.getInstance("MD5");
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
        byte[] byteArray = password.getBytes(StandardCharsets.UTF_8);
        byte[] md5Bytes = md5.digest(byteArray);
        StringBuilder hexValue = new StringBuilder();
        for (byte md5Byte : md5Bytes) {
            int val = ((int) md5Byte) & 0xff;
            if (val < 16) {
                hexValue.append("0");
            }
            hexValue.append(Integer.toHexString(val));
        }
        return hexValue.toString();
    }
}
server/visits/dmvisit_admin/src/main/java/com/doumee/device/ElectronicSubscribeController.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,67 @@
package com.doumee.device;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.nio.charset.StandardCharsets;
import java.security.MessageDigest;
@RestController
@RequestMapping("/electronic")
public class ElectronicSubscribeController {
    @RequestMapping("/subscribe")
    public String subscribe(@RequestBody(required=false) String body,
                            @RequestHeader(value="sign", required=false) String sign) {
        if(body==null) {
            body = "";
        }
        if(!checkSign(body, sign)) {
            return "sign check failed";
        }
        if("".equals(body)) {
            System.out.println("接收到服务器路径测试请求");
        } else {
            System.out.println("接收到订阅消息");
            System.out.println(body);
            //-----------加入业务逻辑-----------
            //--------------------------------
        }
        return "SUCCESS";
    }
    private boolean checkSign(String response_content, String sign) {
        // éšæœºå­—符串 åŽå°èŽ·å–
        String token = "7O2wtcxNCvtSL7MtIOLs";
        String buf = response_content + token;
        String encode = getMD5(buf);
        return encode.equalsIgnoreCase(sign);
    }
    // md5加密
    private String getMD5(String password) {
        MessageDigest md5 = null;
        try {
            md5 = MessageDigest.getInstance("MD5");
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
        byte[] byteArray = password.getBytes(StandardCharsets.UTF_8);
        byte[] md5Bytes = md5.digest(byteArray);
        StringBuilder hexValue = new StringBuilder();
        for (byte md5Byte : md5Bytes) {
            int val = ((int) md5Byte) & 0xff;
            if (val < 16) {
                hexValue.append("0");
            }
            hexValue.append(Integer.toHexString(val));
        }
        return hexValue.toString();
    }
}
server/visits/dmvisit_admin/src/main/java/com/doumee/service/impl/HkSyncEventServiceImpl.java
@@ -111,7 +111,6 @@
        HKService.cancelEventSub(param);//先取消
//        HKService.eventSub(param);//月台工作状态事件
        param.setEventDest(path+"/platform/carstatus");
        param.setEventTypes(new Integer[]{HKConstants.EventTypes.PLATFORM_CAR_STATUS.getKey()});
        HKService.cancelEventSub(param);//先取消
server/visits/dmvisit_service/src/main/java/com/doumee/core/device/ElectronicToolUitl.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,1141 @@
package com.doumee.core.device;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.HttpClient;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.util.EntityUtils;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.security.MessageDigest;
import java.util.*;
public class ElectronicToolUitl {
    // æŽˆæƒç  ç™»å½• åŽå°èŽ·å–ï¼Œ è”系你的甲方或者是销售
    private static String auth_code = "1f29d378fc6792d5d2b735877993ffb7";
    // éšæœºå­—符串 åŽå°èŽ·å–
    private static String nonce = "lvyOY7fcun719WkxF8ToVYatStgt";
    // æµ‹è¯•用采集器号  è¯·ä½¿ç”¨çœŸå®žè®¾å¤‡é‡‡é›†å™¨å·
    private static String debug_collector = "19020618114";
    // æµ‹è¯•用电表号 è¯·ä½¿ç”¨çœŸå®žè®¾å¤‡é‡‡é›†å™¨å·
    private static String debug_meter = "000066660942";
    // å¼‚步通知地址(服务如果部署在内网,在公网无法直接访问到,需要在路由器上配置端口映射,或者配置内网穿透工具来实现访问) æ­¤å¤„仅为测试 ç¤ºä¾‹
    private static String notify_url = "http://115.221.15.8:8055/notify";
    private static String api_url = "http://api1.tqdianbiao.com";
    private static String api2_url = "http://api2.tqdianbiao.com";
    public static void main(String[] args) {
// æ³¨æ„ å¦‚需使用充值功能 å¯å…ˆäº†è§£ [参数维护模式](http://doc-api.tqdianbiao.com/doc/backend/data_sync_mode.html)
// æ³¨æ„ æœ‰2个系统 æŽˆæƒç ç­‰å‚æ•°  å„自独立   æŽ¥å£åŸŸååˆ†åˆ«ä¸º  https://iot.tqdianbiao.com/  http://api1.tqdianbiao.com
//        -------- ç³»ç»Ÿç»´æŠ¤å…³é”®å‚数模式 æŽ¥å£-------------
//        é‡‡é›†å™¨æ·»åŠ ();
//        é‡‡é›†å™¨åˆ é™¤();
//        æŸ¥è¯¢N个采集器();
//        æŸ¥è¯¢å…¨éƒ¨é‡‡é›†å™¨();
//
//        ç”µèƒ½è¡¨æ·»åŠ ();
//        ç”µèƒ½è¡¨åˆ é™¤();
//        ç”µèƒ½è¡¨æ¡£æ¡ˆæŸ¥è¯¢();
//
//        æ°´è¡¨æ·»åŠ ();
//        æ°´è¡¨åˆ é™¤();
//        æ°´è¡¨æ¡£æ¡ˆæŸ¥è¯¢();
//        æ“ä½œçŠ¶æ€æŸ¥è¯¢();
//        å–消操作();
//        ------------ æŽ¥å…¥æ–¹ç»´æŠ¤å…³é”®å‚数模式 æ•°æ®æŽ¥å£-------------
//        æŠ„电表数据();
//        è®¾ç½®ç”µè¡¨å‚æ•°();
//        ç”µè¡¨æ‹‰é—¸();
//        ç”µè¡¨åˆé—¸();
//        ç”µè¡¨æ¸…é›¶_同步模式();
//        ç”µè¡¨æ¸…é›¶_非同步模式();
//        ç”µè¡¨å¼€æˆ·_同步模式();
//        ç”µè¡¨å¼€æˆ·_非同步模式();
//        ç”µè¡¨å……值_同步模式();
//        ç”µè¡¨å……值_非同步模式();
//        æŠ„水表数据();
//        æ°´è¡¨å…³é˜€();
//        æ°´è¡¨å¼€é˜€();
//        æ°´è¡¨æ¸…é›¶();
//        Mbus水表充值_同步模式();
//        Mbus水表充值_非同步模式();
//        Lora水表充值_同步模式();
//        Lora水表充值_非同步模式();
        Lora普通预付费水表设置水价();
        Lora阶梯预付费水表设置水价();
//        ç¬¬ä¸€å¥—数据接口--------------
//        æŸ¥è¯¢åŽ†å²æ•°æ®æŽ¥å£();
//        æŸ¥è¯¢è®¾å¤‡åˆ—表和当前状态();
//        æŸ¥è¯¢é‡‡é›†å™¨åˆ—表和当前状态();
//        æŸ¥è¯¢ä»·æ ¼æ¡£æ¡ˆ();
//        æŸ¥è¯¢ç”¨æˆ·æ¡£æ¡ˆ();
//        æŸ¥è¯¢å‚数档案();
//        æŸ¥è¯¢ç”µè¡¨å½“前状态数据();
//        æŸ¥è¯¢æ°´è¡¨å½“前状态数据();
    }
    /**
     * æŸ¥è¯¢è®¾å¤‡åˆ—表和当前状态
      */
    private static void queryDeviceList() {
        // æŸ¥è¯¢è®¾å¤‡åˆ—表和当前状态
        String url = api_url+"/Api/Meter";  // "https://iot.tqdianbiao.com/Api/Meter"
        Map<String, Object> params = new HashMap<>();
        params.put("auth", auth_code);
        // Map<String, Object> è½¬æˆurl参数
        String urlParams = getUrlParams(params);
        url = url + "?" + urlParams;
        String resp = HttpClientGet(url);
        simpleRequestPrint(url, resp);
    }
    /**
     * æŸ¥è¯¢é‡‡é›†å™¨åˆ—表和当前状态
     */
    private static void queryCollectorList() {
        // æŸ¥è¯¢é‡‡é›†å™¨åˆ—表和当前状态
        String url = api_url+"/Api/Collector";
        Map<String, Object> params = new HashMap<>();
        params.put("auth", auth_code);
        // Map<String, Object> è½¬æˆurl参数
        String urlParams = getUrlParams(params);
        url = url + "?" + urlParams;
        String resp = HttpClientGet(url);
        simpleRequestPrint(url, resp);
    }
    /**
     * æŸ¥è¯¢ä»·æ ¼æ¡£æ¡ˆ
     */
    private static void queryPrice() {
        // æŸ¥è¯¢ä»·æ ¼æ¡£æ¡ˆ
        String url = api_url+"/Api/Price";
        Map<String, Object> params = new HashMap<>();
        params.put("auth", auth_code);
        // Map<String, Object> è½¬æˆurl参数
        String urlParams = getUrlParams(params);
        url = url + "?" + urlParams;
        String resp = HttpClientGet(url);
        simpleRequestPrint(url, resp);
    }
    /**
     * æŸ¥è¯¢ç”¨æˆ·æ¡£æ¡ˆ
     */
    private static void queryUser() {
        // æŸ¥è¯¢ç”¨æˆ·æ¡£æ¡ˆ
        String url = api_url+"/Api/User";
        Map<String, Object> params = new HashMap<>();
        params.put("auth", auth_code);
        // Map<String, Object> è½¬æˆurl参数
        String urlParams = getUrlParams(params);
        url = url + "?" + urlParams;
        String resp = HttpClientGet(url);
        simpleRequestPrint(url, resp);
    }
    /**
     * æŸ¥è¯¢å‚数档案
     */
    private static void queryParam() {
        // æŸ¥è¯¢å‚数档案
        String url = api_url+"/Api/Param";
        Map<String, Object> params = new HashMap<>();
        params.put("auth", auth_code);
        // Map<String, Object> è½¬æˆurl参数
        String urlParams = getUrlParams(params);
        url = url + "?" + urlParams;
        String resp = HttpClientGet(url);
        simpleRequestPrint(url, resp);
    }
    /**
     * æŸ¥è¯¢ç”µè¡¨å½“前状态数据
     */
    private static void queryEleMeterState() {
        // æŸ¥è¯¢ç”µè¡¨å½“前状态数据
        String url = api_url+"/Api/EleMeterState";
        Map<String, Object> params = new HashMap<>();
        params.put("auth", auth_code);
        // Map<String, Object> è½¬æˆurl参数
        String urlParams = getUrlParams(params);
        url = url + "?" + urlParams;
        String resp = HttpClientGet(url);
        simpleRequestPrint(url, resp);
    }
    /**
     * æŸ¥è¯¢æ°´è¡¨å½“前状态数据
     */
    private static void queryWaterMeterState() {
        // æŸ¥è¯¢æ°´è¡¨å½“前状态数据
        String url = api_url+"/Api/WaterMeterState";
        Map<String, Object> params = new HashMap<>();
        params.put("auth", auth_code);
        // Map<String, Object> è½¬æˆurl参数
        String urlParams = getUrlParams(params);
        url = url + "?" + urlParams;
        String resp = HttpClientGet(url);
        simpleRequestPrint(url, resp);
    }
    /**
     * æŸ¥è¯¢åŽ†å²æ•°æ®æŽ¥å£
     */
    private static void queryDataRequest() {
        // æŸ¥è¯¢åŽ†å²æ•°æ®æŽ¥å£
        String url = api_url+"/Api/DataRequest";
        Map<String, Object> params = new HashMap<>();
        params.put("auth",          auth_code);
        params.put("type",          "json");
        params.put("functionids",   "3,4,5");
        params.put("start_time",    "2020-01-01 00:00:00");
        params.put("end_time",      "2020-06-01 00:00:00");
        params.put("offset",        0);
        params.put("limit",         100);
        // Map<String, Object> è½¬æˆurl参数
        String urlParams = getUrlParams(params);
        url = url + "?" + urlParams;
        String resp = HttpClientGet(url);
        simpleRequestPrint(url, resp);
    }
    private static void simpleRequestPrint(String url, String resp) {
        String name=Thread.currentThread().getStackTrace()[2].getMethodName();
        System.out.println(name);
        System.out.println("请求参数:" + url);
        System.out.println("返回数据:" + resp);
    }
    private static String HttpClientGet(String url) {
        try {
            CloseableHttpClient client = HttpClients.createDefault();
            HttpGet httpGet = new HttpGet(url);
            CloseableHttpResponse Response = client.execute(httpGet);
            HttpEntity entity = Response.getEntity();
            String resp = EntityUtils.toString(entity, "UTF-8");
            Response.close();
            return  resp;
        } catch (Exception e) {
            System.out.println(e.getMessage());
            return "";
        }
    }
    private static String getUrlParams(Map<String, Object> map) {
        if (map == null || map.size() == 0) {
            return "";
        }
        List<String> list = new ArrayList<>();
        map.forEach((key, value)->{
            try {
                list.add(key + "=" + URLEncoder.encode(value.toString(), "UTF-8"));
            } catch (UnsupportedEncodingException e) {
                e.printStackTrace();
            }
        });
        return String.join("&", list);
    }
    /**
     * ç”µè¡¨å¼€æˆ·_同步模式
     */
    private static void openAcount() {
        String url = api2_url+"/Api_v2/ele_security/open_acount";
        // è¯·æ±‚内容,调用接口所需要的数据(电表开户,同步模式)
        List<Map<String, Object>> req = new ArrayList<>();
        Map<String, Object> item = new HashMap<>();
        Map<String, Object> params = new HashMap<>();
        params.put("money", "100");
        item.put("opr_id", generateOperateId());
        item.put("time_out", 0);
        item.put("must_online", true);
        item.put("retry_times", 1);
        item.put("cid", "19020618114");
        item.put("address", "000066660942");
        item.put("params", params);
        req.add(item);
        String request_content = JSON.toJSONString(req);
        testApiAsync(url, request_content);
    }
    /**
     * ç”µè¡¨å¼€æˆ·_非同步模式
     */
    private static void ç”µè¡¨å¼€æˆ·_非同步模式() {
        String url = api2_url+"/Api_v2/ele_security/open_acount";
        // è¯·æ±‚内容,调用接口所需要的数据(电表开户,非同步模式)
        List<Map<String, Object>> req = new ArrayList<>();
        Map<String, Object> item = new HashMap<>();
        Map<String, Object> params = new HashMap<>();
        params.put("money", "100");
        params.put("account_id", "123456");
        params.put("count", "1");
        item.put("opr_id", generateOperateId());
        item.put("time_out", 0);
        item.put("must_online", true);
        item.put("retry_times", 1);
        item.put("cid", "19020618114");
        item.put("address", "000066660942");
        item.put("params", params);
        req.add(item);
        String request_content = JSON.toJSONString(req);
        testApiAsync(url, request_content);
    }
    private static void ç”µè¡¨å……值_同步模式() {
        String url = api2_url+"/Api_v2/ele_security/recharge";
        // è¯·æ±‚内容,调用接口所需要的数据(电表充值,同步模式)
        List<Map<String, Object>> req = new ArrayList<>();
        Map<String, Object> item = new HashMap<>();
        Map<String, Object> params = new HashMap<>();
        params.put("money", "100");
        item.put("opr_id", generateOperateId());
        item.put("time_out", 0);
        item.put("must_online", true);
        item.put("retry_times", 1);
        item.put("cid", "19020618114");
        item.put("address", "000066660942");
        item.put("params", params);
        req.add(item);
        String request_content = JSON.toJSONString(req);
        testApiAsync(url, request_content);
    }
    private static void ç”µè¡¨å……值_非同步模式() {
        String url = api2_url+"/Api_v2/ele_security/recharge";
        // è¯·æ±‚内容,调用接口所需要的数据(电表充值,非同步模式)
        List<Map<String, Object>> req = new ArrayList<>();
        Map<String, Object> item = new HashMap<>();
        Map<String, Object> params = new HashMap<>();
        params.put("money", "100");
        params.put("account_id", "123456");
        params.put("count", "2");
        item.put("opr_id", generateOperateId());
        item.put("time_out", 0);
        item.put("must_online", true);
        item.put("retry_times", 1);
        item.put("cid", "19020618114");
        item.put("address", "000066660942");
        item.put("params", params);
        req.add(item);
        String request_content = JSON.toJSONString(req);
        testApiAsync(url, request_content);
    }
    private static void Lora普通预付费水表设置水价() {
        String url = api2_url+"/Api_v2/water_write/price";
        // è¯·æ±‚内容,调用接口所需要的数据(Lora普通预付费水表设置水价)
        List<Map<String, Object>> req = new ArrayList<>();
        Map<String, Object> item = new HashMap<>();
        Map<String, Object> params = new HashMap<>();
        params.put("p1", "1");
        item.put("opr_id", generateOperateId());
        item.put("time_out", 0);
        item.put("must_online", true);
        item.put("retry_times", 1);
        item.put("cid", "10000000031");
        item.put("address", "20040900000003");
        item.put("params", params);
        req.add(item);
        String request_content = JSON.toJSONString(req);
        testApiAsync(url, request_content);
    }
    private static void Lora阶梯预付费水表设置水价() {
        String url = api2_url+"/Api_v2/water_write/price";
        // è¯·æ±‚内容,调用接口所需要的数据(Lora阶梯预付费水表设置水价)
        List<Map<String, Object>> req = new ArrayList<>();
        Map<String, Object> item = new HashMap<>();
        Map<String, Object> params = new HashMap<>();
        params.put("p1", "1");
        params.put("p2", "2");
        params.put("p3", "3");
        params.put("p4", "40");
        params.put("p5", "50");
        item.put("opr_id", generateOperateId());
        item.put("time_out", 0);
        item.put("must_online", true);
        item.put("retry_times", 1);
        item.put("cid", "10000000031");
        item.put("address", "20040900000003");
        item.put("params", params);
        req.add(item);
        String request_content = JSON.toJSONString(req);
        testApiAsync(url, request_content);
    }
    private static void Lora水表充值_同步模式() {
        String url = api2_url+"/Api_v2/water_security/recharge";
        // è¯·æ±‚内容,调用接口所需要的数据(Lora水表充值,同步模式)
        List<Map<String, Object>> req = new ArrayList<>();
        Map<String, Object> item = new HashMap<>();
        Map<String, Object> params = new HashMap<>();
        params.put("money", "100");
        item.put("opr_id", generateOperateId());
        item.put("time_out", 0);
        item.put("must_online", true);
        item.put("retry_times", 1);
        item.put("cid", "10000000031");
        item.put("address", "20040900000003");
        item.put("params", params);
        req.add(item);
        String request_content = JSON.toJSONString(req);
        testApiAsync(url, request_content);
    }
    private static void Lora水表充值_非同步模式() {
        String url = api2_url+"/Api_v2/water_security/recharge";
        // è¯·æ±‚内容,调用接口所需要的数据(Lora水表充值,非同步模式)
        List<Map<String, Object>> req = new ArrayList<>();
        Map<String, Object> item = new HashMap<>();
        Map<String, Object> params = new HashMap<>();
        params.put("money", "100");
        params.put("count", "2");
        item.put("opr_id", generateOperateId());
        item.put("time_out", 0);
        item.put("must_online", true);
        item.put("retry_times", 1);
        item.put("cid", "10000000031");
        item.put("address", "20040900000003");
        item.put("params", params);
        req.add(item);
        String request_content = JSON.toJSONString(req);
        testApiAsync(url, request_content);
    }
    private static void Mbus水表充值_同步模式() {
        String url = api2_url+"/Api_v2/water_security/recharge";
        // è¯·æ±‚内容,调用接口所需要的数据(Mbus水表充值,同步模式)
        List<Map<String, Object>> req = new ArrayList<>();
        Map<String, Object> item = new HashMap<>();
        Map<String, Object> params = new HashMap<>();
        params.put("money", "100");
        item.put("opr_id", generateOperateId());
        item.put("time_out", 0);
        item.put("must_online", true);
        item.put("retry_times", 1);
        item.put("cid", "88020206100");
        item.put("address", "C1E81000007859");
        item.put("params", params);
        req.add(item);
        String request_content = JSON.toJSONString(req);
        testApiAsync(url, request_content);
    }
    private static void Mbus水表充值_非同步模式() {
        String url = api2_url+"/Api_v2/water_security/recharge";
        // è¯·æ±‚内容,调用接口所需要的数据(Mbus水表充值,非同步模式)
        List<Map<String, Object>> req = new ArrayList<>();
        Map<String, Object> item = new HashMap<>();
        Map<String, Object> params = new HashMap<>();
        params.put("money", "100");
        params.put("price", "5");
        params.put("count", "2");
        item.put("opr_id", generateOperateId());
        item.put("time_out", 0);
        item.put("must_online", true);
        item.put("retry_times", 1);
        item.put("cid", "88020206100");
        item.put("address", "C1E81000007859");
        item.put("params", params);
        req.add(item);
        String request_content = JSON.toJSONString(req);
        testApiAsync(url, request_content);
    }
    private static void æ°´è¡¨æ¸…é›¶() {
        String url = api2_url+"/Api_v2/water_security/reset";
        // è¯·æ±‚内容,调用接口所需要的数据(水表清零)
        List<Map<String, Object>> req = new ArrayList<>();
        Map<String, Object> item = new HashMap<>();
        item.put("opr_id", generateOperateId());
        item.put("time_out", 0);
        item.put("must_online", true);
        item.put("retry_times", 1);
        item.put("cid", "88020206100");
        item.put("address", "C1E81000007859");
        req.add(item);
        String request_content = JSON.toJSONString(req);
        testApiAsync(url, request_content);
    }
    private static void ç”µè¡¨æ¸…é›¶_非同步模式() {
        String url = api2_url+"/Api_v2/ele_security/reset";
        // è¯·æ±‚内容,调用接口所需要的数据(电表清零,非同步模式)
        List<Map<String, Object>> req = new ArrayList<>();
        Map<String, Object> item = new HashMap<>();
        Map<String, Object> params = new HashMap<>();
        params.put("account_id", "123456");
        item.put("opr_id", generateOperateId());
        item.put("time_out", 0);
        item.put("must_online", true);
        item.put("retry_times", 1);
        item.put("cid", "19020618114");
        item.put("address", "000066660942");
        item.put("params", params);
        req.add(item);
        String request_content = JSON.toJSONString(req);
        testApiAsync(url, request_content);
    }
    private static void ç”µè¡¨æ¸…é›¶_同步模式() {
        String url = api2_url+"/Api_v2/ele_security/reset";
        // è¯·æ±‚内容,调用接口所需要的数据(电表清零,同步模式)
        List<Map<String, Object>> req = new ArrayList<>();
        Map<String, Object> item = new HashMap<>();
        item.put("opr_id", generateOperateId());
        item.put("time_out", 0);
        item.put("must_online", true);
        item.put("retry_times", 1);
        item.put("cid", "19020618114");
        item.put("address", "000066660942");
        req.add(item);
        String request_content = JSON.toJSONString(req);
        testApiAsync(url, request_content);
    }
    private static void ç”µè¡¨æ‹‰é—¸() {
        String url = api2_url+"/Api_v2/ele_control";
        // è¯·æ±‚内容,调用接口所需要的数据(电表拉闸)
        List<Map<String, Object>> req = new ArrayList<>();
        Map<String, Object> item = new HashMap<>();
        item.put("opr_id", generateOperateId());
        item.put("time_out", 0);
        item.put("must_online", true);
        item.put("retry_times", 1);
        item.put("cid", "19020618114");
        item.put("address", "000066660942");
        item.put("type", 10);
        req.add(item);
        String request_content = JSON.toJSONString(req);
        testApiAsync(url, request_content);
    }
    private static void ç”µè¡¨åˆé—¸() {
        String url = api2_url+"/Api_v2/ele_control";
        // è¯·æ±‚内容,调用接口所需要的数据(电表合闸)
        List<Map<String, Object>> req = new ArrayList<>();
        Map<String, Object> item = new HashMap<>();
        item.put("opr_id", generateOperateId());
        item.put("time_out", 0);
        item.put("must_online", true);
        item.put("retry_times", 1);
        item.put("cid", "19020618114");
        item.put("address", "000066660942");
        item.put("type", 11);
        req.add(item);
        String request_content = JSON.toJSONString(req);
        testApiAsync(url, request_content);
    }
    private static void æ°´è¡¨å…³é˜€() {
        String url = api2_url+"/Api_v2/water_control";
        // è¯·æ±‚内容,调用接口所需要的数据(水表关阀)
        List<Map<String, Object>> req = new ArrayList<>();
        Map<String, Object> item = new HashMap<>();
        item.put("opr_id", generateOperateId());
        item.put("time_out", 0);
        item.put("must_online", true);
        item.put("retry_times", 1);
        item.put("cid", "88020206100");
        item.put("address", "C1E81000007859");
        item.put("type", 53);
        req.add(item);
        String request_content = JSON.toJSONString(req);
        testApiAsync(url, request_content);
    }
    private static void æ°´è¡¨å¼€é˜€() {
        String url = api2_url+"/Api_v2/water_control";
        // è¯·æ±‚内容,调用接口所需要的数据(水表开阀)
        List<Map<String, Object>> req = new ArrayList<>();
        Map<String, Object> item = new HashMap<>();
        item.put("opr_id", generateOperateId());
        item.put("time_out", 0);
        item.put("must_online", true);
        item.put("retry_times", 1);
        item.put("cid", "88020206100");
        item.put("address", "C1E81000007859");
        item.put("type", 43);
        req.add(item);
        String request_content = JSON.toJSONString(req);
        testApiAsync(url, request_content);
    }
    private static void è®¾ç½®ç”µè¡¨å‚æ•°() {
        String url = api2_url+"/Api_v2/ele_write";
        // è¯·æ±‚内容,调用接口所需要的数据(一级报警值)
        List<Map<String, Object>> req = new ArrayList<>();
        Map<String, Object> item = new HashMap<>();
        Map<String, Object> params = new HashMap<>();
        params.put("p1", "300");
        item.put("opr_id", generateOperateId());
        item.put("time_out", 0);
        item.put("must_online", true);
        item.put("retry_times", 1);
        item.put("cid", "19020618114");
        item.put("address", "000066660942");
        item.put("type", 24);
        item.put("params", params);
        req.add(item);
        String request_content = JSON.toJSONString(req);
        testApiAsync(url, request_content);
    }
    private static void æŠ„电表数据() {
        String url = api2_url+"/Api_v2/ele_read";
        // è¯·æ±‚内容,调用接口所需要的数据(抄电表数据)
        List<Map<String, Object>> req = new ArrayList<>();
        Map<String, Object> item = new HashMap<>();
        item.put("opr_id", generateOperateId());
        item.put("time_out", 0);
        item.put("must_online", true);
        item.put("retry_times", 1);
        item.put("cid", "19020618114");
        item.put("address", "000066660942");
        item.put("type", 3);
        req.add(item);
        String request_content = JSON.toJSONString(req);
        testApiAsync(url, request_content);
    }
    private static void æŠ„水表数据() {
        String url = api2_url+"/Api_v2/water_read";
        // è¯·æ±‚内容,调用接口所需要的数据(抄水表数据)
        List<Map<String, Object>> req = new ArrayList<>();
        Map<String, Object> item = new HashMap<>();
        item.put("opr_id", generateOperateId());
        item.put("time_out", 0);
        item.put("must_online", true);
        item.put("retry_times", 1);
        item.put("cid", "88020206100");
        item.put("address", "C1E81000007859");
        item.put("type", 42);
        req.add(item);
        String request_content = JSON.toJSONString(req);
        testApiAsync(url, request_content);
    }
    private static String generateOperateId() {
        return UUID.randomUUID().toString().replaceAll("-", "");
    }
    private static void ç”µèƒ½è¡¨æ¡£æ¡ˆæŸ¥è¯¢()
    {
        String url = api2_url+"/Api_v2/ele_meter/query";
        // è¯·æ±‚内容,调用接口所需要的数据(查询指定的采集器下的电能表信息)
        List<Map<String, String>> req = new ArrayList<>();
        Map<String, String> item = new HashMap<>();
        item.put("cid", "12345678901");     // æŸ¥è¯¢å…¶ä»–区域的采集器下的电能表(未找到采集器)
        req.add(item);
        item = new HashMap<>();
        item.put("cid", "29020618114");     // æŸ¥è¯¢ä¸å­˜åœ¨çš„采集器下的电能表(未找到采集器)
        req.add(item);
        item = new HashMap<>();
        item.put("cid", "19020618114");     // æŸ¥è¯¢æœ¬åŒºåŸŸå·²ç»æ·»åŠ çš„é‡‡é›†å™¨ä¸‹çš„ç”µèƒ½è¡¨(得到正确结果:"address":["000066660942"])
        req.add(item);
        item = new HashMap<>();
        item.put("cid", "1902061811411");   // æŸ¥è¯¢ä¸åˆæ³•的采集器下的电能表(只支持11/12位采集器号)
        req.add(item);
        String request_content = JSON.toJSONString(req);
        testApi(url, request_content);
    }
    private static void ç”µèƒ½è¡¨åˆ é™¤()
    {
        String url = api2_url+"/Api_v2/ele_meter/delete";
        // è¯·æ±‚内容,调用接口所需要的数据(删除指定的电能表信息)
        List<Map<String, String>> req = new ArrayList<>();
        Map<String, String> item = new HashMap<>();
        item.put("cid", "19020618114");
        item.put("address", "000066660942");
        req.add(item);
        item = new HashMap<>();
        item.put("cid", "19020618114");
        item.put("address", "0000666609");      // ä¸åˆæ³•的表号
        req.add(item);
        item = new HashMap<>();
        item.put("cid", "1902061811");          // ä¸åˆæ³•的采集器号
        item.put("address", "000066660942");
        req.add(item);
        item = new HashMap<>();
        item.put("cid", "12345678901");         // éžæœ¬åŒºåŸŸé‡‡é›†å™¨å·
        item.put("address", "000066660942");
        req.add(item);
        item = new HashMap<>();
        item.put("cid", "11335577990");
        item.put("address", "000066660942");    // ä¸å­˜åœ¨çš„采集器号
        req.add(item);
        String request_content = JSON.toJSONString(req);
        testApi(url, request_content);
    }
    private static void ç”µèƒ½è¡¨æ·»åŠ ()
    {
        String url = api2_url+"/Api_v2/ele_meter/add";
        // è¯·æ±‚内容,调用接口所需要的数据(添加指定的电能表信息)
        List<Map<String, String>> req = new ArrayList<>();
        Map<String, String> item = new HashMap<>();
        item.put("cid", "19020618114");
        item.put("address", "000066660942");
        req.add(item);
        item = new HashMap<>();
        item.put("cid", "19020618114");
        item.put("address", "0000666609");      // ä¸åˆæ³•的表号
        req.add(item);
        item = new HashMap<>();
        item.put("cid", "1902061811");          // ä¸åˆæ³•的采集器号
        item.put("address", "000066660942");
        req.add(item);
        item = new HashMap<>();
        item.put("cid", "12345678901");         // éžæœ¬åŒºåŸŸé‡‡é›†å™¨å·
        item.put("address", "000066660942");
        req.add(item);
        item = new HashMap<>();
        item.put("cid", "11335577990");
        item.put("address", "000066660942");    // ä¸å­˜åœ¨çš„采集器号
        req.add(item);
        String request_content = JSON.toJSONString(req);
        testApi(url, request_content);
    }
    private static void æ°´è¡¨æ¡£æ¡ˆæŸ¥è¯¢()
    {
        String url = api2_url+"/Api_v2/water_meter/query";
        // è¯·æ±‚内容,调用接口所需要的数据(查询指定的采集器下的水表信息)
        List<Map<String, String>> req = new ArrayList<>();
        Map<String, String> item = new HashMap<>();
        item.put("cid", "19020618114");
        req.add(item);
        String request_content = JSON.toJSONString(req);
        testApi(url, request_content);
    }
    private static void æ°´è¡¨åˆ é™¤()
    {
        String url = api2_url+"/Api_v2/water_meter/delete";
        // è¯·æ±‚内容,调用接口所需要的数据(删除指定的水表信息)
        List<Map<String, String>> req = new ArrayList<>();
        Map<String, String> item = new HashMap<>();
        item.put("cid", "19020618114");
        item.put("address", "000066660942");
        req.add(item);
        String request_content = JSON.toJSONString(req);
        testApi(url, request_content);
    }
    private static void æ°´è¡¨æ·»åŠ ()
    {
        String url = api2_url+"/Api_v2/water_meter/add";
        // è¯·æ±‚内容,调用接口所需要的数据(添加指定的水表信息)
        List<Map<String, String>> req = new ArrayList<>();
        Map<String, String> item = new HashMap<>();
        item.put("cid", "19020618114");
        item.put("address", "000066660942");
        req.add(item);
        String request_content = JSON.toJSONString(req);
        testApi(url, request_content);
    }
    private static void æ“ä½œçŠ¶æ€æŸ¥è¯¢()
    {
        String url = api2_url+"/Api_v2/request/status";
        // è¯·æ±‚内容,调用接口所需要的数据(操作状态查询)
        List<Map<String, String>> req = new ArrayList<>();
        Map<String, String> item = new HashMap<>();
        item.put("opr_id", "123456");
        req.add(item);
        String request_content = JSON.toJSONString(req);
        testApi(url, request_content);
    }
    private static void å–消操作()
    {
        String url = api2_url+"/Api_v2/request/cancel";
        // è¯·æ±‚内容,调用接口所需要的数据(取消操作)
        List<Map<String, String>> req = new ArrayList<>();
        Map<String, String> item = new HashMap<>();
        item.put("opr_id", "123456");
        req.add(item);
        String request_content = JSON.toJSONString(req);
        testApi(url, request_content);
    }
    private static void é‡‡é›†å™¨åˆ é™¤()
    {
        String url = api2_url+"/Api_v2/collector/delete";
        // è¯·æ±‚内容,调用接口所需要的数据(删除指定的采集器信息)
        List<Map<String, String>> req = new ArrayList<>();
        Map<String, String> item = new HashMap<>();
        item.put("cid", "12345678901");     // åˆ é™¤å…¶ä»–区域的采集器
        req.add(item);
        item = new HashMap<>();
        item.put("cid", "29020618114");     // åˆ é™¤ä¸å­˜åœ¨çš„采集器
        req.add(item);
        item = new HashMap<>();
        item.put("cid", "19020618114");     // åˆ é™¤æœ¬åŒºåŸŸå·²ç»æ·»åŠ çš„é‡‡é›†å™¨
        req.add(item);
        item = new HashMap<>();
        item.put("cid", "1902061811411");   // åˆ é™¤ä¸åˆæ³•的采集器
        req.add(item);
        String request_content = JSON.toJSONString(req);
        testApi(url, request_content);
    }
    private static void é‡‡é›†å™¨æ·»åŠ ()
    {
        String url = api2_url+"/Api_v2/collector/add";
        // è¯·æ±‚内容,调用接口所需要的数据(添加指定的采集器信息)
        List<Map<String, String>> req = new ArrayList<>();
        Map<String, String> item = new HashMap<>();
        item.put("cid", "12345678901");     // é‡‡é›†å™¨å·è¢«å…¶ä»–区域用户添加过的
        req.add(item);
        item = new HashMap<>();
        item.put("cid", "19020618114");     // å¤šæ¬¡è°ƒç”¨å‡ä¼šè¿”回添加成功
        req.add(item);
        String request_content = JSON.toJSONString(req);
        testApi(url, request_content);
    }
    private static void æŸ¥è¯¢å…¨éƒ¨é‡‡é›†å™¨()
    {
        String url = api2_url+"/Api_v2/collector/query";
        // è¯·æ±‚内容,调用接口所需要的数据(查询所有采集器信息)
        String request_content = "[]";
        testApi(url, request_content);
    }
    private static void æŸ¥è¯¢N个采集器()
    {
        String url = api2_url+"/Api_v2/collector/query";
        // è¯·æ±‚内容,调用接口所需要的数据(查询指定的采集器信息)
        List<Map<String, String>> req = new ArrayList<>();
        Map<String, String> item = new HashMap<>();
        item.put("cid", "100000000101");
        req.add(item);
        item = new HashMap<>();
        item.put("cid", "10000000101");
        req.add(item);
        item = new HashMap<>();
        item.put("cid", "1000000101");      // é‡‡é›†å™¨å·ä¸ç¬¦åˆè§„范
        req.add(item);
        item = new HashMap<>();
        item.put("cid", "50000000101");     // ä¸å­˜åœ¨çš„采集器
        req.add(item);
        String request_content = JSON.toJSONString(req);
        testApi(url, request_content);
    }
    private static void testApi(String url, String request_content)
    {
        String name=Thread.currentThread().getStackTrace()[2].getMethodName();
        System.out.println(name);
        String response = request(url, request_content);
        printResponse(response);
    }
    private static void testApiAsync(String url, String request_content)
    {
        String name=Thread.currentThread().getStackTrace()[2].getMethodName();
        System.out.println(name);
        String response = requestAsync(url, request_content);
        printResponse(response);
    }
    // æ‰“印响应内容
    private static void printResponse(String response) {
        JSONObject jsonObject = JSON.parseObject(response);
        String status = jsonObject.getString("status");
        if(!"SUCCESS".equals(status)) {
            System.out.println(jsonObject.getString("error_msg"));
        } else {
            String response_content = jsonObject.getString("response_content");
            System.out.println("response_content: " + response_content);
            JSONArray contentArray = JSON.parseArray(response_content);
            int index = 1;
            System.out.println("返回结果:");
            for(int i = 0; i < contentArray.size(); ++i) {
                System.out.println("[" + index++ + "]");
                JSONObject contentObject = contentArray.getJSONObject(i);
                Set<String> keySet = contentObject.keySet();
                for(String key: keySet) {
                    System.out.println(key + ": " + contentObject.get(key));
                }
            }
        }
    }
    // è¯·æ±‚接口
    private static String request(String url, String request_content){
        // æ—¶é—´æˆ³
        String timestamp = String.valueOf(new Date().getTime()/1000);
        // ç”¨äºŽç­¾åçš„内容
        Map<String, String> data = new HashMap<>();
        data.put("timestamp", timestamp);
        data.put("auth_code", auth_code);
        data.put("request_content", request_content);
        // èŽ·å–ç­¾å
        String sign = getSign(data);
        data.put("sign", sign);
        try {
            return sendHttpRequest(url, data);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return "";
    }
    // è¯·æ±‚接口
    private static String requestAsync(String url, String request_content){
        // æ—¶é—´æˆ³
        String timestamp = String.valueOf(new Date().getTime()/1000);
        // ç”¨äºŽç­¾åçš„内容
        Map<String, String> data = new HashMap<>();
        data.put("timestamp", timestamp);
        data.put("auth_code", auth_code);
        data.put("request_content", request_content);
        data.put("notify_url", notify_url);
        // èŽ·å–ç­¾å
        String sign = getSign(data);
        data.put("sign", sign);
        try {
            return sendHttpRequest(url, data);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return "";
    }
    // ç”Ÿæˆç­¾åå­—符串
    private static String getSign(Map<String, String> data)
    {
        // èŽ·å–å…³é”®å­—åˆ—è¡¨
        List<String> keys = new ArrayList<>(data.keySet());
        // å…³é”®å­—列表排序
        keys.sort(Comparator.naturalOrder());
        StringBuilder sb = new StringBuilder();
        for (String key : keys)
        {
            // å–各个字段内容拼接字符串
            sb.append(data.get(key));
        }
        // åŠ ä¸ŠåŒæ–¹çº¦å®šéšæœºå­—ç¬¦ä¸²
        String txt = sb.toString() + nonce;
        // è®¡ç®—哈希值
        return getMD5(txt);
    }
    // md5加密
    private static String getMD5(String password) {
        MessageDigest md5 = null;
        try {
            md5 = MessageDigest.getInstance("MD5");
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
        byte[] byteArray = password.getBytes(StandardCharsets.UTF_8);
        byte[] md5Bytes = md5.digest(byteArray);
        StringBuilder hexValue = new StringBuilder();
        for (byte md5Byte : md5Bytes) {
            int val = ((int) md5Byte) & 0xff;
            if (val < 16) {
                hexValue.append("0");
            }
            hexValue.append(Integer.toHexString(val));
        }
        return hexValue.toString();
    }
    // å‘送http请求
    private static String sendHttpRequest(String url, Map<String, String> bodyMap) throws Exception {
        System.out.println("请求地址:" + url);
        System.out.println("发送参数:" + bodyMap.toString());
        HttpClient client = HttpClientBuilder.create().build();
        HttpPost postRequest = new HttpPost(url);
        List<NameValuePair> nvps = new ArrayList<>();
        for(String key : bodyMap.keySet()) {
            nvps.add(new BasicNameValuePair(key,bodyMap.get(key)));
        }
        postRequest.setEntity(new UrlEncodedFormEntity(nvps,"utf-8"));
        int retry = 3;
        HttpResponse execute = null;
        while(retry-- > 0) {
            try {
                execute = client.execute(postRequest);
                break;
            } catch (Exception e) {
                Thread.sleep(5000);
            }
        }
        if(execute == null) {
            throw new Exception("接口请求失败");
        }
        String resp = EntityUtils.toString(execute.getEntity(), "UTF-8");
        System.out.println("接口返回:" + resp);
        return resp;
    }
}
server/visits/dmvisit_service/src/main/java/com/doumee/dao/business/model/Device.java
@@ -114,7 +114,7 @@
    @ExcelColumn(name="端口")
    private String port;
    @ApiModelProperty(value = "出入类型")
    @ApiModelProperty(value = "出入类型 ä»˜è´¹ç±»åž‹ï¼ˆ0预付费) ")
    @ExcelColumn(name="出入类型")
    private String inoutType;
server/visits/dmvisit_service/src/main/resources/application-dev.yml
@@ -33,7 +33,6 @@
  visitor-data-origin: 0 #访客数据 0自建 2以海康为主 1华晟ERP系统
  need-deal-img: true #是否需要处理图片数据
########################压缩包文件位置  ########################
zip_file_path: d://
# Swagger配置