235 lines
8.0 KiB
Java
235 lines
8.0 KiB
Java
package nlib.col.service.impl;
|
|
|
|
import java.util.HashMap;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.springframework.http.HttpMethod;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import com.fasterxml.jackson.databind.deser.std.ReferenceTypeDeserializer;
|
|
|
|
import nlib.col.service.CartService;
|
|
import nlib.col.service.CollectionVO;
|
|
import nlib.col.service.RentService;
|
|
import nlib.restful.DataApi;
|
|
import nlib.restful.service.DataApiReqVO;
|
|
import nlib.restful.service.DataApiResVO;
|
|
import nlib.restful.service.XmlConverter;
|
|
import nlib.util.StringUtil;
|
|
|
|
@Service("rentService")
|
|
public class RentServiceImpl implements RentService
|
|
{
|
|
private static final Logger log = LoggerFactory.getLogger(RentServiceImpl.class);
|
|
|
|
@Resource(name="rentDAO")
|
|
private RentDAO rentDAO;
|
|
|
|
@Resource(name="cartDAO")
|
|
private CartDAO cartDAO;
|
|
|
|
|
|
/** RESTFul API 송수신 모듈 */
|
|
@Resource(name = "dataApi")
|
|
private DataApi dataApi;
|
|
|
|
|
|
/**
|
|
* 사용자의 대출건이 존재하는 문화원 정보 목록을 조회한다.
|
|
*
|
|
* @param mbInfoId
|
|
* @return
|
|
*/
|
|
public List<HashMap<String, String>> listRentMngOrg(String mbInfoId) {
|
|
return rentDAO.listRentMngOrg(mbInfoId);
|
|
}
|
|
|
|
/**
|
|
* 대출 목록 조회한다.
|
|
*
|
|
* @param searchVO
|
|
* @return
|
|
*/
|
|
public DataApiResVO listRentItems(CollectionVO searchVO) {
|
|
|
|
if(searchVO == null || StringUtil.isEmpty(searchVO.getMbInfoId())) {
|
|
log.error("listRentItems > 대출 목록 조회 요청 정보가 없습니다.");
|
|
return new DataApiResVO("F", "회원정보가 부적합합니다.");
|
|
}
|
|
|
|
// API 호출
|
|
/*
|
|
mngOrgCd 문화원코드
|
|
mbInfoId 사용자아이디
|
|
rows 페이지크기(페이지당최대표출건수)
|
|
page 페이지번호
|
|
bookLtRvStatusCd 대출상태구분코드("": 전체, A:신청, B:대출준비완료, C:취소, W:대출중, R0:정상반납, R1:연체반납 P:연체)
|
|
*/
|
|
DataApiReqVO reqVO = new DataApiReqVO("/uac/service/nlib/rent/listRentItem", HttpMethod.GET);
|
|
reqVO.setMbInfoId(searchVO.getMbInfoId()); // 통신 시, 암호화되어 송수신됨
|
|
reqVO.setPageSize(searchVO.getPageSize());
|
|
reqVO.setPageIndex(searchVO.getPageIndex());
|
|
reqVO.putInfoItem("mngOrgCd", searchVO.getMngOrgCd());
|
|
reqVO.putInfoItem("bookLtRvStatusCd", searchVO.getBookLtRvStatusCd());
|
|
return dataApi.request(reqVO);
|
|
}
|
|
|
|
|
|
/**
|
|
* 대출(예약)신청을 취소한다.
|
|
*
|
|
* @param searchVO
|
|
* @return
|
|
*/
|
|
public DataApiResVO cancelRentItem(CollectionVO searchVO) {
|
|
|
|
String message = null;
|
|
|
|
if(searchVO == null || StringUtil.isEmpty(searchVO.getMbInfoId())) {
|
|
message = "대출(예약)신청 취소 요청 정보가 부적합합니다 (MbInfoId)";
|
|
log.error("cancelRentItem > " + message);
|
|
return new DataApiResVO("E", message);
|
|
}
|
|
|
|
if(StringUtil.isEmpty(searchVO.getMngOrgCd())) {
|
|
message = "문화원정보가 부적합합니다. 다시 요청하여 주시기 바랍니다.";
|
|
log.error("cancelRentItem > " + message);
|
|
return new DataApiResVO("E", message);
|
|
}
|
|
|
|
if(StringUtil.isEmpty(searchVO.getRsrvId())) {
|
|
message = "취소할 대출(예약)선청번호 정보가 부적합합니다. 다시 요청하여 주시기 바랍니다.";
|
|
log.error("cancelRentItem > " + message);
|
|
return new DataApiResVO("E", message);
|
|
}
|
|
|
|
// API 호출
|
|
/*
|
|
mngOrgCd 문화원코드
|
|
mbInfoId 사용자아이디
|
|
rsrvId 대출신청예약번호
|
|
*/
|
|
DataApiReqVO reqVO = new DataApiReqVO("/uac/service/nlib/rent/deleteRentItem", HttpMethod.POST);
|
|
reqVO.setMbInfoId(searchVO.getMbInfoId()); // 통신 시, 암호화되어 송수신됨
|
|
reqVO.putInfoItem("mngOrgCd", searchVO.getMngOrgCd());
|
|
reqVO.putInfoItem("rsrvId", searchVO.getRsrvId());
|
|
return dataApi.request(reqVO);
|
|
}
|
|
|
|
|
|
/**
|
|
* 대출을 신청한다.
|
|
*
|
|
* @param list
|
|
* @param mbInfoId
|
|
* @param mngOrgCd
|
|
* @return
|
|
*/
|
|
public List<CollectionVO> insertRentItems(List<CollectionVO> list, String mbInfoId, String mngOrgCd, boolean fromCart) throws Exception {
|
|
|
|
if(list == null || list.size() < 1) return null;
|
|
|
|
if(StringUtil.isEmpty(mbInfoId)) {
|
|
log.error("insertRentItems > 사용자ID를 확인할 수 없습니다.");
|
|
return null;
|
|
}
|
|
|
|
if(StringUtil.isEmpty(mngOrgCd)) {
|
|
log.error("insertRentItems > 관리문화원 코드를 확인할 수 없습니다.");
|
|
return null;
|
|
}
|
|
|
|
|
|
// API 호출
|
|
/*
|
|
mngOrgCd 문화원코드 O String SU01
|
|
mbInfoId 사용자아이디 O String "BDCCAF34CF8AA365C660ADB121CE6741
|
|
(ARIAUtil 암호화)"
|
|
masterId -> jsonMasterId 자료번호 : 다건 가능하여야 함 O String UR-013ABB95CCD84FDA9600CCAE97032C4D
|
|
|
|
*/
|
|
DataApiReqVO reqVO = new DataApiReqVO("/uac/service/nlib/rent/insertRentItem", HttpMethod.POST);
|
|
reqVO.setMbInfoId(mbInfoId); // 통신 시, 암호화되어 송수신됨
|
|
reqVO.putInfoItem("mngOrgCd", mngOrgCd);
|
|
CollectionVO cVO = null;
|
|
DataApiResVO resVO = null;
|
|
for(int i=0; i<list.size(); i++) {
|
|
cVO = list.get(i);
|
|
if(StringUtil.isEmpty(cVO.getMasterId())) {
|
|
cVO.setResult("F-REQ-MASTERID", "자료ID 정보가 없습니다.");
|
|
continue;
|
|
}
|
|
reqVO.putInfoItem("masterId", cVO.getMasterId());
|
|
resVO = dataApi.request(reqVO);
|
|
cVO.setResult(resVO.getResultCode(), resVO.getResultMessage());
|
|
|
|
// 대출예약번호/일자 설정 (rsrvId)
|
|
if(StringUtil.startsWithIgnoreCase(resVO.getResultCode(), "S")) {
|
|
cVO.setRsrvId(resVO.getInfoItem("rsrvId", ""));
|
|
cVO.setRsrvDd(StringUtil.formatDateStr(resVO.getInfoItem("rsrvDd", ""), ""));
|
|
cVO.setRsrvDivCd(resVO.getInfoItem("rsrvDivCd")); // 대출상태구분코드
|
|
if("1".equals(cVO.getRsrvDivCd())) cVO.setRsrvDivNm("대출신청");
|
|
else if("2".equals(cVO.getRsrvDivCd())) cVO.setRsrvDivNm("대출예약");
|
|
|
|
// 카트에서의 처리 여부 업데이트
|
|
if(fromCart) {
|
|
cVO.setMbInfoId(mbInfoId);
|
|
cVO.setCartProcDivCd("R"); // 대출신청완료
|
|
cVO.setModId(mbInfoId);
|
|
int retUpdateProc = cartDAO.changeCartProcDivCd(cVO);
|
|
log.debug("insertRentItems > retUpdateProc=" + retUpdateProc);
|
|
}
|
|
|
|
} else {
|
|
cVO.setRsrvId(null);
|
|
cVO.setRsrvDd(null);
|
|
}
|
|
|
|
}
|
|
|
|
return list;
|
|
}
|
|
|
|
/**
|
|
* 사용자의 대출현황을 조회한다.
|
|
*
|
|
* @param mbInfoId
|
|
* @return
|
|
*/
|
|
public Map<String, String> getRentStats(String mbInfoId) {
|
|
|
|
if(StringUtil.isEmpty(mbInfoId)) return null;
|
|
|
|
DataApiReqVO reqVO = new DataApiReqVO("/uac/service/nlib/col/getLentReqStatCnt", HttpMethod.GET);
|
|
reqVO.setMbInfoId(mbInfoId); // 통신 시, 암호화되어 송수신됨
|
|
DataApiResVO resVO = dataApi.request(reqVO);
|
|
Map<String, String> retMap = new HashMap<String, String>();
|
|
|
|
if(StringUtil.isNotEmpty(resVO.getResultCode()) && resVO.getResultCode().charAt(0) == 'S') {
|
|
|
|
retMap.put("lentAppCnt" , resVO.getInfoItem("lentAppCnt" , "0")); // 대출-신청
|
|
retMap.put("lentResvCnt" , resVO.getInfoItem("lentResvCnt" , "0")); // 대출-예약
|
|
retMap.put("lentCancelCnt", resVO.getInfoItem("lentCancelCnt", "0")); // 대출-취소
|
|
retMap.put("lentCnt" , resVO.getInfoItem("lentCnt" , "0")); // 대출-대출중
|
|
retMap.put("lentRtnCnt" , resVO.getInfoItem("lentRtnCnt" , "0")); // 대출-반납
|
|
retMap.put("lentOverCnt" , resVO.getInfoItem("lentOverCnt" , "0")); // 대출-연체
|
|
|
|
retMap.put("reqAppCnt" , resVO.getInfoItem("reqAppCnt" , "0")); // 열람현황-신청
|
|
retMap.put("reqCancelCnt" , resVO.getInfoItem("reqCancelCnt" , "0")); // 열람현황-취소
|
|
retMap.put("reqOkCnt" , resVO.getInfoItem("reqOkCnt" , "0")); // 열람현황-승인
|
|
retMap.put("reqCompCnt" , resVO.getInfoItem("reqCompCnt" , "0")); // 열람현황-반려
|
|
|
|
} else {
|
|
|
|
retMap.put("resultMessage" , resVO.getResultMessage());
|
|
}
|
|
|
|
return retMap;
|
|
}
|
|
|
|
} |