|
|
|
@ -1,12 +1,19 @@
|
|
|
|
|
package cokr.xit.adds.nims.web;
|
|
|
|
|
|
|
|
|
|
import java.io.ByteArrayOutputStream;
|
|
|
|
|
import java.io.File;
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
import java.net.URI;
|
|
|
|
|
import java.net.http.HttpClient;
|
|
|
|
|
import java.net.http.HttpRequest;
|
|
|
|
|
import java.net.http.HttpResponse;
|
|
|
|
|
import java.nio.charset.StandardCharsets;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
import java.util.Set;
|
|
|
|
|
import java.util.UUID;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
import java.util.stream.IntStream;
|
|
|
|
|
|
|
|
|
@ -19,6 +26,7 @@ import org.springframework.web.bind.annotation.ModelAttribute;
|
|
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
|
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
import org.springframework.web.servlet.ModelAndView;
|
|
|
|
|
|
|
|
|
|
import com.fasterxml.jackson.core.type.TypeReference;
|
|
|
|
@ -79,6 +87,12 @@ public class AddsNimsController extends ApplicationController {
|
|
|
|
|
@Value("${app.inf.nims.api.dsuseMgtListForRptDoc}")
|
|
|
|
|
private String dsuseMgtListForRptDocEndpoint;
|
|
|
|
|
|
|
|
|
|
@Value("${app.inf.nims.api.saveDsuseMgtRslt}")
|
|
|
|
|
private String saveDsuseMgtRsltEndpoint;
|
|
|
|
|
|
|
|
|
|
@Value("${app.inf.nims.api.saveDsuseMgtReceipt}")
|
|
|
|
|
private String saveDsuseMgtReceiptEndpoint;
|
|
|
|
|
|
|
|
|
|
@Resource(name="sigunguDepartmentService")
|
|
|
|
|
private SigunguDepartmentService sggDeptService;
|
|
|
|
|
|
|
|
|
@ -148,9 +162,7 @@ public class AddsNimsController extends ApplicationController {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
mav.addObject("fileInfo", toJson(fileInfo));
|
|
|
|
|
return mav
|
|
|
|
|
.addObject("pageName", "dsuseMgtReceiptInfo") // View(jsp)에서 사용할 id 뒤에 붙일 suffix
|
|
|
|
|
.addObject("apiHost", apiHost);
|
|
|
|
|
return mav.addObject("pageName", "dsuseMgtReceiptInfo"); // View(jsp)에서 사용할 id 뒤에 붙일 suffix
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@RequestMapping(value = "/removeDsuseMgt.do", name="신청서 접수 목록 조회")
|
|
|
|
@ -224,8 +236,7 @@ public class AddsNimsController extends ApplicationController {
|
|
|
|
|
.addObject("pageName", "dsuseMgtRsltInfo") // View(jsp)에서 사용할 id 뒤에 붙일 suffix
|
|
|
|
|
.addObject("infoPrefix", "dsuseMgtRsltInfo") // prefix
|
|
|
|
|
.addObject("infoPrefixUrl", "/adds/nims") // prefixUrl
|
|
|
|
|
.addObject("dsuseRsltInfo", toJson(dsuseRsltInfo)) // View(jsp)에서 사용할 id 뒤에 붙일 suffix
|
|
|
|
|
.addObject("apiHost", apiHost);
|
|
|
|
|
.addObject("dsuseRsltInfo", toJson(dsuseRsltInfo)); // View(jsp)에서 사용할 id 뒤에 붙일 suffix
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@RequestMapping(value = "/getDsuseMgtRsltImgDscdmngList.do", name="결과[통보] 처리 등록 이미지 폐기관리 목록 조회")
|
|
|
|
@ -381,7 +392,6 @@ public class AddsNimsController extends ApplicationController {
|
|
|
|
|
mav.addObject("DEPTList", deptList);
|
|
|
|
|
|
|
|
|
|
mav.addObject("pageName", "dsuseMgtDoc");
|
|
|
|
|
mav.addObject("apiHost", apiHost);
|
|
|
|
|
return mav;
|
|
|
|
|
}
|
|
|
|
|
//-------------------------------------------------------------------------------------------------
|
|
|
|
@ -455,6 +465,64 @@ public class AddsNimsController extends ApplicationController {
|
|
|
|
|
|
|
|
|
|
return json.parse(rslt, new TypeReference<>() {});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@RequestMapping(value = "/saveDsuseMgtReceipt.do", name="폐기신청서 접수", produces = "application/json;charset=UTF-8")
|
|
|
|
|
public @ResponseBody ApiBaseResponse<JSONObject> saveDsuseMgtReceipt(
|
|
|
|
|
@RequestParam("dsuseMgtJsonStr") String dsuseMgtJsonStr,
|
|
|
|
|
@RequestParam("dsuseMgtDtlsJsonStr") String dsuseMgtDtlsJsonStr,
|
|
|
|
|
@RequestParam(value = "dsusePrdImgFiles", required = false) List<MultipartFile> dsusePrdImgFiles) {
|
|
|
|
|
|
|
|
|
|
String boundary = UUID.randomUUID().toString();
|
|
|
|
|
try {
|
|
|
|
|
HttpRequest.BodyPublisher bodyPublisher = buildMultipartBodyReceipt(dsuseMgtJsonStr, dsuseMgtDtlsJsonStr,
|
|
|
|
|
dsusePrdImgFiles, boundary);
|
|
|
|
|
|
|
|
|
|
HttpRequest request = HttpRequest.newBuilder()
|
|
|
|
|
.uri(URI.create(apiHost + saveDsuseMgtReceiptEndpoint))
|
|
|
|
|
.header("Content-Type", "multipart/form-data; boundary=" + boundary)
|
|
|
|
|
.POST(bodyPublisher)
|
|
|
|
|
.build();
|
|
|
|
|
|
|
|
|
|
HttpResponse<String> apiRslt = HttpClient.newHttpClient()
|
|
|
|
|
.send(request, HttpResponse.BodyHandlers.ofString());
|
|
|
|
|
|
|
|
|
|
String rslt = apiRslt.body();
|
|
|
|
|
return json.parse(rslt, new TypeReference<>() {});
|
|
|
|
|
}catch (Exception e){
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@RequestMapping(value = "/saveDsuseMgtRslt.do", name="폐기결과[통보] 처리", produces = "application/json;charset=UTF-8")
|
|
|
|
|
public @ResponseBody ApiBaseResponse<JSONObject> saveDsuseMgtRslt(
|
|
|
|
|
@RequestParam("dsuseMgtRsltJsonStr") String dsuseMgtRsltJsonStr,
|
|
|
|
|
@RequestParam(value = "dsuseDsuseImgFiles", required = false) List<MultipartFile> dsuseDsuseImgFiles,
|
|
|
|
|
@RequestParam("fileChangeYn") String fileChangeYn) {
|
|
|
|
|
|
|
|
|
|
String boundary = UUID.randomUUID().toString();
|
|
|
|
|
try {
|
|
|
|
|
HttpRequest.BodyPublisher bodyPublisher = buildMultipartBody(dsuseMgtRsltJsonStr, dsuseDsuseImgFiles,
|
|
|
|
|
fileChangeYn, boundary);
|
|
|
|
|
|
|
|
|
|
HttpRequest request = HttpRequest.newBuilder()
|
|
|
|
|
.uri(URI.create(apiHost + saveDsuseMgtRsltEndpoint))
|
|
|
|
|
.header("Content-Type", "multipart/form-data; boundary=" + boundary)
|
|
|
|
|
.POST(bodyPublisher)
|
|
|
|
|
.build();
|
|
|
|
|
|
|
|
|
|
HttpResponse<String> apiRslt = HttpClient.newHttpClient()
|
|
|
|
|
.send(request, HttpResponse.BodyHandlers.ofString());
|
|
|
|
|
|
|
|
|
|
String rslt = apiRslt.body();
|
|
|
|
|
return json.parse(rslt, new TypeReference<>() {});
|
|
|
|
|
}catch (Exception e){
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------------------------------
|
|
|
|
|
// API server call
|
|
|
|
|
//-------------------------------------------------------------------------------------------------
|
|
|
|
@ -644,6 +712,70 @@ public class AddsNimsController extends ApplicationController {
|
|
|
|
|
}
|
|
|
|
|
return partitions;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private HttpRequest.BodyPublisher buildMultipartBody(String dsuseMgtRsltJsonStr, List<MultipartFile> files, String fileChangeYn, String boundary) throws IOException {
|
|
|
|
|
var byteOut = new ByteArrayOutputStream();
|
|
|
|
|
String lineSeparator = "\r\n";
|
|
|
|
|
|
|
|
|
|
// JSON part
|
|
|
|
|
byteOut.write(("--" + boundary + lineSeparator).getBytes(StandardCharsets.UTF_8));
|
|
|
|
|
byteOut.write(("Content-Disposition: form-data; name=\"dsuseMgtRsltJsonStr\"" + lineSeparator).getBytes(StandardCharsets.UTF_8));
|
|
|
|
|
byteOut.write(("Content-Type: application/json; charset=UTF-8" + lineSeparator + lineSeparator).getBytes(StandardCharsets.UTF_8));
|
|
|
|
|
byteOut.write((dsuseMgtRsltJsonStr + lineSeparator).getBytes(StandardCharsets.UTF_8));
|
|
|
|
|
|
|
|
|
|
// File parts
|
|
|
|
|
if (files != null) {
|
|
|
|
|
for (MultipartFile file : files) {
|
|
|
|
|
byteOut.write(("--" + boundary + lineSeparator).getBytes(StandardCharsets.UTF_8));
|
|
|
|
|
byteOut.write(("Content-Disposition: form-data; name=\"dsuseDsuseImgFiles\"; filename=\"" + file.getOriginalFilename() + "\"" + lineSeparator).getBytes(StandardCharsets.UTF_8));
|
|
|
|
|
byteOut.write(("Content-Type: " + file.getContentType() + lineSeparator + lineSeparator).getBytes(StandardCharsets.UTF_8));
|
|
|
|
|
byteOut.write(file.getBytes());
|
|
|
|
|
byteOut.write((lineSeparator).getBytes(StandardCharsets.UTF_8));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// fileChangeYn part
|
|
|
|
|
byteOut.write(("--" + boundary + lineSeparator).getBytes(StandardCharsets.UTF_8));
|
|
|
|
|
byteOut.write(("Content-Disposition: form-data; name=\"fileChangeYn\"" + lineSeparator).getBytes(StandardCharsets.UTF_8));
|
|
|
|
|
byteOut.write(("Content-Type: text/plain; charset=UTF-8" + lineSeparator + lineSeparator).getBytes(StandardCharsets.UTF_8));
|
|
|
|
|
byteOut.write((fileChangeYn + lineSeparator).getBytes(StandardCharsets.UTF_8));
|
|
|
|
|
|
|
|
|
|
byteOut.write(("--" + boundary + "--" + lineSeparator).getBytes(StandardCharsets.UTF_8));
|
|
|
|
|
|
|
|
|
|
return HttpRequest.BodyPublishers.ofByteArray(byteOut.toByteArray());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private HttpRequest.BodyPublisher buildMultipartBodyReceipt(String dsuseMgtJsonStr, String dsuseMgtDtlsJsonStr, List<MultipartFile> files, String boundary) throws IOException {
|
|
|
|
|
var byteOut = new ByteArrayOutputStream();
|
|
|
|
|
String lineSeparator = "\r\n";
|
|
|
|
|
|
|
|
|
|
// JSON part
|
|
|
|
|
byteOut.write(("--" + boundary + lineSeparator).getBytes(StandardCharsets.UTF_8));
|
|
|
|
|
byteOut.write(("Content-Disposition: form-data; name=\"dsuseMgtJsonStr\"" + lineSeparator).getBytes(StandardCharsets.UTF_8));
|
|
|
|
|
byteOut.write(("Content-Type: application/json; charset=UTF-8" + lineSeparator + lineSeparator).getBytes(StandardCharsets.UTF_8));
|
|
|
|
|
byteOut.write((dsuseMgtJsonStr + lineSeparator).getBytes(StandardCharsets.UTF_8));
|
|
|
|
|
|
|
|
|
|
// File parts
|
|
|
|
|
if (files != null) {
|
|
|
|
|
for (MultipartFile file : files) {
|
|
|
|
|
byteOut.write(("--" + boundary + lineSeparator).getBytes(StandardCharsets.UTF_8));
|
|
|
|
|
byteOut.write(("Content-Disposition: form-data; name=\"dsusePrdImgFiles\"; filename=\"" + file.getOriginalFilename() + "\"" + lineSeparator).getBytes(StandardCharsets.UTF_8));
|
|
|
|
|
byteOut.write(("Content-Type: " + file.getContentType() + lineSeparator + lineSeparator).getBytes(StandardCharsets.UTF_8));
|
|
|
|
|
byteOut.write(file.getBytes());
|
|
|
|
|
byteOut.write((lineSeparator).getBytes(StandardCharsets.UTF_8));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// fileChangeYn part
|
|
|
|
|
byteOut.write(("--" + boundary + lineSeparator).getBytes(StandardCharsets.UTF_8));
|
|
|
|
|
byteOut.write(("Content-Disposition: form-data; name=\"dsuseMgtDtlsJsonStr\"" + lineSeparator).getBytes(StandardCharsets.UTF_8));
|
|
|
|
|
byteOut.write(("Content-Type: text/plain; charset=UTF-8" + lineSeparator + lineSeparator).getBytes(StandardCharsets.UTF_8));
|
|
|
|
|
byteOut.write((dsuseMgtDtlsJsonStr + lineSeparator).getBytes(StandardCharsets.UTF_8));
|
|
|
|
|
|
|
|
|
|
byteOut.write(("--" + boundary + "--" + lineSeparator).getBytes(StandardCharsets.UTF_8));
|
|
|
|
|
|
|
|
|
|
return HttpRequest.BodyPublishers.ofByteArray(byteOut.toByteArray());
|
|
|
|
|
}
|
|
|
|
|
//-------------------------------------------------------------------------------------------------
|
|
|
|
|
// private method
|
|
|
|
|
//-------------------------------------------------------------------------------------------------
|
|
|
|
|