From a9eb6d2346b121b57ec5caaba25fef748411f389 Mon Sep 17 00:00:00 2001 From: leebeomjun Date: Thu, 12 Oct 2023 14:30:10 +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=A0=88=EC=9D=B4=EC=95=84=EC=9B=83=20=EC=A1=B0?= =?UTF-8?q?=ED=9A=8C=20sql=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/cokr/xit/fims/crdn/CrdnQuery.java | 20 ++++++++ .../xit/fims/crdn/dao/CrdnTeamMapper.java | 1 + .../xit/fims/crdn/dao/GlobalStngMapper.java | 8 +++ .../fims/crdn/parsing/AttachedTxtParser.java | 2 +- .../fims/crdn/parsing/LayoutDescriptor.java | 45 ++++++++++++++++ .../crdn/parsing/LayoutDiscriminator.java | 14 +++++ .../xit/fims/crdn/parsing/LayoutParser.java | 12 +++-- .../fims/crdn/parsing/OnlyImageParser.java | 2 +- .../fims/crdn/parsing/SingleFileParser.java | 2 +- .../fims/crdn/service/CrdnStngService.java | 7 +++ .../fims/crdn/service/bean/CrdnStngBean.java | 9 ++++ .../service/bean/CrdnStngServiceBean.java | 11 ++++ .../xit/fims/crdn/web/Crdn05Controller.java | 51 +++++++++++++------ .../mapper/fims/crdn/global-stng-mapper.xml | 43 ++++++++++++++++ .../WEB-INF/jsp/fims/crdn/crdn05020-info.jsp | 2 +- 15 files changed, 207 insertions(+), 22 deletions(-) create mode 100644 src/main/java/cokr/xit/fims/crdn/parsing/LayoutDiscriminator.java diff --git a/src/main/java/cokr/xit/fims/crdn/CrdnQuery.java b/src/main/java/cokr/xit/fims/crdn/CrdnQuery.java index 0059d690..c6958057 100644 --- a/src/main/java/cokr/xit/fims/crdn/CrdnQuery.java +++ b/src/main/java/cokr/xit/fims/crdn/CrdnQuery.java @@ -54,6 +54,8 @@ public class CrdnQuery extends CmmnQuery { private String crdnSttsCd; private String ansSeCd; private String ansRsnCd; + private String instCd; + private String deptCd; //포함, 제외, 특정 자료 private String schOnlySamePlace; @@ -340,6 +342,24 @@ public class CrdnQuery extends CmmnQuery { return self(); } + public String getInstCd() { + return ifEmpty(instCd, () -> null); + } + + public T setInstCd(String instCd) { + this.instCd = instCd; + return self(); + } + + public String getDeptCd() { + return ifEmpty(deptCd, () -> null); + } + + public T setDeptCd(String deptCd) { + this.deptCd = deptCd; + return self(); + } + public String getAplcnYmd() { return ifEmpty(aplcnYmd, () -> null); } diff --git a/src/main/java/cokr/xit/fims/crdn/dao/CrdnTeamMapper.java b/src/main/java/cokr/xit/fims/crdn/dao/CrdnTeamMapper.java index dea0f0f8..a491ac6d 100644 --- a/src/main/java/cokr/xit/fims/crdn/dao/CrdnTeamMapper.java +++ b/src/main/java/cokr/xit/fims/crdn/dao/CrdnTeamMapper.java @@ -22,4 +22,5 @@ public interface CrdnTeamMapper extends AbstractMapper { * @return 단속팀 정보 */ DataObject selectTeamInfo(String teamId); + } 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 4ad0baf7..09e255f2 100644 --- a/src/main/java/cokr/xit/fims/crdn/dao/GlobalStngMapper.java +++ b/src/main/java/cokr/xit/fims/crdn/dao/GlobalStngMapper.java @@ -5,6 +5,7 @@ import java.util.List; 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; @Mapper("globalStngMapper") @@ -37,4 +38,11 @@ public interface GlobalStngMapper extends AbstractMapper { String sggCd = selectSggCd(currentUser().getInstitute()); return selectStdgNmList(sggCd); }; + + + /** 연계파일 레이아웃 정보를 조회한다. + * @param query 연계파일 레이아웃 조회조건 + * @return 연계파일 레이아웃 정보 + */ + List selectLinkFileLayoutMetadata(CrdnQuery query); } \ 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 1c9f1c3f..b35cc726 100644 --- a/src/main/java/cokr/xit/fims/crdn/parsing/AttachedTxtParser.java +++ b/src/main/java/cokr/xit/fims/crdn/parsing/AttachedTxtParser.java @@ -16,7 +16,7 @@ import org.apache.commons.io.FilenameUtils; import cokr.xit.foundation.data.DataObject; -public class AttachedTxtParser implements LayoutParser{ +public class AttachedTxtParser extends LayoutParser{ private DataObject before = new DataObject(); private int tempGroupSeq = 1; diff --git a/src/main/java/cokr/xit/fims/crdn/parsing/LayoutDescriptor.java b/src/main/java/cokr/xit/fims/crdn/parsing/LayoutDescriptor.java index 583779af..872567d8 100644 --- a/src/main/java/cokr/xit/fims/crdn/parsing/LayoutDescriptor.java +++ b/src/main/java/cokr/xit/fims/crdn/parsing/LayoutDescriptor.java @@ -7,34 +7,79 @@ import lombok.Setter; @Setter public class LayoutDescriptor { + /** + * 파일 레이아웃 ID + */ private String fileLayoutId; + /** + * 시군구 코드 + */ private String sggCd; + /** + * 업무 구분 코드 + */ private String taskSeCd; + /** + * 기관 코드 + */ private String instCd; + /** + * 부서 코드 + */ private String deptCd; + /** + * 연계 파일 위치 + */ private String linkFileLocation; + /** + * 파일그룹 + */ private String fileGroup; + /** + * 파일그룹 내부 파일갯수 + */ private String countPerFileGroup; + /** + * 파일명 길이 + */ private String fileNameLength; + /** + * 파일명 내부 항목 + */ private String fileNameItmes; + /** + * 파일명 구분자 + */ private String fileNameSeperator; + /** + * 파일내용 항목 + */ private String contentItems; + /** + * 파일내용 구분자 + */ private String contentSeperator; + /** + * 파일내용 2차구분자 + */ private String contentSecondSeperator; + /** + * 2차구분자 시작 항목 + */ private String secondSeperatorStarterItems; } diff --git a/src/main/java/cokr/xit/fims/crdn/parsing/LayoutDiscriminator.java b/src/main/java/cokr/xit/fims/crdn/parsing/LayoutDiscriminator.java new file mode 100644 index 00000000..89d4d978 --- /dev/null +++ b/src/main/java/cokr/xit/fims/crdn/parsing/LayoutDiscriminator.java @@ -0,0 +1,14 @@ +package cokr.xit.fims.crdn.parsing; + +import java.nio.file.Path; +import java.util.List; +import java.util.stream.Stream; + +public class LayoutDiscriminator { + + public static LayoutDescriptor choice(Stream 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 c68fdb8f..fd5d6903 100644 --- a/src/main/java/cokr/xit/fims/crdn/parsing/LayoutParser.java +++ b/src/main/java/cokr/xit/fims/crdn/parsing/LayoutParser.java @@ -6,18 +6,24 @@ import java.util.stream.Stream; import cokr.xit.foundation.data.DataObject; -public interface LayoutParser { +abstract public class LayoutParser { + + LayoutDescriptor descriptor = new LayoutDescriptor(); + + public void setDescriptor(LayoutDescriptor descriptor) { + this.descriptor = descriptor; + } /**장비 단속 연계 파일에서 단속정보를 추출한다.
* @param fileList 연계파일리스트 * @return 단속정보 */ - public List parsing(Stream fileList); + abstract public List parsing(Stream fileList); /**현재 연계 파일의 정보가 이전 연계 파일의 정보와 다른 단속건인지 판단한다.
* @param currentItem 현재 연계 파일 정보, beforeItem 이전 연계 파일 정보 * @return 개별 단속자료 여부 */ - public boolean isChangeCrackdown(DataObject currentItem, DataObject beforeItem); + abstract public boolean isChangeCrackdown(DataObject currentItem, DataObject 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 d0b82085..4c8e6f0e 100644 --- a/src/main/java/cokr/xit/fims/crdn/parsing/OnlyImageParser.java +++ b/src/main/java/cokr/xit/fims/crdn/parsing/OnlyImageParser.java @@ -15,7 +15,7 @@ import org.apache.commons.io.FilenameUtils; import cokr.xit.foundation.data.DataObject; -public class OnlyImageParser implements LayoutParser { +public class OnlyImageParser extends LayoutParser { private DataObject before = new DataObject(); private int tempGroupSeq = 1; 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 49ec7ad0..5950aab1 100644 --- a/src/main/java/cokr/xit/fims/crdn/parsing/SingleFileParser.java +++ b/src/main/java/cokr/xit/fims/crdn/parsing/SingleFileParser.java @@ -18,7 +18,7 @@ import cokr.xit.base.file.FileInfo; import cokr.xit.fims.cmmn.CmmnUtil; import cokr.xit.foundation.data.DataObject; -public class SingleFileParser implements LayoutParser { +public class SingleFileParser extends LayoutParser { private int tempGroupSeq = 1; diff --git a/src/main/java/cokr/xit/fims/crdn/service/CrdnStngService.java b/src/main/java/cokr/xit/fims/crdn/service/CrdnStngService.java index 6a534c2f..a550f1b1 100644 --- a/src/main/java/cokr/xit/fims/crdn/service/CrdnStngService.java +++ b/src/main/java/cokr/xit/fims/crdn/service/CrdnStngService.java @@ -3,6 +3,7 @@ package cokr.xit.fims.crdn.service; import java.util.List; import cokr.xit.fims.crdn.CrdnQuery; +import cokr.xit.fims.crdn.parsing.LayoutDescriptor; import cokr.xit.foundation.data.DataObject; public interface CrdnStngService { @@ -18,4 +19,10 @@ public interface CrdnStngService { * @return 단속팀 정보 */ DataObject getTeamInfo(String teamId); + + /** 연계파일 레이아웃 정보를 조회한다. + * @param sggCd 시군구코드, taskSeCd 과태료구분, instCd 기관코드, deptCd 부서코드 + * @return 연계파일 레이아웃 정보 + */ + List getLinkFileLayoutMetadata(String sggCd, String taskSeCd, String instCd, String deptCd); } 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 76dc11bc..67539379 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 @@ -12,6 +12,7 @@ import cokr.xit.fims.crdn.CrdnQuery; import cokr.xit.fims.crdn.dao.CrdnTeamMapper; import cokr.xit.fims.crdn.dao.ExmptnVhclMapper; import cokr.xit.fims.crdn.dao.GlobalStngMapper; +import cokr.xit.fims.crdn.parsing.LayoutDescriptor; import cokr.xit.foundation.AbstractComponent; import cokr.xit.foundation.data.DataObject; @@ -216,4 +217,12 @@ public class CrdnStngBean extends AbstractComponent { return crdnTeamMapper.selectTeamInfo(teamId); } + /** 연계파일 레이아웃 정보를 조회한다. + * @param query 연계파일 레이아웃 조회조건 + * @return 연계파일 레이아웃 정보 + */ + public List getLinkFileLayoutMetadata(CrdnQuery query) { + return globalStngMapper.selectLinkFileLayoutMetadata(query); + } + } diff --git a/src/main/java/cokr/xit/fims/crdn/service/bean/CrdnStngServiceBean.java b/src/main/java/cokr/xit/fims/crdn/service/bean/CrdnStngServiceBean.java index 295f3422..41e31b4f 100644 --- a/src/main/java/cokr/xit/fims/crdn/service/bean/CrdnStngServiceBean.java +++ b/src/main/java/cokr/xit/fims/crdn/service/bean/CrdnStngServiceBean.java @@ -7,6 +7,7 @@ import javax.annotation.Resource; import org.springframework.stereotype.Service; import cokr.xit.fims.crdn.CrdnQuery; +import cokr.xit.fims.crdn.parsing.LayoutDescriptor; import cokr.xit.fims.crdn.service.CrdnStngService; import cokr.xit.foundation.component.AbstractServiceBean; import cokr.xit.foundation.data.DataObject; @@ -27,4 +28,14 @@ public class CrdnStngServiceBean extends AbstractServiceBean implements CrdnStng return crdnStngBean.selectTeamInfo(teamId); } + @Override + public List getLinkFileLayoutMetadata(String sggCd, String taskSeCd, String instCd, String deptCd) { + CrdnQuery query = new CrdnQuery(); + query.setSggCd(sggCd); + query.setTaskSeCd(taskSeCd); + query.setInstCd(instCd); + query.setDeptCd(deptCd); + return crdnStngBean.getLinkFileLayoutMetadata(query); + } + } 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 41ef5c3f..fd007a6e 100644 --- a/src/main/java/cokr/xit/fims/crdn/web/Crdn05Controller.java +++ b/src/main/java/cokr/xit/fims/crdn/web/Crdn05Controller.java @@ -20,6 +20,8 @@ import org.springframework.web.servlet.ModelAndView; import cokr.xit.base.code.CommonCode; import cokr.xit.base.file.FileInfo; import cokr.xit.base.file.web.FileInfoFactory; +import cokr.xit.base.user.ManagedUser; +import cokr.xit.base.user.dao.UserMapper; import cokr.xit.base.web.ApplicationController; import cokr.xit.fims.cmmn.ftp.FTPUtil; import cokr.xit.fims.cmmn.ftp.RemoteSystemInfo; @@ -27,11 +29,13 @@ import cokr.xit.fims.crdn.Crdn; import cokr.xit.fims.crdn.CrdnQuery; import cokr.xit.fims.crdn.dao.CrdnInstMapper; import cokr.xit.fims.crdn.dao.GlobalStngMapper; +import cokr.xit.fims.crdn.parsing.AttachedTxtParser; +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.SingleFileParser; import cokr.xit.fims.crdn.parsing.OnlyImageParser; import cokr.xit.fims.crdn.parsing.ParsingUtil; -import cokr.xit.fims.crdn.parsing.AttachedTxtParser; +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; @@ -77,6 +81,9 @@ public class Crdn05Controller extends ApplicationController { @Resource(name="globalStngMapper") protected GlobalStngMapper globalStngMapper; + @Resource(name="userMapper") + protected UserMapper userMapper; + /** 단속 자료 등록 메인화면을 연다. * @return fims/crdn/crdn05010-main */ @@ -129,12 +136,12 @@ public class Crdn05Controller extends ApplicationController { boolean saved = false; String entType = hReq.getParameter("entType"); - LayoutParser enterprise = null; + LayoutParser parser = null; switch(entType){ - case "ino": enterprise = new OnlyImageParser(); break; + case "ino": parser = new OnlyImageParser(); break; //case "knl": break; - case "hitecom": enterprise = new SingleFileParser(); break; - case "xit": enterprise = new AttachedTxtParser(); break; + case "hitecom": parser = new SingleFileParser(); break; + case "xit": parser = new AttachedTxtParser(); break; //case "": enterprise = new (); break; } @@ -185,12 +192,12 @@ public class Crdn05Controller extends ApplicationController { boolean saved = false; String entType = hReq.getParameter("entType"); - LayoutParser enterprise = null; + LayoutParser parser = null; switch(entType){ - case "ino": enterprise = new OnlyImageParser(); break; + case "ino": parser = new OnlyImageParser(); break; //case "knl": break; - case "hitecom": enterprise = new SingleFileParser(); break; - case "xit": enterprise = new AttachedTxtParser(); break; + case "hitecom": parser = new SingleFileParser(); break; + case "xit": parser = new AttachedTxtParser(); break; //case "": enterprise = new (); break; } @@ -224,16 +231,17 @@ public class Crdn05Controller extends ApplicationController { ModelAndView mav = new ModelAndView("jsonView"); String entType = hReq.getParameter("entType"); - LayoutParser enterprise = null; + LayoutParser parser = null; switch(entType){ - case "ino": enterprise = new OnlyImageParser(); break; + case "ino": parser = new OnlyImageParser(); break; //case "knl": break; - case "hitecom": enterprise = new SingleFileParser(); break; - case "xit": enterprise = new AttachedTxtParser(); 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"); @@ -247,7 +255,20 @@ public class Crdn05Controller extends ApplicationController { e.printStackTrace(); } - List dataObjectList = enterprise.parsing(fileList); + String sggCd = globalStngMapper.selectSggCdForCurrentUser(); + ManagedUser currentUser = userMapper.getUser(currentUser().getAccount(), institute); + String deptCd = currentUser.getDeptCode(); + List candidates = crdnStngService.getLinkFileLayoutMetadata(sggCd, taskSeCd, institute, deptCd); + + if(candidates == null || candidates.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, ""); return mav; } 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 5482886f..b3a61609 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 @@ -2,6 +2,24 @@ + + + + + + + + + + + + + + + + + + + + \ 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 e74ba94b..d1d5a09c 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 @@ -22,6 +22,7 @@ class="w-px-120 bg-lighter pe-2 col-form-label text-sm-end">장비업체