fix: 폐기보고확인 API 서버 call 반영반영, 폐기신청/결과처리 서버 call 공통 처리

dev
Jonguk. Lim 4 months ago
parent 42d43c78b6
commit 8f161d7fad

@ -3,8 +3,11 @@ package cokr.xit.adds.cmm.model;
import java.util.List;
import org.apache.commons.lang3.StringUtils;
import org.springmodules.validation.bean.conf.loader.annotation.handler.NotEmpty;
import lombok.Builder;
import lombok.Data;
import lombok.Setter;
/**
* <pre>
@ -373,7 +376,54 @@ public class NimsApiRequest {
private String adds12;
private String userId;
}
@Data
public static class DsuseRptMappingInqReq {
private String dscdmngId;
private String userId;
}
@Data
public static class DsuseMgtMappingReq {
private String dscdmngId;
/**
* <pre>
* - ADDS11
* 01-
* 06-
* 07-
* 11-
* 21-
* 99-
* </pre>
*/
private String prgrsSttsCd = "11";
/**
*
*/
private String usrRptIdNo;
/**
*
*/
private String orgUsrRptIdNo;
/**
* (0-,1-,2-)
*/
private String rptTyCd;
/**
* - NIMS
*/
private String stts;
private String userId;
private String rgtr;
}
}

@ -93,6 +93,12 @@ public class AddsNimsController extends ApplicationController {
@Value("${app.inf.nims.api.saveDsuseMgtReceipt}")
private String saveDsuseMgtReceiptEndpoint;
@Value("${app.inf.nims.api.nimsRptDsuseMgtMapping}")
private String dsuseRptAndDsuseMgtMappingEndpoint;
@Value("${app.inf.nims.api.modifyMappingDsuseMgt}")
private String modifyMappingDsuseMgtEndpoint;
@Resource(name="sigunguDepartmentService")
private SigunguDepartmentService sggDeptService;
@ -488,10 +494,9 @@ public class AddsNimsController extends ApplicationController {
String rslt = apiRslt.body();
return json.parse(rslt, new TypeReference<>() {});
}catch (Exception e){
} catch (IOException | InterruptedException e){
throw new RuntimeException(e);
}
return null;
}
@ -517,12 +522,22 @@ public class AddsNimsController extends ApplicationController {
String rslt = apiRslt.body();
return json.parse(rslt, new TypeReference<>() {});
}catch (Exception e){
} catch (IOException | InterruptedException e){
throw new RuntimeException(e);
}
return null;
}
@RequestMapping(value = "/getDsuseRptAndDsuseMgtMapping.do", name="폐기보고 매핑 조회", produces = "application/json;charset=UTF-8")
public @ResponseBody ApiBaseResponse<List<JSONObject>> getDsuseRptAndDsuseMgtMapping(@ModelAttribute NimsApiRequest.DsuseRptMappingInqReq dto) {
String rslt = ApiUtil.callNimsApi(apiHost + dsuseRptAndDsuseMgtMappingEndpoint, dto);
return json.parse(rslt, new TypeReference<>() {});
}
@RequestMapping(value = "/modifyMappingDsuseMgt.do", name="폐기보고 확인 정보 저장", produces = "application/json;charset=UTF-8")
public @ResponseBody ApiBaseResponse<List<JSONObject>> modifyMappingDsuseMgt(@ModelAttribute NimsApiRequest.DsuseMgtMappingReq dto) {
String rslt = ApiUtil.callNimsApi(apiHost + modifyMappingDsuseMgtEndpoint, dto);
return json.parse(rslt, new TypeReference<>() {});
}
//-------------------------------------------------------------------------------------------------
// API server call
//-------------------------------------------------------------------------------------------------
@ -717,29 +732,9 @@ public class AddsNimsController extends ApplicationController {
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));
writeJsonString("dsuseMgtRsltJsonStr", dsuseMgtRsltJsonStr, boundary, byteOut, lineSeparator);
writeMultipartFiles("dsuseDsuseImgFiles", files, boundary, byteOut, lineSeparator);
writeJsonString("fileChangeYn", fileChangeYn, boundary, byteOut, lineSeparator);
byteOut.write(("--" + boundary + "--" + lineSeparator).getBytes(StandardCharsets.UTF_8));
return HttpRequest.BodyPublishers.ofByteArray(byteOut.toByteArray());
@ -749,32 +744,33 @@ public class AddsNimsController extends ApplicationController {
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));
writeJsonString("dsuseMgtJsonStr", dsuseMgtJsonStr, boundary, byteOut, lineSeparator);
writeMultipartFiles("dsusePrdImgFiles", files, boundary, byteOut, lineSeparator);
writeJsonString("dsuseMgtDtlsJsonStr", dsuseMgtDtlsJsonStr, boundary, byteOut, lineSeparator);
byteOut.write(("--" + boundary + "--" + lineSeparator).getBytes(StandardCharsets.UTF_8));
// File parts
return HttpRequest.BodyPublishers.ofByteArray(byteOut.toByteArray());
}
private static void writeMultipartFiles(String attName, List<MultipartFile> files, String boundary, ByteArrayOutputStream byteOut,
String lineSeparator) throws IOException {
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-Disposition: form-data; name=\"" + attName + "\"; 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));
byteOut.write(lineSeparator.getBytes(StandardCharsets.UTF_8));
}
}
}
// fileChangeYn part
private static void writeJsonString(String attName, String dsuseMgtJsonStr, String boundary, ByteArrayOutputStream byteOut,
String lineSeparator) throws IOException {
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());
byteOut.write(("Content-Disposition: form-data; name=\"" + attName + "\"" + 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));
}
//-------------------------------------------------------------------------------------------------
// private method

