|
|
|
|
@ -17,6 +17,7 @@ import javax.annotation.Resource;
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
|
|
|
|
|
|
import org.springframework.stereotype.Controller;
|
|
|
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
import org.springframework.web.servlet.ModelAndView;
|
|
|
|
|
@ -357,7 +358,7 @@ public class Crdn05Controller extends ApplicationController {
|
|
|
|
|
*/
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@RequestMapping(name="장비업체 단속파일로 단속자료 생성", value="/020/upload.do")
|
|
|
|
|
@PostMapping(name="장비업체 단속파일로 단속자료 생성", value="/020/upload.do")
|
|
|
|
|
public ModelAndView createCrdnFromLinkFile(HttpServletRequest hreq, MultipartFile[] uploadFiles) {
|
|
|
|
|
UserInfo currentUser = currentUser();
|
|
|
|
|
String sggCd = currentUser.getOrgID(),
|
|
|
|
|
@ -397,67 +398,58 @@ public class Crdn05Controller extends ApplicationController {
|
|
|
|
|
parsed.addAll(parser.parse(workPath, List.of(uploadFiles)));
|
|
|
|
|
} else { // 서버 cctv 디렉토리
|
|
|
|
|
String[] dirs = blankIfEmpty(hreq.getParameter("dirs")).split(",");
|
|
|
|
|
Stream.of(dirs)
|
|
|
|
|
.forEach(dir -> {
|
|
|
|
|
String srcDir = FimsConf.get().violationFileDir(dir);
|
|
|
|
|
Path destDir = ensureDir(srcDir + File.separator + "work").toPath();
|
|
|
|
|
try {
|
|
|
|
|
Files.list(Paths.get(srcDir))
|
|
|
|
|
.filter(src -> {
|
|
|
|
|
String str = src.toString();
|
|
|
|
|
return !str.contains("work")
|
|
|
|
|
&& !str.contains("success")
|
|
|
|
|
&& Files.isRegularFile(src);
|
|
|
|
|
})
|
|
|
|
|
.forEach(src -> {
|
|
|
|
|
try {
|
|
|
|
|
Files.move(src, destDir.resolve(src.getFileName()), StandardCopyOption.REPLACE_EXISTING);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
throw runtimeException(e);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
throw runtimeException(e);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
List<File> files = Stream.of(dirs)
|
|
|
|
|
.map(path -> Paths.get(FimsConf.get().violationFileDir(path) + File.separator + "work"))
|
|
|
|
|
.flatMap(path -> {
|
|
|
|
|
try {
|
|
|
|
|
return Files.walk(path).filter(file -> Files.isRegularFile(file));
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
throw runtimeException(e);
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
.map(Path::toFile)
|
|
|
|
|
.toList();
|
|
|
|
|
parsed.addAll(parser.parse(files));
|
|
|
|
|
for (String dir: dirs) {
|
|
|
|
|
String srcDir = FimsConf.get().violationFileDir(dir);
|
|
|
|
|
List<String> filenames = List.of(blankIfEmpty(hreq.getParameter("filenames")).split(","));
|
|
|
|
|
log().debug("{} filenames received", filenames.size());
|
|
|
|
|
Path workDir = ensureDir(srcDir + File.separator + "work").toPath();
|
|
|
|
|
try {
|
|
|
|
|
// 파일들을 작업 디렉토리로 이동
|
|
|
|
|
List<Path> filepaths = Files.list(Paths.get(srcDir))
|
|
|
|
|
.filter(path -> contains(path.toString(), filenames, false))
|
|
|
|
|
.toList();
|
|
|
|
|
log().debug("{} filepaths extracted", filepaths.size());
|
|
|
|
|
filepaths.forEach(src -> {
|
|
|
|
|
try {
|
|
|
|
|
Files.move(src, workDir.resolve(src.getFileName()), StandardCopyOption.REPLACE_EXISTING);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
throw runtimeException(e);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
List<File> files = Files.list(workDir)
|
|
|
|
|
.filter(path -> contains(path.toString(), filenames, true))
|
|
|
|
|
.map(path -> path.toFile())
|
|
|
|
|
.toList();
|
|
|
|
|
log().debug("{} files parsed", files.size());
|
|
|
|
|
parsed.addAll(parser.parse(files));
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
throw runtimeException(e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
nextTempGroupSeq = parser.getTempGroupSeq();
|
|
|
|
|
}
|
|
|
|
|
/*
|
|
|
|
|
if (parsed.isEmpty())
|
|
|
|
|
return new ModelAndView("jsonView")
|
|
|
|
|
.addObject("saved", false)
|
|
|
|
|
.addObject("alertMessage", "등록할 파일을 찾지 못했습니다")
|
|
|
|
|
.addObject("failReason", "등록할 파일을 찾지 못했습니다");
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
Map<String, Object> result = importService.createCrdnByEquipmentLinkFile(processInfo, parsed);
|
|
|
|
|
return new ModelAndView("jsonView")
|
|
|
|
|
.addAllObjects(result);
|
|
|
|
|
/*
|
|
|
|
|
boolean saved = (boolean)resultMap.get("saved");
|
|
|
|
|
|
|
|
|
|
ModelAndView mav = new ModelAndView("jsonView")
|
|
|
|
|
.addObject("saved", saved);
|
|
|
|
|
if (!isEmpty(resultMap.get("alertMessage")))
|
|
|
|
|
mav.addObject("alertMessage", resultMap.get("alertMessage"));
|
|
|
|
|
.addAllObjects(result);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!saved)
|
|
|
|
|
mav.addObject("failReason", ifEmpty(resultMap.get("failReason"), () -> "알 수 없는 오류"));
|
|
|
|
|
private boolean contains(String path, List<String> filenames, boolean inWork) {
|
|
|
|
|
if (!inWork) {
|
|
|
|
|
if (path.contains("work")
|
|
|
|
|
|| path.contains("success")
|
|
|
|
|
|| path.contains("fail")
|
|
|
|
|
|| path.contains("duplicates")
|
|
|
|
|
) return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return mav;
|
|
|
|
|
*/
|
|
|
|
|
for (String filename: filenames) {
|
|
|
|
|
if (path.endsWith(filename))
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**단속자료 수기 등록 팝업화면을 반환한다.
|
|
|
|
|
|