|
|
|
@ -1,12 +1,63 @@
|
|
|
|
|
package cokr.xit.fims.crdn.parsing;
|
|
|
|
|
|
|
|
|
|
import java.nio.file.Path;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
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;
|
|
|
|
|
import net.minidev.json.JSONArray;
|
|
|
|
|
import net.minidev.json.JSONObject;
|
|
|
|
|
import net.minidev.json.parser.JSONParser;
|
|
|
|
|
import net.minidev.json.parser.ParseException;
|
|
|
|
|
|
|
|
|
|
abstract public class LayoutParser {
|
|
|
|
|
|
|
|
|
|
String[] allItem = {
|
|
|
|
|
"FILE_GROUP_TYPE","FILE_PATH","FILE_NAME","FILE_LAST_MODIFIED","FILE_SIZE","FILE_EXTENSION","LINK_ENT_NM","ENT_NM",
|
|
|
|
|
"FILE_SEQ","PHOTO_CNT","PHOTO_TYPE_CD","PHOTO_TYPE_NM","FILE_STATUS_CD","FILE_STATUS_NM",
|
|
|
|
|
"VHRNO",
|
|
|
|
|
"CRDN_TIMESTAMP","CRDN_YMD_TM","CRDN_YMD","CRDN_TM","CRDN_END_TM","CRDN_BGNG_TM",
|
|
|
|
|
"CRDN_PLC","CRDN_ROAD_NM","CRDN_STDG_NM","GPS_X","GPS_Y","CRDN_SPAREA_NM","CRDN_SPAREA_CD",
|
|
|
|
|
"BZENTY_CD","TEAM_ID","EQPMNT_CD","CRDN_SE_CD","CRDN_SE_NM",
|
|
|
|
|
"MOSC_X","MOSC_Y","PLATE_WIDTH","PLATE_HEIGHT",
|
|
|
|
|
"VLTN_CD","VLTN_NM","CRDN_CN_CD","CRDN_CN_NM",
|
|
|
|
|
"CAR_VELOCITY"
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
public DataObject createParsedDataObject() {
|
|
|
|
|
DataObject dataObject = new DataObject();
|
|
|
|
|
for(int i=0; i < allItem.length; i++) {
|
|
|
|
|
dataObject.put(allItem[i], "");
|
|
|
|
|
}
|
|
|
|
|
return dataObject;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Map<String, List<CommonCode>> allCode = new HashMap<String, List<CommonCode>>(){{
|
|
|
|
|
put("PHOTO_TYPE",new ArrayList<>() {{
|
|
|
|
|
add(new CommonCode() {{ setCode("1"); setValue("입차사진"); }});
|
|
|
|
|
add(new CommonCode() {{ setCode("2"); setValue("주차사진"); }});
|
|
|
|
|
add(new CommonCode() {{ setCode("3"); setValue("위반사진"); }});
|
|
|
|
|
add(new CommonCode() {{ setCode("4"); setValue("출차사진"); }});
|
|
|
|
|
}});
|
|
|
|
|
put("FILE_STATUS",new ArrayList<>() {{
|
|
|
|
|
add(new CommonCode() {{ setCode("S"); setValue("정상등록자료"); }});
|
|
|
|
|
add(new CommonCode() {{ setCode("E"); setValue("삭제자료"); }});
|
|
|
|
|
}});
|
|
|
|
|
put("CRDN_CN",new ArrayList<>() {{
|
|
|
|
|
add(new CommonCode() {{ setCode("00"); setValue("사용안함"); }});
|
|
|
|
|
add(new CommonCode() {{ setCode("01"); setValue("일반차량(전기차)"); }});
|
|
|
|
|
add(new CommonCode() {{ setCode("02"); setValue("장기주차(전기차)"); }});
|
|
|
|
|
}});
|
|
|
|
|
}};
|
|
|
|
|
|
|
|
|
|
public void addCommonCode(Map<String, List<CommonCode>> commonCode) {
|
|
|
|
|
this.allCode.putAll(commonCode);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LayoutDescriptor descriptor = new LayoutDescriptor();
|
|
|
|
|
|
|
|
|
|
public void setDescriptor(LayoutDescriptor descriptor) {
|
|
|
|
@ -25,4 +76,97 @@ abstract public class LayoutParser {
|
|
|
|
|
*/
|
|
|
|
|
abstract public boolean isChangeCrackdown(DataObject currentItem, DataObject beforeItem);
|
|
|
|
|
|
|
|
|
|
/**파싱된 데이터를 정제한다.<br />
|
|
|
|
|
* @param dataObject
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
public void refineValue(DataObject dataObject) {
|
|
|
|
|
|
|
|
|
|
//단속일시 설정
|
|
|
|
|
if(!dataObject.string("CRDN_TIMESTAMP").equals("")) {
|
|
|
|
|
dataObject.put("CRDN_YMD", dataObject.string("CRDN_TIMESTAMP").substring(0, 8));
|
|
|
|
|
dataObject.put("CRDN_TM", dataObject.string("CRDN_TIMESTAMP").substring(8, 14));
|
|
|
|
|
dataObject.put("CRDN_YMD_TM", dataObject.string("CRDN_TIMESTAMP").substring(0, 14));
|
|
|
|
|
} else if(!dataObject.string("CRDN_YMD_TM").equals("")) {
|
|
|
|
|
dataObject.put("CRDN_YMD", dataObject.string("CRDN_YMD_TM").substring(0, 8));
|
|
|
|
|
dataObject.put("CRDN_TM", dataObject.string("CRDN_YMD_TM").substring(8, 14));
|
|
|
|
|
dataObject.put("CRDN_TIMESTAMP", dataObject.string("CRDN_YMD_TM")+"000");
|
|
|
|
|
} else if(!dataObject.string("CRDN_YMD").equals("")){
|
|
|
|
|
dataObject.put("CRDN_YMD_TM", dataObject.string("CRDN_YMD")+dataObject.string("CRDN_TM"));
|
|
|
|
|
dataObject.put("CRDN_TIMESTAMP", dataObject.string("CRDN_YMD")+dataObject.string("CRDN_TM")+"000");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CodeConverter codeConverter = new CodeConverter(allCode);
|
|
|
|
|
|
|
|
|
|
//위반내용
|
|
|
|
|
String vltnGroup = "";
|
|
|
|
|
switch (descriptor.getTaskSeCd()) {
|
|
|
|
|
case "PVS" -> { vltnGroup = "WEB002"; }
|
|
|
|
|
case "BPV" -> { vltnGroup = "FIM005"; }
|
|
|
|
|
case "DPV" -> { vltnGroup = "FIM006"; }
|
|
|
|
|
case "ECA" -> { vltnGroup = "FIM061"; }
|
|
|
|
|
}
|
|
|
|
|
if(!vltnGroup.equals("")) {
|
|
|
|
|
codeConverter.fillIfEmpty(dataObject, vltnGroup, "VLTN_CD", "VLTN_NM");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//특별구역
|
|
|
|
|
codeConverter.fillIfEmpty(dataObject, "FIM007", "CRDN_SPAREA_CD", "CRDN_SPAREA_NM");
|
|
|
|
|
|
|
|
|
|
codeConverter.fillIfEmpty(dataObject, "PHOTO_TYPE", "PHOTO_TYPE_CD", "PHOTO_TYPE_NM");
|
|
|
|
|
codeConverter.fillIfEmpty(dataObject, "FILE_STATUS", "FILE_STATUS_CD", "FILE_STATUS_NM");
|
|
|
|
|
codeConverter.fillIfEmpty(dataObject, "CRDN_CN", "CRDN_CN_CD", "CRDN_CN_NM");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**파일명을 분석한다.<br />
|
|
|
|
|
* @param dataObject
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
public void analyzeFileName(DataObject dataObject, String noExtensionName) {
|
|
|
|
|
|
|
|
|
|
String fileNameItmesJSONString = descriptor.getFileNameItmes();
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
JSONParser jsonParser = new JSONParser(-1);
|
|
|
|
|
JSONArray jsonArray = (JSONArray)jsonParser.parse(fileNameItmesJSONString);
|
|
|
|
|
|
|
|
|
|
if(descriptor.getFileNameSeperator().equals("byte")) {
|
|
|
|
|
|
|
|
|
|
//TODO
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
|
|
String[] fileNameSplit = noExtensionName.split(Matcher.quoteReplacement(descriptor.getFileNameSeperator()));
|
|
|
|
|
|
|
|
|
|
for(int i=0; i<jsonArray.size(); i++) {
|
|
|
|
|
JSONObject jsonObject = (JSONObject)jsonArray.get(i);
|
|
|
|
|
|
|
|
|
|
String key = jsonObject.keySet().iterator().next();
|
|
|
|
|
|
|
|
|
|
if(fileNameSplit.length > i) {
|
|
|
|
|
dataObject.put(key, fileNameSplit[i]);
|
|
|
|
|
} else {
|
|
|
|
|
dataObject.put(key, "");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} catch (ParseException e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**파일명이나 파일내용을 특정 구분자로 자른다.<br />
|
|
|
|
|
* @param string 문자열, sep 구분자
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
public String[] smartSplit(String string, String sep) {
|
|
|
|
|
if(sep.equals("LineBreak")) {
|
|
|
|
|
return string.split("\r?\n|\r");
|
|
|
|
|
} else {
|
|
|
|
|
return string.split(Matcher.quoteReplacement(sep));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|