|
|
@ -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,35 +137,31 @@ 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++) {
|
|
|
|
|
|
|
|
DataObject remoteInfo = globalStngMapper.selectRemoteInfo(layoutDescriptors.get(i).getFileLayoutId());
|
|
|
|
|
|
|
|
if(remoteInfo == null) {
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
File workDir = new File(workPath);
|
|
|
|
workDir.mkdirs();
|
|
|
|
workDir.mkdirs();
|
|
|
|
|
|
|
|
|
|
|
|
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 {
|
|
|
|
try {
|
|
|
|
boolean result = FTPUtil.fileDown(rs, remoteWorkPath, workPath);
|
|
|
|
boolean result = FTPUtil.fileDown(rs, remoteWorkPath, workPath);
|
|
|
|
if(!result) {
|
|
|
|
if(!result) {
|
|
|
@ -177,6 +175,7 @@ public class Crdn05Controller extends ApplicationController {
|
|
|
|
mav.addObject("saved", saved);
|
|
|
|
mav.addObject("saved", saved);
|
|
|
|
return mav;
|
|
|
|
return mav;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
saved = true;
|
|
|
|
saved = true;
|
|
|
|
mav.addObject("saved", saved);
|
|
|
|
mav.addObject("saved", saved);
|
|
|
@ -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");
|
|
|
|
String taskSeCd = hReq.getParameter("taskSeCd");
|
|
|
|
LayoutParser parser = null;
|
|
|
|
String institute = currentUser().getInstitute();
|
|
|
|
switch(entType){
|
|
|
|
String sggCd = globalStngMapper.selectSggCdForCurrentUser();
|
|
|
|
case "ino": parser = new OnlyImageParser(); break;
|
|
|
|
ManagedUser currentUser = userMapper.getUser(currentUser().getAccount(), institute);
|
|
|
|
//case "knl": break;
|
|
|
|
String deptCd = currentUser.getDeptCode();
|
|
|
|
case "hitecom": parser = new SingleFileParser(); break;
|
|
|
|
List<LayoutDescriptor> layoutDescriptors = crdnStngService.getLinkFileLayoutMetadata(sggCd, taskSeCd, institute, deptCd);
|
|
|
|
case "xit": parser = new AttachedTxtParser(); break;
|
|
|
|
|
|
|
|
//case "": enterprise = new (); break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(layoutDescriptors == null || layoutDescriptors.isEmpty()) {
|
|
|
|
|
|
|
|
throw new RuntimeException("연계파일 레이아웃 정보 조회에 실패하였습니다.");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
String institute = currentUser().getInstitute();
|
|
|
|
for(int i=0; i < layoutDescriptors.size(); i++) {
|
|
|
|
String taskSeCd = hReq.getParameter("taskSeCd");
|
|
|
|
String workPath = layoutDescriptors.get(i).getLinkFileLocation();
|
|
|
|
String equipmentType = hReq.getParameter("equipmentType");
|
|
|
|
|
|
|
|
String workPath = ParsingUtil.getWorkDirectoryPath(institute, taskSeCd, entType, equipmentType);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Stream<Path> fileList = null;
|
|
|
|
List<Path> fileList = null;
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
//폴더는 제외하고 파일만 필터링
|
|
|
|
//폴더는 제외하고 파일만 필터링
|
|
|
|
fileList = Files.walk(Paths.get(workPath)).filter(Files::isRegularFile);
|
|
|
|
fileList = Files.walk(Paths.get(workPath)).filter(Files::isRegularFile).toList();
|
|
|
|
} catch (IOException e) {
|
|
|
|
} catch (IOException e) {
|
|
|
|
e.printStackTrace();
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
String sggCd = globalStngMapper.selectSggCdForCurrentUser();
|
|
|
|
LayoutParser parser = null;
|
|
|
|
ManagedUser currentUser = userMapper.getUser(currentUser().getAccount(), institute);
|
|
|
|
switch(layoutDescriptors.get(i).getFileGroup()){
|
|
|
|
String deptCd = currentUser.getDeptCode();
|
|
|
|
case "TXT": parser = new AttachedTxtParser(); break;
|
|
|
|
List<LayoutDescriptor> candidates = crdnStngService.getLinkFileLayoutMetadata(sggCd, taskSeCd, institute, deptCd);
|
|
|
|
case "JPG": parser = new OnlyImageParser(); break;
|
|
|
|
|
|
|
|
case "BIN": parser = new SingleFileParser(); break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if(candidates == null || candidates.isEmpty()) {
|
|
|
|
if(!fileList.isEmpty()) {
|
|
|
|
throw new RuntimeException("연계파일 레이아웃 정보 조회에 실패하였습니다.");
|
|
|
|
parsedDataList.addAll(parser.parsing(fileList));
|
|
|
|
} 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, parsedDataList, "");
|
|
|
|
mav = setCollectionInfo(mav, dataObjectList, "");
|
|
|
|
|
|
|
|
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);
|
|
|
|