@ -12,6 +12,9 @@ import com.dsideal.QingLong.Global.Model.GlobalModel;
import com.dsideal.QingLong.Util.ChineseCharacterUtil ;
import com.dsideal.QingLong.Util.CommonUtil ;
import com.dsideal.QingLong.Util.PoiUtil ;
import com.dsideal.QingLong.Util.SimilarUtil ;
import com.hankcs.hanlp.seg.common.Term ;
import com.hankcs.hanlp.tokenizer.StandardTokenizer ;
import com.jfinal.kit.Kv ;
import com.jfinal.kit.StrKit ;
import com.jfinal.plugin.activerecord.Db ;
@ -1694,7 +1697,7 @@ public class CollectModel {
case 2 : //数字
int v2 ;
if ( StrKit . isBlank ( entry . getValue ( ) . toString ( ) ) ) v2 = 0 ;
else v2 = Integer . parseInt ( entry . getValue ( ) . toString ( ) ) ;
else v2 = Integer . parseInt ( entry . getValue ( ) . toString ( ) ) ;
record . set ( key , v2 ) ;
break ;
case 3 : //小数
@ -2578,20 +2581,19 @@ public class CollectModel {
*
* @return
* /
public Page < Record > getAllBureau ( int is_match , int page , int limit ) {
public Page < Record > getAllBureau ( int is_match , int page , int limit ) {
//返回查询列表
GlobalModel gm = new GlobalModel ( ) ;
String city_id = gm . getGlobalValueByKey ( "install_area" ) ;
Kv kv = Kv . by ( "city_id" , city_id ) ;
kv . set ( "is_match" , is_match ) ;
Kv kv = Kv . by ( "city_id" , city_id ) ;
kv . set ( "is_match" , is_match ) ;
SqlPara sqlPara = Db . getSqlPara ( "Collect.getAllBureau" , kv ) ;
Page < Record > pageRecord = Db . paginate ( page , limit , sqlPara ) ;
return pageRecord ;
}
/ * *
* 功 能 : 匹 配 第 三 方 系 统 与 我 们 的 系 统 单 位 ID 一 致
*
@ -2613,4 +2615,122 @@ public class CollectModel {
record . set ( "third_party_id" , null ) ;
Db . update ( "t_base_organization" , "org_id" , record ) ;
}
public static String KEY = "TY_BUREAU" ;
/ * *
* 功 能 : 利 用 中 文 分 词 技 术 , 将 两 个 字 符 串 都 进 行 分 词 , 通 过 对 比 完 全 命 中 的 数 量 来 评 估 是 不 是 两 个 单 位 名 称 是 同 一 个 单 位
*
* @param s1
* @param s2
* @return
* /
public static boolean check ( String s1 , String s2 ) {
//静态变量
String [ ] area = {
"南关区" , "宽城区" , "朝阳区" , "二道区" , "绿园区" , "双阳区" , "九台市" ,
"农安县" , "经开区" , "德惠市" , "高新区" , "净月区" , "汽开区" , "榆树市" , "公主岭市" , "长春市"
} ;
List < String > areaList = Arrays . stream ( area ) . toList ( ) ;
List < Term > termList1 = StandardTokenizer . segment ( s1 ) ;
Map < String , Integer > map = new HashMap < > ( ) ;
for ( Term term : termList1 ) {
String key = SimilarUtil . Convert ( term . word ) ;
for ( int i = 0 ; i < areaList . size ( ) ; i + + ) {
if ( areaList . get ( i ) . startsWith ( key ) ) {
key = areaList . get ( i ) ;
break ;
}
}
int x = 0 ;
if ( map . containsKey ( key ) ) x = map . get ( key ) ;
map . put ( key , x + 1 ) ;
}
List < Term > termList2 = StandardTokenizer . segment ( s2 ) ;
for ( Term term : termList2 ) {
String key = SimilarUtil . Convert ( term . word ) ;
for ( int i = 0 ; i < areaList . size ( ) ; i + + ) {
if ( areaList . get ( i ) . startsWith ( key ) ) {
key = areaList . get ( i ) ;
break ;
}
}
int x = 0 ;
if ( map . containsKey ( key ) ) x = map . get ( key ) ;
map . put ( key , x + 1 ) ;
}
// 使用 for-each 循环遍历 Map
for ( Map . Entry < String , Integer > entry : map . entrySet ( ) ) {
if ( entry . getValue ( ) = = 1 ) return false ;
}
return true ;
}
/ * *
* 功 能 : 绑 定 两 个 组 织 机 构 码 之 间 的 关 联 关 系
*
* @param org_id
* @param ty_org_id
* /
public void bind ( String org_id , String ty_org_id ) {
//与我系统中单位名称完全一致,则自动完成关联
String sql = "update t_base_organization set third_party_id=? where org_id=?" ;
Db . update ( sql , ty_org_id , org_id ) ;
}
/ * *
* 功 能 : 一 键 匹 配
* /
public int OneKeyMatch ( ) {
int cnt = 0 ;
//从天喻获取所有单位名单
String sql = "select t1.org_id,t1.org_name from ds_base_bureau as t1 where t1.org_id not in (select t2.org_id from t_base_organization as t2 where t2.org_id=t2.bureau_id and t2.third_party_id is not null) order by t1.org_name" ;
List < Record > list = Db . find ( sql ) ;
List < JSONObject > tyList = new ArrayList < > ( ) ;
for ( Record record : list ) {
String org_id = record . getStr ( "org_id" ) ;
String org_name = record . getStr ( "org_name" ) ;
JSONObject jo2 = new JSONObject ( ) ;
jo2 . put ( "org_id" , org_id ) ;
jo2 . put ( "org_name" , org_name ) ;
tyList . add ( jo2 ) ;
}
String [ ] array = new String [ tyList . size ( ) ] ;
for ( int i = 0 ; i < tyList . size ( ) ; i + + ) {
array [ i ] = tyList . get ( i ) . getString ( "org_name" ) ;
}
//我们系统中的单位名称
sql = "select org_id,org_name from t_base_organization where bureau_id=org_id and is_virtual=0 and third_party_id is null" ;
List < Record > ourList = Db . find ( sql ) ;
for ( Record record : ourList ) {
String org_name = record . getStr ( "org_name" ) ;
String org_id = record . getStr ( "org_id" ) ;
JSONObject jo = SimilarUtil . Get ( org_name , array ) ;
int idx = jo . getInteger ( "idx" ) ;
String ty_org_name = array [ idx ] ;
double similary = jo . getDouble ( "similary" ) ;
String ty_org_id = tyList . get ( idx ) . getString ( "org_id" ) ;
if ( Math . abs ( similary - 1.0 ) < 0.0001 ) {
//与我系统中单位名称完全一致,则自动完成关联
bind ( org_id , ty_org_id ) ;
cnt + + ;
} else {
//没有完全一致的,就让系统推荐一个
//再用其它的算法检查一下这个推荐的是不是合适
boolean success = check ( org_name , ty_org_name ) ;
if ( success ) {
bind ( org_id , ty_org_id ) ;
cnt + + ;
}
}
}
return cnt ;
}
}