|
|
|
@ -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;
|
|
|
|
|
|
|
|
|
|
/**단속 자료 등록 서비스 웹 컨트롤러.<br />
|
|
|
|
@ -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<LayoutDescriptor> 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<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);
|
|
|
|
|
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<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 equipmentType = hReq.getParameter("equipmentType");
|
|
|
|
|
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 institute = currentUser().getInstitute();
|
|
|
|
|
String sggCd = globalStngMapper.selectSggCdForCurrentUser();
|
|
|
|
|
ManagedUser currentUser = userMapper.getUser(currentUser().getAccount(), institute);
|
|
|
|
|
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("연계파일 레이아웃 정보 조회에 실패하였습니다.");
|
|
|
|
|
} else if(candidates.size() == 1) {
|
|
|
|
|
parser.setDescriptor(candidates.get(0));
|
|
|
|
|
} else {
|
|
|
|
|
parser.setDescriptor(LayoutDiscriminator.choice(fileList, candidates));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
List<DataObject> dataObjectList = parser.parsing(fileList);
|
|
|
|
|
mav = setCollectionInfo(mav, dataObjectList, "");
|
|
|
|
|
for(int i=0; i < layoutDescriptors.size(); i++) {
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -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
|
|
|
|
|
* <pre><code> {
|
|
|
|
|
* "saved": 등록되었으면 true, 그렇지 않으면 false
|
|
|
|
|
* }</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");
|
|
|
|
|
String institute = currentUser().getInstitute();
|
|
|
|
|
|
|
|
|
@ -320,10 +319,10 @@ public class Crdn05Controller extends ApplicationController {
|
|
|
|
|
Map<String, String> processInfo = new HashMap<String,String>();
|
|
|
|
|
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<String, Object> resultMap = importService.createCrdnByEquipmentLinkFile(processInfo, linkFileInfoList);
|
|
|
|
|