kgdxpr 1 year ago
commit 839484e368

@ -0,0 +1,69 @@
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);
}
}
}

@ -57,10 +57,10 @@ public class ZjcqController extends Controller {
*/ */
@Before({GET.class}) @Before({GET.class})
@IsLoginInterface({}) @IsLoginInterface({})
@EmptyInterface({"lx_ids"}) @EmptyInterface({"lx_ids","ly_ids"})
@IsNumericInterface({"count"}) @IsNumericInterface({"count"})
public void doZjcq(int ys_id, String lx_ids, int ys_person_count) { public void doZjcq(int ys_id, String lx_ids, String ly_ids, int ys_person_count) {
List<Record> list = zm.doZjcq(ys_id, lx_ids, ys_person_count); List<Record> list = zm.doZjcq(ys_id, lx_ids,ly_ids, ys_person_count);
renderJson(list); renderJson(list);
} }

@ -1,8 +1,5 @@
package com.dsideal.QingLong.Zjcq.Model; package com.dsideal.QingLong.Zjcq.Model;
import com.dsideal.QingLong.Interceptor.IsLoginInterface;
import com.jfinal.aop.Before;
import com.jfinal.ext.interceptor.GET;
import com.jfinal.plugin.activerecord.Db; import com.jfinal.plugin.activerecord.Db;
import com.jfinal.plugin.activerecord.Page; import com.jfinal.plugin.activerecord.Page;
import com.jfinal.plugin.activerecord.Record; import com.jfinal.plugin.activerecord.Record;
@ -15,20 +12,21 @@ public class ZjcqModel {
* *
*/ */
public List<Record> getLxList() { public List<Record> getLxList() {
String sql = "select * from t_zhuanjia_lx order by lx_id"; String sql = "select * from t_zhuanjia_lx order by sort_id";
return Db.find(sql); return Db.find(sql);
} }
/** /**
* *
* *
* @param ys_id * @param ys_id ID
* @param lx_ids * @param lx_ids IDS
* @param ys_person_count * @param ly_ids IDS
* @param ys_person_count
* @return * @return
*/ */
public List<Record> doZjcq(int ys_id, String lx_ids, int ys_person_count) { public List<Record> doZjcq(int ys_id, String lx_ids, String ly_ids, int ys_person_count) {
String sql = "select * from t_zhuangjia_base where lx_id in (" + lx_ids + ") and b_use=1 order by random() limit ?"; String sql = "select t1.* from t_zhuanjia_base as t1 inner join t_zhuanjia_base_zc as t2 on t1.person_id=t2.person_id and t2.zc_id in (" + ly_ids + ") where t1.lx_id in (" + lx_ids + ") and t1.b_use=1 order by random() limit ?";
List<Record> list = Db.find(sql, ys_person_count); List<Record> list = Db.find(sql, ys_person_count);
//保存专家抽取结果 //保存专家抽取结果
sql = "delete from t_zhuanjia_record_detail where ys_id=?"; sql = "delete from t_zhuanjia_record_detail where ys_id=?";

Loading…
Cancel
Save