@ -68,12 +68,16 @@ app:
nimsDsuseRptInfo: /api/biz/nims/v1/getNimsDsuseRptInfo
# 바코드 조회
prdMnfSeqInfoOfBarcode: /api/biz/nims/v1/getPrdMnfSeqInfoOfBarcode
# 보고문서 정보 목록 조회
dsuseMgtListForRptDoc: /api/biz/nims/v1/getDsuseMgtListForRptDoc
# 폐기신청서 접수
saveDsuseMgtReceipt: /api/biz/nims/v1/saveDsuseMgtReceipt
# 폐기결과[통보] 처리
saveDsuseMgtRslt: /api/biz/nims/v1/saveDsuseMgtRslt
# Nims 폐기보고 폐기관리 매핑 조회
nimsRptDsuseMgtMapping: /api/biz/nims/v1/getDsuseRptAndDsuseMgtMapping
# 폐기보고 정보 매핑
modifyMappingDsuseMgt: /api/biz/nims/v1/modifyMappingDsuseMgt
# 보고문서 정보 목록 조회
dsuseMgtListForRptDoc: /api/biz/nims/v1/getDsuseMgtListForRptDoc
logging:
file:

@ -293,7 +293,8 @@
$P.mappingControl = new DatasetControl({
urls : {
load : '<c:url value="${apiHost}/api/biz/nims/v1/getDsuseMgtMapping" />',
<%--load : '<c:url value="${apiHost}/api/biz/nims/v1/getDsuseMgtMapping" />',--%>
load : wctx.url("/adds/nims/getDsuseRptAndDsuseMgtMapping.do")
}
, prefix: "dsuseMgtMapping"
, prefixName: "마약류 제품 조회"
@ -315,7 +316,7 @@
$P.mappingDtlControl = new DatasetControl({
prefix: "dsuseMgtMapping"
, prefixName: "마약류 취급업체 조회"
, prefixName: "폐기보고 확인 조회"
, keymapper: info => info ? info.mnfSeq : ""
, dataGetter: obj => obj.${infoPrefix}MappingDtl
, infoSize: "xl"
@ -401,7 +402,8 @@
ajax.post({
url: '<c:url value="${apiHost}/api/biz/nims/v1/modifyMappingDsuseMgt"/>'
<%--url: '<c:url value="${apiHost}/api/biz/nims/v1/modifyMappingDsuseMgt"/>'--%>
url: wctx.url("/adds/nims/modifyMappingDsuseMgt.do")
, data: JSON.stringify({
dscdmngId: $P.formFields.get().dscdmngId,
prgrsSttsCd: "21",

Loading…
Cancel
Save