You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

69 lines
2.3 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

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 java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import static com.dsideal.QingLong.Const.DbConst.MASTER;
public class ZhuangJaiLingYu {
public static HikariCpPlugin createDruidPlugin(String url, String username, String password, String driverClass) {
HikariCpPlugin hp = new HikariCpPlugin(url, username, password, driverClass);
return hp;
}
public static String replaceMultipleSpaces(String input) {
Pattern pattern = Pattern.compile("\\s+");
Matcher matcher = pattern.matcher(input);
return matcher.replaceAll(" ");
}
public static void main(String[] args) {
String masterUrl = "jdbc:postgresql://10.10.14.71:5432/szjz_db";
String passWord = "DsideaL147258369";
String driverClass = "org.postgresql.Driver";
String userName = "postgres";
HikariCpPlugin druidMaster = createDruidPlugin(masterUrl, userName, passWord, driverClass);
druidMaster.start();
ActiveRecordPlugin arpMaster = new ActiveRecordPlugin(MASTER, druidMaster);
arpMaster.setDevMode(false);
arpMaster.setDialect(new PostgreSqlDialect());
arpMaster.start();
String sql = "select * from t_zhuangjia_base";
List<Record> list = Db.find(sql);
Set<String> set=new HashSet<>();
for (Record record : list) {
if (record.getStr("ly")!=null && !record.getStr("ly").isEmpty()) {
String ly = replaceMultipleSpaces(record.getStr("ly"));
ly=ly.replace("",",");
ly = ly.replace(" ", ",");
ly=ly.replace(",,",",");
for (String s : ly.split(",")) {
set.add(s);
}
}else{
System.out.println(record.getInt("person_id"));
}
}
for (String s : set) {
System.out.println(s);
}
}
}