From 3e42b62497b710307ef78628960e12a44cfb8b6f Mon Sep 17 00:00:00 2001 From: leebeomjun Date: Fri, 13 Oct 2023 10:45:56 +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=EB=93=B1=EB=A1=9D=EC=8B=9C=20=EC=97=85=EC=B2=B4=20?= =?UTF-8?q?=EC=84=A0=ED=83=9D=ED=95=98=EB=8A=94=20=EB=B6=80=EB=B6=84=20?= =?UTF-8?q?=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/cokr/xit/fims/crdn/CrdnQuery.java | 10 + .../xit/fims/crdn/dao/GlobalStngMapper.java | 7 + .../fims/crdn/parsing/AttachedTxtParser.java | 7 +- .../crdn/parsing/LayoutDiscriminator.java | 6 +- .../xit/fims/crdn/parsing/LayoutParser.java | 3 +- .../fims/crdn/parsing/OnlyImageParser.java | 7 +- .../xit/fims/crdn/parsing/ParsingUtil.java | 28 --- .../fims/crdn/parsing/SingleFileParser.java | 5 +- .../xit/fims/crdn/service/bean/CrdnBean.java | 2 +- .../fims/crdn/service/bean/CrdnStngBean.java | 6 + .../crdn/service/bean/ImportServiceBean.java | 56 ++--- .../xit/fims/crdn/web/Crdn05Controller.java | 191 +++++++++--------- .../cokr/xit/fims/task/web/BpvController.java | 4 +- .../cokr/xit/fims/task/web/DpvController.java | 4 +- .../cokr/xit/fims/task/web/EcaController.java | 4 +- .../cokr/xit/fims/task/web/PvsController.java | 4 +- .../mapper/fims/crdn/global-stng-mapper.xml | 22 +- .../WEB-INF/jsp/fims/crdn/crdn05020-info.jsp | 126 ++++-------- 18 files changed, 237 insertions(+), 255 deletions(-) delete mode 100644 src/main/java/cokr/xit/fims/crdn/parsing/ParsingUtil.java diff --git a/src/main/java/cokr/xit/fims/crdn/CrdnQuery.java b/src/main/java/cokr/xit/fims/crdn/CrdnQuery.java index c6958057..ff971c77 100644 --- a/src/main/java/cokr/xit/fims/crdn/CrdnQuery.java +++ b/src/main/java/cokr/xit/fims/crdn/CrdnQuery.java @@ -30,6 +30,7 @@ public class CrdnQuery extends CmmnQuery { private String[] crdnIDs; private String amtDcsnCdGroupId; private String dtlAmtDcsnCdGroupId; + private String fileLayoutId; //날짜 private String aplcnYmd; @@ -396,6 +397,15 @@ public class CrdnQuery extends CmmnQuery { return self(); } + public String getFileLayoutId() { + return ifEmpty(fileLayoutId, () -> null); + } + + public T setFileLayoutId(String fileLayoutId) { + this.fileLayoutId = fileLayoutId; + return self(); + } + public String getDtlAmtDcsnCd() { return ifEmpty(dtlAmtDcsnCd, () -> null); } diff --git a/src/main/java/cokr/xit/fims/crdn/dao/GlobalStngMapper.java b/src/main/java/cokr/xit/fims/crdn/dao/GlobalStngMapper.java index 09e255f2..51425825 100644 --- a/src/main/java/cokr/xit/fims/crdn/dao/GlobalStngMapper.java +++ b/src/main/java/cokr/xit/fims/crdn/dao/GlobalStngMapper.java @@ -7,6 +7,7 @@ import org.egovframe.rte.psl.dataaccess.mapper.Mapper; import cokr.xit.fims.crdn.CrdnQuery; import cokr.xit.fims.crdn.parsing.LayoutDescriptor; import cokr.xit.foundation.component.AbstractMapper; +import cokr.xit.foundation.data.DataObject; @Mapper("globalStngMapper") public interface GlobalStngMapper extends AbstractMapper { @@ -45,4 +46,10 @@ public interface GlobalStngMapper extends AbstractMapper { * @return 연계파일 레이아웃 정보 */ List selectLinkFileLayoutMetadata(CrdnQuery query); + + /** 레이아웃별 연계파일의 ftp정보를 조회한다. + * @param fileLayoutId 파일 레이아웃 ID + * @return ftp정보 + */ + DataObject selectRemoteInfo(String fileLayoutId); } \ No newline at end of file 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 6372ea4b..03e19ac7 100644 --- a/src/main/java/cokr/xit/fims/crdn/parsing/AttachedTxtParser.java +++ b/src/main/java/cokr/xit/fims/crdn/parsing/AttachedTxtParser.java @@ -10,7 +10,6 @@ import java.util.ArrayList; import java.util.List; import java.util.regex.Matcher; import java.util.stream.Collectors; -import java.util.stream.Stream; import org.apache.commons.io.FilenameUtils; @@ -22,10 +21,10 @@ public class AttachedTxtParser extends LayoutParser{ private int tempGroupSeq = 1; @Override - public List parsing(Stream fileList) { + public List parsing(List fileList) { //파일명으로 정렬(파싱 전) - List sortedFileList = fileList + List sortedFileList = fileList.stream() .sorted((item1, item2) -> item1.toFile().getName().compareTo(item2.toFile().getName())) .collect(Collectors.toList()); @@ -33,6 +32,8 @@ public class AttachedTxtParser extends LayoutParser{ sortedFileList.forEach(item -> { DataObject dataObject = new DataObject(); + dataObject.put("FILE_GROUP_TYPE", "TXT"); + File file = item.toFile(); String filePath = file.getPath(); dataObject.put("FILE_PATH", filePath); diff --git a/src/main/java/cokr/xit/fims/crdn/parsing/LayoutDiscriminator.java b/src/main/java/cokr/xit/fims/crdn/parsing/LayoutDiscriminator.java index 89d4d978..1cce75df 100644 --- a/src/main/java/cokr/xit/fims/crdn/parsing/LayoutDiscriminator.java +++ b/src/main/java/cokr/xit/fims/crdn/parsing/LayoutDiscriminator.java @@ -1,12 +1,12 @@ package cokr.xit.fims.crdn.parsing; -import java.nio.file.Path; import java.util.List; -import java.util.stream.Stream; + +import org.springframework.web.multipart.MultipartFile; public class LayoutDiscriminator { - public static LayoutDescriptor choice(Stream fileList, List candidates) { + public static LayoutDescriptor choice(MultipartFile[] fileList, List candidates) { // TODO return null; } 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 fd5d6903..edab7306 100644 --- a/src/main/java/cokr/xit/fims/crdn/parsing/LayoutParser.java +++ b/src/main/java/cokr/xit/fims/crdn/parsing/LayoutParser.java @@ -2,7 +2,6 @@ package cokr.xit.fims.crdn.parsing; import java.nio.file.Path; import java.util.List; -import java.util.stream.Stream; import cokr.xit.foundation.data.DataObject; @@ -18,7 +17,7 @@ abstract public class LayoutParser { * @param fileList 연계파일리스트 * @return 단속정보 */ - abstract public List parsing(Stream fileList); + abstract public List parsing(List fileList); /**현재 연계 파일의 정보가 이전 연계 파일의 정보와 다른 단속건인지 판단한다.
* @param currentItem 현재 연계 파일 정보, beforeItem 이전 연계 파일 정보 diff --git a/src/main/java/cokr/xit/fims/crdn/parsing/OnlyImageParser.java b/src/main/java/cokr/xit/fims/crdn/parsing/OnlyImageParser.java index af379558..15538671 100644 --- a/src/main/java/cokr/xit/fims/crdn/parsing/OnlyImageParser.java +++ b/src/main/java/cokr/xit/fims/crdn/parsing/OnlyImageParser.java @@ -8,7 +8,6 @@ import java.util.Date; import java.util.List; import java.util.regex.Matcher; import java.util.stream.Collectors; -import java.util.stream.Stream; import org.apache.commons.io.FilenameUtils; @@ -21,17 +20,19 @@ public class OnlyImageParser extends LayoutParser { private int tempGroupSeq = 1; @Override - public List parsing(Stream fileList) { + public List parsing(List fileList) { List dataObjectList = new ArrayList<>(); //파일명으로 정렬(파싱 전) - List sortedFileList = fileList + List sortedFileList = fileList.stream() .sorted((item1, item2) -> item1.toFile().getName().compareTo(item2.toFile().getName())) .collect(Collectors.toList()); sortedFileList.forEach(item -> { DataObject dataObject = new DataObject(); + dataObject.put("FILE_GROUP_TYPE", "JPG"); + File file = item.toFile(); String filePath = file.getPath(); dataObject.put("FILE_PATH", filePath); diff --git a/src/main/java/cokr/xit/fims/crdn/parsing/ParsingUtil.java b/src/main/java/cokr/xit/fims/crdn/parsing/ParsingUtil.java deleted file mode 100644 index d5285ac0..00000000 --- a/src/main/java/cokr/xit/fims/crdn/parsing/ParsingUtil.java +++ /dev/null @@ -1,28 +0,0 @@ -package cokr.xit.fims.crdn.parsing; - -import java.io.File; - -public class ParsingUtil { - - /**자치단체,과태료업무,장비업체,장비구분에 따른 연계 파일 작업 디렉토리 경로를 반환한다.
- * @param institute 기관구분, taskSeCd 과태료구분, entType 업체구분, equipmentType 장비구분 - * @return 작업 디렉토리 경로 - */ - public static String getWorkDirectoryPath(String institute, String taskSeCd, String entType, String equipmentType) { - String workPath = ""; - - if(entType.equals("ino")) { - workPath = "files"+File.separator+"tempForIno"; - } - if(entType.equals("knl")) { - workPath = "files"+File.separator+"tempForKnl"; - } - if(entType.equals("hitecom")) { - workPath = "files"+File.separator+"tempForHitecom"; - } - if(entType.equals("xit")) { - workPath = "files"+File.separator+"tempForXit"; - } - return workPath; - } -} 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 a04a60e5..f4eae89a 100644 --- a/src/main/java/cokr/xit/fims/crdn/parsing/SingleFileParser.java +++ b/src/main/java/cokr/xit/fims/crdn/parsing/SingleFileParser.java @@ -12,7 +12,6 @@ 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; @@ -23,12 +22,14 @@ public class SingleFileParser extends LayoutParser { private int tempGroupSeq = 1; @Override - public List parsing(Stream fileList) { + public List parsing(List fileList) { List dataObjectList = new ArrayList<>(); fileList.forEach(item -> { DataObject dataObject = new DataObject(); + dataObject.put("FILE_GROUP_TYPE", "BIN"); + File file = item.toFile(); String filePath = file.getPath(); dataObject.put("FILE_PATH", filePath); 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 38787d6b..f2540c97 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 @@ -366,7 +366,7 @@ public class CrdnBean extends AbstractComponent { } //빈 디렉토리 삭제 - CmmnUtil.deleteEmptyDir(new File("files"+File.separator+"tempForIno"), false); + CmmnUtil.deleteEmptyDir(new File(workPath), false); } catch (Exception e) { throw new RuntimeException(e); } diff --git a/src/main/java/cokr/xit/fims/crdn/service/bean/CrdnStngBean.java b/src/main/java/cokr/xit/fims/crdn/service/bean/CrdnStngBean.java index 67539379..db840e39 100644 --- a/src/main/java/cokr/xit/fims/crdn/service/bean/CrdnStngBean.java +++ b/src/main/java/cokr/xit/fims/crdn/service/bean/CrdnStngBean.java @@ -225,4 +225,10 @@ public class CrdnStngBean extends AbstractComponent { return globalStngMapper.selectLinkFileLayoutMetadata(query); } + public LayoutDescriptor getLinkFileLayoutMetadata(String fileLayoutId) { + CrdnQuery query = new CrdnQuery(); + query.setFileLayoutId(fileLayoutId); + List list = globalStngMapper.selectLinkFileLayoutMetadata(query); + return list == null ? null : list.get(0); + } } 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 298c1e24..77687f68 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 @@ -80,11 +80,12 @@ public class ImportServiceBean extends AbstractServiceBean implements ImportServ public HashMap createCrdnByEquipmentLinkFile(Map processInfo, List linkFileInfoList) { HashMap resultMap = new HashMap<>(); boolean saved = false; + String workPath = processInfo.get("workPath"); String institute = processInfo.get("institute"); String taskSeCd = processInfo.get("taskSeCd"); - String entType = processInfo.get("entType"); - String equipmentType = processInfo.get("equipmentType"); - String workPath = processInfo.get("workPath"); + + String fileGroupType = processInfo.get("fileGroupType"); + Crdn crdn = new Crdn(); crdn.setCrdnRegSeCd("07"); @@ -93,10 +94,7 @@ public class ImportServiceBean extends AbstractServiceBean implements ImportServ List fileInfoList = new ArrayList(); // - if(entType.equals("ino")) { - crdn.setCrdnInptSeCd("11"); - - crdn.setVltnCd("01"); + if(fileGroupType.equals("JPG")) { //1. 연계파일정보를 단속 엔티티로 변환 DataObject bgngData = linkFileInfoList.stream() @@ -111,6 +109,14 @@ public class ImportServiceBean extends AbstractServiceBean implements ImportServ crdn.setCrdnEndTm(endData.string("CRDN_TM")); DataObject linkFileInfo = endData; + + String entType = linkFileInfo.string("ENT_TYPE"); + if(entType.equals("ino")) crdn.setCrdnInptSeCd("11"); + if(entType.equals("knl")) crdn.setCrdnInptSeCd("12"); + else crdn.setCrdnInptSeCd("15"); + + crdn.setCrdnInptSeCd("11"); + crdn.setVltnCd("01"); crdn.setSggCd(globalStngMapper.selectSggCdForCurrentUser()); crdn.setVhrno(linkFileInfo.string("VHRNO")); crdn.setCrdnYmd(linkFileInfo.string("CRDN_YMD")); @@ -135,19 +141,9 @@ public class ImportServiceBean extends AbstractServiceBean implements ImportServ } - // - if(entType.equals("knl")) { - crdn.setCrdnInptSeCd("12"); - - crdn.setVltnCd("01"); - } //XIT권장포맷 - if(entType.equals("xit")) { - - crdn.setCrdnInptSeCd("15"); - - crdn.setVltnCd("01"); + if(fileGroupType.equals("TXT")) { //1. 연계파일정보를 단속 엔티티로 변환 crdn.setSggCd(globalStngMapper.selectSggCdForCurrentUser()); @@ -159,6 +155,13 @@ public class ImportServiceBean extends AbstractServiceBean implements ImportServ } } + String entType = metaFileInfo.string("ENT_TYPE"); + if(entType.equals("ino")) crdn.setCrdnInptSeCd("11"); + if(entType.equals("knl")) crdn.setCrdnInptSeCd("12"); + else crdn.setCrdnInptSeCd("15"); + + crdn.setVltnCd("01"); + crdn.setCrdnSeCd(metaFileInfo.string("CRDN_SE_CD")); crdn.setCrdnYmd(metaFileInfo.string("CRDN_YMD")); crdn.setCrdnTm(metaFileInfo.string("CRDN_TM")); @@ -194,12 +197,7 @@ public class ImportServiceBean extends AbstractServiceBean implements ImportServ } // - if(entType.equals("hitecom")) { - crdn.setCrdnSeCd("07"); - - crdn.setCrdnInptSeCd("15"); - - crdn.setVltnCd("01"); + if(fileGroupType.equals("BIN")) { //1. 연계파일정보를 단속 엔티티로 변환 if(linkFileInfoList.size() != 1) { @@ -208,6 +206,16 @@ public class ImportServiceBean extends AbstractServiceBean implements ImportServ return resultMap; } DataObject linkFileInfo = linkFileInfoList.get(0); + + String entType = linkFileInfo.string("ENT_TYPE"); + if(entType.equals("ino")) crdn.setCrdnInptSeCd("11"); + if(entType.equals("knl")) crdn.setCrdnInptSeCd("12"); + else crdn.setCrdnInptSeCd("15"); + + crdn.setVltnCd("01"); + + crdn.setCrdnSeCd("07"); + crdn.setSggCd(globalStngMapper.selectSggCdForCurrentUser()); crdn.setVhrno(linkFileInfo.string("VHRNO")); crdn.setCrdnYmd(linkFileInfo.string("CRDN_YMD")); 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 fd007a6e..b6170673 100644 --- a/src/main/java/cokr/xit/fims/crdn/web/Crdn05Controller.java +++ b/src/main/java/cokr/xit/fims/crdn/web/Crdn05Controller.java @@ -9,7 +9,6 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.stream.Stream; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; @@ -34,11 +33,11 @@ import cokr.xit.fims.crdn.parsing.LayoutDescriptor; import cokr.xit.fims.crdn.parsing.LayoutDiscriminator; import cokr.xit.fims.crdn.parsing.LayoutParser; import cokr.xit.fims.crdn.parsing.OnlyImageParser; -import cokr.xit.fims.crdn.parsing.ParsingUtil; import cokr.xit.fims.crdn.parsing.SingleFileParser; import cokr.xit.fims.crdn.service.CrdnService; import cokr.xit.fims.crdn.service.CrdnStngService; import cokr.xit.fims.crdn.service.ImportService; +import cokr.xit.fims.crdn.service.bean.CrdnStngBean; import cokr.xit.foundation.data.DataObject; /**단속 자료 등록 서비스 웹 컨트롤러.
@@ -75,6 +74,9 @@ public class Crdn05Controller extends ApplicationController { @Resource(name="crdnStngService") private CrdnStngService crdnStngService; + @Resource(name="crdnStngBean") + private CrdnStngBean crdnStngBean; + @Resource(name="crdnInstMapper") private CrdnInstMapper crdnInstMapper; @@ -135,47 +137,44 @@ public class Crdn05Controller extends ApplicationController { ModelAndView mav = new ModelAndView("jsonView"); boolean saved = false; - String entType = hReq.getParameter("entType"); - LayoutParser parser = null; - switch(entType){ - case "ino": parser = new OnlyImageParser(); break; - //case "knl": break; - case "hitecom": parser = new SingleFileParser(); break; - case "xit": parser = new AttachedTxtParser(); break; - //case "": enterprise = new (); break; - } - String institute = currentUser().getInstitute(); String taskSeCd = hReq.getParameter("taskSeCd"); - String equipmentType = hReq.getParameter("equipmentType"); + String sggCd = globalStngMapper.selectSggCdForCurrentUser(); + ManagedUser currentUser = userMapper.getUser(currentUser().getAccount(), institute); + String deptCd = currentUser.getDeptCode(); + List layoutDescriptors = crdnStngService.getLinkFileLayoutMetadata(sggCd, taskSeCd, institute, deptCd); - String workPath = ParsingUtil.getWorkDirectoryPath(institute, taskSeCd, entType, equipmentType); - File workDir = new File(workPath); - workDir.mkdirs(); + for(int i=0; i < layoutDescriptors.size(); i++) { + DataObject remoteInfo = globalStngMapper.selectRemoteInfo(layoutDescriptors.get(i).getFileLayoutId()); + if(remoteInfo == null) { + continue; + } - RemoteSystemInfo rs = new RemoteSystemInfo(); - rs.setIp("211.119.124.9"); - rs.setId("xituser"); - rs.setPw("xituser!@"); - rs.setOsType("linux"); - - String remoteWorkPath = File.separator + "applications" - + File.separator + "tempForFTPTest" - + File.separator + "GCloud" - + File.separator + entType - + File.separator; - try { - boolean result = FTPUtil.fileDown(rs, remoteWorkPath, workPath); - if(!result) { - saved = false; - mav.addObject("saved", saved); - return mav; - } - } catch (Exception e) { - e.printStackTrace(); - saved = false; - mav.addObject("saved", saved); - return mav; + RemoteSystemInfo rs = new RemoteSystemInfo(); + rs.setIp(remoteInfo.string("REMOTE_IP")); + rs.setId(remoteInfo.string("REMOTE_ID")); + rs.setPw(remoteInfo.string("REMOTE_PASSWORD")); + rs.setOsType(remoteInfo.string("REMOTE_OS")); + + String remoteWorkPath = remoteInfo.string("REMOTE_WORK_PATH"); + + String workPath = layoutDescriptors.get(i).getLinkFileLocation(); + File workDir = new File(workPath); + workDir.mkdirs(); + + try { + boolean result = FTPUtil.fileDown(rs, remoteWorkPath, workPath); + if(!result) { + saved = false; + mav.addObject("saved", saved); + return mav; + } + } catch (Exception e) { + e.printStackTrace(); + saved = false; + mav.addObject("saved", saved); + return mav; + } } saved = true; @@ -191,33 +190,38 @@ public class Crdn05Controller extends ApplicationController { ModelAndView mav = new ModelAndView("jsonView"); boolean saved = false; - String entType = hReq.getParameter("entType"); - LayoutParser parser = null; - switch(entType){ - case "ino": parser = new OnlyImageParser(); break; - //case "knl": break; - case "hitecom": parser = new SingleFileParser(); break; - case "xit": parser = new AttachedTxtParser(); break; - //case "": enterprise = new (); break; - } - String institute = currentUser().getInstitute(); String taskSeCd = hReq.getParameter("taskSeCd"); - String equipmentType = hReq.getParameter("equipmentType"); - String workPath = ParsingUtil.getWorkDirectoryPath(institute, taskSeCd, entType, equipmentType); + String sggCd = globalStngMapper.selectSggCdForCurrentUser(); + ManagedUser currentUser = userMapper.getUser(currentUser().getAccount(), institute); + String deptCd = currentUser.getDeptCode(); + + List layoutDescriptors = crdnStngService.getLinkFileLayoutMetadata(sggCd, taskSeCd, institute, deptCd); + + LayoutDescriptor layoutDescriptor = new LayoutDescriptor(); + + if(layoutDescriptors.size() == 1) { + layoutDescriptor = layoutDescriptors.get(0); + } else if(layoutDescriptors.size() >= 2) { + layoutDescriptor = LayoutDiscriminator.choice(uploadFiles, layoutDescriptors); + } + + String workPath = layoutDescriptor.getLinkFileLocation(); File workDir = new File(workPath); workDir.mkdirs(); try { - for(int i=0; i < uploadFiles.length; i++) { - File newFile = new File(workPath+File.separator+uploadFiles[i].getOriginalFilename()); - uploadFiles[i].transferTo(newFile); + for(int j=0; j < uploadFiles.length; j++) { + File newFile = new File(workPath+File.separator+uploadFiles[j].getOriginalFilename()); + uploadFiles[j].transferTo(newFile); } } catch (Exception e) { saved = false; mav.addObject("saved", saved); return mav; } + + saved = true; mav.addObject("saved", saved); return mav; @@ -229,47 +233,43 @@ public class Crdn05Controller extends ApplicationController { */ public ModelAndView getEquipmentFileInfoList(HttpServletRequest hReq) { ModelAndView mav = new ModelAndView("jsonView"); + List parsedDataList = new ArrayList(); - String entType = hReq.getParameter("entType"); - LayoutParser parser = null; - switch(entType){ - case "ino": parser = new OnlyImageParser(); break; - //case "knl": break; - case "hitecom": parser = new SingleFileParser(); break; - case "xit": parser = new AttachedTxtParser(); break; - //case "": enterprise = new (); break; - } - - - - String institute = currentUser().getInstitute(); String taskSeCd = hReq.getParameter("taskSeCd"); - String equipmentType = hReq.getParameter("equipmentType"); - String workPath = ParsingUtil.getWorkDirectoryPath(institute, taskSeCd, entType, equipmentType); - - Stream fileList = null; - try { - //폴더는 제외하고 파일만 필터링 - fileList = Files.walk(Paths.get(workPath)).filter(Files::isRegularFile); - } catch (IOException e) { - e.printStackTrace(); - } - + String institute = currentUser().getInstitute(); String sggCd = globalStngMapper.selectSggCdForCurrentUser(); ManagedUser currentUser = userMapper.getUser(currentUser().getAccount(), institute); String deptCd = currentUser.getDeptCode(); - List candidates = crdnStngService.getLinkFileLayoutMetadata(sggCd, taskSeCd, institute, deptCd); + List layoutDescriptors = crdnStngService.getLinkFileLayoutMetadata(sggCd, taskSeCd, institute, deptCd); - if(candidates == null || candidates.isEmpty()) { + if(layoutDescriptors == null || layoutDescriptors.isEmpty()) { throw new RuntimeException("연계파일 레이아웃 정보 조회에 실패하였습니다."); - } else if(candidates.size() == 1) { - parser.setDescriptor(candidates.get(0)); - } else { - parser.setDescriptor(LayoutDiscriminator.choice(fileList, candidates)); } - List dataObjectList = parser.parsing(fileList); - mav = setCollectionInfo(mav, dataObjectList, ""); + for(int i=0; i < layoutDescriptors.size(); i++) { + String workPath = layoutDescriptors.get(i).getLinkFileLocation(); + + List fileList = null; + try { + //폴더는 제외하고 파일만 필터링 + fileList = Files.walk(Paths.get(workPath)).filter(Files::isRegularFile).toList(); + } catch (IOException e) { + e.printStackTrace(); + } + + LayoutParser parser = null; + switch(layoutDescriptors.get(i).getFileGroup()){ + case "TXT": parser = new AttachedTxtParser(); break; + case "JPG": parser = new OnlyImageParser(); break; + case "BIN": parser = new SingleFileParser(); break; + } + + if(!fileList.isEmpty()) { + parsedDataList.addAll(parser.parsing(fileList)); + } + } + + mav = setCollectionInfo(mav, parsedDataList, ""); return mav; } @@ -284,13 +284,12 @@ public class Crdn05Controller extends ApplicationController { ModelAndView mav = new ModelAndView("jsonView"); - String entType = hReq.getParameter("entType"); + String fileLayoutId = hReq.getParameter("fileLayoutId"); String fileName = hReq.getParameter("fileName"); - String institute = currentUser().getInstitute(); - String taskSeCd = hReq.getParameter("taskSeCd"); - String equipmentType = hReq.getParameter("equipmentType"); - String workPath = ParsingUtil.getWorkDirectoryPath(institute, taskSeCd, entType, equipmentType); + LayoutDescriptor info = crdnStngBean.getLinkFileLayoutMetadata(fileLayoutId); + + String workPath = info.getLinkFileLocation(); boolean saved = crdnService.removeEquipmentLinkFile(workPath, fileName); @@ -300,13 +299,13 @@ public class Crdn05Controller extends ApplicationController { /**단속 연계 파일로 단속자료를 생성한다. - * @param entType 장비업체 유형, linkFileInfos 연계파일정보 + * @param taskSeCd 업무 구분, fileGroupType 파일그룹타입, linkFileInfos 연계파일정보 * @return jsonView *
 {
 	 *     "saved": 등록되었으면 true, 그렇지 않으면 false
 	 * }
*/ - public ModelAndView createCrdnByLinkFile(String taskSeCd, String entType, String equipmentType, String[] linkFileInfos) { + public ModelAndView createCrdnByLinkFile(String taskSeCd, String fileGroupType, String[] linkFileInfos) { ModelAndView mav = new ModelAndView("jsonView"); String institute = currentUser().getInstitute(); @@ -320,10 +319,10 @@ public class Crdn05Controller extends ApplicationController { Map processInfo = new HashMap(); processInfo.put("institute", institute); processInfo.put("taskSeCd", taskSeCd); - processInfo.put("entType", entType); - processInfo.put("equipmentType", equipmentType); - String workPath = ParsingUtil.getWorkDirectoryPath(institute, taskSeCd, entType, equipmentType); + processInfo.put("fileGroupType", fileGroupType); + + String workPath = crdnStngBean.getLinkFileLayoutMetadata("fileLayoutId").getLinkFileLocation(); processInfo.put("workPath", workPath); HashMap resultMap = importService.createCrdnByEquipmentLinkFile(processInfo, linkFileInfoList); diff --git a/src/main/java/cokr/xit/fims/task/web/BpvController.java b/src/main/java/cokr/xit/fims/task/web/BpvController.java index d1a2a8a2..a889cb3f 100644 --- a/src/main/java/cokr/xit/fims/task/web/BpvController.java +++ b/src/main/java/cokr/xit/fims/task/web/BpvController.java @@ -242,8 +242,8 @@ public class BpvController { @Override @RequestMapping(name="전용차로과태료업무 장비업체 단속파일로 단속자료 생성", value=METHOD_URL.createCrdnByLinkFile) - public ModelAndView createCrdnByLinkFile(String taskSeCd, String entType, String equipmentType, String[] linkFileInfos) { - return super.createCrdnByLinkFile(taskSeCd, entType, equipmentType, linkFileInfos); + public ModelAndView createCrdnByLinkFile(String taskSeCd, String fileGroupType, String[] linkFileInfos) { + return super.createCrdnByLinkFile(taskSeCd, fileGroupType, linkFileInfos); } @Override diff --git a/src/main/java/cokr/xit/fims/task/web/DpvController.java b/src/main/java/cokr/xit/fims/task/web/DpvController.java index 7f2872fc..35425d3f 100644 --- a/src/main/java/cokr/xit/fims/task/web/DpvController.java +++ b/src/main/java/cokr/xit/fims/task/web/DpvController.java @@ -268,8 +268,8 @@ public class DpvController { @Override @RequestMapping(name="장애인과태료업무 장비업체 단속파일로 단속자료 생성", value=METHOD_URL.createCrdnByLinkFile) - public ModelAndView createCrdnByLinkFile(String taskSeCd, String entType, String equipmentType, String[] linkFileInfos) { - return super.createCrdnByLinkFile(taskSeCd, entType, equipmentType, linkFileInfos); + public ModelAndView createCrdnByLinkFile(String taskSeCd, String fileGroupType, String[] linkFileInfos) { + return super.createCrdnByLinkFile(taskSeCd, fileGroupType, linkFileInfos); } @Override diff --git a/src/main/java/cokr/xit/fims/task/web/EcaController.java b/src/main/java/cokr/xit/fims/task/web/EcaController.java index 055e223c..57f67f14 100644 --- a/src/main/java/cokr/xit/fims/task/web/EcaController.java +++ b/src/main/java/cokr/xit/fims/task/web/EcaController.java @@ -243,8 +243,8 @@ public class EcaController { @Override @RequestMapping(name="전기차과태료업무 장비업체 단속파일로 단속자료 생성", value=METHOD_URL.createCrdnByLinkFile) - public ModelAndView createCrdnByLinkFile(String taskSeCd, String entType, String equipmentType, String[] linkFileInfos) { - return super.createCrdnByLinkFile(taskSeCd, entType, equipmentType, linkFileInfos); + public ModelAndView createCrdnByLinkFile(String taskSeCd, String fileGroupType, String[] linkFileInfos) { + return super.createCrdnByLinkFile(taskSeCd, fileGroupType, linkFileInfos); } @Override diff --git a/src/main/java/cokr/xit/fims/task/web/PvsController.java b/src/main/java/cokr/xit/fims/task/web/PvsController.java index c7d1af44..b0bf877e 100644 --- a/src/main/java/cokr/xit/fims/task/web/PvsController.java +++ b/src/main/java/cokr/xit/fims/task/web/PvsController.java @@ -255,8 +255,8 @@ public class PvsController { @Override @RequestMapping(name="주정차과태료업무 장비업체 단속파일로 단속자료 생성", value=METHOD_URL.createCrdnByLinkFile) - public ModelAndView createCrdnByLinkFile(String taskSeCd, String entType, String equipmentType, String[] linkFileInfos) { - return super.createCrdnByLinkFile(taskSeCd, entType, equipmentType, linkFileInfos); + public ModelAndView createCrdnByLinkFile(String taskSeCd, String fileGroupType, String[] linkFileInfos) { + return super.createCrdnByLinkFile(taskSeCd, fileGroupType, linkFileInfos); } @Override diff --git a/src/main/resources/sql/mapper/fims/crdn/global-stng-mapper.xml b/src/main/resources/sql/mapper/fims/crdn/global-stng-mapper.xml index b3a61609..8ae0b750 100644 --- a/src/main/resources/sql/mapper/fims/crdn/global-stng-mapper.xml +++ b/src/main/resources/sql/mapper/fims/crdn/global-stng-mapper.xml @@ -59,7 +59,7 @@ SELECT CONCAT(A.EMD_NM, + + \ No newline at end of file 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 fef8f0de..aa72afc4 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 @@ -18,40 +18,12 @@
- - - - -
-
- - +
+
+