단속연계파일 파싱 수정(소수점제거, 공백제거)

main
이범준 1 year ago
parent 2710f9f8e6
commit c3b3cde9c6

@ -47,19 +47,9 @@ public class AttachedTxtParser extends LayoutParser{
this.refineValue(dataObject); this.refineValue(dataObject);
this.analyzeFileContent(dataObject, file);
this.refineValue(dataObject);
try {
JSONParser jsonParser = new JSONParser(-1);
JSONArray jsonArray = (JSONArray)jsonParser.parse(descriptor.getContentItems());
} catch (Exception e) {
throw new RuntimeException(e);
}
if(!before.isEmpty()) { if(!before.isEmpty()) {
boolean isChangeTempGroup = this.isChangeCrackdown(dataObject, before); boolean isChangeTempGroup = this.isChangeCrackdown(dataObject, before);

@ -111,6 +111,11 @@ abstract public class LayoutParser {
*/ */
public void refineValue(DataObject dataObject) { public void refineValue(DataObject dataObject) {
//공백 제거
for(int i=0; i < allItem.length; i++) {
dataObject.put(allItem[i],dataObject.string(allItem[i]).trim());
}
//단속일시 설정 //단속일시 설정
if(!dataObject.string("CRDN_TIMESTAMP").equals("")) { if(!dataObject.string("CRDN_TIMESTAMP").equals("")) {
dataObject.put("CRDN_YMD", dataObject.string("CRDN_TIMESTAMP").substring(0, 8)); dataObject.put("CRDN_YMD", dataObject.string("CRDN_TIMESTAMP").substring(0, 8));
@ -125,6 +130,11 @@ abstract public class LayoutParser {
dataObject.put("CRDN_TIMESTAMP", dataObject.string("CRDN_YMD")+dataObject.string("CRDN_TM")+"000"); dataObject.put("CRDN_TIMESTAMP", dataObject.string("CRDN_YMD")+dataObject.string("CRDN_TM")+"000");
} }
//숫자형 값에서 불필요한 0제거
String[] numberValues = {"PHOTO_CNT", "GPS_X", "GPS_Y", "MOSC_X", "MOSC_Y", "PLATE_WIDHT", "PLATE_HEIGHT"};
this.refineNumberValue(dataObject, numberValues);
//코드변환
CodeConverter codeConverter = new CodeConverter(allCode); CodeConverter codeConverter = new CodeConverter(allCode);
//위반내용 //위반내용
@ -147,6 +157,35 @@ abstract public class LayoutParser {
codeConverter.fillIfEmpty(dataObject, "CRDN_CN", "CRDN_CN_CD", "CRDN_CN_NM"); codeConverter.fillIfEmpty(dataObject, "CRDN_CN", "CRDN_CN_CD", "CRDN_CN_NM");
} }
/** dataObject .<br />
* @param dataObject, items
* @return
*/
public void refineNumberValue(DataObject dataObject, String[] items) {
for(int i=0;i<items.length;i++) {
String itemValue = dataObject.string(items[i]);
if(!itemValue.equals("")) {
//소수부 0제거
if(itemValue.contains(".")) {
itemValue = itemValue.replaceAll("0+$", "");
if(itemValue.endsWith(".")){
itemValue = itemValue + "0";
}
}
//정수부 0제거
if(itemValue.startsWith("0") && !itemValue.equals("0") && !itemValue.startsWith("0.")) {
itemValue = itemValue.replaceAll("^0+", "");
if(itemValue.equals("") || itemValue.startsWith(".")) {
itemValue = "0" + itemValue;
}
}
dataObject.put(items[i], itemValue);
}
}
}
/** .<br /> /** .<br />
* @param dataObject * @param dataObject
* @return * @return

@ -39,9 +39,10 @@ public class SingleFileParser extends LayoutParser {
this.setFileDefaultInfo(dataObject, file); this.setFileDefaultInfo(dataObject, file);
this.analyzeFileContent(dataObject, file); this.analyzeFileContent(dataObject, file);
this.refineValue(dataObject);
dataObject.put("TEMP_GROUP_ID", tempGroupSeq); dataObject.put("TEMP_GROUP_ID", tempGroupSeq);
tempGroupSeq++; tempGroupSeq++;
@ -63,6 +64,7 @@ public class SingleFileParser extends LayoutParser {
JSONArray jsonArray = (JSONArray)jsonParser.parse(descriptor.getContentItems()); JSONArray jsonArray = (JSONArray)jsonParser.parse(descriptor.getContentItems());
//텍스트 영역 파싱
BufferedReader textReader = new BufferedReader(new InputStreamReader(new FileInputStream(file), Charset.forName("EUC-KR"))); BufferedReader textReader = new BufferedReader(new InputStreamReader(new FileInputStream(file), Charset.forName("EUC-KR")));
String textConent = CmmnUtil.substringByBytes(org.apache.commons.io.IOUtils.toString(textReader), 1, this.getSumByte(jsonArray)); String textConent = CmmnUtil.substringByBytes(org.apache.commons.io.IOUtils.toString(textReader), 1, this.getSumByte(jsonArray));
@ -88,7 +90,7 @@ public class SingleFileParser extends LayoutParser {
} }
} }
//이미지 영역 파싱
BufferedReader imageReader = new BufferedReader(new InputStreamReader(new FileInputStream(file), Charset.forName("ISO-8859-1"))); BufferedReader imageReader = new BufferedReader(new InputStreamReader(new FileInputStream(file), Charset.forName("ISO-8859-1")));
String imgContent = org.apache.commons.io.IOUtils.toString(imageReader).substring(this.getSumByte(jsonArray)); String imgContent = org.apache.commons.io.IOUtils.toString(imageReader).substring(this.getSumByte(jsonArray));

Loading…
Cancel
Save