255 lines
8.6 KiB
Java
255 lines
8.6 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 nlib.col.service.CollectionVO;
|
|
import nlib.col.service.ReadService;
|
|
import nlib.info.service.InformService;
|
|
import nlib.restful.DataApi;
|
|
import nlib.restful.service.DataApiReqVO;
|
|
import nlib.restful.service.DataApiResVO;
|
|
import nlib.util.StringUtil;
|
|
|
|
@Service("readService")
|
|
public class ReadServiceImpl implements ReadService {
|
|
|
|
private static final Logger log = LoggerFactory.getLogger(ReadServiceImpl.class);
|
|
|
|
@Resource(name="readDAO")
|
|
private ReadDAO readDAO;
|
|
|
|
@Resource(name="informService")
|
|
private InformService informService;
|
|
|
|
/** RESTFul API 송수신 모듈 */
|
|
@Resource(name = "dataApi")
|
|
private DataApi dataApi;
|
|
|
|
/**
|
|
* 열람신청희망 가능 일자 목록을 조회한다.
|
|
*
|
|
* @param mbInfoId
|
|
* @return
|
|
*/
|
|
public List<HashMap<String, String>> listDates() {
|
|
return readDAO.listDates();
|
|
}
|
|
|
|
|
|
/**
|
|
* 열람을 신청한다.
|
|
*
|
|
* @param list
|
|
* @param mbInfoId
|
|
* @param mngOrgCd
|
|
* @return
|
|
*/
|
|
public List<CollectionVO> insertReadItems(List<CollectionVO> list, String mbInfoId, CollectionVO readVO) throws Exception {
|
|
|
|
if(list == null || list.size() < 1) {
|
|
log.error("insertReadItems > 열람 신청 대상 목록이 없습니다.");
|
|
return null;
|
|
}
|
|
if(readVO == null) {
|
|
log.error("insertReadItems > 매개변수 readVO는 null일 수 없습니다.");
|
|
return null;
|
|
}
|
|
|
|
if(StringUtil.isEmpty(mbInfoId)) {
|
|
log.error("insertReadItems > 사용자ID를 확인할 수 없습니다.");
|
|
return null;
|
|
}
|
|
|
|
if(StringUtil.isEmpty(readVO.getMngOrgCd())) {
|
|
log.error("insertReadItems > 관리문화원 코드를 확인할 수 없습니다.");
|
|
return null;
|
|
}
|
|
|
|
if(StringUtil.isEmpty(readVO.getHopeReqPridDtmFrom() )) {
|
|
log.error("insertReadItems > 방문희망일 시작일자를 확인할 수 없습니다.");
|
|
return null;
|
|
}
|
|
|
|
if(StringUtil.isEmpty(readVO.getHopeReqPridDtmTo() )) {
|
|
log.error("insertReadItems > 방문희망일 종료일자를 확인할 수 없습니다.");
|
|
return null;
|
|
}
|
|
|
|
if(readVO.getHopeReqPridDtmFrom().compareTo(readVO.getHopeReqPridDtmTo()) > 0) {
|
|
log.error("insertReadItems > 방문희망일 종료일자는 시작일자 이후이어야 합니다.");
|
|
return null;
|
|
}
|
|
|
|
// 해당 문화원의 업무시간 조회
|
|
HashMap<String, String> operation = informService.selectNCultureOpenTime(readVO.getMngOrgCd());
|
|
|
|
// API 호출
|
|
/*
|
|
mngOrgCd 문화원코드 O String SU01
|
|
mbInfoId 사용자아이디 O String "BDCCAF34CF8AA365C660ADB121CE6741
|
|
(ARIAUtil 암호화)"
|
|
jsonMasterId 자료번호목록 O String [{"masterId":"xxxx"}, {"masterId":"xxxb"},…]
|
|
hopeReqPridDtmFrom 희망열람기간시작일자 O String 202109071300
|
|
hopeReqPridDtmTo 희망열람기간종료일자 O String 202109101400
|
|
purpose 열람목적 String 열람목적
|
|
*/
|
|
DataApiReqVO reqVO = new DataApiReqVO("/uac/service/nlib/col/insertReserveItem", HttpMethod.POST);
|
|
reqVO.setMbInfoId(mbInfoId); // 통신 시, 암호화되어 송수신됨
|
|
reqVO.putInfoItem("mngOrgCd" , readVO.getMngOrgCd());
|
|
reqVO.putInfoItem("hopeReqPridDtmFrom", readVO.getHopeReqPridDtmFrom().replaceAll("-", "") + StringUtil.getString(operation.get("OPEN_TIME"), "0900").replaceAll(":", "").substring(0, 4));
|
|
reqVO.putInfoItem("hopeReqPridDtmTo" , readVO.getHopeReqPridDtmTo().replaceAll("-", "") + StringUtil.getString(operation.get("CLOSED_TIME"), "1800").replaceAll(":", "").substring(0, 4));
|
|
CollectionVO cVO = null;
|
|
DataApiResVO resVO = null;
|
|
String jsonMasterId = "";
|
|
|
|
for(int i=0; i<list.size(); i++) {
|
|
cVO = list.get(i);
|
|
if(StringUtil.isEmpty(cVO.getMasterId())) {
|
|
cVO.setResult("F-REQ-MASTERID", "자료ID 정보가 없습니다.");
|
|
continue;
|
|
}
|
|
jsonMasterId += (", {\"masterId\":" + "\"" + cVO.getMasterId() + "\"}");
|
|
|
|
}
|
|
|
|
if(StringUtil.isEmpty(jsonMasterId)) {
|
|
log.error("insertReadItems > 열람 신청 대상으로 생성된 목록이 없습니다.");
|
|
return null;
|
|
}
|
|
|
|
jsonMasterId = "[" + jsonMasterId.substring(1) + "]";
|
|
|
|
reqVO.putInfoItem("jsonMasterId", jsonMasterId);
|
|
resVO = dataApi.request(reqVO);
|
|
CollectionVO rVO = null;
|
|
cVO.setResult(resVO.getResultCode(), resVO.getResultMessage());
|
|
|
|
readVO.setResultCode(resVO.getResultCode());
|
|
readVO.setResultMessage(resVO.getResultMessage());
|
|
|
|
// 대출예약번호/일자 설정 (rsrvId)
|
|
if(StringUtil.startsWithIgnoreCase(resVO.getResultCode(), "S")) {
|
|
readVO.setHopeReqPridDtmFrom(StringUtil.formatDateStr(resVO.getInfoItem("hopeReqPridDtmFrom", ""),""));
|
|
readVO.setHopeReqPridDtmTo(StringUtil.formatDateStr(resVO.getInfoItem("hopeReqPridDtmTo", ""),""));
|
|
readVO.setRsrvId(resVO.getInfoItem("reqId", "")); // 열람신청번호
|
|
readVO.setRsrvId(resVO.getInfoItem("reqDd", "")); // 열람신청일자
|
|
readVO.setSelItems(resVO.getInfoItem("masterId")); // 자료번호
|
|
} else {
|
|
readVO.setRsrvId(null); // 열람신청번호
|
|
readVO.setRsrvId(null); // 열람신청일자
|
|
}
|
|
|
|
return list;
|
|
}
|
|
|
|
/**
|
|
* 사용자의 열람건이 존재하는 문화원 정보 목록을 조회한다.
|
|
*
|
|
* @param mbInfoId
|
|
* @return
|
|
*/
|
|
public List<HashMap<String, String>> listReadMngOrg(String mbInfoId) {
|
|
return readDAO.listReadMngOrg(mbInfoId);
|
|
}
|
|
|
|
/**
|
|
* 열람 목록 조회한다.
|
|
*
|
|
* @param searchVO
|
|
* @return
|
|
*/
|
|
public DataApiResVO listReadItems(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/col/listReserveItem", HttpMethod.GET);
|
|
reqVO.setMbInfoId(searchVO.getMbInfoId()); // 통신 시, 암호화되어 송수신됨
|
|
reqVO.setPageSize(searchVO.getPageSize());
|
|
reqVO.setPageIndex(searchVO.getPageIndex());
|
|
reqVO.putInfoItem("mngOrgCd", StringUtil.getString(searchVO.getMngOrgCd(), "KCCF")); // DDDDDDDDDDDDDDDDDDDd api 변경시까지 유지
|
|
reqVO.putInfoItem("reqStatusDivCd", searchVO.getReqStatusDivCd());
|
|
return dataApi.request(reqVO);
|
|
}
|
|
|
|
|
|
/**
|
|
* 열람신청을 취소한다.
|
|
*
|
|
* @param searchVO
|
|
* @return
|
|
*/
|
|
public DataApiResVO cancelReadItem(CollectionVO searchVO) {
|
|
|
|
String message = null;
|
|
|
|
if(searchVO == null || StringUtil.isEmpty(searchVO.getMbInfoId())) {
|
|
message = "로그인하신 후, 이용바랍니다.";
|
|
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.getReqId())) {
|
|
message = "취소할 방문열람신청번호 정보가 부적합합니다. 다시 요청하여 주시기 바랍니다.";
|
|
log.error("cancelRentItem > " + message);
|
|
return new DataApiResVO("E", message);
|
|
}
|
|
|
|
if(StringUtil.isEmpty(searchVO.getMasterId())) {
|
|
message = "취소할 자료정보 정보가 부적합합니다. 다시 요청하여 주시기 바랍니다.";
|
|
log.error("cancelRentItem > " + message);
|
|
return new DataApiResVO("E", message);
|
|
}
|
|
|
|
// API 호출
|
|
/*
|
|
mngOrgCd 문화원코드
|
|
mbInfoId 사용자아이디
|
|
reqId 열람신청번호
|
|
masterId 자료번호
|
|
*/
|
|
DataApiReqVO reqVO = new DataApiReqVO("/uac/service/nlib/col/deleteReserveItem", HttpMethod.POST);
|
|
reqVO.setMbInfoId(searchVO.getMbInfoId()); // 통신 시, 암호화되어 송수신됨
|
|
reqVO.putInfoItem("mngOrgCd", searchVO.getMngOrgCd());
|
|
reqVO.putInfoItem("reqId", searchVO.getReqId());
|
|
reqVO.putInfoItem("masterId", searchVO.getMasterId());
|
|
return dataApi.request(reqVO);
|
|
}
|
|
|
|
/**
|
|
* 사용자의 방문열람현황을 조회한다.
|
|
*
|
|
* @param mbInfoId
|
|
* @return
|
|
*/
|
|
public Map<String, String> getReadStats(String mbInfoId) {
|
|
return readDAO.getReadStats(mbInfoId);
|
|
}
|
|
|
|
}
|