1、包结构修改
2、dict的bug修改 3、arangodb查询find()默认1000条修改为库里所有数据
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
import net.tccn.base.*;
|
||||
import net.tccn.dbq.fbean.FBean;
|
||||
import net.tccn.dbq.jdbc.api.DbAccount;
|
||||
import net.tccn.dbq.jdbc.api.DbKit;
|
||||
import net.tccn.dbq.parser.ParseMysql;
|
||||
import net.tccn.base.dbq.fbean.FBean;
|
||||
import net.tccn.base.dbq.jdbc.api.DbAccount;
|
||||
import net.tccn.base.dbq.jdbc.api.DbKit;
|
||||
import net.tccn.base.dbq.parser.ParseMysql;
|
||||
import net.tccn.dict.Dict;
|
||||
import net.tccn.dict.DictKit;
|
||||
import net.tccn.meta.MetaService;
|
||||
import net.tccn.meta.MetaTable;
|
||||
@@ -22,6 +23,8 @@ import java.io.IOException;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.locks.ReentrantReadWriteLock;
|
||||
import java.util.function.BiPredicate;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
import static java.util.Arrays.asList;
|
||||
|
||||
@@ -66,7 +69,7 @@ public class RunTest<T> {
|
||||
System.out.println("list:" + parse[1]);
|
||||
}
|
||||
|
||||
@Test
|
||||
//@Test
|
||||
public void jdbcTest() {
|
||||
//DbAccount jdbcAccount = new DbAccount("jdbc:mysql://192.168.202.11:3306/gxbii_dev", "root", "eversec123098");
|
||||
DbAccount dbAccount = new DbAccount();
|
||||
@@ -91,7 +94,7 @@ public class RunTest<T> {
|
||||
System.out.println(int.class);*/
|
||||
}
|
||||
|
||||
@Test
|
||||
//@Test
|
||||
public void toAsTest() {
|
||||
Date date = Kv.toAs("2019-03-17 12:11:12", Date.class);
|
||||
System.out.println(date);
|
||||
@@ -128,7 +131,7 @@ public class RunTest<T> {
|
||||
System.out.println(kv);
|
||||
}
|
||||
|
||||
@Test
|
||||
//@Test
|
||||
public void upDb$() {
|
||||
/*MetaKit.getMetaServices().forEach(m -> {
|
||||
List<String> shows = new ArrayList<>();
|
||||
@@ -146,7 +149,7 @@ public class RunTest<T> {
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
//@Test
|
||||
public void findMaxNum() {
|
||||
int xx = asList("1", "5", "3").stream().filter(x -> !x.isEmpty()).mapToInt(x -> {
|
||||
return Integer.parseInt(x) * 2;
|
||||
@@ -166,12 +169,12 @@ public class RunTest<T> {
|
||||
user.save();
|
||||
}
|
||||
|
||||
@Test
|
||||
//@Test
|
||||
public void t() {
|
||||
System.out.println(MetaKit.nextAlias());
|
||||
}
|
||||
|
||||
@Test
|
||||
//@Test
|
||||
public void kvTest() {
|
||||
Map map = new HashMap<>();
|
||||
|
||||
@@ -186,7 +189,7 @@ public class RunTest<T> {
|
||||
System.out.println(kv);
|
||||
}
|
||||
|
||||
@Test
|
||||
//@Test
|
||||
public void tplTest() {
|
||||
TplKit use = TplKit.use(true);
|
||||
use.addTpl(new File(FileKit.rootPath(), "tpl")); //ok
|
||||
@@ -243,7 +246,7 @@ public class RunTest<T> {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
//@Test
|
||||
public void dataToFileTest() {
|
||||
|
||||
List<MetaService> metaServices = MetaService.dao.find();
|
||||
@@ -256,7 +259,7 @@ public class RunTest<T> {
|
||||
FileKit.strToFile(convert.convertTo(metaKit), file);
|
||||
}
|
||||
|
||||
@Test
|
||||
//@Test
|
||||
public void readJson() {
|
||||
File file = new File("tmp/MetaService.json");
|
||||
try {
|
||||
@@ -333,7 +336,7 @@ public class RunTest<T> {
|
||||
}
|
||||
|
||||
// 通用导出组件测试
|
||||
@Test
|
||||
//@Test
|
||||
public void exportTest() {
|
||||
List<Map> list = dbKitTest();
|
||||
|
||||
@@ -351,7 +354,7 @@ public class RunTest<T> {
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
//@Test
|
||||
public void switchTest() {
|
||||
String a = "2";
|
||||
switch (a) {
|
||||
@@ -367,7 +370,7 @@ public class RunTest<T> {
|
||||
System.out.println("end");
|
||||
}
|
||||
|
||||
@Test
|
||||
//@Test
|
||||
public void exceptionTest() {
|
||||
|
||||
try {
|
||||
@@ -377,4 +380,251 @@ public class RunTest<T> {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* IP区间包含IP数计算,含首尾
|
||||
*
|
||||
* @param startIp 其实ip
|
||||
* @param endIp 结束ip
|
||||
* @return
|
||||
*/
|
||||
public int ipv4Count(String startIp, String endIp) {
|
||||
String[] srartArr = startIp.split("[.]");
|
||||
String[] endArr = endIp.split("[.]");
|
||||
int[] c = new int[4];
|
||||
int[] carryOver = {16581375, 65025, 255, 1}; // IP进位数
|
||||
|
||||
for (int i = 0; i < 4; i++) {
|
||||
if (!srartArr[i].equals(endArr[i])) {
|
||||
c[i] = Integer.parseInt(endArr[i]) - Integer.parseInt(srartArr[i]);
|
||||
}
|
||||
}
|
||||
int count = 0;
|
||||
for (int i = 0; i < c.length; i++) {
|
||||
if (c[i] != 0) {
|
||||
count += c[i] * carryOver[i];
|
||||
}
|
||||
}
|
||||
return (count < 0 ? -count : count) + 1;
|
||||
}
|
||||
|
||||
//@Test
|
||||
public void timerTest() {
|
||||
Timer timer = new Timer();
|
||||
|
||||
timer.schedule(new TimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
System.out.println("run task..");
|
||||
}
|
||||
}, 5000, 2000);
|
||||
|
||||
int[] n = {0};
|
||||
timer.schedule(new TimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
System.out.println("周期任务 .. " + ++n[0]);
|
||||
if (n[0] == 2) {
|
||||
System.out.println("周期任务完成");
|
||||
cancel();
|
||||
}
|
||||
}
|
||||
}, 6000, 1000);
|
||||
|
||||
|
||||
try {
|
||||
Thread.sleep(1000 * 10);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//---------------------------- LOCK TEST -----------------------------
|
||||
ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
|
||||
|
||||
ReentrantReadWriteLock.WriteLock writeLock = lock.writeLock();
|
||||
ReentrantReadWriteLock.ReadLock readLock = lock.readLock();
|
||||
|
||||
|
||||
int[] n = {0};
|
||||
|
||||
public String read() {
|
||||
readLock.lock();
|
||||
try {
|
||||
try {
|
||||
Thread.sleep(100);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
System.out.println("read result:" + n[0]);
|
||||
return n[0] + "";
|
||||
} finally {
|
||||
readLock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
public void write() {
|
||||
writeLock.lock();
|
||||
try {
|
||||
try {
|
||||
Thread.sleep(100);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
n[0]++;
|
||||
|
||||
} finally {
|
||||
writeLock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
//@Test
|
||||
public void lockTest() {
|
||||
|
||||
new Thread(() -> {
|
||||
for (int i = 0; i < 50; i++) {
|
||||
read();
|
||||
try {
|
||||
Thread.sleep(100);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}).start();
|
||||
|
||||
new Thread(() -> {
|
||||
for (int i = 0; i < 50; i++) {
|
||||
write();
|
||||
System.out.println("写入数据次数:--------" + (i + 1));
|
||||
try {
|
||||
Thread.sleep(150);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}).start();
|
||||
|
||||
new Thread(() -> {
|
||||
for (int i = 0; i < 50; i++) {
|
||||
write();
|
||||
System.out.println("write:--------" + (i + 1));
|
||||
}
|
||||
}).start();
|
||||
|
||||
try {
|
||||
Thread.sleep(1000 * 30);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
//@Test
|
||||
public void tx() {
|
||||
System.out.println(ipv4Count("0.0.0.2", "0.0.0.0"));
|
||||
}
|
||||
|
||||
Predicate<Dict> isProvice = (s) -> String.valueOf(s.getValue()).trim().endsWith("0000");
|
||||
Predicate<Dict> isCity = (s) -> !isProvice.test(s) && String.valueOf(s.getValue()).trim().endsWith("00");
|
||||
BiPredicate<Dict, Dict> belongProvice = (p, x) -> String.valueOf(x.getValue()).trim().startsWith(String.valueOf(p.getValue()).trim().substring(0, 2));
|
||||
|
||||
@Test
|
||||
public void dictTest() {
|
||||
MetaKit.init();
|
||||
System.out.println("-------- 1 -------");
|
||||
DictKit dictKit = DictKit.use("ipsm_v4");
|
||||
System.out.println(dictKit.getDictLabel("useSubclass", "3"));
|
||||
System.out.println(dictKit.getDictValue("isp", "广电"));
|
||||
|
||||
|
||||
/*List<Dict> list = dictKit.getDicts("city");
|
||||
|
||||
list.stream().filter(x -> x.getValue().startsWith("52") && isCity.test(x)).sorted((a, b) -> a.getValue().compareTo(b.getValue())).forEach(x -> {
|
||||
System.out.println(x);
|
||||
});
|
||||
|
||||
|
||||
List<Map> data = new ArrayList<>();
|
||||
list.stream().filter(x -> isProvice.test(x)).sorted((a, b) -> a.getValue().compareTo(b.getValue())).forEach(x -> {
|
||||
Kv kv = Kv.of("value", x.get("value")).set("label", x.get("label"));
|
||||
List<Kv> childs = new ArrayList<>();
|
||||
list.stream().filter(y -> y.getValue().startsWith(x.getValue().substring(0,2))
|
||||
&& isCity.test(y)
|
||||
).forEach(y -> {
|
||||
childs.add(Kv.of("label", y.get("label")).set("value", y.get("value")));
|
||||
});
|
||||
|
||||
childs.forEach(y -> {
|
||||
List<Kv> childs2 = new ArrayList<>();
|
||||
list.stream().filter(z -> z.getValue().startsWith(String.valueOf(y.get("value")).substring(0, 3))
|
||||
&& !z.getValue().endsWith("00")
|
||||
).forEach(z -> {
|
||||
childs2.add(Kv.of("label", z.get("label")).set("value", z.get("value")));
|
||||
});
|
||||
y.set("childs", childs2);
|
||||
});
|
||||
|
||||
|
||||
kv.set("childs", childs);
|
||||
data.add(kv);
|
||||
});
|
||||
|
||||
FileKit.strToFile(convert.convertTo(data), new File("tmp/city.json"));*/
|
||||
|
||||
}
|
||||
|
||||
public void dictType() {
|
||||
|
||||
}
|
||||
|
||||
//@Test
|
||||
public void txx() {
|
||||
//2400:18c0:0:0:0:0:0:0
|
||||
|
||||
//System.out.println(Integer.parseInt("2400", 16));
|
||||
//System.out.println(Math.pow(2, 32));
|
||||
|
||||
/*String[] arr = "213123".split("");
|
||||
|
||||
for (String x : arr) {
|
||||
System.out.println(x);
|
||||
}*/
|
||||
|
||||
|
||||
/*for (int i = 1; i < 8; i++) {
|
||||
String v = "1";
|
||||
for (int j = 0; j < i; j++) {
|
||||
v = ride(v , "65536");
|
||||
}
|
||||
System.out.printf("%s - %s%n", i, v);
|
||||
}*/
|
||||
|
||||
/*String ip = "::9";
|
||||
|
||||
System.out.println(ipv6Num("::1"));
|
||||
System.out.println(ip);*/
|
||||
|
||||
|
||||
//System.out.println(ipv6Num("2400:18c0:0:0:0:0:0:0"));
|
||||
|
||||
/*for (int x = 0; x < 100; x++) {
|
||||
for (int y = 0; y < 100; y++) {
|
||||
long a = Integer.parseInt(IpKit.add(x + "", y + ""));
|
||||
long b = x + y;
|
||||
if (a != b) {
|
||||
System.out.printf("%d + %d = %s, \t %s \n", x, y, a, b);
|
||||
} else {
|
||||
System.out.printf("=");
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
/*System.out.println(toNum("127.0.0.1"));
|
||||
|
||||
System.out.println(ipCount("0::0:0", "0::0:2"));*/
|
||||
|
||||
//System.out.println(toNum("254.16.3.56"));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user