커밋 APi 수정
This commit is contained in:
@@ -1113,6 +1113,121 @@ public class ApprovalService {
|
||||
return CommonUtils.toUpperCaseMapKey(resultMap);
|
||||
}
|
||||
|
||||
/**
|
||||
* Amaranth10 전자결재 건수 조회
|
||||
* 세션에서 empseq를 가져와 서버 인증으로 직접 결재함 조회
|
||||
* @param request
|
||||
* @param paramMap
|
||||
* @return
|
||||
*/
|
||||
public Map getAmaranthApprovalCnt(HttpServletRequest request, Map paramMap){
|
||||
Map<String,Object> resultMap = new HashMap();
|
||||
|
||||
try{
|
||||
// 파라미터에서 empseq 가져오기 (header.jsp에서 전달)
|
||||
String empSeq = CommonUtils.checkNull(paramMap.get("empseq"));
|
||||
String userId = CommonUtils.checkNull(paramMap.get("userId"));
|
||||
String compSeq = "1000"; // 회사 시퀀스
|
||||
|
||||
System.out.println("=== Amaranth 결재 건수 조회 ===");
|
||||
System.out.println("userId: " + userId);
|
||||
System.out.println("empSeq: " + empSeq);
|
||||
|
||||
// empSeq가 비어있으면 에러 처리
|
||||
if(empSeq == null || empSeq.isEmpty()){
|
||||
System.err.println("empSeq가 비어있습니다. LoginId 업데이트 배치를 먼저 실행하세요.");
|
||||
resultMap.put("CNT", "0");
|
||||
return CommonUtils.toUpperCaseMapKey(resultMap);
|
||||
}
|
||||
|
||||
// Amaranth10 결재함 조회 (서버 인증 - 인증 토큰 불필요)
|
||||
com.pms.api.AmaranthApprovalApiClient apiClient = new com.pms.api.AmaranthApprovalApiClient();
|
||||
String baseUrl = "https://erp.rps-korea.com";
|
||||
|
||||
String boxListJson = apiClient.getApprovalBoxListDirect(baseUrl, empSeq, compSeq);
|
||||
|
||||
// 미결 건수 추출 (boxCode = "20")
|
||||
int pendingCnt = extractPendingCount(boxListJson);
|
||||
|
||||
resultMap.put("CNT", String.valueOf(pendingCnt));
|
||||
resultMap.put("AMARANTH_CNT", String.valueOf(pendingCnt));
|
||||
|
||||
System.out.println("Amaranth 미결 건수: " + pendingCnt);
|
||||
|
||||
}catch(Exception e){
|
||||
System.err.println("Amaranth 결재 건수 조회 오류: " + e.getMessage());
|
||||
e.printStackTrace();
|
||||
resultMap.put("CNT", "0");
|
||||
resultMap.put("ERROR", e.getMessage());
|
||||
}
|
||||
|
||||
return CommonUtils.toUpperCaseMapKey(resultMap);
|
||||
}
|
||||
|
||||
/**
|
||||
* JSON에서 미결 건수 추출 (boxCode = "20" 미결문서)
|
||||
* 응답 구조: resultData.result.boxList[].boxCode, docCnt
|
||||
*/
|
||||
private int extractPendingCount(String jsonResponse){
|
||||
int count = 0;
|
||||
|
||||
try {
|
||||
System.out.println("=== 미결 건수 파싱 시작 ===");
|
||||
System.out.println("응답 내용: " + jsonResponse);
|
||||
|
||||
// boxCode "20" 찾기 (미결문서)
|
||||
// "boxCode":"20" 또는 "boxCode": "20" 형태
|
||||
int searchFrom = 0;
|
||||
while(true) {
|
||||
int boxCodeIndex = jsonResponse.indexOf("\"boxCode\"", searchFrom);
|
||||
if(boxCodeIndex == -1) break;
|
||||
|
||||
// "boxCode" 뒤의 값 추출
|
||||
int colonIndex = jsonResponse.indexOf(":", boxCodeIndex + 9);
|
||||
if(colonIndex == -1) break;
|
||||
|
||||
int valueStart = jsonResponse.indexOf("\"", colonIndex);
|
||||
if(valueStart == -1) break;
|
||||
|
||||
int valueEnd = jsonResponse.indexOf("\"", valueStart + 1);
|
||||
if(valueEnd == -1) break;
|
||||
|
||||
String boxCodeValue = jsonResponse.substring(valueStart + 1, valueEnd);
|
||||
|
||||
if("20".equals(boxCodeValue)) {
|
||||
// boxCode "20" 객체의 시작 위치 찾기 (이전 { 찾기)
|
||||
int objStart = jsonResponse.lastIndexOf("{", boxCodeIndex);
|
||||
if(objStart >= 0) {
|
||||
String objStr = jsonResponse.substring(objStart, boxCodeIndex);
|
||||
|
||||
// docCnt 추출
|
||||
int docCntIndex = objStr.indexOf("\"docCnt\"");
|
||||
if(docCntIndex >= 0) {
|
||||
int dcColonIndex = objStr.indexOf(":", docCntIndex + 8);
|
||||
int dcValueStart = objStr.indexOf("\"", dcColonIndex);
|
||||
int dcValueEnd = objStr.indexOf("\"", dcValueStart + 1);
|
||||
|
||||
if(dcValueStart >= 0 && dcValueEnd > dcValueStart) {
|
||||
String docCntStr = objStr.substring(dcValueStart + 1, dcValueEnd);
|
||||
count = Integer.parseInt(docCntStr.trim());
|
||||
System.out.println("미결문서(boxCode=20) docCnt: " + count);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
searchFrom = valueEnd + 1;
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
System.err.println("미결 건수 추출 오류: " + e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
public ArrayList getApprovalLine(HttpServletRequest request, Map paramMap){
|
||||
ArrayList<HashMap<String,Object>> resultList = new ArrayList();
|
||||
SqlSession sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
||||
|
||||
Reference in New Issue
Block a user