parent
c98d85d5e9
commit
27d55cf264
@ -1,75 +0,0 @@
|
||||
package UnitTest;
|
||||
|
||||
import java.sql.*;
|
||||
|
||||
public class OpenGaussWriteShiWu_JDBC {
|
||||
|
||||
// JDBC连接参数
|
||||
private static final String DB_DRIVER = "org.postgresql.Driver";
|
||||
private static final String DB_CONNECTION = "jdbc:postgresql://10.10.14.63:15400/test_db";
|
||||
private static final String DB_USER = "postgres";
|
||||
private static final String DB_PASSWORD = "DsideaL147258369";
|
||||
|
||||
// 批量插入数据
|
||||
public static void batchInsertData() {
|
||||
// JDBC连接对象
|
||||
Connection conn = null;
|
||||
// JDBC执行语句对象
|
||||
Statement stmt = null;
|
||||
|
||||
try {
|
||||
// 加载JDBC驱动程序
|
||||
Class.forName(DB_DRIVER);
|
||||
// 获取JDBC连接对象
|
||||
conn = DriverManager.getConnection(DB_CONNECTION, DB_USER, DB_PASSWORD);
|
||||
// 设置事务自动提交为false
|
||||
conn.setAutoCommit(false);
|
||||
// 获取JDBC执行语句对象
|
||||
stmt = conn.createStatement();
|
||||
// 批量插入数据的SQL语句
|
||||
String sql = "INSERT INTO test(id, txt) VALUES (?, ?)";
|
||||
// 预编译SQL语句并添加批量操作数据
|
||||
long start = System.currentTimeMillis();
|
||||
|
||||
int cnt=0;
|
||||
for (int k = 1; k <= 10; k++) {
|
||||
PreparedStatement pstmt = conn.prepareStatement(sql);
|
||||
for (int i = 1; i <= 10000; i++) {
|
||||
cnt++;
|
||||
pstmt.setInt(1, cnt);
|
||||
pstmt.setString(2, "黄海_" + i);
|
||||
pstmt.addBatch();
|
||||
}
|
||||
// 执行批量插入操作
|
||||
pstmt.executeBatch();
|
||||
// 提交事务
|
||||
conn.commit();
|
||||
}
|
||||
|
||||
long end = System.currentTimeMillis();
|
||||
long elapsed = end - start;
|
||||
System.out.println("程序耗时:" + elapsed + " 毫秒");
|
||||
} catch (SQLException | ClassNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
try {
|
||||
conn.rollback();
|
||||
} catch (SQLException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
} finally {
|
||||
try {
|
||||
if (stmt != null) {
|
||||
stmt.close();
|
||||
}
|
||||
if (conn != null) {
|
||||
conn.close();
|
||||
}
|
||||
} catch (SQLException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
public static void main(String[] args) {
|
||||
batchInsertData();
|
||||
}
|
||||
}
|
@ -1,52 +0,0 @@
|
||||
package UnitTest;
|
||||
|
||||
import com.dsideal.QingLong.Util.CommonUtil;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public class TestC {
|
||||
|
||||
public static int maxSumTwoNoOverlap(int[] nums, int firstLen, int secondLen) {
|
||||
int n = nums.length;
|
||||
int[] prefixSum = new int[n + 1];
|
||||
for (int i = 1; i <= n; i++) {
|
||||
prefixSum[i] = prefixSum[i - 1] + nums[i - 1];
|
||||
}
|
||||
int maxSum = 0;
|
||||
int[] maxSumLeft = new int[n];
|
||||
int[] maxSumRight = new int[n];
|
||||
int maxLeft = 0, maxRight = 0;
|
||||
for (int i = firstLen - 1; i <= n - secondLen; i++) {
|
||||
int sum = prefixSum[i + 1] - prefixSum[i - firstLen + 1];
|
||||
if (sum > maxLeft) {
|
||||
maxLeft = sum;
|
||||
}
|
||||
maxSumLeft[i] = maxLeft;
|
||||
}
|
||||
for (int i = n - secondLen; i >= firstLen - 1; i--) {
|
||||
int sum = prefixSum[i + secondLen] - prefixSum[i];
|
||||
if (sum >= maxRight) {
|
||||
maxRight = sum;
|
||||
}
|
||||
maxSumRight[i] = maxRight;
|
||||
}
|
||||
for (int i = firstLen - 1; i <= n - secondLen; i++) {
|
||||
int sum = prefixSum[i + 1] - prefixSum[i - firstLen + 1];
|
||||
maxSum = Math.max(maxSum, sum + maxSumRight[i + 1]);
|
||||
maxSum = Math.max(maxSum, sum + maxSumLeft[i - 1]);
|
||||
}
|
||||
return maxSum;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
int[] nums1 = { 0, 6, 5, 2, 2, 5, 1, 9, 4 };
|
||||
int firstLen1 = 1;
|
||||
int secondLen1 = 2;
|
||||
System.out.println(maxSumTwoNoOverlap(nums1, firstLen1, secondLen1)); // expect 20
|
||||
}
|
||||
}
|
@ -1,32 +0,0 @@
|
||||
package UnitTest;
|
||||
|
||||
import com.jfinal.plugin.activerecord.ActiveRecordPlugin;
|
||||
import com.jfinal.plugin.activerecord.Db;
|
||||
import com.jfinal.plugin.activerecord.Record;
|
||||
import com.jfinal.plugin.activerecord.dialect.PostgreSqlDialect;
|
||||
import com.jfinal.plugin.hikaricp.HikariCpPlugin;
|
||||
import org.apache.poi.ss.usermodel.*;
|
||||
import org.apache.poi.xssf.streaming.SXSSFWorkbook;
|
||||
import org.apache.poi.xssf.usermodel.DefaultIndexedColorMap;
|
||||
import org.apache.poi.xssf.usermodel.XSSFColor;
|
||||
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class TestExportExcel {
|
||||
|
||||
public static void main(String[] args) throws IOException {
|
||||
//读取库
|
||||
HikariCpPlugin hp = new HikariCpPlugin("jdbc:postgresql://10.10.14.71:5432/szjz_db", "postgres",
|
||||
"DsideaL147258369", "org.postgresql.Driver");
|
||||
hp.start();
|
||||
|
||||
ActiveRecordPlugin arp = new ActiveRecordPlugin(hp);
|
||||
arp.setDialect(new PostgreSqlDialect());
|
||||
arp.start();
|
||||
|
||||
}
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
package UnitTest;
|
||||
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
|
||||
public class TestGrid {
|
||||
|
||||
public static void main(String[] args) {
|
||||
String path = "D:\\dsWork\\QingLong\\src\\main\\java\\UnitTest\\TestGrid.json";
|
||||
String content = FileUtil.readUtf8String(path);
|
||||
}
|
||||
}
|
@ -1,96 +0,0 @@
|
||||
[
|
||||
{
|
||||
"id": "input_6",
|
||||
"index": 0,
|
||||
"label": "单行文本",
|
||||
"tag": "input",
|
||||
"tagIcon": "input",
|
||||
"placeholder": "请输入",
|
||||
"defaultValue": null,
|
||||
"labelWidth": 110,
|
||||
"width": "100%",
|
||||
"clearable": true,
|
||||
"maxlength": null,
|
||||
"showWordLimit": false,
|
||||
"readonly": false,
|
||||
"disabled": false,
|
||||
"required": true,
|
||||
"expression": "",
|
||||
"document": ""
|
||||
},
|
||||
{
|
||||
"id": "grid_8",
|
||||
"index": 1,
|
||||
"tag": "grid",
|
||||
"span": 2,
|
||||
"columns": [
|
||||
{
|
||||
"span": 12,
|
||||
"list": [
|
||||
{
|
||||
"id": "input_9",
|
||||
"index": 0,
|
||||
"label": "单行文本",
|
||||
"tag": "input",
|
||||
"tagIcon": "input",
|
||||
"placeholder": "请输入",
|
||||
"defaultValue": null,
|
||||
"labelWidth": 110,
|
||||
"width": "100%",
|
||||
"clearable": true,
|
||||
"maxlength": null,
|
||||
"showWordLimit": false,
|
||||
"readonly": false,
|
||||
"disabled": false,
|
||||
"required": true,
|
||||
"expression": "",
|
||||
"document": ""
|
||||
},
|
||||
{
|
||||
"id": "input_11",
|
||||
"index": 1,
|
||||
"label": "单行文本",
|
||||
"tag": "input",
|
||||
"tagIcon": "input",
|
||||
"placeholder": "请输入",
|
||||
"defaultValue": null,
|
||||
"labelWidth": 110,
|
||||
"width": "100%",
|
||||
"clearable": true,
|
||||
"maxlength": null,
|
||||
"showWordLimit": false,
|
||||
"readonly": false,
|
||||
"disabled": false,
|
||||
"required": true,
|
||||
"expression": "",
|
||||
"document": ""
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"span": 12,
|
||||
"list": [
|
||||
{
|
||||
"id": "input_10",
|
||||
"index": 0,
|
||||
"label": "单行文本",
|
||||
"tag": "input",
|
||||
"tagIcon": "input",
|
||||
"placeholder": "请输入",
|
||||
"defaultValue": null,
|
||||
"labelWidth": 110,
|
||||
"width": "100%",
|
||||
"clearable": true,
|
||||
"maxlength": null,
|
||||
"showWordLimit": false,
|
||||
"readonly": false,
|
||||
"disabled": false,
|
||||
"required": true,
|
||||
"expression": "",
|
||||
"document": ""
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
@ -1,12 +0,0 @@
|
||||
|
||||
<div>
|
||||
实验室建设年份: <input type="text" name="xx_kxsysjsnf1" value="2024"> 实验室面积: <input type="text" name="xx_kxsysmj1" value="200">
|
||||
</div>
|
||||
|
||||
<div>
|
||||
实验室建设年份: <input type="text" name="xx_kxsysjsnf2" value="2021"> 实验室面积: <input type="text" name="xx_kxsysmj2" value="140">
|
||||
</div>
|
||||
|
||||
<div>
|
||||
实验室建设年份: <input type="text" name="xx_kxsysjsnf3" value="2000"> 实验室面积: <input type="text" name="xx_kxsysmj3" value="230">
|
||||
</div>
|
@ -1,60 +0,0 @@
|
||||
package UnitTest;
|
||||
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import com.jfinal.kit.Kv;
|
||||
import com.jfinal.kit.StrKit;
|
||||
import org.jsoup.Jsoup;
|
||||
import org.jsoup.nodes.Document;
|
||||
import org.jsoup.nodes.Element;
|
||||
import com.jfinal.plugin.activerecord.Record;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.jsoup.select.Elements;
|
||||
|
||||
public class TestHtml {
|
||||
|
||||
public static Record CkSave(String html) {
|
||||
Document doc = Jsoup.parseBodyFragment(html);
|
||||
Element body = doc.body();
|
||||
Elements elements = body.getAllElements().getFirst().getElementsByTag("input");
|
||||
for (int i = 0; i < elements.size(); i += 3) {
|
||||
/*
|
||||
家用器具使用与维护
|
||||
xx_ldjy_jsfl
|
||||
xx_ldjy_js 666
|
||||
其他
|
||||
xx_ldjy_jsfl_VOtzywtcmC BBB
|
||||
xx_ldjy_js_VOtzywtcmC 999
|
||||
* */
|
||||
Element input = elements.get(i);
|
||||
|
||||
if (input.attr("value").trim().endsWith("其他")) {
|
||||
Element input2 = elements.get(i + 1);
|
||||
String v2 = input2.attr("value");
|
||||
|
||||
Element input3 = elements.get(i + 2);
|
||||
String v3 = input3.attr("value");
|
||||
|
||||
System.out.println("lx_name=" + v2 + ",js=" + v3);
|
||||
} else {
|
||||
Element input3 = elements.get(i + 2);
|
||||
String v3 = input3.attr("value");
|
||||
|
||||
System.out.println("lx_name=" + input.attr("value").trim() + ",js=" + v3);
|
||||
}
|
||||
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
//开始解析
|
||||
String html = FileUtil.readUtf8String("C:\\Users\\Administrator\\Desktop\\Html\\劳动.txt");
|
||||
|
||||
|
||||
CkSave(html);
|
||||
}
|
||||
}
|
@ -1,59 +0,0 @@
|
||||
package UnitTest;
|
||||
|
||||
import com.dsideal.QingLong.Start;
|
||||
import com.jfinal.kit.Kv;
|
||||
import com.jfinal.kit.PropKit;
|
||||
import com.jfinal.plugin.activerecord.ActiveRecordPlugin;
|
||||
import com.jfinal.plugin.activerecord.CaseInsensitiveContainerFactory;
|
||||
import com.jfinal.plugin.activerecord.Db;
|
||||
import com.jfinal.plugin.activerecord.SqlPara;
|
||||
import com.jfinal.plugin.activerecord.Record;
|
||||
import com.jfinal.plugin.activerecord.dialect.PostgreSqlDialect;
|
||||
import com.jfinal.plugin.hikaricp.HikariCpPlugin;
|
||||
|
||||
import java.io.File;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class TestIn {
|
||||
public static void main(String[] args) throws URISyntaxException {
|
||||
//告之配置文件位置
|
||||
PropKit.use("application.properties");
|
||||
HikariCpPlugin hp = new HikariCpPlugin(PropKit.get("jdbcUrl"), PropKit.get("user"),
|
||||
PropKit.get("password").trim(), PropKit.get("driverClassName"));
|
||||
hp.start();
|
||||
// 配置ActiveRecord插件
|
||||
ActiveRecordPlugin arp = new ActiveRecordPlugin(hp);
|
||||
//配置默认小写
|
||||
arp.setContainerFactory(new CaseInsensitiveContainerFactory(true));
|
||||
|
||||
arp.setDialect(new PostgreSqlDialect());
|
||||
//遍历sql目录下所有的sql文件
|
||||
File sqlDir;
|
||||
String basePath = Start.class.getClassLoader().getResource(".").getPath();
|
||||
sqlDir = new File(basePath + "/Sql");
|
||||
File[] sqlFiles = sqlDir.listFiles();
|
||||
for (File sqlFile : sqlFiles != null ? sqlFiles : new File[0]) {
|
||||
//只加载.sql文件
|
||||
if (sqlFile.getName().indexOf(".sql") > 0) {
|
||||
arp.addSqlTemplate("/Sql/" + sqlFile.getName());
|
||||
}
|
||||
}
|
||||
arp.start();
|
||||
|
||||
//JFinal的in查询现在太方便了
|
||||
List<String> idList = new ArrayList<>();
|
||||
idList.add("A36E0132-625C-4C43-A1B9-8312DD8CCF07");
|
||||
idList.add("11716B1E-CD95-4E36-9857-296ABE6E4B96");
|
||||
Kv kv = Kv.by("idList", idList);
|
||||
SqlPara sqlPara = Db.getSqlPara("Test.huanghai_in", kv);
|
||||
List<Record> list = Db.find(sqlPara);
|
||||
System.out.println(list);
|
||||
|
||||
kv = Kv.by("org_name", "第八中学");
|
||||
sqlPara = Db.getSqlPara("Test.huanghai_like", kv);
|
||||
list = Db.find(sqlPara);
|
||||
System.out.println(list.get(0).getStr("org_name"));
|
||||
}
|
||||
}
|
@ -1,30 +0,0 @@
|
||||
package UnitTest;
|
||||
|
||||
import com.dsideal.QingLong.Util.RedisKit;
|
||||
import com.jfinal.kit.PropKit;
|
||||
import com.jfinal.plugin.redis.RedisPlugin;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
public class TestJedisSet {
|
||||
public static void main(String[] args) {
|
||||
PropKit.use("application.properties");
|
||||
// 用于缓存模块的redis服务
|
||||
RedisPlugin redis = new RedisPlugin("myRedis", PropKit.get("redis_ip"), PropKit.getInt("redis_port"), 10 * 1000);
|
||||
redis.start();
|
||||
String SYS_JRXT="SYS_JRXT";
|
||||
RedisKit.SAdd(SYS_JRXT,"a");
|
||||
RedisKit.SAdd(SYS_JRXT,"b");
|
||||
RedisKit.SAdd(SYS_JRXT,"c");
|
||||
Set<String> s=RedisKit.SMembers(SYS_JRXT);
|
||||
for (String string : s) {
|
||||
System.out.println(string);
|
||||
}
|
||||
System.out.println("===================================");
|
||||
RedisKit.SRem(SYS_JRXT,"b");
|
||||
s=RedisKit.SMembers(SYS_JRXT);
|
||||
for (String string : s) {
|
||||
System.out.println(string);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,39 +0,0 @@
|
||||
package UnitTest;
|
||||
|
||||
import com.jfinal.plugin.activerecord.ActiveRecordPlugin;
|
||||
import com.jfinal.plugin.activerecord.Db;
|
||||
import com.jfinal.plugin.activerecord.Record;
|
||||
import com.jfinal.plugin.activerecord.dialect.PostgreSqlDialect;
|
||||
import com.jfinal.plugin.druid.DruidPlugin;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class TestOpenGauss {
|
||||
public static void main(String[] args) {
|
||||
//读取库
|
||||
DruidPlugin druid = new DruidPlugin("jdbc:postgresql://10.10.14.62:5432/ccdjzswd_db", "dsideal",
|
||||
"DsideaL147258369", "org.postgresql.Driver");
|
||||
druid.start();
|
||||
|
||||
ActiveRecordPlugin arp = new ActiveRecordPlugin(druid);
|
||||
arp.setDialect(new PostgreSqlDialect());
|
||||
arp.start();
|
||||
|
||||
String sql = "truncate table t1";
|
||||
Db.update(sql);
|
||||
|
||||
List<Record> aList = new ArrayList<>();
|
||||
for (int i = 1; i <= 1000; i++) {
|
||||
Record record = new Record();
|
||||
record.set("id", i);
|
||||
record.set("name", "黄海" + i);
|
||||
aList.add(record);
|
||||
}
|
||||
Db.batchSave("t1", aList, 100);
|
||||
|
||||
sql = "select * from t1";
|
||||
List<Record> list = Db.find(sql);
|
||||
System.out.println(list);
|
||||
}
|
||||
}
|
@ -1,28 +0,0 @@
|
||||
package UnitTest;
|
||||
|
||||
public class test01 {
|
||||
/* 零钱兑换:贪心 */
|
||||
private static int coinChangeGreedy(int[] coins, int amt) {
|
||||
// 假设 coins 列表有序
|
||||
int i = coins.length - 1;
|
||||
int count = 0;
|
||||
// 循环进行贪心选择,直到无剩余金额
|
||||
while (amt > 0) {
|
||||
// 找到小于且最接近剩余金额的硬币
|
||||
while (i > 0 && coins[i] > amt) {
|
||||
i--;
|
||||
}
|
||||
// 选择 coins[i]
|
||||
amt -= coins[i];
|
||||
System.out.println(coins[i]);
|
||||
count++;
|
||||
}
|
||||
// 若未找到可行方案,则返回 -1
|
||||
return amt == 0 ? count : -1;
|
||||
}
|
||||
public static void main(String[] args) {
|
||||
|
||||
int[] coins = {1,5,10,20,50,100};
|
||||
System.out.println(coinChangeGreedy(coins,1257));
|
||||
}
|
||||
}
|
@ -1,20 +0,0 @@
|
||||
package UnitTest;
|
||||
|
||||
public class test1 {
|
||||
public static void main(String[] args) {
|
||||
MultiThreadTool multiThreadTool = new MultiThreadTool(20);
|
||||
|
||||
for (int i = 0; i < 100; i++) {
|
||||
int taskIndex = i;
|
||||
multiThreadTool.execute(() -> {
|
||||
System.out.println("Task " + taskIndex + " is running.");
|
||||
try {
|
||||
Thread.sleep(1000); // 模拟任务执行
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
System.out.println("Task " + taskIndex + " is completed.");
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
package com.dsideal.QingLong.Const;
|
||||
|
||||
public class DbConst {
|
||||
public static String MASTER="master";
|
||||
public static String SLAVE="slave";
|
||||
public static String SZJZ="SZJZ";
|
||||
public static String MAXKB="MAXKB";
|
||||
}
|
Loading…
Reference in new issue