feat: JSP -> 서버호출로 변경

dev
Jonguk. Lim 4 months ago
parent c4daf2d734
commit 8806ee3a71

@ -283,6 +283,21 @@ public class NimsApiRequest {
*/
private String t = StringUtils.EMPTY;
/**
*
*/
private String prdValidDe;
/**
*
*/
private String mnfNo;
/**
*
*/
private String mnfSeqNo;
/**
* <pre>
*

@ -1,12 +1,10 @@
package cokr.xit.adds.nims.web;
import java.io.File;
import java.net.http.HttpResponse;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.function.Consumer;
import javax.annotation.Resource;
@ -33,24 +31,20 @@ import cokr.xit.adds.cmmn.hwp.format.DisposeProcessDetails;
import cokr.xit.adds.cmmn.hwp.format.DisposeResultReport;
import cokr.xit.adds.nims.DsuseMgtDocQuery;
import cokr.xit.adds.nims.DsuseMgtReceiptQuery;
import cokr.xit.adds.nims.ProductQuery;
import cokr.xit.adds.nims.service.DsuseMgtDocService;
import cokr.xit.adds.nims.service.DsuseMgtReceiptService;
import cokr.xit.applib.Print;
import cokr.xit.applib.PrintOption;
import cokr.xit.applib.ogdp.OgdpQuery;
import cokr.xit.applib.ogdp.service.bean.DefaultOgdpBean;
import cokr.xit.base.code.CommonCode;
import cokr.xit.base.file.FileInfo;
import cokr.xit.base.file.FileInfo.Relation;
import cokr.xit.base.file.service.FileQuery;
import cokr.xit.base.file.service.FileService;
import cokr.xit.base.user.DepartmentQuery;
import cokr.xit.base.user.service.SigunguDepartmentService;
import cokr.xit.base.web.ApplicationController;
import cokr.xit.foundation.data.DataObject;
import cokr.xit.foundation.data.JSON;
import cokr.xit.foundation.web.WebClient;
import net.minidev.json.JSONObject;
import net.minidev.json.parser.ParseException;
@Controller
@RequestMapping(
@ -67,6 +61,12 @@ public class AddsNimsController extends ApplicationController {
@Value("${app.inf.nims.api.bsshInfo}")
private String bsshInfoEndpoint;
@Value("${app.inf.nims.api.productInfo}")
private String productInfoEndpoint;
@Value("${app.inf.nims.api.seqInfo}")
private String productSeqInfoEndpoint;
@Value("${app.inf.nims.api.productAndseqInfo}")
private String productAndseqInfoEndpoint;
@ -484,72 +484,27 @@ public class AddsNimsController extends ApplicationController {
//-------------------------------------------------------------------------------------------------
//TODO : 서버통신으로 변경 할것
@RequestMapping(value = "/getNimsProductInfoKdAndMnfSeqInfo.do", name="제품 & 시리얼번호 검색", produces = "application/json;charset=UTF-8")
public @ResponseBody ApiBaseResponse<List<JSONObject>> getNimsProductInfoKdAndMnfSeqInfo(@ModelAttribute NimsApiRequest.ProductInfoReq dto) throws JsonProcessingException, ParseException {
String rslt = ApiUtil.callNimsApi(apiHost + productAndseqInfoEndpoint, dto);
return json.parse(rslt, new TypeReference<>() {});
}
@RequestMapping(value = "/getNimsBsshInfoSt.do", name="업체(마약류취급자) 검색", produces = "application/json;charset=UTF-8")
public @ResponseBody ApiBaseResponse<List<JSONObject>> getNimsBsshInfoSt(@ModelAttribute NimsApiRequest.BsshInfoReq dto) throws JsonProcessingException, ParseException {
String rslt = ApiUtil.callNimsApi(apiHost + bsshInfoEndpoint, dto);
return json.parse(rslt, new TypeReference<>() {});
}
//TODO : 서버통신으로 변경 할것
@RequestMapping(name="업체(마약류취급자) 검색", value="")
public ModelAndView getbsshList2(ProductQuery query) throws JsonProcessingException, ParseException {
ModelAndView mav = new ModelAndView();
JSON json = new JSON();
System.out.println("취급자 조회 : " + query.getSchProductCd());
mav.setViewName("jsonView");
String sMethod = "POST";
DataObject dataObject = new DataObject();
//dataObject.put("k","");
dataObject.put("fg","1");
dataObject.put("pg","1");
dataObject.put("ymd","");
dataObject.put("fg2","");
//query.setSchProductCd("8806578045922");
if(!isEmpty(query.getSchProductCd())) dataObject.put("p",query.getSchProductCd());
if(!isEmpty(query.getSchProductNm())) dataObject.put("pn",query.getSchProductNm());
dataObject.put("dbSkipYn","N");
dataObject.put("userId","suji");
Consumer<WebClient.Request> configurer = (request) -> {
request.uri(apiHost + "/api/biz/nims/v1/getNimsBsshInfoSt")
.contentType(WebClient.Request.ContentType.JSON)
.bodyData(json.stringify(dataObject));
};
HttpResponse<String> hresp = null;
if(sMethod.equals("POST")) {
hresp = new WebClient()
.post(configurer);
} else if(sMethod.equals("GET")) {
hresp = new WebClient()
.get(configurer);
}
String resBody = hresp.body();
ApiBaseResponse<List<JSONObject>> jsonData = json.parse(resBody, new TypeReference<>() {});
// ApiBaseResponse(code=400, message=상품번호 또는 상품명은 필수 입니다, data=null, totalCount=0, success=false, responseTime=2024-06-12 15:35:24)
if(!jsonData.getSuccess()){
// error 처리
// throw new Exception(data.getMessage());
}
List<JSONObject> data = jsonData.getData();
System.out.println(resBody);
@RequestMapping(value = "/getNimsProductInfoKd.do", name="제품 검색", produces = "application/json;charset=UTF-8")
public @ResponseBody ApiBaseResponse<List<JSONObject>> getNimsProductInfoKd(@ModelAttribute NimsApiRequest.ProductInfoReq dto) throws JsonProcessingException, ParseException {
String rslt = ApiUtil.callNimsApi(apiHost + productInfoEndpoint, dto);
return json.parse(rslt, new TypeReference<>() {});
}
ModelAndView result = new ModelAndView("jsonView");
result.addObject("productMainList", data);
@RequestMapping(value = "/getNimsProductSeqInfo.do", name="제품 시리얼번호 검색", produces = "application/json;charset=UTF-8")
public @ResponseBody ApiBaseResponse<List<JSONObject>> getNimsProductSeqInfo(@ModelAttribute NimsApiRequest.MnfSeqInfoReq dto) throws JsonProcessingException, ParseException {
String rslt = ApiUtil.callNimsApi(apiHost + productSeqInfoEndpoint, dto);
return json.parse(rslt, new TypeReference<>() {});
}
return result;
@RequestMapping(value = "/getNimsProductInfoKdAndMnfSeqInfo.do", name="제품 & 시리얼번호 검색", produces = "application/json;charset=UTF-8")
public @ResponseBody ApiBaseResponse<List<JSONObject>> getNimsProductInfoKdAndMnfSeqInfo(@ModelAttribute NimsApiRequest.ProductInfoReq dto) throws JsonProcessingException, ParseException {
String rslt = ApiUtil.callNimsApi(apiHost + productAndseqInfoEndpoint, dto);
return json.parse(rslt, new TypeReference<>() {});
}
}

@ -101,8 +101,19 @@
**************************************************************************/
$P.control = new DatasetControl({
urls : {
// FIXME: 2024-07-05 제품검색 완료후 교체
load : wctx.url("/adds/nims/getNimsProductInfoKdAndMnfSeqInfo.do"),
<%--load : '<c:url value="${apiHost}/api/biz/nims/v1/getNimsProductInfoKdAndMnfSeqInfo" />',--%>
//load : wctx.url("/adds/nims/getNimsProductInfoKd.do"), // 제품 검색
//load : wctx.url("/adds/nims/getNimsProductSeqInfo.do"), // 시리얼번호 검색
/*
{
fg: "1", // 1-제조번호, 2-시리얼번호
p: "717726", //제품코드
t: "", //제조번호 또는 시리얼번호,
userId: "${currentUser.account}"
}
*/
}
, prefix: "productMain"
, prefixName: "마약류 제품 조회"

Loading…
Cancel
Save