|
@ -0,0 +1,106 @@
|
|
|
package com.yihu.hos.standard.match.dictionary;
|
|
|
|
|
|
import com.yihu.hos.standard.dao.IStdDictionaryModelDao;
|
|
|
import com.yihu.hos.standard.dao.StdDictionaryEntryModelDao;
|
|
|
import com.yihu.hos.standard.match.matchModel.DictItemMatchVO;
|
|
|
import com.yihu.hos.standard.model.adapter.AdapterDictEntryModel;
|
|
|
import com.yihu.hos.standard.service.adapter.AdapterDictEntryService;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
|
|
|
/**
|
|
|
* Created by Administrator on 2016/6/24.
|
|
|
* 字典项匹配器
|
|
|
*/
|
|
|
public class DictItemStrategyExecute implements Runnable {
|
|
|
public static Map<String, List<Integer>> size = new HashMap<String, List<Integer>>();
|
|
|
private DictItemMatchVO matchVO;
|
|
|
private DictitemStandardExistStrategy standardExistStrategy;
|
|
|
private AdapterDictEntryModel adapterDictEntryModel;
|
|
|
private String adapter_std_version;
|
|
|
private String version;
|
|
|
private IStdDictionaryModelDao stdDictionaryDao;
|
|
|
private StdDictionaryEntryModelDao stdDictionaryEntryDao;
|
|
|
private AdapterDictEntryService adapterDictEntryService;
|
|
|
|
|
|
public DictItemStrategyExecute(
|
|
|
AdapterDictEntryModel adapterDictEntryModel,
|
|
|
DictItemMatchVO matchVO,
|
|
|
String adapter_std_version,
|
|
|
String version,
|
|
|
IStdDictionaryModelDao stdDictionaryDao,
|
|
|
StdDictionaryEntryModelDao stdDictionaryEntryDao,
|
|
|
AdapterDictEntryService adapterDictEntryService) {
|
|
|
this.adapterDictEntryModel = adapterDictEntryModel;
|
|
|
this.matchVO = matchVO;
|
|
|
this.adapter_std_version = adapter_std_version;
|
|
|
this.version = version;
|
|
|
|
|
|
standardExistStrategy = new DictitemStandardExistStrategy();
|
|
|
standardExistStrategy.setStdDictionaryDao(stdDictionaryDao);
|
|
|
standardExistStrategy.setStdDictionaryEntryDao(stdDictionaryEntryDao);
|
|
|
standardExistStrategy.setAdapterDictEntryService(adapterDictEntryService);
|
|
|
}
|
|
|
|
|
|
public static void setVersionYes(String version) {
|
|
|
List<Integer> sizeList = new ArrayList<Integer>();
|
|
|
size.put(version, sizeList);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void run() {
|
|
|
try {
|
|
|
if (matchVO != null) {
|
|
|
if (standardExistStrategy.match(adapterDictEntryModel, matchVO,adapter_std_version, version)) {
|
|
|
updateAdapt(version);
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
updateAdapt(version);
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
public static Map<String, List<Integer>> getSize() {
|
|
|
return size;
|
|
|
}
|
|
|
|
|
|
public synchronized static void updateAdapt(String version) {
|
|
|
List<Integer> sizeList = size.get(version);
|
|
|
sizeList.add(1, sizeList.get(1) + 1);
|
|
|
System.out.println("更新匹配数目:" + sizeList.get(0) + "/" + (sizeList.get(1)));
|
|
|
}
|
|
|
|
|
|
public synchronized static void setFirst(String version, Integer allCount) {
|
|
|
List<Integer> sizeList = new ArrayList<Integer>();
|
|
|
sizeList.add(0, allCount);
|
|
|
sizeList.add(1, 0);
|
|
|
size.put(version, sizeList);
|
|
|
}
|
|
|
|
|
|
public synchronized static void removeAdapt(String version) {
|
|
|
size.remove(version);
|
|
|
}
|
|
|
|
|
|
public synchronized static boolean isAdapt(String version) {
|
|
|
if (size.get(version) == null) {
|
|
|
return false;
|
|
|
} else {
|
|
|
return true;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
public synchronized static Map getAllNumAndAdaptNum(String version) {
|
|
|
Map<String, Integer> adapt = new HashMap<String, Integer>();
|
|
|
List<Integer> list = size.get(version);
|
|
|
if(list!=null){
|
|
|
adapt.put("all", list.get(0));
|
|
|
adapt.put("adapt", list.get(1));
|
|
|
}
|
|
|
return adapt;
|
|
|
}
|
|
|
}
|