feat: 거주자심의관리 반영

dev
Lim Jonguk 3 years ago
parent 0f63e7fcba
commit 09d9e55aff

@ -75,6 +75,16 @@ public class CtgyConstants {
private final String desc;
}
@Getter
@AllArgsConstructor
public enum Resident {
DATAGB_1("1", ""),
DATAGB_2("2", "")
;
private final String code;
private final String desc;
}
@Getter
@AllArgsConstructor
public enum PublicBoard {

@ -43,11 +43,11 @@ public class ResidentController {
@Operation(summary = "거주자의견진술 상세" , description = "거주자의견진술 상세")
@Parameters({
@Parameter(in = ParameterIn.PATH, name = "scCode", description = "의견진술번호", required = true, example = "3326"),
@Parameter(in = ParameterIn.PATH, name = "scCode", description = "의견진술번호", required = true, example = "3778"),
})
@GetMapping(value = "/{scCode}", produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<? extends IRestResponse> findByScCode(@PathVariable final Long scCode) {
return RestResponse.of(service.findByScCode(scCode));
public ResponseEntity<? extends IRestResponse> findResident(@PathVariable final Long scCode) {
return RestResponse.of(service.findResident(scCode));
}
}

@ -117,4 +117,16 @@ public class GnRecallScDto {
@Schema(title = " ", example = " ", description = " ")
private String scBunji;
@Schema(required = true, title = " ", example = " ", description = " ")
private String scContDocNm;
@Schema(required = true, title = " ", example = " ", description = " ")
private String scIngbNm;
@Schema(required = true, title = " ", example = " ", description = " ")
private String scTransferNm;
@Schema(required = true, title = " ", example = " ", description = " ")
private String scStateNm;
}

@ -13,4 +13,6 @@ import java.util.List;
public interface IResidentRepositoryCustom {
Page<GnRecallScDto> findResidents(Pageable pageable);
GnRecallScDto findResident(Long scCode);
}

@ -1,16 +1,22 @@
package com.xit.biz.ctgy.repository;
import com.querydsl.core.BooleanBuilder;
import com.querydsl.core.QueryResults;
import com.querydsl.core.types.ExpressionUtils;
import com.querydsl.core.types.Projections;
import com.querydsl.jpa.JPAExpressions;
import com.querydsl.jpa.impl.JPAQueryFactory;
import com.xit.biz.ctgy.CtgyConstants;
import com.xit.biz.ctgy.dto.GnRecallScDto;
import com.xit.core.util.Checks;
import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.Pageable;
import java.util.ArrayList;
import java.util.List;
import static com.xit.biz.cmm.entity.QCmmCodeS.cmmCodeS;
import static com.xit.biz.ctgy.entity.QGnRecallSc.gnRecallSc;
@ -22,15 +28,22 @@ public class IResidentRepositoryImpl implements IResidentRepositoryCustom {
@Override
public Page<GnRecallScDto> findResidents(Pageable pageable) {
// BooleanBuilder builder = new BooleanBuilder();
// if (!Checks.isEmpty(pMinSimsa680GroupDto.getMsYear())) {
// builder.and(minSimsa680.msYear.eq(pMinSimsa680GroupDto.getMsYear()));
// }
// if (!Checks.isEmpty(pMinSimsa680GroupDto.getMsChasu())) {
// builder.and(minSimsa680.msChasu.like(String.valueOf(pMinSimsa680GroupDto.getMsChasu())));
// }
QueryResults<GnRecallScDto> rslt =
queryFactory
// 커버링 인덱스로 대상 조회
QueryResults<Long> scCodeList = queryFactory
.select(gnRecallSc.scCode)
.from(gnRecallSc)
.where(gnRecallSc.scDatagb.eq(CtgyConstants.Resident.DATAGB_1.getCode()))
.orderBy(gnRecallSc.scCode.desc())
.offset(pageable.getPageSize())
.limit(pageable.getPageSize())
.fetchResults();
// 대상이 없을 경우 추가 쿼리 수행 할 필요 없이 바로 반환
if (Checks.isEmpty(scCodeList)) {
new PageImpl<>(new ArrayList<>(), pageable, 0);
}
List<GnRecallScDto> rslt = queryFactory
.select(Projections.fields(
GnRecallScDto.class,
gnRecallSc.scCode,
@ -58,14 +71,99 @@ public class IResidentRepositoryImpl implements IResidentRepositoryCustom {
"scIngbNm")
))
.from(gnRecallSc)
//.where(builder)
//.groupBy(minSimsa680.msYear, minSimsa680.msChasu, minSimsa680.msSdate, minSimsa680.msStartsi, minSimsa680.msEdate, minSimsa680.msCdate, minSimsa680.msClosesi)
//.orderBy(minSimsa680.msYear.desc(), minSimsa680.msChasu.desc())
.offset(pageable.getOffset())
.limit(pageable.getPageSize())
.fetchResults();
.where(gnRecallSc.scCode.in(scCodeList.getResults()))
.orderBy(gnRecallSc.scCode.desc())
.fetch();
return new PageImpl<>(rslt, pageable, scCodeList.getTotal());
}
return new PageImpl<>(rslt.getResults(), pageable, rslt.getTotal());
@Override
public GnRecallScDto findResident(Long scCode) {
BooleanBuilder builder = new BooleanBuilder();
builder.and(gnRecallSc.scDatagb.eq(CtgyConstants.Resident.DATAGB_1.getCode()));
builder.and(gnRecallSc.scCode.eq(scCode));
return queryFactory
.select(Projections.fields(
GnRecallScDto.class,
gnRecallSc.scCode,
gnRecallSc.scSeq,
gnRecallSc.scCarnum,
gnRecallSc.scName,
gnRecallSc.scDong,
gnRecallSc.scContDoc,
gnRecallSc.scCdate,
gnRecallSc.scIngb,
gnRecallSc.scWdate,
gnRecallSc.scJbtime,
gnRecallSc.scPos,
gnRecallSc.scFrecad1,
gnRecallSc.scFrecad2,
gnRecallSc.scFrecad3,
gnRecallSc.scFrecad4,
gnRecallSc.scContad1,
gnRecallSc.scContad2,
gnRecallSc.scContad3,
gnRecallSc.scContad4,
gnRecallSc.scContad5,
gnRecallSc.scContad6,
gnRecallSc.scContad7,
gnRecallSc.scContad8,
gnRecallSc.scPicad1,
gnRecallSc.scPicad2,
gnRecallSc.scPicad3,
gnRecallSc.scPicad4,
gnRecallSc.scTransfer,
gnRecallSc.scAnswer,
gnRecallSc.scState,
gnRecallSc.zipcode1,
gnRecallSc.zipcode2,
gnRecallSc.scJuso,
gnRecallSc.scBunji,
ExpressionUtils.as(
JPAExpressions.select(cmmCodeS.codeNm)
.from(cmmCodeS)
.where(gnRecallSc.scContDoc.eq(cmmCodeS.codeCd), cmmCodeS.codeGrpId.eq("TRAFFIC"),
cmmCodeS.codeLcd.eq("GANGNAM_SIMSA"),
cmmCodeS.codeMcd.eq("SC_CONT_DOC")),
"scContDocNm"),
ExpressionUtils.as(
JPAExpressions.select(cmmCodeS.codeNm)
.from(cmmCodeS)
.where(gnRecallSc.scIngb.eq(cmmCodeS.codeCd), cmmCodeS.codeGrpId.eq("TRAFFIC"),
cmmCodeS.codeLcd.eq("GANGNAM_SIMSA"),
cmmCodeS.codeMcd.eq("RC_INGB")),
"scIngbNm")
// ExpressionUtils.as(
// JPAExpressions.select(cmmCodeS.codeNm)
// .from(cmmCodeS)
// .where(gnRecallSc.scIngb.eq(cmmCodeS.codeCd), cmmCodeS.codeGrpId.eq("TRAFFIC"),
// cmmCodeS.codeLcd.eq("GANGNAM_SIMSA"),
// cmmCodeS.codeMcd.eq("SC_TRANSFER")),
// "scTransferNm"),
// ExpressionUtils.as(
// JPAExpressions.select(cmmCodeS.codeNm)
// .from(cmmCodeS)
// .where(gnRecallSc.scIngb.eq(cmmCodeS.codeCd), cmmCodeS.codeGrpId.eq("TRAFFIC"),
// cmmCodeS.codeLcd.eq("GANGNAM_SIMSA"),
// cmmCodeS.codeMcd.eq("SC_STATE")),
// "scStateNm")
))
.from(gnRecallSc)
.where(builder)
.fetchOne();
/*
SELECT SC_CODE, SC_SEQ, SC_CARNUM, SC_NAME, SC_DONG,
GET_RECALL_CONTID(SC_CONT_DOC) SC_CONT_DOC, SC_CDATE, GET_RECALL_INGB_STR(SC_INGB) SC_INGB, SC_WDATE, SC_JBTIME,
SC_POS, SC_FRECAD1, SC_FRECAD2, SC_FRECAD3, SC_FRECAD4,
SC_CONTAD1, SC_CONTAD2, SC_CONTAD3, SC_CONTAD4, SC_CONTAD5,
SC_CONTAD6, SC_CONTAD7, SC_CONTAD8, SC_PICAD1, SC_PICAD2,
SC_PICAD3, SC_PICAD4, (SELECT CDNAME FROM MIN_MAINCODE WHERE C2='6' AND C3=SC_TRANSFER) SC_TRANSFER, SC_ANSWER,
(SELECT CDNAME FROM MIN_MAINCODE WHERE C2='7' AND C3=SC_STATE) SC_STATE, ZIPCODE1, ZIPCODE2, SC_JUSO, SC_BUNJI
FROM GN_RECALL_SC
WHERE SC_DATAGB = '1'
AND SC_CODE =
*/
}
}

@ -11,7 +11,7 @@ public interface IResidentService {
Page<GnRecallScDto> findResidents(Pageable pageable);
Page<GnRecallSc> findAll(GnRecallSc entity, Pageable pageable);
GnRecallScDto findResident(Long scCode);
GnRecallSc findByScCode(Long scCode);
Page<GnRecallSc> findAll(GnRecallSc entity, Pageable pageable);
}

@ -27,6 +27,12 @@ public class ResidentService implements IResidentService {
return page;
}
@Override
@Transactional(readOnly = true)
public GnRecallScDto findResident(Long scCode) {
return repository.findResident(scCode);
}
@Override
@Transactional(readOnly = true)
public Page<GnRecallSc> findAll(GnRecallSc entity, Pageable pageable) {
@ -43,10 +49,4 @@ public class ResidentService implements IResidentService {
// List<CmmUser> userList = page.getContent();
return page;
}
@Override
@Transactional(readOnly = true)
public GnRecallSc findByScCode(Long scCode) {
return repository.findByScCode(scCode);
}
}

@ -56,6 +56,10 @@ public class RestResponse<T> implements IRestResponse, Serializable {
this.message = new RestMessage(SUCCESS, SUCCESS_MESSAGE);
this.data = data;
if(data == null){
this.count = 0;
}else {
// Pageing 처리
if (Page.class.isAssignableFrom(data.getClass())) {
@ -76,6 +80,7 @@ public class RestResponse<T> implements IRestResponse, Serializable {
}
}
}
}
public static <T> ResponseEntity<? extends IRestResponse> of(T data){
return ResponseEntity.ok().body(new RestResponse<>(data));

@ -1,6 +1,9 @@
package com.xit.biz.ctgy.repository;
import com.querydsl.core.types.Expression;
import com.querydsl.jpa.impl.JPAQueryFactory;
import com.xit.biz.ctgy.entity.QGnRecallSc;
import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;
@ -10,11 +13,12 @@ import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles;
import javax.persistence.EntityManager;
import javax.persistence.Tuple;
import javax.transaction.Transactional;
import java.lang.reflect.Modifier;
import java.sql.Date;
import java.time.LocalDate;
import java.util.Map;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
import static com.xit.biz.ctgy.entity.QMinSimsa680.minSimsa680;
@ -24,6 +28,7 @@ import static com.xit.biz.ctgy.entity.QMinUserinfo.minUserinfo;
@SpringBootTest
@Transactional
@ActiveProfiles({"dev"})
@Slf4j
class RecallRepositoryTest {
@Autowired
@ -40,6 +45,30 @@ class RecallRepositoryTest {
void afterEach(){
}
@Test
void dddd(){
QGnRecallSc qGnRecallSc = QGnRecallSc.gnRecallSc;
final List<Expression<?>> columns = Arrays.stream(QGnRecallSc.class.getDeclaredFields())
.filter(field -> !Modifier.isStatic(field.getModifiers()))
.map(field -> {
try {
return (Expression<?>) field.get(qGnRecallSc);
}
catch (final Exception e) {
log.trace("should never happen", e);
return null;
}
})
.collect(Collectors.toList());
log.debug("{}", qGnRecallSc);
// Adding transient fields
// CollectionUtils.addAll(columns, new Expression[] { qOtherBean, qStupidJoinBean });
}
@Test
@DisplayName("sim_result:심사목록에서 기간 클릭시")
void sim_reg() {

Loading…
Cancel
Save