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 java.util.List;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springmodules.validation.bean.conf.loader.annotation.handler.NotEmpty;
import lombok.Builder;
import lombok.Data; import lombok.Data;
import lombok.Setter;
/** /**
* <pre> * <pre>
@ -373,7 +376,54 @@ public class NimsApiRequest {
private String adds12; private String adds12;
private String userId; 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}") @Value("${app.inf.nims.api.saveDsuseMgtReceipt}")
private String saveDsuseMgtReceiptEndpoint; private String saveDsuseMgtReceiptEndpoint;
@Value("${app.inf.nims.api.nimsRptDsuseMgtMapping}")
private String dsuseRptAndDsuseMgtMappingEndpoint;
@Value("${app.inf.nims.api.modifyMappingDsuseMgt}")
private String modifyMappingDsuseMgtEndpoint;
@Resource(name="sigunguDepartmentService") @Resource(name="sigunguDepartmentService")
private SigunguDepartmentService sggDeptService; private SigunguDepartmentService sggDeptService;
@ -488,10 +494,9 @@ public class AddsNimsController extends ApplicationController {
String rslt = apiRslt.body(); String rslt = apiRslt.body();
return json.parse(rslt, new TypeReference<>() {}); 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(); String rslt = apiRslt.body();
return json.parse(rslt, new TypeReference<>() {}); 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 // API server call
//------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------
@ -717,29 +732,9 @@ public class AddsNimsController extends ApplicationController {
var byteOut = new ByteArrayOutputStream(); var byteOut = new ByteArrayOutputStream();
String lineSeparator = "\r\n"; String lineSeparator = "\r\n";
// JSON part writeJsonString("dsuseMgtRsltJsonStr", dsuseMgtRsltJsonStr, boundary, byteOut, lineSeparator);
byteOut.write(("--" + boundary + lineSeparator).getBytes(StandardCharsets.UTF_8)); writeMultipartFiles("dsuseDsuseImgFiles", files, boundary, byteOut, lineSeparator);
byteOut.write(("Content-Disposition: form-data; name=\"dsuseMgtRsltJsonStr\"" + lineSeparator).getBytes(StandardCharsets.UTF_8)); writeJsonString("fileChangeYn", fileChangeYn, boundary, byteOut, lineSeparator);
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)); byteOut.write(("--" + boundary + "--" + lineSeparator).getBytes(StandardCharsets.UTF_8));
return HttpRequest.BodyPublishers.ofByteArray(byteOut.toByteArray()); return HttpRequest.BodyPublishers.ofByteArray(byteOut.toByteArray());
@ -749,32 +744,33 @@ public class AddsNimsController extends ApplicationController {
var byteOut = new ByteArrayOutputStream(); var byteOut = new ByteArrayOutputStream();
String lineSeparator = "\r\n"; String lineSeparator = "\r\n";
// JSON part writeJsonString("dsuseMgtJsonStr", dsuseMgtJsonStr, boundary, byteOut, lineSeparator);
byteOut.write(("--" + boundary + lineSeparator).getBytes(StandardCharsets.UTF_8)); writeMultipartFiles("dsusePrdImgFiles", files, boundary, byteOut, lineSeparator);
byteOut.write(("Content-Disposition: form-data; name=\"dsuseMgtJsonStr\"" + lineSeparator).getBytes(StandardCharsets.UTF_8)); writeJsonString("dsuseMgtDtlsJsonStr", dsuseMgtDtlsJsonStr, boundary, byteOut, lineSeparator);
byteOut.write(("Content-Type: application/json; charset=UTF-8" + lineSeparator + lineSeparator).getBytes(StandardCharsets.UTF_8)); byteOut.write(("--" + boundary + "--" + lineSeparator).getBytes(StandardCharsets.UTF_8));
byteOut.write((dsuseMgtJsonStr + lineSeparator).getBytes(StandardCharsets.UTF_8));
return HttpRequest.BodyPublishers.ofByteArray(byteOut.toByteArray());
}
// File parts private static void writeMultipartFiles(String attName, List<MultipartFile> files, String boundary, ByteArrayOutputStream byteOut,
String lineSeparator) throws IOException {
if (files != null) { if (files != null) {
for (MultipartFile file : files) { for (MultipartFile file : files) {
byteOut.write(("--" + boundary + lineSeparator).getBytes(StandardCharsets.UTF_8)); 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(("Content-Type: " + file.getContentType() + lineSeparator + lineSeparator).getBytes(StandardCharsets.UTF_8));
byteOut.write(file.getBytes()); 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(("--" + boundary + lineSeparator).getBytes(StandardCharsets.UTF_8));
byteOut.write(("Content-Disposition: form-data; name=\"dsuseMgtDtlsJsonStr\"" + lineSeparator).getBytes(StandardCharsets.UTF_8)); byteOut.write(("Content-Disposition: form-data; name=\"" + attName + "\"" + lineSeparator).getBytes(StandardCharsets.UTF_8));
byteOut.write(("Content-Type: text/plain; charset=UTF-8" + lineSeparator + lineSeparator).getBytes(StandardCharsets.UTF_8)); byteOut.write(("Content-Type: application/json; charset=UTF-8" + lineSeparator + lineSeparator).getBytes(StandardCharsets.UTF_8));
byteOut.write((dsuseMgtDtlsJsonStr + lineSeparator).getBytes(StandardCharsets.UTF_8)); byteOut.write((dsuseMgtJsonStr + lineSeparator).getBytes(StandardCharsets.UTF_8));
byteOut.write(("--" + boundary + "--" + lineSeparator).getBytes(StandardCharsets.UTF_8));
return HttpRequest.BodyPublishers.ofByteArray(byteOut.toByteArray());
} }
//------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------
// private method // private method

@ -68,12 +68,16 @@ app:
nimsDsuseRptInfo: /api/biz/nims/v1/getNimsDsuseRptInfo nimsDsuseRptInfo: /api/biz/nims/v1/getNimsDsuseRptInfo
# 바코드 조회 # 바코드 조회
prdMnfSeqInfoOfBarcode: /api/biz/nims/v1/getPrdMnfSeqInfoOfBarcode prdMnfSeqInfoOfBarcode: /api/biz/nims/v1/getPrdMnfSeqInfoOfBarcode
# 보고문서 정보 목록 조회
dsuseMgtListForRptDoc: /api/biz/nims/v1/getDsuseMgtListForRptDoc
# 폐기신청서 접수 # 폐기신청서 접수
saveDsuseMgtReceipt: /api/biz/nims/v1/saveDsuseMgtReceipt saveDsuseMgtReceipt: /api/biz/nims/v1/saveDsuseMgtReceipt
# 폐기결과[통보] 처리 # 폐기결과[통보] 처리
saveDsuseMgtRslt: /api/biz/nims/v1/saveDsuseMgtRslt 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: logging:
file: file:

@ -293,7 +293,8 @@
$P.mappingControl = new DatasetControl({ $P.mappingControl = new DatasetControl({
urls : { 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" , prefix: "dsuseMgtMapping"
, prefixName: "마약류 제품 조회" , prefixName: "마약류 제품 조회"
@ -315,7 +316,7 @@
$P.mappingDtlControl = new DatasetControl({ $P.mappingDtlControl = new DatasetControl({
prefix: "dsuseMgtMapping" prefix: "dsuseMgtMapping"
, prefixName: "마약류 취급업체 조회" , prefixName: "폐기보고 확인 조회"
, keymapper: info => info ? info.mnfSeq : "" , keymapper: info => info ? info.mnfSeq : ""
, dataGetter: obj => obj.${infoPrefix}MappingDtl , dataGetter: obj => obj.${infoPrefix}MappingDtl
, infoSize: "xl" , infoSize: "xl"
@ -401,7 +402,8 @@
ajax.post({ 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({ , data: JSON.stringify({
dscdmngId: $P.formFields.get().dscdmngId, dscdmngId: $P.formFields.get().dscdmngId,
prgrsSttsCd: "21", prgrsSttsCd: "21",

Loading…
Cancel
Save