결재원복복
This commit is contained in:
@@ -1767,6 +1767,152 @@ public class ApprovalService {
|
||||
|
||||
// Amaranth10 그룹 시퀀스 (상신 Body 구성용)
|
||||
private static final String GROUP_SEQ = "gcmsAmaranth40578";
|
||||
private static final String AMARANTH_BASE_URL = "https://erp.rps-korea.com";
|
||||
|
||||
/**
|
||||
* Amaranth10 전자결재 SSO URL 생성 (B방식 - 팝업 직접 오픈)
|
||||
* 1단계: 인증 토큰 발급 (api99u01A01)
|
||||
* 2단계: SSO 호출 (api99u01A02) → fullUrl 획득
|
||||
*
|
||||
* @param request HttpServletRequest (세션에서 사용자 정보 추출)
|
||||
* @param paramMap targetType, targetObjId, approvalTitle, outProcessCode, formId 등
|
||||
* @return fullUrl이 포함된 JSON 문자열
|
||||
*/
|
||||
public String getAmaranthSsoUrl(HttpServletRequest request, Map paramMap){
|
||||
try {
|
||||
HttpSession session = request.getSession();
|
||||
PersonBean person = (PersonBean)session.getAttribute(Constants.PERSON_BEAN);
|
||||
if(person == null){
|
||||
return "{\"resultCode\":-1,\"resultMsg\":\"세션이 만료되었습니다. 다시 로그인하세요.\"}";
|
||||
}
|
||||
|
||||
String empSeq = CommonUtils.checkNull(person.getEmpseq());
|
||||
if(empSeq.isEmpty()){
|
||||
return "{\"resultCode\":-1,\"resultMsg\":\"empSeq 정보가 없습니다. 관리자에게 문의하세요.\"}";
|
||||
}
|
||||
|
||||
// 파라미터 추출
|
||||
String targetType = CommonUtils.checkNull(paramMap.get("targetType"));
|
||||
String targetObjId = CommonUtils.checkNull(paramMap.get("targetObjId"));
|
||||
String approvalTitle = CommonUtils.checkNull(paramMap.get("approvalTitle"));
|
||||
String outProcessCode = CommonUtils.checkNull(paramMap.get("outProcessCode"));
|
||||
String formId = CommonUtils.checkNull(paramMap.get("formId"));
|
||||
String compSeq = CommonUtils.checkNull(paramMap.get("compSeq"), "1000");
|
||||
String deptSeq = CommonUtils.checkNull(paramMap.get("deptSeq"));
|
||||
|
||||
// approKey 생성: "UB_" + UUID (외부시스템과 결재문서 매핑 키)
|
||||
String approKey = "UB_" + java.util.UUID.randomUUID().toString();
|
||||
|
||||
System.out.println("=== Amaranth SSO URL 생성 ===");
|
||||
System.out.println("empSeq: " + empSeq);
|
||||
System.out.println("targetType: " + targetType + ", targetObjId: " + targetObjId);
|
||||
System.out.println("outProcessCode: " + outProcessCode + ", formId: " + formId);
|
||||
System.out.println("approKey: " + approKey);
|
||||
|
||||
// API 호출
|
||||
com.pms.api.AmaranthApprovalApiClient apiClient = new com.pms.api.AmaranthApprovalApiClient();
|
||||
String apiResponse = apiClient.getSsoUrl(
|
||||
AMARANTH_BASE_URL, empSeq, outProcessCode, formId,
|
||||
approKey, approvalTitle, "W", compSeq, deptSeq
|
||||
);
|
||||
|
||||
System.out.println("SSO API 응답: " + apiResponse);
|
||||
|
||||
// 응답에서 fullUrl 추출하여 approKey와 함께 반환
|
||||
String fullUrl = extractJsonStringValue(apiResponse, "fullUrl");
|
||||
String resultCode = extractJsonStringValue(apiResponse, "resultCode");
|
||||
|
||||
if("0".equals(resultCode) && !fullUrl.isEmpty()){
|
||||
StringBuilder result = new StringBuilder();
|
||||
result.append("{\"resultCode\":0,\"resultMsg\":\"SUCCESS\",\"resultData\":{");
|
||||
result.append("\"fullUrl\":\"").append(escapeJsonValue(fullUrl)).append("\",");
|
||||
result.append("\"approKey\":\"").append(escapeJsonValue(approKey)).append("\",");
|
||||
result.append("\"targetType\":\"").append(escapeJsonValue(targetType)).append("\",");
|
||||
result.append("\"targetObjId\":\"").append(escapeJsonValue(targetObjId)).append("\"");
|
||||
result.append("}}");
|
||||
return result.toString();
|
||||
} else {
|
||||
String resultMsg = extractJsonStringValue(apiResponse, "resultMsg");
|
||||
return "{\"resultCode\":-1,\"resultMsg\":\"SSO URL 생성 실패: " + escapeJsonValue(resultMsg) + "\"}";
|
||||
}
|
||||
|
||||
} catch(Exception e){
|
||||
System.err.println("Amaranth SSO URL 생성 오류: " + e.getMessage());
|
||||
e.printStackTrace();
|
||||
return "{\"resultCode\":-1,\"resultMsg\":\"" + escapeJsonValue(e.getMessage()) + "\"}";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Amaranth10 전자결재 콜백 처리
|
||||
* 결재 이벤트(상신/진행/종결/반려/삭제 등) 발생 시 Amaranth10에서 호출
|
||||
*
|
||||
* @param paramMap 콜백 파라미터 (processId, approkey, docId, docSts, userId, formId 등)
|
||||
* @return 처리 결과 JSON
|
||||
*/
|
||||
public String handleAmaranthApprovalCallback(Map paramMap){
|
||||
String approkey = CommonUtils.checkNull(paramMap.get("approkey"));
|
||||
String docId = CommonUtils.checkNull(paramMap.get("docId"));
|
||||
String docSts = CommonUtils.checkNull(paramMap.get("docSts"));
|
||||
String docTitle = CommonUtils.checkNull(paramMap.get("docTitle"));
|
||||
String userId = CommonUtils.checkNull(paramMap.get("userId"));
|
||||
String processId = CommonUtils.checkNull(paramMap.get("processId"));
|
||||
|
||||
System.out.println("=== Amaranth 결재 콜백 수신 ===");
|
||||
System.out.println("approkey: " + approkey);
|
||||
System.out.println("docId: " + docId);
|
||||
System.out.println("docSts: " + docSts + " (" + getDocStsName(docSts) + ")");
|
||||
System.out.println("docTitle: " + docTitle);
|
||||
System.out.println("userId: " + userId);
|
||||
System.out.println("processId: " + processId);
|
||||
System.out.println("전체 파라미터: " + paramMap);
|
||||
|
||||
// TODO: approkey로 우리 시스템의 대상 문서를 찾아서 상태 업데이트
|
||||
// 예: approval 테이블에서 approkey로 조회 → targetObjId의 상태 변경
|
||||
|
||||
return "{\"resultCode\":\"SUCCESS\",\"resultMessage\":\"성공하였습니다.\"}";
|
||||
}
|
||||
|
||||
/**
|
||||
* Amaranth10 결재작성 시 본문 내용 조회 (Binding WebAPI / WebAPI)
|
||||
* 결재 작성 화면이 열릴 때 Amaranth10에서 호출
|
||||
*
|
||||
* @param paramMap approkey, formId, docId, userId, empSeq 등
|
||||
* @return 제목/본문 JSON
|
||||
*/
|
||||
public String getAmaranthApprovalContents(Map paramMap){
|
||||
String approkey = CommonUtils.checkNull(paramMap.get("approkey"));
|
||||
String docId = CommonUtils.checkNull(paramMap.get("docId"));
|
||||
|
||||
System.out.println("=== Amaranth 결재 본문 조회 ===");
|
||||
System.out.println("approkey: " + approkey);
|
||||
System.out.println("docId: " + docId);
|
||||
System.out.println("전체 파라미터: " + paramMap);
|
||||
|
||||
// TODO: approkey로 대상 문서 데이터를 조회하여 본문 HTML 또는 Binding JSON 구성
|
||||
// Binding WebAPI 방식일 경우 ITEMS/TABLE 구조의 JSON 반환
|
||||
|
||||
StringBuilder result = new StringBuilder();
|
||||
result.append("{\"resultCode\":0,\"resultMessage\":\"SUCCESS\",\"resultData\":{");
|
||||
result.append("\"title\":\"결재 문서\",");
|
||||
result.append("\"contents\":\"<p>본문 내용</p>\"");
|
||||
result.append("}}");
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 결재 상태코드 → 한글명 변환
|
||||
*/
|
||||
private String getDocStsName(String docSts){
|
||||
if("10".equals(docSts)) return "임시보관";
|
||||
if("20".equals(docSts)) return "상신";
|
||||
if("30".equals(docSts)) return "진행";
|
||||
if("40".equals(docSts)) return "발신종결";
|
||||
if("90".equals(docSts)) return "종결";
|
||||
if("100".equals(docSts)) return "반려";
|
||||
if("110".equals(docSts)) return "보류";
|
||||
return "기타(" + docSts + ")";
|
||||
}
|
||||
|
||||
public Map checkApprovalComplete(Map paramMap){
|
||||
Map<String,Object> resultMap = new HashMap();
|
||||
|
||||
Reference in New Issue
Block a user