단속연계파일 파일 파싱 수정(파일 그룹핑)

main
이범준 1 year ago
parent c3b3cde9c6
commit 32dabc9e8e

@ -5,13 +5,7 @@ import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.nio.charset.Charset; import java.nio.charset.Charset;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
import org.apache.commons.io.FilenameUtils;
import cokr.xit.foundation.data.DataObject; import cokr.xit.foundation.data.DataObject;
import net.minidev.json.JSONArray; import net.minidev.json.JSONArray;
@ -20,65 +14,12 @@ import net.minidev.json.parser.JSONParser;
public class AttachedTxtParser extends LayoutParser{ public class AttachedTxtParser extends LayoutParser{
private DataObject before = new DataObject(); public AttachedTxtParser(){
private int tempGroupSeq = 1; this.groupingType = "TXT";
this.need = new Need(true,false,true);
@Override
public List<DataObject> parsing(List<Path> fileList) {
//파일명으로 정렬(파싱 전)
List<Path> sortedFileList = fileList.stream()
.sorted((item1, item2) -> item1.toFile().getName().compareTo(item2.toFile().getName()))
.collect(Collectors.toList());
List<DataObject> dataObjectList = new ArrayList<>();
sortedFileList.forEach(item -> {
DataObject dataObject = this.createParsedDataObject();
dataObject.put("FILE_GROUP_TYPE", "TXT");
File file = item.toFile();
this.setFileDefaultInfo(dataObject, file);
String noExtensionName = FilenameUtils.removeExtension(dataObject.string("FILE_NAME"));
this.analyzeFileName(dataObject, noExtensionName);
this.refineValue(dataObject);
this.analyzeFileContent(dataObject, file);
this.refineValue(dataObject);
if(!before.isEmpty()) {
boolean isChangeTempGroup = this.isChangeCrackdown(dataObject, before);
if(isChangeTempGroup) {
tempGroupSeq++;
}
}
dataObject.put("TEMP_GROUP_ID", tempGroupSeq);
dataObjectList.add(dataObject);
before = dataObject;
});
return dataObjectList;
} }
@Override @Override
public boolean isChangeCrackdown(DataObject currentItem, DataObject beforeItem) {
String currentFileNamePrefix = currentItem.string("FILE_NAME").substring(0,25);
String beforeFileNamePrefix = beforeItem.string("FILE_NAME").substring(0,25);
if(currentFileNamePrefix.equals(beforeFileNamePrefix)) {
return false;
} else {
return true;
}
}
public void analyzeFileContent(DataObject dataObject, File file) { public void analyzeFileContent(DataObject dataObject, File file) {
try { try {
@ -130,19 +71,6 @@ public class AttachedTxtParser extends LayoutParser{
partSplitCursor++; partSplitCursor++;
} }
//
if(descriptor.getTaskSeCd().equals("PVS") || descriptor.getTaskSeCd().equals("BPV")) {
if(descriptor.getEnterpriseName().equals("xit")) {
if(!dataObject.string("GPS_X").equals("")) {
dataObject.put("CRDN_SE_CD", "02");
} else {
dataObject.put("CRDN_SE_CD", "01");
}
}
}
this.refineValue(dataObject);
} else { } else {
for(int i=0; i<jsonArray.size(); i++) { for(int i=0; i<jsonArray.size(); i++) {
@ -154,8 +82,9 @@ public class AttachedTxtParser extends LayoutParser{
} }
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); throw new RuntimeException(e);
} }
} }
} }

@ -1,7 +0,0 @@
package cokr.xit.fims.crdn.parsing;
public class CommonLayoutParser {
}

@ -47,6 +47,21 @@ public class LayoutDescriptor {
*/ */
private String countPerFileGroup; private String countPerFileGroup;
/**
*
*/
private String sameItemsInFileGroup;
/**
*
*/
private String increaseItemInFileGroup;
/**
*
*/
private String increaseTypeInFileGroup;
/** /**
* *
*/ */
@ -91,4 +106,5 @@ public class LayoutDescriptor {
* *
*/ */
private String linkEnterpriseName; private String linkEnterpriseName;
} }

