feat: '진행현황 관리' 페이지에서 등록 또는 수정 시 '기준코드' 목록 불러오는 API 추가
parent
79c62396f3
commit
baff901cee
|
|
@ -112,4 +112,42 @@ public class AdminCommitteeController extends BaseController {
|
|||
}
|
||||
|
||||
|
||||
@Operation(
|
||||
summary = "'진행현황 관리' 페이지에서 등록 또는 수정 시 '기준코드' 목록 불러오는 API",
|
||||
description = "관리자 단에서 '위원회관리' > '진행현황 관리' 페이지에서 하단 '등록' 버튼 누른 후 '기준코드'에서 보여질 기준코드 목록 불러오는 API",
|
||||
tags = {"AdminCommitteeController"}
|
||||
)
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(responseCode = "200", description = "조회 성공")
|
||||
})
|
||||
@GetMapping(value = "/progress-status/standard-code-api/list")
|
||||
public ResultVO getCommitteeProgressStatusStandardCodeApiList(
|
||||
HttpServletRequest request,
|
||||
@AuthenticationPrincipal LoginVO user
|
||||
)
|
||||
throws Exception {
|
||||
|
||||
ResultVO resultVO = new ResultVO();
|
||||
|
||||
try {
|
||||
resultVO = adminCommitteeProgressStatusService.getCommitteeProgressStatusStandardCodeApiList(resultVO, request, user);
|
||||
} catch (Exception e) {
|
||||
resultVO.setResultCode(ResponseCode.FAILED.getCode());
|
||||
resultVO.setResultMessage(e.getMessage());
|
||||
}
|
||||
|
||||
|
||||
System.out.println(
|
||||
"\n--------------------------------------------------------------\n" +
|
||||
request.getRequestURI() + " OUT:" +
|
||||
"\n--------------------------------------------------------------\n" +
|
||||
"resultVO.toString():" + "\n" +
|
||||
resultVO.toString() + "\n" +
|
||||
"\n--------------------------------------------------------------\n"
|
||||
);
|
||||
|
||||
return resultVO;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,5 +15,7 @@ public interface AdminCommitteeProgressStatusService {
|
|||
public ResultVO deleteCommitteeProgressStatus(ResultVO resultVO, HttpServletRequest request, LoginVO user, Long drftSeq) throws Exception;
|
||||
|
||||
public ResultVO getCommitteeProgressStatusDetail(ResultVO resultVO, HttpServletRequest request, LoginVO user, Long drftSeq) throws Exception;
|
||||
public ResultVO getCommitteeProgressStatusStandardCodeApiList(ResultVO resultVO, HttpServletRequest request, LoginVO user) throws Exception;
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -17,12 +17,17 @@ import org.egovframe.rte.fdl.cmmn.EgovAbstractServiceImpl;
|
|||
import org.egovframe.rte.ptl.mvc.tags.ui.pagination.PaginationInfo;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.json.simple.JSONArray;
|
||||
import org.json.simple.JSONObject;
|
||||
import org.json.simple.parser.JSONParser;
|
||||
|
||||
@Service("adminCommitteeProgressStatusService")
|
||||
@RequiredArgsConstructor
|
||||
public class AdminCommitteeProgressStatusServiceImpl extends EgovAbstractServiceImpl implements AdminCommitteeProgressStatusService {
|
||||
|
|
@ -192,12 +197,12 @@ public class AdminCommitteeProgressStatusServiceImpl extends EgovAbstractService
|
|||
@Override
|
||||
public ResultVO deleteCommitteeProgressStatus(ResultVO resultVO, HttpServletRequest request, LoginVO user, Long cmtSeq) throws Exception {
|
||||
System.out.println(
|
||||
"\n--------------------------------------------------------------\n" +
|
||||
request.getRequestURI() + " IN:" +
|
||||
"\n--------------------------------------------------------------\n" +
|
||||
"cmtSeq:" + "\n" +
|
||||
cmtSeq + "\n" +
|
||||
"\n--------------------------------------------------------------\n"
|
||||
"\n--------------------------------------------------------------\n" +
|
||||
request.getRequestURI() + " IN:" +
|
||||
"\n--------------------------------------------------------------\n" +
|
||||
"cmtSeq:" + "\n" +
|
||||
cmtSeq + "\n" +
|
||||
"\n--------------------------------------------------------------\n"
|
||||
);
|
||||
|
||||
|
||||
|
|
@ -224,14 +229,14 @@ public class AdminCommitteeProgressStatusServiceImpl extends EgovAbstractService
|
|||
@Override
|
||||
public ResultVO getCommitteeProgressStatusDetail(ResultVO resultVO, HttpServletRequest request, LoginVO user, Long drftSeq) throws Exception {
|
||||
System.out.println(
|
||||
"\n--------------------------------------------------------------\n" +
|
||||
request.getRequestURI() + " IN:" +
|
||||
"\n--------------------------------------------------------------\n" +
|
||||
"user.getEmail():" + "\n" +
|
||||
user.getEmail() + "\n" +
|
||||
"drftSeq:" + "\n" +
|
||||
drftSeq + "\n" +
|
||||
"\n--------------------------------------------------------------\n"
|
||||
"\n--------------------------------------------------------------\n" +
|
||||
request.getRequestURI() + " IN:" +
|
||||
"\n--------------------------------------------------------------\n" +
|
||||
"user.getEmail():" + "\n" +
|
||||
user.getEmail() + "\n" +
|
||||
"drftSeq:" + "\n" +
|
||||
drftSeq + "\n" +
|
||||
"\n--------------------------------------------------------------\n"
|
||||
);
|
||||
|
||||
Map<String, Object> item = tnCmtDraftRepository.getCommitteeProgressStatusDetail(drftSeq);
|
||||
|
|
@ -245,4 +250,99 @@ public class AdminCommitteeProgressStatusServiceImpl extends EgovAbstractService
|
|||
return resultVO;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResultVO getCommitteeProgressStatusStandardCodeApiList(ResultVO resultVO, HttpServletRequest request, LoginVO user) throws Exception {
|
||||
|
||||
System.out.println("\n--------------------------------------------------------------\n" +
|
||||
request.getRequestURI() + " IN:" +
|
||||
"\n--------------------------------------------------------------\n" +
|
||||
"user.getEmail():" + "\n" +
|
||||
user.getEmail() + "\n" +
|
||||
"\n--------------------------------------------------------------\n");
|
||||
long startTime = System.currentTimeMillis();
|
||||
List<Map<String, Object>> standardCodeList = tnCmtDraftRepository.getCommitteeProgressStatusStandardCodeApiList();
|
||||
Map<Integer, List<Map<String, Object>>> nodeMap = new HashMap<>();
|
||||
|
||||
// nodeMap 초기화
|
||||
for (int i = 1; i <= 6; i++) {
|
||||
nodeMap.put(i, new ArrayList<>());
|
||||
}
|
||||
|
||||
// docLevel 별로 데이터 분류
|
||||
for (Map<String, Object> standardCode : standardCodeList) {
|
||||
int nDocLevel = (int) standardCode.get("doc_level");
|
||||
nodeMap.get(nDocLevel).add(standardCode);
|
||||
}
|
||||
|
||||
JSONArray items = buildJsonTree(nodeMap, 1, null); // 재귀 호출 시작 (루트 노드부터)
|
||||
|
||||
Map<String, Object> dto = new HashMap<>();
|
||||
dto.put("items", items);
|
||||
resultVO.setResult(dto);
|
||||
resultVO.setResultCode(ResponseCode.SUCCESS.getCode());
|
||||
resultVO.setResultMessage(ResponseCode.SUCCESS.getMessage());
|
||||
|
||||
long endTime = System.currentTimeMillis();
|
||||
long elapsedTime = endTime - startTime;
|
||||
System.out.println("처리 시간: " + elapsedTime + "ms");
|
||||
|
||||
return resultVO;
|
||||
}
|
||||
|
||||
|
||||
private JSONArray buildJsonTree(Map<Integer, List<Map<String, Object>>> nodeMap, int docLevel, Integer upperParentgroupSeq) {
|
||||
JSONArray items = new JSONArray();
|
||||
List<Map<String, Object>> currentNodes = nodeMap.get(docLevel);
|
||||
|
||||
for (Map<String, Object> node : currentNodes) {
|
||||
Integer groupSeq = (Integer) node.get("group_seq");
|
||||
Integer parentGroupSeq = (Integer) node.get("parent_group_seq");
|
||||
JSONObject item = new JSONObject();
|
||||
if( upperParentgroupSeq == null || upperParentgroupSeq.equals( parentGroupSeq) ) {
|
||||
String kcscCd = (String)node.get("kcsc_cd");
|
||||
String groupFullCd = (String) node.get("group_full_cd");
|
||||
item.put("docLevel", node.get("doc_level"));
|
||||
item.put("groupTitle", makeCode(kcscCd, groupFullCd, docLevel));
|
||||
item.put("groupNm", node.get("group_nm"));
|
||||
item.put("groupSeq", groupSeq);
|
||||
if (nodeMap.containsKey(docLevel + 1)) { // 자식 노드 존재 여부 확인
|
||||
item.put("children", buildJsonTree(nodeMap, docLevel + 1, groupSeq)); // 재귀 호출
|
||||
} else {
|
||||
item.put("children", new JSONArray());
|
||||
}
|
||||
|
||||
items.add(item);
|
||||
}
|
||||
}
|
||||
|
||||
return items;
|
||||
}
|
||||
|
||||
private String makeCode(String kcscCd, String groupFullCd, int docLevel) {
|
||||
if( docLevel < 3 ) {
|
||||
int codeLength = groupFullCd.length();
|
||||
String firstWord = kcscCd.split(" ")[0]; // 공백을 기준으로 문자열을 분리하고 첫 번째 요소를 가져옴
|
||||
|
||||
if (codeLength == 2) {
|
||||
return String.format("%s %s %s", firstWord, groupFullCd, "00 00");
|
||||
} else {
|
||||
return String.format("%s %s %s", spaceEveryTwoChars(firstWord), groupFullCd, "00");
|
||||
}
|
||||
|
||||
} else {
|
||||
return kcscCd;
|
||||
}
|
||||
}
|
||||
|
||||
public static String spaceEveryTwoChars(String input) {
|
||||
StringBuilder result = new StringBuilder();
|
||||
for (int i = 0; i < input.length(); i++) {
|
||||
result.append(input.charAt(i));
|
||||
if ((i + 1) % 2 == 0 && i != input.length() - 1) { // 짝수 번째 문자이고 마지막 문자가 아닌 경우
|
||||
result.append(" "); // 띄어쓰기 추가
|
||||
}
|
||||
}
|
||||
return result.toString();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -282,4 +282,26 @@ public interface TnCmtDraftRepository extends JpaRepository<TnCmtDraft, Long> {
|
|||
);
|
||||
|
||||
|
||||
@Query(value =
|
||||
"select\n" +
|
||||
" tdg.group_seq,\n" +
|
||||
" tdg.kcsc_cd,\n" +
|
||||
" tdg.group_cur_cd,\n" +
|
||||
" tdg.group_nm,\n" +
|
||||
" tdg.group_full_cd,\n" +
|
||||
" tdg.doc_level,\n" +
|
||||
" tdg.parent_group_seq\n" +
|
||||
"from\n" +
|
||||
" tn_document_group tdg\n" +
|
||||
" left join tc_code_item tci on tdg.item_cd = tci.item_cd\n" +
|
||||
"where\n" +
|
||||
" tdg.use_yn = 'Y' and\n" +
|
||||
" tdg.item_cd <> '00'\n" +
|
||||
"order by \n" +
|
||||
" tdg.group_full_cd\n" +
|
||||
"limit 10000",
|
||||
nativeQuery = true)
|
||||
List<Map<String, Object>> getCommitteeProgressStatusStandardCodeApiList( );
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ spring.sql.init.encoding=utf-8
|
|||
spring.datasource.hikari.maximum-pool-size=4
|
||||
#postgresql
|
||||
spring.datasource.driverClassName=org.postgresql.Driver
|
||||
spring.datasource.url=jdbc:postgresql://118.219.150.34:50503/kcsc
|
||||
spring.datasource.url=jdbc:postgresql://127.0.0.1:5432/kcsc
|
||||
spring.datasource.username=dbnt0031
|
||||
spring.datasource.password=dbnt0928!
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue