단속연계파일 파싱 수정
parent
6ffa467974
commit
844db5100d
@ -0,0 +1,53 @@
|
|||||||
|
package cokr.xit.fims.crdn.parsing;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
|
||||||
|
import cokr.xit.base.code.CommonCode;
|
||||||
|
import cokr.xit.foundation.data.DataObject;
|
||||||
|
|
||||||
|
|
||||||
|
public class CodeConverter {
|
||||||
|
|
||||||
|
Map<String, List<CommonCode>> commonCodes = new HashMap<String, List<CommonCode>>();
|
||||||
|
|
||||||
|
CodeConverter(Map<String, List<CommonCode>> commonCodes){
|
||||||
|
this.commonCodes = commonCodes;
|
||||||
|
}
|
||||||
|
|
||||||
|
String valueToCode(String codeGroupName, String value){
|
||||||
|
String result = "";
|
||||||
|
|
||||||
|
List<CommonCode> commonCodeList = commonCodes.get(codeGroupName);
|
||||||
|
|
||||||
|
for(int i = 0; i < commonCodeList.size(); i++) {
|
||||||
|
if(value.replaceAll(Matcher.quoteReplacement(" "), "").equals(commonCodeList.get(i).getValue().replaceAll(Matcher.quoteReplacement(" "), ""))) {
|
||||||
|
result = commonCodeList.get(i).getCode();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
String codeToValue(String codeGroupName, String code){
|
||||||
|
String result = "";
|
||||||
|
|
||||||
|
List<CommonCode> commonCodeList = commonCodes.get(codeGroupName);
|
||||||
|
|
||||||
|
for(int i = 0; i < commonCodeList.size(); i++) {
|
||||||
|
if(code.equals(commonCodeList.get(i).getCode())) {
|
||||||
|
result = commonCodeList.get(i).getValue();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void fillIfEmpty(DataObject dataObject, String codeGroupName, String codeName, String valueName) {
|
||||||
|
if(!dataObject.string(valueName).equals("") && dataObject.string(codeName).equals("")) {
|
||||||
|
dataObject.put(codeName, this.valueToCode(codeGroupName, dataObject.string(valueName)));
|
||||||
|
} else if(dataObject.string(valueName).equals("") && !dataObject.string(codeName).equals("")) {
|
||||||
|
dataObject.put(valueName, this.codeToValue(codeGroupName, dataObject.string(codeName)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue