diff --git a/src/main/java/cokr/xit/fims/cmmn/ftp/FTPUtil.java b/src/main/java/cokr/xit/fims/cmmn/ftp/FTPUtil.java index b63dca27..a6ae1562 100644 --- a/src/main/java/cokr/xit/fims/cmmn/ftp/FTPUtil.java +++ b/src/main/java/cokr/xit/fims/cmmn/ftp/FTPUtil.java @@ -152,7 +152,7 @@ public class FTPUtil { } } catch (IOException e) { e.printStackTrace(); - throw new RuntimeException(); + throw new RuntimeException(e); } // 커서 이동에 실패하면 false를 리턴한다. diff --git a/src/main/java/cokr/xit/fims/crdn/parsing/HiteCom.java b/src/main/java/cokr/xit/fims/crdn/parsing/HiteCom.java index 5c29f269..4f0527e8 100644 --- a/src/main/java/cokr/xit/fims/crdn/parsing/HiteCom.java +++ b/src/main/java/cokr/xit/fims/crdn/parsing/HiteCom.java @@ -1,17 +1,20 @@ package cokr.xit.fims.crdn.parsing; +import java.io.ByteArrayInputStream; import java.io.File; import java.io.IOException; -import java.io.UnsupportedEncodingException; +import java.io.InputStream; import java.nio.charset.Charset; import java.nio.file.Files; import java.nio.file.Path; import java.util.ArrayList; import java.util.Base64; +import java.util.Base64.Decoder; import java.util.Base64.Encoder; import java.util.List; import java.util.stream.Stream; +import cokr.xit.base.file.FileInfo; import cokr.xit.fims.cmmn.CmmnUtil; import cokr.xit.foundation.data.DataObject; @@ -44,11 +47,10 @@ public class HiteCom implements EquipmentEnterprise { String fileCn = ""; try { fileCn = new String(fileCn0.getBytes("ISO-8859-1"), "EUC-KR"); - } catch (UnsupportedEncodingException e) { - e.printStackTrace(); + } catch (Exception e) { + throw new RuntimeException(e); } - System.out.println("substring...."); dataObject.put("TEXT_SIZE", CmmnUtil.substringByBytes(fileCn, 0, 7)); dataObject.put("EQUIPMENT", CmmnUtil.substringByBytes(fileCn, 8, 12)); dataObject.put("CAR_VELOCITY", CmmnUtil.substringByBytes(fileCn, 13, 15).replaceAll("^0+", "")); //차량속도 @@ -122,8 +124,8 @@ public class HiteCom implements EquipmentEnterprise { } - tempGroupSeq++; dataObject.put("TEMP_GROUP_ID", tempGroupSeq); + tempGroupSeq++; dataObject.put("ENT_TYPE", "hitecom"); dataObjectList.add(dataObject); @@ -137,4 +139,22 @@ public class HiteCom implements EquipmentEnterprise { return true; } + public static FileInfo base64ToFileInfo(String fileName, String base64str, int sortOrder) { + try { + Decoder decoder = Base64.getDecoder(); + byte[] b64byte = decoder.decode(base64str.getBytes("ISO-8859-1")); + InputStream is = new ByteArrayInputStream(b64byte); + + FileInfo fileInfo = new FileInfo(); + fileInfo.setName(fileName+".jpg"); + fileInfo.setInputStream(is); + fileInfo.setMimeType("image/jpeg"); + fileInfo.setSize(is.available()); + fileInfo.setSortOrder(sortOrder); + return fileInfo; + } catch (Exception e) { + throw new RuntimeException(e); + } + } + } diff --git a/src/main/java/cokr/xit/fims/crdn/service/bean/CrdnBean.java b/src/main/java/cokr/xit/fims/crdn/service/bean/CrdnBean.java index 4f453537..38787d6b 100644 --- a/src/main/java/cokr/xit/fims/crdn/service/bean/CrdnBean.java +++ b/src/main/java/cokr/xit/fims/crdn/service/bean/CrdnBean.java @@ -368,7 +368,7 @@ public class CrdnBean extends AbstractComponent { //빈 디렉토리 삭제 CmmnUtil.deleteEmptyDir(new File("files"+File.separator+"tempForIno"), false); } catch (Exception e) { - throw new RuntimeException(); + throw new RuntimeException(e); } return saved; diff --git a/src/main/java/cokr/xit/fims/crdn/service/bean/ImportServiceBean.java b/src/main/java/cokr/xit/fims/crdn/service/bean/ImportServiceBean.java index b34c9c22..9215b869 100644 --- a/src/main/java/cokr/xit/fims/crdn/service/bean/ImportServiceBean.java +++ b/src/main/java/cokr/xit/fims/crdn/service/bean/ImportServiceBean.java @@ -19,6 +19,7 @@ import cokr.xit.base.file.service.bean.FileBean; import cokr.xit.base.file.web.FileInfoFactory; import cokr.xit.fims.crdn.Crdn; import cokr.xit.fims.crdn.dao.GlobalStngMapper; +import cokr.xit.fims.crdn.parsing.HiteCom; import cokr.xit.fims.crdn.service.CrdnService; import cokr.xit.fims.crdn.service.ImportService; import cokr.xit.foundation.component.AbstractServiceBean; @@ -91,6 +92,7 @@ public class ImportServiceBean extends AbstractServiceBean implements ImportServ List fileInfoList = new ArrayList(); + // if(entType.equals("ino")) { crdn.setCrdnInptSeCd("11"); @@ -133,14 +135,62 @@ public class ImportServiceBean extends AbstractServiceBean implements ImportServ } + // if(entType.equals("knl")) { crdn.setCrdnInptSeCd("12"); crdn.setVltnCd("01"); + } + + // + if(entType.equals("hitecom")) { + crdn.setCrdnInptSeCd("15"); + + crdn.setVltnCd("01"); + + //1. 연계파일정보를 단속 엔티티로 변환 + if(linkFileInfoList.size() != 1) { + resultMap.put("saved", false); + resultMap.put("failReason", "그룹핑 오류"); + return resultMap; + } + DataObject linkFileInfo = linkFileInfoList.get(0); + crdn.setSggCd(globalStngMapper.selectSggCdForCurrentUser()); + crdn.setVhrno(linkFileInfo.string("VHRNO")); + crdn.setCrdnYmd(linkFileInfo.string("CRDN_YMD")); + crdn.setCrdnTm(linkFileInfo.string("CRDN_TM")); + 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("EQUIPMENT"); + //linkFileInfo.string("PLATE_WIDTH"); + //linkFileInfo.string("PLATE_HEIGHT"); + + try { + FileInfo FileInfo1 = HiteCom.base64ToFileInfo(linkFileInfo.string("CAR_IMAGE_NM"), linkFileInfo.string("CAR_IMAGE"), 1); + fileInfoList.add(FileInfo1); + FileInfo FileInfo2 = HiteCom.base64ToFileInfo(linkFileInfo.string("PLATE_IMAGE_NM"), linkFileInfo.string("PLATE_IMAGE"), 2); + fileInfoList.add(FileInfo2); + + int otherPhotoCnt = linkFileInfo.number("PHOTO_CNT").intValue() - 2; + for(int i=1; i <= otherPhotoCnt; i++){ + String fileName = linkFileInfo.string("MOVING_IMAGE"+i+"_NM"); + String b64str = linkFileInfo.string("MOVING_IMAGE"+i); + FileInfo FileInfo = HiteCom.base64ToFileInfo(fileName, b64str, i + 2); + fileInfoList.add(FileInfo); + } + + } catch (Exception e) { + throw new RuntimeException(e); + } } + + //2. 차적 조회 List crdns = new ArrayList(); crdns.add(crdn); diff --git a/src/main/java/cokr/xit/fims/crdn/web/Crdn05Controller.java b/src/main/java/cokr/xit/fims/crdn/web/Crdn05Controller.java index c5ed0dc5..b32b5e00 100644 --- a/src/main/java/cokr/xit/fims/crdn/web/Crdn05Controller.java +++ b/src/main/java/cokr/xit/fims/crdn/web/Crdn05Controller.java @@ -292,7 +292,9 @@ public class Crdn05Controller extends ApplicationController { List linkFileInfoList = new ArrayList(); for(String linkFileInfo : linkFileInfos) { - linkFileInfoList.add(fromJson(linkFileInfo, DataObject.class)); + if(!linkFileInfo.equals("{}")) { + linkFileInfoList.add(fromJson(linkFileInfo, DataObject.class)); + } } Map processInfo = new HashMap(); diff --git a/src/main/webapp/WEB-INF/jsp/fims/crdn/crdn05020-info.jsp b/src/main/webapp/WEB-INF/jsp/fims/crdn/crdn05020-info.jsp index 289f4173..4266853e 100644 --- a/src/main/webapp/WEB-INF/jsp/fims/crdn/crdn05020-info.jsp +++ b/src/main/webapp/WEB-INF/jsp/fims/crdn/crdn05020-info.jsp @@ -460,6 +460,9 @@ $(document).ready(function(){ formData.append("taskSeCd", "${taskSeCd}"); formData.append("entType", $P.entType); formData.append("equipmentType", $("#equipmentType--${pageName}").val()); + if($P.tempGroup[firstGroupKey].length == 1){ + formData.append("linkFileInfos", JSON.stringify({})); + } for(var i=0; i<$P.tempGroup[firstGroupKey].length; i++){ formData.append("linkFileInfos", JSON.stringify($P.tempGroup[firstGroupKey][i])); } @@ -520,7 +523,7 @@ $(document).ready(function(){ $P.removeTableRow = (removedFileName) => { if($P.entType != ""){ - var fileListTable = $("#table-responsive--${pageName}").find("."+$P.entType).find("table"); + var fileListTable = $("#table-responsive--${pageName}").find("."+$P.entType).find("table")[0]; var targetArr = []; if(Array.isArray(removedFileName)){