From c3b3cde9c61ada54ea0af3064232ff978cb399a4 Mon Sep 17 00:00:00 2001 From: leebeomjun Date: Tue, 17 Oct 2023 09:18:38 +0900 Subject: [PATCH] =?UTF-8?q?=EB=8B=A8=EC=86=8D=EC=97=B0=EA=B3=84=ED=8C=8C?= =?UTF-8?q?=EC=9D=BC=20=ED=8C=8C=EC=8B=B1=20=EC=88=98=EC=A0=95(=EC=86=8C?= =?UTF-8?q?=EC=88=98=EC=A0=90=EC=A0=9C=EA=B1=B0,=20=EA=B3=B5=EB=B0=B1?= =?UTF-8?q?=EC=A0=9C=EA=B1=B0)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fims/crdn/parsing/AttachedTxtParser.java | 14 +------ .../xit/fims/crdn/parsing/LayoutParser.java | 39 +++++++++++++++++++ .../fims/crdn/parsing/SingleFileParser.java | 6 ++- 3 files changed, 45 insertions(+), 14 deletions(-) diff --git a/src/main/java/cokr/xit/fims/crdn/parsing/AttachedTxtParser.java b/src/main/java/cokr/xit/fims/crdn/parsing/AttachedTxtParser.java index 8f14f44f..e8a682b0 100644 --- a/src/main/java/cokr/xit/fims/crdn/parsing/AttachedTxtParser.java +++ b/src/main/java/cokr/xit/fims/crdn/parsing/AttachedTxtParser.java @@ -47,19 +47,9 @@ public class AttachedTxtParser extends LayoutParser{ this.refineValue(dataObject); + this.analyzeFileContent(dataObject, file); - - try { - - JSONParser jsonParser = new JSONParser(-1); - - JSONArray jsonArray = (JSONArray)jsonParser.parse(descriptor.getContentItems()); - - - - } catch (Exception e) { - throw new RuntimeException(e); - } + this.refineValue(dataObject); if(!before.isEmpty()) { boolean isChangeTempGroup = this.isChangeCrackdown(dataObject, before); diff --git a/src/main/java/cokr/xit/fims/crdn/parsing/LayoutParser.java b/src/main/java/cokr/xit/fims/crdn/parsing/LayoutParser.java index 48e39528..896941a0 100644 --- a/src/main/java/cokr/xit/fims/crdn/parsing/LayoutParser.java +++ b/src/main/java/cokr/xit/fims/crdn/parsing/LayoutParser.java @@ -111,6 +111,11 @@ abstract public class LayoutParser { */ 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("")) { 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"); } + //숫자형 값에서 불필요한 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); //위반내용 @@ -147,6 +157,35 @@ abstract public class LayoutParser { codeConverter.fillIfEmpty(dataObject, "CRDN_CN", "CRDN_CN_CD", "CRDN_CN_NM"); } + /** dataObject 내에서 숫자형 데이터 항목을 정제한다.
+ * @param dataObject, items 숫자형 데이터 이름 + * @return + */ + public void refineNumberValue(DataObject dataObject, String[] items) { + for(int i=0;i * @param dataObject * @return diff --git a/src/main/java/cokr/xit/fims/crdn/parsing/SingleFileParser.java b/src/main/java/cokr/xit/fims/crdn/parsing/SingleFileParser.java index c8740bf4..fd67a958 100644 --- a/src/main/java/cokr/xit/fims/crdn/parsing/SingleFileParser.java +++ b/src/main/java/cokr/xit/fims/crdn/parsing/SingleFileParser.java @@ -39,9 +39,10 @@ public class SingleFileParser extends LayoutParser { this.setFileDefaultInfo(dataObject, file); - this.analyzeFileContent(dataObject, file); + this.refineValue(dataObject); + dataObject.put("TEMP_GROUP_ID", tempGroupSeq); tempGroupSeq++; @@ -63,6 +64,7 @@ public class SingleFileParser extends LayoutParser { JSONArray jsonArray = (JSONArray)jsonParser.parse(descriptor.getContentItems()); + //텍스트 영역 파싱 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)); @@ -88,7 +90,7 @@ public class SingleFileParser extends LayoutParser { } } - + //이미지 영역 파싱 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));