단속연계파일 등록시 업체 선택하는 부분 제거

main
이범준 1 year ago
parent ffec84c997
commit 3e42b62497

@ -30,6 +30,7 @@ public class CrdnQuery extends CmmnQuery {
private String[] crdnIDs; private String[] crdnIDs;
private String amtDcsnCdGroupId; private String amtDcsnCdGroupId;
private String dtlAmtDcsnCdGroupId; private String dtlAmtDcsnCdGroupId;
private String fileLayoutId;
//날짜 //날짜
private String aplcnYmd; private String aplcnYmd;
@ -396,6 +397,15 @@ public class CrdnQuery extends CmmnQuery {
return self(); return self();
} }
public String getFileLayoutId() {
return ifEmpty(fileLayoutId, () -> null);
}
public <T extends CrdnQuery> T setFileLayoutId(String fileLayoutId) {
this.fileLayoutId = fileLayoutId;
return self();
}
public String getDtlAmtDcsnCd() { public String getDtlAmtDcsnCd() {
return ifEmpty(dtlAmtDcsnCd, () -> null); return ifEmpty(dtlAmtDcsnCd, () -> null);
} }

@ -7,6 +7,7 @@ import org.egovframe.rte.psl.dataaccess.mapper.Mapper;
import cokr.xit.fims.crdn.CrdnQuery; import cokr.xit.fims.crdn.CrdnQuery;
import cokr.xit.fims.crdn.parsing.LayoutDescriptor; import cokr.xit.fims.crdn.parsing.LayoutDescriptor;
import cokr.xit.foundation.component.AbstractMapper; import cokr.xit.foundation.component.AbstractMapper;
import cokr.xit.foundation.data.DataObject;
@Mapper("globalStngMapper") @Mapper("globalStngMapper")
public interface GlobalStngMapper extends AbstractMapper { public interface GlobalStngMapper extends AbstractMapper {
@ -45,4 +46,10 @@ public interface GlobalStngMapper extends AbstractMapper {
* @return * @return
*/ */
List<LayoutDescriptor> selectLinkFileLayoutMetadata(CrdnQuery query); List<LayoutDescriptor> selectLinkFileLayoutMetadata(CrdnQuery query);
/** ftp .
* @param fileLayoutId ID
* @return ftp
*/
DataObject selectRemoteInfo(String fileLayoutId);
} }

@ -10,7 +10,6 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.apache.commons.io.FilenameUtils; import org.apache.commons.io.FilenameUtils;
@ -22,10 +21,10 @@ public class AttachedTxtParser extends LayoutParser{
private int tempGroupSeq = 1; private int tempGroupSeq = 1;
@Override @Override
public List<DataObject> parsing(Stream<Path> fileList) { public List<DataObject> parsing(List<Path> fileList) {
//파일명으로 정렬(파싱 전) //파일명으로 정렬(파싱 전)
List<Path> sortedFileList = fileList List<Path> sortedFileList = fileList.stream()
.sorted((item1, item2) -> item1.toFile().getName().compareTo(item2.toFile().getName())) .sorted((item1, item2) -> item1.toFile().getName().compareTo(item2.toFile().getName()))
.collect(Collectors.toList()); .collect(Collectors.toList());
@ -33,6 +32,8 @@ public class AttachedTxtParser extends LayoutParser{
sortedFileList.forEach(item -> { sortedFileList.forEach(item -> {
DataObject dataObject = new DataObject(); DataObject dataObject = new DataObject();
dataObject.put("FILE_GROUP_TYPE", "TXT");
File file = item.toFile(); File file = item.toFile();
String filePath = file.getPath(); String filePath = file.getPath();
dataObject.put("FILE_PATH", filePath); dataObject.put("FILE_PATH", filePath);

@ -1,12 +1,12 @@
package cokr.xit.fims.crdn.parsing; package cokr.xit.fims.crdn.parsing;
import java.nio.file.Path;
import java.util.List; import java.util.List;
import java.util.stream.Stream;
import org.springframework.web.multipart.MultipartFile;
public class LayoutDiscriminator { public class LayoutDiscriminator {
public static LayoutDescriptor choice(Stream<Path> fileList, List<LayoutDescriptor> candidates) { public static LayoutDescriptor choice(MultipartFile[] fileList, List<LayoutDescriptor> candidates) {
// TODO // TODO
return null; return null;
} }

@ -2,7 +2,6 @@ package cokr.xit.fims.crdn.parsing;
import java.nio.file.Path; import java.nio.file.Path;
import java.util.List; import java.util.List;
import java.util.stream.Stream;
import cokr.xit.foundation.data.DataObject; import cokr.xit.foundation.data.DataObject;
@ -18,7 +17,7 @@ abstract public class LayoutParser {
* @param fileList * @param fileList
* @return * @return
*/ */
abstract public List<DataObject> parsing(Stream<Path> fileList); abstract public List<DataObject> parsing(List<Path> fileList);
/** .<br /> /** .<br />
* @param currentItem , beforeItem * @param currentItem , beforeItem

@ -8,7 +8,6 @@ import java.util.Date;
import java.util.List; import java.util.List;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.apache.commons.io.FilenameUtils; import org.apache.commons.io.FilenameUtils;
@ -21,17 +20,19 @@ public class OnlyImageParser extends LayoutParser {
private int tempGroupSeq = 1; private int tempGroupSeq = 1;
@Override @Override
public List<DataObject> parsing(Stream<Path> fileList) { public List<DataObject> parsing(List<Path> fileList) {
List<DataObject> dataObjectList = new ArrayList<>(); List<DataObject> dataObjectList = new ArrayList<>();
//파일명으로 정렬(파싱 전) //파일명으로 정렬(파싱 전)
List<Path> sortedFileList = fileList List<Path> sortedFileList = fileList.stream()
.sorted((item1, item2) -> item1.toFile().getName().compareTo(item2.toFile().getName())) .sorted((item1, item2) -> item1.toFile().getName().compareTo(item2.toFile().getName()))
.collect(Collectors.toList()); .collect(Collectors.toList());
sortedFileList.forEach(item -> { sortedFileList.forEach(item -> {
DataObject dataObject = new DataObject(); DataObject dataObject = new DataObject();
dataObject.put("FILE_GROUP_TYPE", "JPG");
File file = item.toFile(); File file = item.toFile();
String filePath = file.getPath(); String filePath = file.getPath();
dataObject.put("FILE_PATH", filePath); dataObject.put("FILE_PATH", filePath);

@ -1,28 +0,0 @@
package cokr.xit.fims.crdn.parsing;
import java.io.File;
public class ParsingUtil {
/**,,, .<br />
* @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;
}
}

@ -12,7 +12,6 @@ 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 java.util.List;
import java.util.stream.Stream;
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,12 +22,14 @@ public class SingleFileParser extends LayoutParser {
private int tempGroupSeq = 1; private int tempGroupSeq = 1;
@Override @Override
public List<DataObject> parsing(Stream<Path> fileList) { public List<DataObject> parsing(List<Path> fileList) {
List<DataObject> dataObjectList = new ArrayList<>(); List<DataObject> dataObjectList = new ArrayList<>();
fileList.forEach(item -> { fileList.forEach(item -> {
DataObject dataObject = new DataObject(); DataObject dataObject = new DataObject();
dataObject.put("FILE_GROUP_TYPE", "BIN");
File file = item.toFile(); File file = item.toFile();
String filePath = file.getPath(); String filePath = file.getPath();
dataObject.put("FILE_PATH", filePath); dataObject.put("FILE_PATH", filePath);

@ -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) { } catch (Exception e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }

@ -225,4 +225,10 @@ public class CrdnStngBean extends AbstractComponent {
return globalStngMapper.selectLinkFileLayoutMetadata(query); return globalStngMapper.selectLinkFileLayoutMetadata(query);
} }
public LayoutDescriptor getLinkFileLayoutMetadata(String fileLayoutId) {
CrdnQuery query = new CrdnQuery();
query.setFileLayoutId(fileLayoutId);
List<LayoutDescriptor> list = globalStngMapper.selectLinkFileLayoutMetadata(query);
return list == null ? null : list.get(0);
}
} }

@ -80,11 +80,12 @@ public class ImportServiceBean extends AbstractServiceBean implements ImportServ
public HashMap<String, Object> createCrdnByEquipmentLinkFile(Map<String,String> processInfo, List<DataObject> linkFileInfoList) { public HashMap<String, Object> createCrdnByEquipmentLinkFile(Map<String,String> processInfo, List<DataObject> linkFileInfoList) {
HashMap<String, Object> resultMap = new HashMap<>(); HashMap<String, Object> resultMap = new HashMap<>();
boolean saved = false; boolean saved = false;
String workPath = processInfo.get("workPath");
String institute = processInfo.get("institute"); String institute = processInfo.get("institute");
String taskSeCd = processInfo.get("taskSeCd"); String taskSeCd = processInfo.get("taskSeCd");
String entType = processInfo.get("entType");
String equipmentType = processInfo.get("equipmentType"); String fileGroupType = processInfo.get("fileGroupType");
String workPath = processInfo.get("workPath");
Crdn crdn = new Crdn(); Crdn crdn = new Crdn();
crdn.setCrdnRegSeCd("07"); crdn.setCrdnRegSeCd("07");
@ -93,10 +94,7 @@ public class ImportServiceBean extends AbstractServiceBean implements ImportServ
List<FileInfo> fileInfoList = new ArrayList<FileInfo>(); List<FileInfo> fileInfoList = new ArrayList<FileInfo>();
// //
if(entType.equals("ino")) { if(fileGroupType.equals("JPG")) {
crdn.setCrdnInptSeCd("11");
crdn.setVltnCd("01");
//1. 연계파일정보를 단속 엔티티로 변환 //1. 연계파일정보를 단속 엔티티로 변환
DataObject bgngData = linkFileInfoList.stream() DataObject bgngData = linkFileInfoList.stream()
@ -111,6 +109,14 @@ public class ImportServiceBean extends AbstractServiceBean implements ImportServ
crdn.setCrdnEndTm(endData.string("CRDN_TM")); crdn.setCrdnEndTm(endData.string("CRDN_TM"));
DataObject linkFileInfo = endData; 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.setSggCd(globalStngMapper.selectSggCdForCurrentUser());
crdn.setVhrno(linkFileInfo.string("VHRNO")); crdn.setVhrno(linkFileInfo.string("VHRNO"));
crdn.setCrdnYmd(linkFileInfo.string("CRDN_YMD")); 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권장포맷 //XIT권장포맷
if(entType.equals("xit")) { if(fileGroupType.equals("TXT")) {
crdn.setCrdnInptSeCd("15");
crdn.setVltnCd("01");
//1. 연계파일정보를 단속 엔티티로 변환 //1. 연계파일정보를 단속 엔티티로 변환
crdn.setSggCd(globalStngMapper.selectSggCdForCurrentUser()); 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.setCrdnSeCd(metaFileInfo.string("CRDN_SE_CD"));
crdn.setCrdnYmd(metaFileInfo.string("CRDN_YMD")); crdn.setCrdnYmd(metaFileInfo.string("CRDN_YMD"));
crdn.setCrdnTm(metaFileInfo.string("CRDN_TM")); crdn.setCrdnTm(metaFileInfo.string("CRDN_TM"));
@ -194,12 +197,7 @@ public class ImportServiceBean extends AbstractServiceBean implements ImportServ
} }
// //
if(entType.equals("hitecom")) { if(fileGroupType.equals("BIN")) {
crdn.setCrdnSeCd("07");
crdn.setCrdnInptSeCd("15");
crdn.setVltnCd("01");
//1. 연계파일정보를 단속 엔티티로 변환 //1. 연계파일정보를 단속 엔티티로 변환
if(linkFileInfoList.size() != 1) { if(linkFileInfoList.size() != 1) {
@ -208,6 +206,16 @@ public class ImportServiceBean extends AbstractServiceBean implements ImportServ
return resultMap; return resultMap;
} }
DataObject linkFileInfo = linkFileInfoList.get(0); 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.setSggCd(globalStngMapper.selectSggCdForCurrentUser());
crdn.setVhrno(linkFileInfo.string("VHRNO")); crdn.setVhrno(linkFileInfo.string("VHRNO"));
crdn.setCrdnYmd(linkFileInfo.string("CRDN_YMD")); crdn.setCrdnYmd(linkFileInfo.string("CRDN_YMD"));

@ -9,7 +9,6 @@ import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.stream.Stream;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest; 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.LayoutDiscriminator;
import cokr.xit.fims.crdn.parsing.LayoutParser; import cokr.xit.fims.crdn.parsing.LayoutParser;
import cokr.xit.fims.crdn.parsing.OnlyImageParser; 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.parsing.SingleFileParser;
import cokr.xit.fims.crdn.service.CrdnService; import cokr.xit.fims.crdn.service.CrdnService;
import cokr.xit.fims.crdn.service.CrdnStngService; import cokr.xit.fims.crdn.service.CrdnStngService;
import cokr.xit.fims.crdn.service.ImportService; import cokr.xit.fims.crdn.service.ImportService;
import cokr.xit.fims.crdn.service.bean.CrdnStngBean;
import cokr.xit.foundation.data.DataObject; import cokr.xit.foundation.data.DataObject;
/** .<br /> /** .<br />
@ -75,6 +74,9 @@ public class Crdn05Controller extends ApplicationController {
@Resource(name="crdnStngService") @Resource(name="crdnStngService")
private CrdnStngService crdnStngService; private CrdnStngService crdnStngService;
@Resource(name="crdnStngBean")
private CrdnStngBean crdnStngBean;
@Resource(name="crdnInstMapper") @Resource(name="crdnInstMapper")
private CrdnInstMapper crdnInstMapper; private CrdnInstMapper crdnInstMapper;
@ -135,47 +137,44 @@ public class Crdn05Controller extends ApplicationController {
ModelAndView mav = new ModelAndView("jsonView"); ModelAndView mav = new ModelAndView("jsonView");
boolean saved = false; 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 institute = currentUser().getInstitute();
String taskSeCd = hReq.getParameter("taskSeCd"); 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<LayoutDescriptor> layoutDescriptors = crdnStngService.getLinkFileLayoutMetadata(sggCd, taskSeCd, institute, deptCd);
String workPath = ParsingUtil.getWorkDirectoryPath(institute, taskSeCd, entType, equipmentType); for(int i=0; i < layoutDescriptors.size(); i++) {
File workDir = new File(workPath); DataObject remoteInfo = globalStngMapper.selectRemoteInfo(layoutDescriptors.get(i).getFileLayoutId());
workDir.mkdirs(); if(remoteInfo == null) {
continue;
}
RemoteSystemInfo rs = new RemoteSystemInfo(); RemoteSystemInfo rs = new RemoteSystemInfo();
rs.setIp("211.119.124.9"); rs.setIp(remoteInfo.string("REMOTE_IP"));
rs.setId("xituser"); rs.setId(remoteInfo.string("REMOTE_ID"));
rs.setPw("xituser!@"); rs.setPw(remoteInfo.string("REMOTE_PASSWORD"));
rs.setOsType("linux"); rs.setOsType(remoteInfo.string("REMOTE_OS"));
String remoteWorkPath = File.separator + "applications" String remoteWorkPath = remoteInfo.string("REMOTE_WORK_PATH");
+ File.separator + "tempForFTPTest"
+ File.separator + "GCloud" String workPath = layoutDescriptors.get(i).getLinkFileLocation();
+ File.separator + entType File workDir = new File(workPath);
+ File.separator; workDir.mkdirs();
try {
boolean result = FTPUtil.fileDown(rs, remoteWorkPath, workPath); try {
if(!result) { boolean result = FTPUtil.fileDown(rs, remoteWorkPath, workPath);
saved = false; if(!result) {
mav.addObject("saved", saved); saved = false;
return mav; mav.addObject("saved", saved);
} return mav;
} catch (Exception e) { }
e.printStackTrace(); } catch (Exception e) {
saved = false; e.printStackTrace();
mav.addObject("saved", saved); saved = false;
return mav; mav.addObject("saved", saved);
return mav;
}
} }
saved = true; saved = true;
@ -191,33 +190,38 @@ public class Crdn05Controller extends ApplicationController {
ModelAndView mav = new ModelAndView("jsonView"); ModelAndView mav = new ModelAndView("jsonView");
boolean saved = false; 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 institute = currentUser().getInstitute();
String taskSeCd = hReq.getParameter("taskSeCd"); String taskSeCd = hReq.getParameter("taskSeCd");
String equipmentType = hReq.getParameter("equipmentType"); String sggCd = globalStngMapper.selectSggCdForCurrentUser();
String workPath = ParsingUtil.getWorkDirectoryPath(institute, taskSeCd, entType, equipmentType); ManagedUser currentUser = userMapper.getUser(currentUser().getAccount(), institute);
String deptCd = currentUser.getDeptCode();
List<LayoutDescriptor> 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); File workDir = new File(workPath);
workDir.mkdirs(); workDir.mkdirs();
try { try {
for(int i=0; i < uploadFiles.length; i++) { for(int j=0; j < uploadFiles.length; j++) {
File newFile = new File(workPath+File.separator+uploadFiles[i].getOriginalFilename()); File newFile = new File(workPath+File.separator+uploadFiles[j].getOriginalFilename());
uploadFiles[i].transferTo(newFile); uploadFiles[j].transferTo(newFile);
} }
} catch (Exception e) { } catch (Exception e) {
saved = false; saved = false;
mav.addObject("saved", saved); mav.addObject("saved", saved);
return mav; return mav;
} }
saved = true; saved = true;
mav.addObject("saved", saved); mav.addObject("saved", saved);
return mav; return mav;
@ -229,47 +233,43 @@ public class Crdn05Controller extends ApplicationController {
*/ */
public ModelAndView getEquipmentFileInfoList(HttpServletRequest hReq) { public ModelAndView getEquipmentFileInfoList(HttpServletRequest hReq) {
ModelAndView mav = new ModelAndView("jsonView"); ModelAndView mav = new ModelAndView("jsonView");
List<DataObject> parsedDataList = new ArrayList<DataObject>();
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 taskSeCd = hReq.getParameter("taskSeCd");
String equipmentType = hReq.getParameter("equipmentType"); String institute = currentUser().getInstitute();
String workPath = ParsingUtil.getWorkDirectoryPath(institute, taskSeCd, entType, equipmentType);
Stream<Path> fileList = null;
try {
//폴더는 제외하고 파일만 필터링
fileList = Files.walk(Paths.get(workPath)).filter(Files::isRegularFile);
} catch (IOException e) {
e.printStackTrace();
}
String sggCd = globalStngMapper.selectSggCdForCurrentUser(); String sggCd = globalStngMapper.selectSggCdForCurrentUser();
ManagedUser currentUser = userMapper.getUser(currentUser().getAccount(), institute); ManagedUser currentUser = userMapper.getUser(currentUser().getAccount(), institute);
String deptCd = currentUser.getDeptCode(); String deptCd = currentUser.getDeptCode();
List<LayoutDescriptor> candidates = crdnStngService.getLinkFileLayoutMetadata(sggCd, taskSeCd, institute, deptCd); List<LayoutDescriptor> layoutDescriptors = crdnStngService.getLinkFileLayoutMetadata(sggCd, taskSeCd, institute, deptCd);
if(candidates == null || candidates.isEmpty()) { if(layoutDescriptors == null || layoutDescriptors.isEmpty()) {
throw new RuntimeException("연계파일 레이아웃 정보 조회에 실패하였습니다."); throw new RuntimeException("연계파일 레이아웃 정보 조회에 실패하였습니다.");
} else if(candidates.size() == 1) {
parser.setDescriptor(candidates.get(0));
} else {
parser.setDescriptor(LayoutDiscriminator.choice(fileList, candidates));
} }
List<DataObject> dataObjectList = parser.parsing(fileList); for(int i=0; i < layoutDescriptors.size(); i++) {
mav = setCollectionInfo(mav, dataObjectList, ""); String workPath = layoutDescriptors.get(i).getLinkFileLocation();
List<Path> 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; return mav;
} }
@ -284,13 +284,12 @@ public class Crdn05Controller extends ApplicationController {
ModelAndView mav = new ModelAndView("jsonView"); ModelAndView mav = new ModelAndView("jsonView");
String entType = hReq.getParameter("entType"); String fileLayoutId = hReq.getParameter("fileLayoutId");
String fileName = hReq.getParameter("fileName"); String fileName = hReq.getParameter("fileName");
String institute = currentUser().getInstitute(); LayoutDescriptor info = crdnStngBean.getLinkFileLayoutMetadata(fileLayoutId);
String taskSeCd = hReq.getParameter("taskSeCd");
String equipmentType = hReq.getParameter("equipmentType"); String workPath = info.getLinkFileLocation();
String workPath = ParsingUtil.getWorkDirectoryPath(institute, taskSeCd, entType, equipmentType);
boolean saved = crdnService.removeEquipmentLinkFile(workPath, fileName); boolean saved = crdnService.removeEquipmentLinkFile(workPath, fileName);
@ -300,13 +299,13 @@ public class Crdn05Controller extends ApplicationController {
/** . /** .
* @param entType , linkFileInfos * @param taskSeCd , fileGroupType , linkFileInfos
* @return jsonView * @return jsonView
* <pre><code> { * <pre><code> {
* "saved": true, false * "saved": true, false
* }</code></pre> * }</code></pre>
*/ */
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"); ModelAndView mav = new ModelAndView("jsonView");
String institute = currentUser().getInstitute(); String institute = currentUser().getInstitute();
@ -320,10 +319,10 @@ public class Crdn05Controller extends ApplicationController {
Map<String, String> processInfo = new HashMap<String,String>(); Map<String, String> processInfo = new HashMap<String,String>();
processInfo.put("institute", institute); processInfo.put("institute", institute);
processInfo.put("taskSeCd", taskSeCd); 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); processInfo.put("workPath", workPath);
HashMap<String, Object> resultMap = importService.createCrdnByEquipmentLinkFile(processInfo, linkFileInfoList); HashMap<String, Object> resultMap = importService.createCrdnByEquipmentLinkFile(processInfo, linkFileInfoList);

@ -242,8 +242,8 @@ public class BpvController {
@Override @Override
@RequestMapping(name="전용차로과태료업무 장비업체 단속파일로 단속자료 생성", value=METHOD_URL.createCrdnByLinkFile) @RequestMapping(name="전용차로과태료업무 장비업체 단속파일로 단속자료 생성", value=METHOD_URL.createCrdnByLinkFile)
public ModelAndView createCrdnByLinkFile(String taskSeCd, String entType, String equipmentType, String[] linkFileInfos) { public ModelAndView createCrdnByLinkFile(String taskSeCd, String fileGroupType, String[] linkFileInfos) {
return super.createCrdnByLinkFile(taskSeCd, entType, equipmentType, linkFileInfos); return super.createCrdnByLinkFile(taskSeCd, fileGroupType, linkFileInfos);
} }
@Override @Override

@ -268,8 +268,8 @@ public class DpvController {
@Override @Override
@RequestMapping(name="장애인과태료업무 장비업체 단속파일로 단속자료 생성", value=METHOD_URL.createCrdnByLinkFile) @RequestMapping(name="장애인과태료업무 장비업체 단속파일로 단속자료 생성", value=METHOD_URL.createCrdnByLinkFile)
public ModelAndView createCrdnByLinkFile(String taskSeCd, String entType, String equipmentType, String[] linkFileInfos) { public ModelAndView createCrdnByLinkFile(String taskSeCd, String fileGroupType, String[] linkFileInfos) {
return super.createCrdnByLinkFile(taskSeCd, entType, equipmentType, linkFileInfos); return super.createCrdnByLinkFile(taskSeCd, fileGroupType, linkFileInfos);
} }
@Override @Override

@ -243,8 +243,8 @@ public class EcaController {
@Override @Override
@RequestMapping(name="전기차과태료업무 장비업체 단속파일로 단속자료 생성", value=METHOD_URL.createCrdnByLinkFile) @RequestMapping(name="전기차과태료업무 장비업체 단속파일로 단속자료 생성", value=METHOD_URL.createCrdnByLinkFile)
public ModelAndView createCrdnByLinkFile(String taskSeCd, String entType, String equipmentType, String[] linkFileInfos) { public ModelAndView createCrdnByLinkFile(String taskSeCd, String fileGroupType, String[] linkFileInfos) {
return super.createCrdnByLinkFile(taskSeCd, entType, equipmentType, linkFileInfos); return super.createCrdnByLinkFile(taskSeCd, fileGroupType, linkFileInfos);
} }
@Override @Override

@ -255,8 +255,8 @@ public class PvsController {
@Override @Override
@RequestMapping(name="주정차과태료업무 장비업체 단속파일로 단속자료 생성", value=METHOD_URL.createCrdnByLinkFile) @RequestMapping(name="주정차과태료업무 장비업체 단속파일로 단속자료 생성", value=METHOD_URL.createCrdnByLinkFile)
public ModelAndView createCrdnByLinkFile(String taskSeCd, String entType, String equipmentType, String[] linkFileInfos) { public ModelAndView createCrdnByLinkFile(String taskSeCd, String fileGroupType, String[] linkFileInfos) {
return super.createCrdnByLinkFile(taskSeCd, entType, equipmentType, linkFileInfos); return super.createCrdnByLinkFile(taskSeCd, fileGroupType, linkFileInfos);
} }
@Override @Override

@ -59,7 +59,7 @@ SELECT CONCAT(A.EMD_NM,
</select> </select>
<select id="selectLinkFileLayoutMetadata" parameterType="map" resultMap="descriptorRow"> <select id="selectLinkFileLayoutMetadata" parameterType="map" resultMap="descriptorRow">
/* 연계파일 레이아웃 정보 조회(crdnTeamMapper.selectLinkFileLayoutMetadata) */ /* 연계파일 레이아웃 정보 조회(globalStngMapper.selectLinkFileLayoutMetadata) */
SELECT FILE_LAYOUT_ID SELECT FILE_LAYOUT_ID
, SGG_CD , SGG_CD
, TASK_SE_CD , TASK_SE_CD
@ -77,10 +77,30 @@ SELECT FILE_LAYOUT_ID
, LINK_FILE_PATH , LINK_FILE_PATH
FROM TB_CRDN_FILE_LAYOUT FROM TB_CRDN_FILE_LAYOUT
WHERE USE_YN = 'Y' WHERE USE_YN = 'Y'
<choose>
<when test="fileLayoutId != null and fileLayoutId != '' ">
AND FILE_LAYOUT_ID = #{fileLayoutId}
</when>
<otherwise>
AND SGG_CD = #{sggCd} AND SGG_CD = #{sggCd}
AND TASK_SE_CD = #{taskSeCd} AND TASK_SE_CD = #{taskSeCd}
AND INST_CD = #{instCd} AND INST_CD = #{instCd}
AND DEPT_CD = #{deptCd} AND DEPT_CD = #{deptCd}
</otherwise>
</choose>
</select>
<select id="selectRemoteInfo" parameterType="string" resultType="dataobject">
/* 연계파일 fpt정보 조회(globalStngMapper.selectRemoteInfo) */
SELECT FILE_LAYOUT_ID
, REMOTE_IP
, REMOTE_ID
, REMOTE_PASSWORD
, REMOTE_OS
, REMOTE_WORK_PATH
FROM TB_FTP_INFO
WHERE FILE_LAYOUT_ID = #{fileLayoutId}
</select> </select>
</mapper> </mapper>

@ -18,40 +18,12 @@
</select> </select>
</div> </div>
<div class="col-md-4"> <div class="col-md-4">
<c:if test="${taskSeCd == 'PVS' or taskSeCd == 'BPV'}">
<label for="equipmentType--${pageName}"
class="w-px-120 bg-lighter pe-2 col-form-label text-sm-end">장비 구분</label>
<select id="equipmentType--${pageName}" name="equipmentType" class="form-select">
<option value="">선택</option>
<option value="고정형">고정형</option>
<option value="주행형">주행형</option>
<option value="버스장착형">버스장착형</option>
<option value="MOBILE">모바일(스마트폰)</option>
</select>
</c:if>
</div>
<div class="col-md-4 d-flex align-items-center flex-nowrap">
<label for="entType--${pageName}"
class="w-px-120 bg-lighter pe-2 col-form-label text-sm-end">장비업체</label>
<select id="entType--${pageName}" name="entType" class="form-select">
<option value="">선택하세요</option>
<option value="xit">XIT권장포맷</option>
<c:if test="${taskSeCd == 'DPV' or taskSeCd == 'ECA'}">
<option value="knl">KNL</option>
<option value="ino">이노</option>
</c:if>
<c:if test="${taskSeCd == 'PVS' or taskSeCd == 'BPV'}">
<option value="gasan">가산정보통신</option>
<option value="elisoft">엘리소프트</option>
<option value="hitecom">하이테콤</option>
</c:if>
<c:if test="${taskSeCd == '미세먼지'}">
<option value="unknown">unknown</option>
</c:if>
</select>
<span class="d-flex justify-content-end float-end ms-auto me-4"> <span class="d-flex justify-content-end float-end ms-auto me-4">
<button type="button" id="btnSearch--${pageName}" class="btn btn-primary">조회</button> <button type="button" id="btnSearch--${pageName}" class="btn btn-primary">조회</button>
</span> </span>
</div>
<div class="col-md-4 d-flex align-items-center flex-nowrap">
</div> </div>
<div class="col-md-12 d-flex align-items-center flex-nowrap"> <div class="col-md-12 d-flex align-items-center flex-nowrap">
<label for="uploadFiles--${pageName}" <label for="uploadFiles--${pageName}"
@ -189,8 +161,6 @@ pageObject["${pageName}"] = {};
$(document).ready(function(){ $(document).ready(function(){
var $P = pageObject["${pageName}"]; var $P = pageObject["${pageName}"];
$P.entType = "";
$P.equipmentType = "";
$P.tempGroup = {}; $P.tempGroup = {};
@ -214,7 +184,7 @@ $(document).ready(function(){
**************************************************************************/ **************************************************************************/
$P.parsedInfoControl.onDatasetChange = (obj) => { $P.parsedInfoControl.onDatasetChange = (obj) => {
$P.renderParsedInfoList(obj["Total"], $P.entType); $P.renderParsedInfoList(obj["Total"]);
$("#parsedInfoPaging--${pageName}").setPagingInfo({ $("#parsedInfoPaging--${pageName}").setPagingInfo({
list: $P.parsedInfoControl.dataset, list: $P.parsedInfoControl.dataset,
@ -232,11 +202,9 @@ $(document).ready(function(){
if(item && item.data){ if(item && item.data){
var dataKey = item.data.FILE_NAME; var dataKey = item.data.FILE_NAME;
if($P.entType != ""){ $("#table-responsive--${pageName}").find("tbody").setCurrentRow(dataKey);
$("#table-responsive--${pageName}").find("tbody").setCurrentRow(dataKey);
}
if(item.data.ENT_TYPE == "hitecom"){ 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.CAR_IMAGE,
"data:image/jpg;base64,"+item.data.PLATE_IMAGE "data:image/jpg;base64,"+item.data.PLATE_IMAGE
@ -267,9 +235,7 @@ $(document).ready(function(){
ajax.post({ ajax.post({
url : wctx.url("/${taskSeCd}/crdn/crdn05/020/importFileFromServer.do"), url : wctx.url("/${taskSeCd}/crdn/crdn05/020/importFileFromServer.do"),
data : { data : {
taskSeCd : $("#taskSeCd--${pageName}").val(), taskSeCd : $("#taskSeCd--${pageName}").val()
entType : $("#entType--${pageName}").val(),
equipmentType : $("#equipmentType--${pageName}").val()
}, },
success : (resp) => { success : (resp) => {
if(resp.saved){ if(resp.saved){
@ -310,20 +276,13 @@ $(document).ready(function(){
//서버에 등록된 파일 조회 //서버에 등록된 파일 조회
$P.searchFileList = () => { $P.searchFileList = () => {
$P.parsedInfoControl.setData([]); $P.parsedInfoControl.setData([]);
$P.entType = $("#entType--${pageName}").val();
$P.equipmentType = $("#equipmentType--${pageName}").val();
ajax.post({ ajax.post({
url : wctx.url("/${taskSeCd}/crdn/crdn05/020/list.do"), url : wctx.url("/${taskSeCd}/crdn/crdn05/020/list.do"),
data : { data : {
taskSeCd : $("#taskSeCd--${pageName}").val(), taskSeCd : $("#taskSeCd--${pageName}").val()
entType : $("#entType--${pageName}").val(),
equipmentType : $("#equipmentType--${pageName}").val()
}, },
success : (resp) => { success : (resp) => {
$P.parsedInfoControl.setData(resp); $P.parsedInfoControl.setData(resp);
@ -332,23 +291,23 @@ $(document).ready(function(){
} }
//테이블 렌더링 //테이블 렌더링
$P.renderParsedInfoList = (total, entType) => { $P.renderParsedInfoList = (total) => {
if(entType != ""){
var parsedInfoList = $P.parsedInfoControl.dataset; var parsedInfoList = $P.parsedInfoControl.dataset;
var empty = parsedInfoList.empty; var empty = parsedInfoList.empty;
var notFound = [$("#table-responsive--${pageName}").find("template.notFound")[0].innerHTML]; var notFound = [$("#table-responsive--${pageName}").find("template.notFound")[0].innerHTML];
var found = $("#table-responsive--${pageName}").find("template.found")[0].innerHTML; var found = $("#table-responsive--${pageName}").find("template.found")[0].innerHTML;
var replacer = (str, dataItem) => str var replacer = (str, dataItem) => str
.replace(/{onclick}/gi, "pageObject['${pageName}'].clickParsedInfoList('" + dataItem.getValue("FILE_NAME") + "');"); .replace(/{onclick}/gi, "pageObject['${pageName}'].clickParsedInfoList('" + dataItem.getValue("FILE_NAME") + "');");
var trs = empty ? notFound : parsedInfoList.inStrings(found,replacer); var trs = empty ? notFound : parsedInfoList.inStrings(found,replacer);
$("#table-responsive--${pageName}").find("tbody").html(trs.join()); $("#table-responsive--${pageName}").find("tbody").html(trs.join());
if(!empty){ if(!empty){
fnDownsizeCheck($("#table-responsive--${pageName}").find("table")[0]); fnDownsizeCheck($("#table-responsive--${pageName}").find("table")[0]);
}
} }
} }
//사진 표시 //사진 표시
@ -400,8 +359,7 @@ $(document).ready(function(){
var firstGroupKey = Object.keys($P.tempGroup)[0]; var firstGroupKey = Object.keys($P.tempGroup)[0];
var formData = new FormData(document.getElementById("frmMultipart--${pageName}")); var formData = new FormData(document.getElementById("frmMultipart--${pageName}"));
formData.append("taskSeCd", "${taskSeCd}"); formData.append("taskSeCd", "${taskSeCd}");
formData.append("entType", $P.entType); formData.append("fileGroupType", $P.tempGroup[firstGroupKey][0].FILE_GROUP_TYPE);
formData.append("equipmentType", $("#equipmentType--${pageName}").val());
if($P.tempGroup[firstGroupKey].length == 1){ if($P.tempGroup[firstGroupKey].length == 1){
formData.append("linkFileInfos", JSON.stringify({})); formData.append("linkFileInfos", JSON.stringify({}));
} }
@ -441,13 +399,13 @@ $(document).ready(function(){
if(current == null) return; if(current == null) return;
var fileName = current.FILE_NAME; var fileName = current.FILE_NAME;
var fileLayoutId = current.FILE_LAYOUT_ID;
ajax.get({ ajax.get({
url : wctx.url("/${taskSeCd}/crdn/crdn05/020/remove.do"), url : wctx.url("/${taskSeCd}/crdn/crdn05/020/remove.do"),
data : { data : {
taskSeCd : $("#taskSeCd--${pageName}").val(), taskSeCd : $("#taskSeCd--${pageName}").val(),
entType : $P.entType, fileLayoutId : fileLayoutId,
equipmentType : $("#equipmentType--${pageName}").val(),
fileName : fileName fileName : fileName
}, },
success : (resp) => { success : (resp) => {
@ -464,23 +422,23 @@ $(document).ready(function(){
} }
$P.removeTableRow = (removedFileName) => { $P.removeTableRow = (removedFileName) => {
if($P.entType != ""){
var fileListTable = $("#table-responsive--${pageName}").find("table")[0]; var fileListTable = $("#table-responsive--${pageName}").find("table")[0];
var targetArr = []; var targetArr = [];
if(Array.isArray(removedFileName)){ if(Array.isArray(removedFileName)){
targetArr = removedFileName; targetArr = removedFileName;
} else { } else {
targetArr = [removedFileName]; targetArr = [removedFileName];
}
for(var i = 0; i < targetArr.length; i++){
var target = targetArr[i];
var tr = $(fileListTable).find("tbody").find("tr[data-key='"+target+"']");
var trIndex = $(fileListTable).find("tbody tr").index(tr);
fileListTable.deleteRow(trIndex+1);
}
} }
for(var i = 0; i < targetArr.length; i++){
var target = targetArr[i];
var tr = $(fileListTable).find("tbody").find("tr[data-key='"+target+"']");
var trIndex = $(fileListTable).find("tbody tr").index(tr);
fileListTable.deleteRow(trIndex+1);
}
} }
/************************************************************************** /**************************************************************************

Loading…
Cancel
Save