| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- package com.steerinfo.util;
- import com.steerinfo.framework.utils.collection.ListUtils;
- import com.steerinfo.meterwork.constants.DbConstants;
- import com.steerinfo.rtdb.*;
- import com.sun.org.apache.bcel.internal.generic.NEW;
- import java.math.BigDecimal;
- import java.util.ArrayList;
- import java.util.List;
- public class TestClient2 {
- public static Client getConnecting() {
- ClientConfig config = new ClientConfig();
- config.username = "guest";
- config.password = "";
- // int j = 0;
- // while (j < 2) {
- // SocketChannelProvider socketChannel = new SingleSocketChannelProviderImpl("172.16.100.139:2013");
- // Client client = new ClientImpl(socketChannel, config);
- // List<ArrayList> res1 = (List<ArrayList>) client.syncOps().call("db.space.Live:select",Collections.emptyList());
- // client.close();
- // List ll = res1.get(0);
- // for (int i = 0; i < ll.size(); i++) {
- // String s = ll.get(i).toString();
- // String head = s.substring(1, s.indexOf(","));
- // if (head.endsWith("56-202/8101/totalpower")) {
- // ////system.out.println(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()) + " : " + s);
- // }
- // if (head.endsWith("totalpower") && head.startsWith("device/iec102-42-159")) {
- // //system.out.println(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()) + " : " + s);
- // }
- // }
- // Thread.sleep(1000 * 10);
- // j++;
- // }
- SocketChannelProvider socketChannel = new SingleSocketChannelProviderImpl("172.22.42.3:2101");
- return new ClientImpl(socketChannel, config);
- }
- public static List connectSelect(String no) {
- try {
- List<ArrayList> res1 = (List<ArrayList>) DbConstants.client.syncOps().call("db.space.TrackWeight:select", no);
- List ll = res1.get(0);
- return ll;
- } catch (Exception e) {
- DbConstants.client.close();
- DbConstants.client = TestClient2.getConnecting();
- return null;
- }
- }
- public static void main(String[] args) {
- ClientConfig config = new ClientConfig();
- config.username = "guest";
- config.password = "";
- SocketChannelProvider socketChannel = new SingleSocketChannelProviderImpl("192.168.102.51:2101");
- Client client = new ClientImpl(socketChannel, config);
- List<ArrayList> res1 = (List<ArrayList>) client.syncOps().call("LiveData:readByPointId", "CAR01");
- if (ListUtils.isNotEmpty(res1)) {
- List listDate1 = res1.get(0);
- BigDecimal westTime = BigDecimal.valueOf(0),eastTime = BigDecimal.valueOf(0);
- String vlprWest = "", vlprEast = "";
- for (Object liveDate : listDate1) {
- String myLiveDate = liveDate.toString();
- String[] listDate = myLiveDate.split(",");
- if (listDate[0].equals("[HMI01VlprWest")) {
- westTime = new BigDecimal(listDate[2].trim());
- vlprWest = listDate[1].trim();
- //system.out.println("测试输出1:" + listDate[1].trim());
- }
- if (listDate[0].equals("[HMI01VlprEast")) {
- eastTime = new BigDecimal(listDate[2].trim());
- vlprEast = listDate[1].trim();
- //system.out.println("测试输出2:" + listDate[1].trim());
- }
- }
- if (westTime.compareTo(eastTime) > 0) {
- //system.out.println("测试输出3:" + vlprWest);
- } else {
- //system.out.println("测试输出4:" + vlprEast);
- }
- }
- client.close();
- List ll = res1.get(0);
- ArrayList arr = (ArrayList) ll.get(0);
- //system.out.println(arr.get(6));
- }
- }
|