@ -9,6 +9,7 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.stream.Collectors;
import org.apache.commons.io.FilenameUtils; import org.apache.commons.io.FilenameUtils;
@ -22,7 +23,26 @@ import net.minidev.json.parser.ParseException;
abstract public class LayoutParser { abstract public class LayoutParser {
protected DataObject before = new DataObject();
protected int tempGroupSeq = 1;
protected String groupingType;
protected Need need;
class Need {
boolean fileNameAnalyze;
boolean contentAnalyze;
boolean checkChangeCrackdown;
Need(boolean fileNameAnalyze, boolean contentAnalyze, boolean checkChangeCrackdown){
this.fileNameAnalyze = fileNameAnalyze;
this.contentAnalyze = contentAnalyze;
this.checkChangeCrackdown = checkChangeCrackdown;
}
}
String[] allItem = { String[] allItem = {
"FILE_GROUP_ID",
"FILE_GROUP_TYPE","FILE_PATH","FILE_NAME","FILE_LAST_MODIFIED","FILE_SIZE","FILE_EXTENSION","LINK_ENT_NM", "FILE_GROUP_TYPE","FILE_PATH","FILE_NAME","FILE_LAST_MODIFIED","FILE_SIZE","FILE_EXTENSION","LINK_ENT_NM",
"FILE_SEQ","PHOTO_CNT","PHOTO_TYPE_CD","PHOTO_TYPE_NM","FILE_STATUS_CD","FILE_STATUS_NM", "FILE_SEQ","PHOTO_CNT","PHOTO_TYPE_CD","PHOTO_TYPE_NM","FILE_STATUS_CD","FILE_STATUS_NM",
"VHRNO", "VHRNO",
@ -70,6 +90,71 @@ abstract public class LayoutParser {
this.descriptor = descriptor; this.descriptor = descriptor;
} }
/** .<br />
* @param fileList
* @return
*/
public List<DataObject> parsing(List<Path> fileList){
List<DataObject> dataObjectList = new ArrayList<>();
//파일명으로 정렬(파싱 전)
List<Path> sortedFileList = fileList.stream()
.sorted((item1, item2) -> item1.toFile().getName().compareTo(item2.toFile().getName()))
.collect(Collectors.toList());
sortedFileList.forEach(item -> {
DataObject dataObject = this.createParsedDataObject();
dataObject.put("FILE_GROUP_TYPE", this.groupingType);
File file = item.toFile();
this.setFileDefaultInfo(dataObject, file);
if(this.need.fileNameAnalyze) {
String noExtensionName = FilenameUtils.removeExtension(dataObject.string("FILE_NAME"));
this.analyzeFileName(dataObject, noExtensionName);
this.refineValue(dataObject);
}
if(this.need.contentAnalyze) {
this.analyzeFileContent(dataObject, file);
this.refineValue(dataObject);
}
//단속구분코드 보정
if(descriptor.getTaskSeCd().equals("PVS") || descriptor.getTaskSeCd().equals("BPV")) {
if(descriptor.getEnterpriseName().equals("xit")) {
if(!dataObject.string("GPS_X").equals("")) {
dataObject.put("CRDN_SE_CD", "02");
} else {
dataObject.put("CRDN_SE_CD", "01");
}
}
}
if(descriptor.getTaskSeCd().equals("BPV")) {
if(descriptor.getEnterpriseName().equals("hitecom")) {
dataObject.put("CRDN_SE_CD", "07");
}
}
if(!before.isEmpty()) {
if(this.need.checkChangeCrackdown) {
boolean isChangeTempGroup = this.isChangeCrackdown(dataObject, before);
if(isChangeTempGroup) {
tempGroupSeq++;
}
} else {
tempGroupSeq++;
}
}
dataObject.put("TEMP_GROUP_ID", tempGroupSeq);
dataObjectList.add(dataObject);
before = dataObject;
});
return dataObjectList;
}
/** .<br /> /** .<br />
* @param dataObject , File * @param dataObject , File
* @return * @return
@ -93,19 +178,53 @@ abstract public class LayoutParser {
} }
} }
/** .<br /> /** .<br />
* @param fileList * @param dataObject
* @return * @return
*/ */
abstract public List<DataObject> parsing(List<Path> fileList); public void analyzeFileName(DataObject dataObject, String noExtensionName) {
/** .<br /> String fileNameItmesJSONString = descriptor.getFileNameItmes();
* @param currentItem , beforeItem
* @return try {
JSONParser jsonParser = new JSONParser(-1);
JSONArray jsonArray = (JSONArray)jsonParser.parse(fileNameItmesJSONString);
String[] fileNameSplit = {};
if(descriptor.getFileNameSeperator().equals("byte")) {
fileNameSplit = this.smartSplit(noExtensionName, jsonArray);
} else {
fileNameSplit = this.smartSplit(noExtensionName, 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 dataObject
* @return
*/ */
abstract public boolean isChangeCrackdown(DataObject currentItem, DataObject beforeItem); abstract public void analyzeFileContent(DataObject dataObject, File file);
/** .<br /> /** .<br />
* @param dataObject * @param dataObject
* @return * @return
*/ */
@ -186,44 +305,39 @@ abstract public class LayoutParser {
} }
} }
/** .<br /> /** .<br />
* @param dataObject * @param currentItem , beforeItem
* @return * @return
*/ */
public void analyzeFileName(DataObject dataObject, String noExtensionName) { public boolean isChangeCrackdown(DataObject currentItem, DataObject beforeItem) {
boolean isSameItemChange = false;
String fileNameItmesJSONString = descriptor.getFileNameItmes(); String sameItems = descriptor.getSameItemsInFileGroup();
String[] sameItemsSplit = sameItems.split(",");
try { for(int i=0; i < sameItemsSplit.length; i++) {
JSONParser jsonParser = new JSONParser(-1); if(!currentItem.string(sameItemsSplit[i]).equals(beforeItem.string(sameItemsSplit[i]))) {
JSONArray jsonArray = (JSONArray)jsonParser.parse(fileNameItmesJSONString); isSameItemChange = true;
}
String[] fileNameSplit = {}; }
if(descriptor.getFileNameSeperator().equals("byte")) { if(isSameItemChange) {
return true;
fileNameSplit = this.smartSplit(noExtensionName, jsonArray);
} else {
fileNameSplit = this.smartSplit(noExtensionName, descriptor.getFileNameSeperator());
} }
for(int i=0; i<jsonArray.size(); i++) { String increaseItem = descriptor.getIncreaseItemInFileGroup();
JSONObject jsonObject = (JSONObject)jsonArray.get(i); if(increaseItem != null && !increaseItem.equals("")) {
String increaseType = descriptor.getIncreaseTypeInFileGroup();
String key = jsonObject.keySet().iterator().next();
if(fileNameSplit.length > i) { if(increaseType.equals("number")){
dataObject.put(key, fileNameSplit[i]); if(currentItem.number(increaseItem).intValue() <= beforeItem.number(increaseItem).intValue()) {
} else { return true;
dataObject.put(key, ""); }
} else if(increaseType.equals("alphabet")) {
if(currentItem.string(increaseItem).charAt(0) <= beforeItem.string(increaseItem).charAt(0)) {
return true;
} }
} }
} catch (ParseException e) {
e.printStackTrace();
} }
return false;
} }
/** .<br /> /** .<br />
@ -264,6 +378,10 @@ abstract public class LayoutParser {
return result; return result;
} }
/** byte .<br />
* @param jsonArray
* @return
*/
public int getSumByte(JSONArray jsonArray){ public int getSumByte(JSONArray jsonArray){
int result = 0; int result = 0;
for(int i=0; i<jsonArray.size(); i++) { for(int i=0; i<jsonArray.size(); i++) {

@ -1,77 +1,20 @@
package cokr.xit.fims.crdn.parsing; package cokr.xit.fims.crdn.parsing;
import java.io.File; import java.io.File;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
import org.apache.commons.io.FilenameUtils;
import cokr.xit.foundation.data.DataObject; import cokr.xit.foundation.data.DataObject;
public class OnlyImageParser extends LayoutParser { public class OnlyImageParser extends LayoutParser {
private DataObject before = new DataObject(); public OnlyImageParser(){
private int tempGroupSeq = 1; this.groupingType = "JPG";
this.need = new Need(true,false,true);
@Override
public List<DataObject> parsing(List<Path> fileList) {
List<DataObject> dataObjectList = new ArrayList<>();
//파일명으로 정렬(파싱 전)
List<Path> sortedFileList = fileList.stream()
.sorted((item1, item2) -> item1.toFile().getName().compareTo(item2.toFile().getName()))
.collect(Collectors.toList());
sortedFileList.forEach(item -> {
DataObject dataObject = this.createParsedDataObject();
dataObject.put("FILE_GROUP_TYPE", "JPG");
File file = item.toFile();
this.setFileDefaultInfo(dataObject, file);
String noExtensionName = FilenameUtils.removeExtension(dataObject.string("FILE_NAME"));
this.analyzeFileName(dataObject, noExtensionName);
this.refineValue(dataObject);
if(!before.isEmpty()) {
boolean isChangeTempGroup = this.isChangeCrackdown(dataObject, before);
if(isChangeTempGroup) {
tempGroupSeq++;
}
}
dataObject.put("TEMP_GROUP_ID", tempGroupSeq);
dataObjectList.add(dataObject);
before = dataObject;
});
return dataObjectList;
} }
@Override @Override
public boolean isChangeCrackdown(DataObject currentItem, DataObject beforeItem) { public void analyzeFileContent(DataObject dataObject, File file) {
if(!currentItem.string("VHRNO").equals(beforeItem.string("VHRNO"))) {
return true;
} }
if(!currentItem.string("PHOTO_CNT").equals(beforeItem.string("PHOTO_CNT"))) {
return true;
}
if(currentItem.number("PHOTO_TYPE_CD").intValue() <= beforeItem.number("PHOTO_TYPE_CD").intValue()) {
return true;
}
return false;
}
} }

@ -7,12 +7,9 @@ import java.io.FileInputStream;
import java.io.InputStream; import java.io.InputStream;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.nio.charset.Charset; import java.nio.charset.Charset;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Base64; import java.util.Base64;
import java.util.Base64.Decoder; import java.util.Base64.Decoder;
import java.util.Base64.Encoder; import java.util.Base64.Encoder;
import java.util.List;
import cokr.xit.base.file.FileInfo; import cokr.xit.base.file.FileInfo;
import cokr.xit.fims.cmmn.CmmnUtil; import cokr.xit.fims.cmmn.CmmnUtil;
@ -23,41 +20,16 @@ import net.minidev.json.parser.JSONParser;
public class SingleFileParser extends LayoutParser { public class SingleFileParser extends LayoutParser {
private int tempGroupSeq = 1; public SingleFileParser(){
this.groupingType = "BIN";
@Override this.need = new Need(false,true,false);
public List<DataObject> parsing(List<Path> fileList) {
List<DataObject> dataObjectList = new ArrayList<>();
fileList.forEach(item -> {
DataObject dataObject = this.createParsedDataObject();
dataObject.put("FILE_GROUP_TYPE", "BIN");
File file = item.toFile();
this.setFileDefaultInfo(dataObject, file);
this.analyzeFileContent(dataObject, file);
this.refineValue(dataObject);
dataObject.put("TEMP_GROUP_ID", tempGroupSeq);
tempGroupSeq++;
dataObjectList.add(dataObject);
});
return dataObjectList;
} }
/** .<br />
* @param dataObject
* @return
*/
@Override @Override
public boolean isChangeCrackdown(DataObject currentItem, DataObject beforeItem) {
return true;
}
public void analyzeFileContent(DataObject dataObject, File file) { public void analyzeFileContent(DataObject dataObject, File file) {
try { try {
JSONParser jsonParser = new JSONParser(-1); JSONParser jsonParser = new JSONParser(-1);
@ -90,6 +62,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")));
@ -128,17 +101,9 @@ public class SingleFileParser extends LayoutParser {
jpgString = new String(encoder.encode(jpgString.getBytes(Charset.forName("ISO-8859-1")))); jpgString = new String(encoder.encode(jpgString.getBytes(Charset.forName("ISO-8859-1"))));
if(jpgNum == 1){ dataObject.put("B64IMAGE"+(jpgNum), jpgString);
dataObject.put("CAR_IMAGE", jpgString); dataObject.put("B64IMAGE"+(jpgNum)+"_NM", jpgName);
dataObject.put("CAR_IMAGE_NM", jpgName);
} else if(jpgNum == 2){
dataObject.put("PLATE_IMAGE", jpgString);
dataObject.put("PLATE_IMAGE_NM", jpgName);
} else {
dataObject.put("MOVING_IMAGE"+(jpgNum-2), jpgString);
dataObject.put("MOVING_IMAGE"+(jpgNum-2)+"_NM", jpgName);
}
jpgString = ""; jpgString = "";
jpgIn = false; jpgIn = false;
} }
@ -149,7 +114,10 @@ public class SingleFileParser extends LayoutParser {
} }
} }
/** 64 fileInfo . <br />
* @param fileName , base64str 64, sortOrder
* @return fileInfo
*/
public static FileInfo base64ToFileInfo(String fileName, String base64str, int sortOrder) { public static FileInfo base64ToFileInfo(String fileName, String base64str, int sortOrder) {
try { try {
Decoder decoder = Base64.getDecoder(); Decoder decoder = Base64.getDecoder();

@ -90,201 +90,234 @@ public class ImportServiceBean extends AbstractServiceBean implements ImportServ
Crdn crdn = new Crdn(); Crdn crdn = new Crdn();
crdn.setCrdnRegSeCd("07"); crdn.setCrdnRegSeCd("07");
crdn.setTaskSeCd(taskSeCd); crdn.setTaskSeCd(taskSeCd);
crdn.setSggCd(globalStngMapper.selectSggCdForCurrentUser());
List<FileInfo> fileInfoList = new ArrayList<FileInfo>(); Map<String, Object> dividedInfo = this.divideInformation(linkFileInfoList, fileGroupType);
// DataObject metaFileInfo = (DataObject) dividedInfo.get("metaInfo");
if(fileGroupType.equals("JPG")) { List<DataObject> imageFileInfoList = (List<DataObject>) dividedInfo.get("imageInfo");
DataObject bgngData = (DataObject) dividedInfo.get("bgngData");
DataObject endData = (DataObject) dividedInfo.get("endData");
//1. 연계파일정보를 단속 엔티티로 변환 //1. 연계파일정보를 단속 엔티티로 변환
DataObject bgngData = linkFileInfoList.stream() this.crdnTimeRangeSet(crdn, bgngData, endData);
.min(Comparator.comparing(item -> new BigInteger(item.string("CRDN_TIMESTAMP"))))
.orElseThrow();
DataObject endData = linkFileInfoList.stream()
.max(Comparator.comparing(item -> new BigInteger(item.string("CRDN_TIMESTAMP"))))
.orElseThrow();
crdn.setCrdnBgngTm(bgngData.string("CRDN_TM"));
crdn.setCrdnEndTm(endData.string("CRDN_TM"));
DataObject linkFileInfo = endData; String entType = metaFileInfo.string("LINK_ENT_NM");
String entType = linkFileInfo.string("LINK_ENT_NM");
if(entType.equals("ino")) crdn.setCrdnInptSeCd("11"); if(entType.equals("ino")) crdn.setCrdnInptSeCd("11");
else if(entType.equals("knl")) crdn.setCrdnInptSeCd("12"); else if(entType.equals("knl")) crdn.setCrdnInptSeCd("12");
else crdn.setCrdnInptSeCd("15"); else crdn.setCrdnInptSeCd("15");
crdn.setCrdnInptSeCd("11");
if(metaFileInfo.string("VLTN_CD").equals("")) {
crdn.setVltnCd("01"); crdn.setVltnCd("01");
crdn.setSggCd(globalStngMapper.selectSggCdForCurrentUser()); } else {
crdn.setVhrno(linkFileInfo.string("VHRNO")); crdn.setVltnCd(metaFileInfo.string("VLTN_CD"));
crdn.setCrdnYmd(linkFileInfo.string("CRDN_YMD")); }
crdn.setCrdnTm(linkFileInfo.string("CRDN_TM")); if(metaFileInfo.string("CRDN_SPAREA_CD").equals("")) {
crdn.setGpsX(linkFileInfo.string("GPS_X")); crdn.setCrdnSpareaCd("00");
crdn.setGpsY(linkFileInfo.string("GPS_Y")); } else {
crdn.setCrdnStdgNm(linkFileInfo.string("CRDN_STDG_NM")); crdn.setCrdnSpareaCd(metaFileInfo.string("CRDN_SPAREA_CD"));
crdn.setCrdnPlc(linkFileInfo.string("CRDN_PLC")); }
crdn.setCrdnRoadNm(linkFileInfo.string("CRDN_ROAD_NM"));
//linkFileInfo.string("EQPMNT_CD");
List<File> files = new ArrayList<>(); crdn.setVhrno(metaFileInfo.string("VHRNO"));
for (DataObject linkFileInfo0 : linkFileInfoList) { crdn.setCrdnYmd(metaFileInfo.string("CRDN_YMD"));
files.add(new File(linkFileInfo0.string("FILE_PATH"))); crdn.setCrdnTm(metaFileInfo.string("CRDN_TM"));
if(crdn.getCrdnBgngTm() == null) {
crdn.setCrdnBgngTm(metaFileInfo.string("CRDN_BGNG_TM"));
crdn.setCrdnEndTm(metaFileInfo.string("CRDN_END_TM"));
} }
fileInfoList = new FileInfoFactory().createFileInfos(null, files); crdn.setGpsX(metaFileInfo.string("GPS_X"));
for (int iLoop = 0; iLoop < fileInfoList.size(); iLoop++) { crdn.setGpsY(metaFileInfo.string("GPS_Y"));
fileInfoList.get(iLoop).setName("image"+iLoop+"."+FilenameUtils.getExtension(fileInfoList.get(iLoop).getName())); crdn.setCrdnPlc(metaFileInfo.string("CRDN_PLC"));
} crdn.setCrdnRoadNm(metaFileInfo.string("CRDN_ROAD_NM"));
crdn.setCrdnStdgNm(metaFileInfo.string("CRDN_STDG_NM"));
} crdn.setCrdnSeCd(metaFileInfo.string("CRDN_SE_CD"));
crdn.setMoscX(metaFileInfo.string("MOSC_X"));
crdn.setMoscY(metaFileInfo.string("MOSC_Y"));
//metaFileInfo.string("EQPMNT_CD");
//metaFileInfo.string("PLATE_WIDTH");
//metaFileInfo.string("PLATE_HEIGHT");
//XIT권장포맷 List<FileInfo> fileInfoList = this.parsedDataInfoToFileInfo(imageFileInfoList, fileGroupType);
if(fileGroupType.equals("TXT")) {
//1. 연계파일정보를 단속 엔티티로 변환
crdn.setSggCd(globalStngMapper.selectSggCdForCurrentUser());
DataObject metaFileInfo = null; //2. 차적 조회
for (DataObject linkFileInfo0 : linkFileInfoList) { List<Crdn> crdns = new ArrayList<Crdn>();
if(linkFileInfo0.string("FILE_EXTENSION").toUpperCase().equals("TXT")) { crdns.add(crdn);
metaFileInfo = linkFileInfo0; importBean.setVehicleInfo(crdns);
}
}
String entType = metaFileInfo.string("LINK_ENT_NM");
if(entType.equals("ino")) crdn.setCrdnInptSeCd("11");
else if(entType.equals("knl")) crdn.setCrdnInptSeCd("12");
else crdn.setCrdnInptSeCd("15");
crdn.setVltnCd("01"); //3.등록
saved = crdnBean.create(null, crdn, fileInfoList);
crdn.setCrdnSeCd(metaFileInfo.string("CRDN_SE_CD")); resultMap.put("saved", saved);
crdn.setCrdnYmd(metaFileInfo.string("CRDN_YMD"));
crdn.setCrdnTm(metaFileInfo.string("CRDN_TM"));
crdn.setVhrno(metaFileInfo.string("VHRNO"));
crdn.setGpsX(metaFileInfo.string("GPS_X"));
crdn.setGpsY(metaFileInfo.string("GPS_Y"));
crdn.setCrdnBgngTm(metaFileInfo.string("CRDN_BGNG_TM"));
crdn.setCrdnEndTm(metaFileInfo.string("CRDN_END_TM"));
crdn.setCrdnPlc(metaFileInfo.string("CRDN_PLC"));
if(metaFileInfo.string("CRDN_SPAREA_NM").equals("어린이보호구역")) { if(saved) {
crdn.setCrdnSpareaCd("01"); for(DataObject delInfo : linkFileInfoList) {
} else { crdnBean.removeEquipmentLinkFile(workPath, delInfo.string("FILE_NAME"));
crdn.setCrdnSpareaCd("00");
} }
crdn.setCrdnStdgNm(metaFileInfo.string("CRDN_STDG_NM"));
//metaFileInfo.string("VLTN_NM"); if(!ifEmpty(crdn.getErsrRegYmd(), () -> "").equals("")) {
//metaFileInfo.string("EQPMNT_CD"); String vhrno = crdn.getVhrno();
String ersrRegYmd = crdn.getErsrRegYmd();
String ersrYear = ersrRegYmd.substring(0, 4);
String ersrMonth = ersrRegYmd.substring(4, 6);
String ersrDay = ersrRegYmd.substring(6, 8);
List<File> files = new ArrayList<>(); String alertMessage = vhrno + " : " + ersrYear + "년" + ersrMonth + "월" + ersrDay + "일로 말소된 차량입니다.";
for (DataObject linkFileInfo0 : linkFileInfoList) { resultMap.put("alertMessage", alertMessage);
if(!linkFileInfo0.string("FILE_EXTENSION").toUpperCase().equals("TXT")) {
files.add(new File(linkFileInfo0.string("FILE_PATH")));
}
} }
fileInfoList = new FileInfoFactory().createFileInfos(null, files); } else {
for (int iLoop = 0; iLoop < fileInfoList.size(); iLoop++) { resultMap.put("failReason", "기타 오류");
fileInfoList.get(iLoop).setName("image"+iLoop+"."+FilenameUtils.getExtension(fileInfoList.get(iLoop).getName()));
} }
return resultMap;
} }
//
if(fileGroupType.equals("BIN")) {
//1. 연계파일정보를 단속 엔티티로 변환 /** , , , . <br />
if(linkFileInfoList.size() != 1) { * @param linkFileInfoList , fileGroupType
resultMap.put("saved", false); * @return , , ,
resultMap.put("failReason", "그룹핑 오류"); */
return resultMap; public Map<String,Object> divideInformation(List<DataObject> linkFileInfoList, String fileGroupType) {
Map<String, Object> result = new HashMap<String, Object>();
DataObject metaFileInfo = null;
List<DataObject> imageFileInfoList = new ArrayList<DataObject>();
DataObject[] bgngAndEnd = {null, null};
if(fileGroupType.equals("TXT")) {
for (DataObject linkFileInfo : linkFileInfoList) {
if(linkFileInfo.string("FILE_EXTENSION").toUpperCase().equals("TXT")) {
metaFileInfo = linkFileInfo;
} else {
imageFileInfoList.add(linkFileInfo);
}
} }
DataObject linkFileInfo = linkFileInfoList.get(0);
String entType = linkFileInfo.string("LINK_ENT_NM"); bgngAndEnd = getBgngDataAndEndData(imageFileInfoList);
if(entType.equals("ino")) crdn.setCrdnInptSeCd("11");
else if(entType.equals("knl")) crdn.setCrdnInptSeCd("12");
else crdn.setCrdnInptSeCd("15");
} else if(fileGroupType.equals("JPG")){
crdn.setVltnCd("01"); imageFileInfoList = linkFileInfoList;
crdn.setCrdnSeCd("07"); bgngAndEnd = getBgngDataAndEndData(linkFileInfoList);
crdn.setSggCd(globalStngMapper.selectSggCdForCurrentUser()); if(bgngAndEnd[1] == null) {
crdn.setVhrno(linkFileInfo.string("VHRNO")); metaFileInfo = linkFileInfoList.get(0);
crdn.setCrdnYmd(linkFileInfo.string("CRDN_YMD")); } else {
crdn.setCrdnTm(linkFileInfo.string("CRDN_TM")); metaFileInfo = bgngAndEnd[1];
crdn.setGpsX(linkFileInfo.string("GPS_X")); }
crdn.setGpsY(linkFileInfo.string("GPS_Y"));
crdn.setMoscX(linkFileInfo.string("MOSC_X"));
crdn.setMoscY(linkFileInfo.string("MOSC_Y"));
//linkFileInfo.string("EQPMNT_CD");
//linkFileInfo.string("PLATE_WIDTH");
//linkFileInfo.string("PLATE_HEIGHT");
try { } else if(fileGroupType.equals("BIN")) {
FileInfo FileInfo1 = SingleFileParser.base64ToFileInfo(linkFileInfo.string("CAR_IMAGE_NM"), linkFileInfo.string("CAR_IMAGE"), 1);
fileInfoList.add(FileInfo1); metaFileInfo = linkFileInfoList.get(0);
FileInfo FileInfo2 = SingleFileParser.base64ToFileInfo(linkFileInfo.string("PLATE_IMAGE_NM"), linkFileInfo.string("PLATE_IMAGE"), 2);
fileInfoList.add(FileInfo2);
int otherPhotoCnt = linkFileInfo.number("PHOTO_CNT").intValue() - 2; int otherPhotoCnt = metaFileInfo.number("PHOTO_CNT").intValue();
for(int i=1; i <= otherPhotoCnt; i++){ for(int i=1; i <= otherPhotoCnt; i++){
String fileName = linkFileInfo.string("MOVING_IMAGE"+i+"_NM"); String fileName = metaFileInfo.string("B64IMAGE"+i+"_NM");
String b64str = linkFileInfo.string("MOVING_IMAGE"+i); String b64str = metaFileInfo.string("B64IMAGE"+i);
FileInfo FileInfo = SingleFileParser.base64ToFileInfo(fileName, b64str, i + 2); DataObject dataObject = new DataObject();
fileInfoList.add(FileInfo); dataObject.put("B64IMAGE_NM", fileName);
dataObject.put("B64IMAGE", b64str);
imageFileInfoList.add(dataObject);
} }
} catch (Exception e) { } else {
throw new RuntimeException(e); return result;
} }
result.put("metaInfo", metaFileInfo);
result.put("imageInfo", imageFileInfoList);
result.put("bgngData", bgngAndEnd[0]);
result.put("endData", bgngAndEnd[1]);
return result;
} }
/** . null . <br />
* @param imageDataList
* @return ,
*/
public DataObject[] getBgngDataAndEndData(List<DataObject> imageDataList) {
DataObject[] bgngAndEnd = {null, null};
if(!imageDataList.get(0).get("CRDN_TIMESTAMP").equals("")) {
//2. 차적 조회 DataObject bgngData = imageDataList.stream()
List<Crdn> crdns = new ArrayList<Crdn>(); .min(Comparator.comparing(item -> new BigInteger(item.string("CRDN_TIMESTAMP"))))
crdns.add(crdn); .orElseThrow();
importBean.setVehicleInfo(crdns);
DataObject endData = imageDataList.stream()
.max(Comparator.comparing(item -> new BigInteger(item.string("CRDN_TIMESTAMP"))))
.orElseThrow();
//3.등록 bgngAndEnd[0] = bgngData;
saved = crdnBean.create(null, crdn, fileInfoList); bgngAndEnd[1] = endData;
}
resultMap.put("saved", saved); return bgngAndEnd;
}
if(saved) { /** . <br />
for(DataObject delInfo : linkFileInfoList) { * @param crdn , bgngData , endData
crdnBean.removeEquipmentLinkFile(workPath, delInfo.string("FILE_NAME")); * @return
*/
public void crdnTimeRangeSet(Crdn crdn, DataObject bgngData, DataObject endData) {
if(bgngData != null && endData != null) {
if(!endData.string("CRDN_BGNG_TM").equals("")) {
crdn.setCrdnBgngTm(endData.string("CRDN_BGNG_TM"));
crdn.setCrdnEndTm(endData.string("CRDN_END_TM"));
} else if(!endData.string("CRDN_TM").equals("")){
crdn.setCrdnBgngTm(bgngData.string("CRDN_TM"));
crdn.setCrdnEndTm(endData.string("CRDN_TM"));
}
}
} }
if(!ifEmpty(crdn.getErsrRegYmd(), () -> "").equals("")) { /** List<FileInfo> . <br />
String vhrno = crdn.getVhrno(); * @param imageFileInfoList , fileGroupType
String ersrRegYmd = crdn.getErsrRegYmd(); * @return fileInfo
String ersrYear = ersrRegYmd.substring(0, 4); */
String ersrMonth = ersrRegYmd.substring(4, 6); public List<FileInfo> parsedDataInfoToFileInfo(List<DataObject> imageFileInfoList, String fileGroupType){
String ersrDay = ersrRegYmd.substring(6, 8); List<FileInfo> fileInfoList = new ArrayList<FileInfo>();
String alertMessage = vhrno + " : " + ersrYear + "년" + ersrMonth + "월" + ersrDay + "일로 말소된 차량입니다."; try {
resultMap.put("alertMessage", alertMessage); //이미지, 이미지및텍스트
if(fileGroupType.equals("JPG") || fileGroupType.equals("TXT")) {
List<File> files = new ArrayList<>();
for (DataObject imageFileInfo : imageFileInfoList) {
files.add(new File(imageFileInfo.string("FILE_PATH")));
} }
} else { fileInfoList = new FileInfoFactory().createFileInfos(null, files);
resultMap.put("failReason", "기타 오류"); for (int iLoop = 0; iLoop < fileInfoList.size(); iLoop++) {
fileInfoList.get(iLoop).setName("image"+iLoop+"."+FilenameUtils.getExtension(fileInfoList.get(iLoop).getName()));
} }
return resultMap; } else if(fileGroupType.equals("BIN")) {
for(int i=0; i < imageFileInfoList.size(); i++){
String fileName = imageFileInfoList.get(i).string("B64IMAGE_NM");
String b64str = imageFileInfoList.get(i).string("B64IMAGE");
FileInfo FileInfo = SingleFileParser.base64ToFileInfo(fileName, b64str, (i+1));
fileInfoList.add(FileInfo);
} }
} }
} catch (Exception e) {
throw new RuntimeException(e);
}
return fileInfoList;
};
}

@ -11,6 +11,9 @@
<result property="linkFileLocation" column="LINK_FILE_PATH" /> <!-- 연계 파일 경로 --> <result property="linkFileLocation" column="LINK_FILE_PATH" /> <!-- 연계 파일 경로 -->
<result property="fileGroup" column="DATA_FILE_SE" /> <!-- 자료 파일 구분 --> <result property="fileGroup" column="DATA_FILE_SE" /> <!-- 자료 파일 구분 -->
<result property="countPerFileGroup" column="FILE_TNOCS" /> <!-- 파일 총 건수 --> <result property="countPerFileGroup" column="FILE_TNOCS" /> <!-- 파일 총 건수 -->
<result property="sameItemsInFileGroup" column="SAME_ITEMS" /> <!-- 동일 항목 -->
<result property="increaseItemInFileGroup" column="INCREASE_ITEM" /> <!-- 증가 항목 -->
<result property="increaseTypeInFileGroup" column="INCREASE_TYPE" /> <!-- 증가 형식 -->
<result property="fileNameLength" column="FILE_NM_SZ" /> <!-- 파일 명 크기 --> <result property="fileNameLength" column="FILE_NM_SZ" /> <!-- 파일 명 크기 -->
<result property="fileNameItmes" column="FILE_NM_LAYOUT" /> <!-- 파일 명 형식 --> <result property="fileNameItmes" column="FILE_NM_LAYOUT" /> <!-- 파일 명 형식 -->
<result property="fileNameSeperator" column="FILE_SE_TYPE" /> <!-- 파일 구분 유형 --> <result property="fileNameSeperator" column="FILE_SE_TYPE" /> <!-- 파일 구분 유형 -->
@ -78,6 +81,9 @@ SELECT A.FILE_LAYOUT_ID
, A.FILE_TNOCS , A.FILE_TNOCS
, A.LINK_FILE_PATH , A.LINK_FILE_PATH
, A.ENT_NM , A.ENT_NM
, A.SAME_ITEMS
, A.INCREASE_ITEM
, A.INCREASE_TYPE
, B.LINK_ENT_NM , B.LINK_ENT_NM
FROM TB_CRDN_FILE_LAYOUT A FROM TB_CRDN_FILE_LAYOUT A
LEFT OUTER JOIN TB_FTP_INFO B ON (A.FILE_LAYOUT_ID = B.FILE_LAYOUT_ID) LEFT OUTER JOIN TB_FTP_INFO B ON (A.FILE_LAYOUT_ID = B.FILE_LAYOUT_ID)

@ -205,13 +205,10 @@ $(document).ready(function(){
$("#table-responsive--${pageName}").find("tbody").setCurrentRow(dataKey); $("#table-responsive--${pageName}").find("tbody").setCurrentRow(dataKey);
if(item.data.FILE_GROUP_TYPE == "BIN"){ if(item.data.FILE_GROUP_TYPE == "BIN"){
var srcArr = [ var srcArr = [];
"data:image/jpg;base64,"+item.data.CAR_IMAGE,
"data:image/jpg;base64,"+item.data.PLATE_IMAGE
];
for(var i=1; i <= item.data.PHOTO_CNT-2; i++){ for(var i=1; i <= item.data.PHOTO_CNT; i++){
srcArr.push("data:image/jpg;base64," + item.data["MOVING_IMAGE"+i]) srcArr.push("data:image/jpg;base64," + item.data["B64IMAGE"+i])
} }
$P.renderImage(srcArr); $P.renderImage(srcArr);

Loading…
Cancel
Save