diff --git a/src/main/resources/data/sql/거주자심의상세.sql b/src/main/resources/data/sql/거주자심의상세.sql new file mode 100644 index 0000000..59a78f2 --- /dev/null +++ b/src/main/resources/data/sql/거주자심의상세.sql @@ -0,0 +1,73 @@ +SELECT T.msu_TEAM, M.MS_CHASU, NVL(SUM(DECODE(MS_RESULT, '2', 1, 0)), 0) RE_BU, NVL(SUM(DECODE(MS_RESULT, '1', 1, 0)), 0) RE_MIBU +FROM MIN_SIMSA680_SC M, + MSU680_SC_VIEW T +WHERE M.MS_MAINCODE = T.MSU_MAINCODE + AND M.MS_DATAGB = '1' + AND MSU_TEAM = '003' + AND MS_CHASU = 12 + AND M.MS_SDATE = '2021-09-10' + AND M.MS_EDATE = '2021-09-11' +GROUP BY T.MSU_TEAM, M.MS_CHASU; + +SELECT NAME, + SUM(DECODE(MSU_RESULT, '2', 1, 0)) BU, + SUM(DECODE(MSU_RESULT, '1', 1, 0)) MIBU, + SUM(DECODE(MSU_RESULT, '1', 1, '2', 1, 0)) TOT, + USERID +FROM MIN_USERINFO, + MIN_SIMSA_USER680_SC, + MIN_SIMSA680_SC +WHERE USERID = MSU_USERID + AND MS_MAINCODE = MSU_MAINCODE + AND MS_DATAGB = '1' + AND MSU_TEAM = '003' + AND MS_CHASU = 12 + AND MS_SDATE = '2021-09-10' + AND MS_EDATE = '2021-09-11' +GROUP BY USERID, NAME +ORDER BY USERID, NAME; + +SELECT MS_SEQ, MS_CARNUM, MS_MAINCODE +FROM MIN_USERINFO, + MIN_SIMSA_USER680_SC, + MIN_SIMSA680_SC +WHERE USERID = MSU_USERID + AND MS_MAINCODE = MSU_MAINCODE + AND MS_DATAGB = '1' + AND MSU_TEAM = '003' + AND MS_CHASU = 12 + AND MS_SDATE = '2021-09-10' + AND MS_EDATE = '2021-09-11' +GROUP BY MS_CARNUM, MS_SEQ, MS_MAINCODE +ORDER BY MS_SEQ; + +-- 부과여부 +SELECT MSU_MAINCODE, + USERID, + NAME, + (SELECT CDNAME FROM MIN_MAINCODE WHERE C2 = '5' AND C3 = MSU_RESULT) MSURESULT, + (SELECT CDNAME FROM MIN_MAINCODE WHERE C2 = '5' AND C3 = MS_RESULT) MSRESULT +FROM MIN_USERINFO, + MIN_SIMSA_USER680_SC, + MIN_SIMSA680_SC +WHERE USERID = MSU_USERID + AND MS_MAINCODE = MSU_MAINCODE + AND MS_DATAGB = '1' + AND MSU_TEAM = '003' + --AND MS_SEQ = + --AND MS_CARNUM = + AND MS_CHASU = 12 + AND MS_SDATE = '2021-09-10' + AND MS_EDATE = '2021-09-11' +ORDER BY USERID, NAME; + +-- excel +SELECT MS_SEQ, DECODE(MSU_RESULT, '2', 'O', '') BU, DECODE(MSU_RESULT, '1', 'O', '') MIBU, MSU_REASON +FROM MIN_USERINFO, + MIN_SIMSA_USER680_SC, + MIN_SIMSA680_SC +WHERE USERID = MSU_USERID + AND MSU_MAINCODE = MS_MAINCODE + AND MS_CHASU = 12 + AND NAME = '"& rUserName &"' +ORDER BY MS_SEQ; \ No newline at end of file diff --git a/src/main/resources/data/sql/주정차심의상세.sql b/src/main/resources/data/sql/주정차심의상세.sql new file mode 100644 index 0000000..9cad10b --- /dev/null +++ b/src/main/resources/data/sql/주정차심의상세.sql @@ -0,0 +1,67 @@ +SELECT msu_TEAM, MS_CHASU, NVL(SUM(DECODE(MS_RESULT, '2', 1, 0)), 0) RE_BU, NVL(SUM(DECODE(MS_RESULT, '1', 1, 0)), 0) RE_MIBU +FROM MIN_SIMSA680, + MSU680_VIEW +WHERE MS_MAINCODE = MSU_MAINCODE + AND MSU_TEAM = '001' + AND MS_CHASU = 58 + AND MS_SDATE = '2021-09-10' + AND MS_EDATE = '2021-09-11' +GROUP BY MSU_TEAM, MS_CHASU; + +SELECT NAME, + SUM(DECODE(MSU_RESULT, '2', 1, 0)) BU, + SUM(DECODE(MSU_RESULT, '1', 1, 0)) MIBU, + SUM(DECODE(MSU_RESULT, '1', 1, '2', 1, 0)) TOT, + USERID +FROM MIN_USERINFO, + MIN_SIMSA_USER680, + MIN_SIMSA680 +WHERE USERID = MSU_USERID + AND MS_MAINCODE = MSU_MAINCODE + AND MSU_TEAM = '001' + --AND MS_CHASU = '"& rChaSu &"' + --AND MS_SDATE = '"& rStartDate &"' + --AND MS_EDATE = '"& rEndDate &"' +GROUP BY USERID, NAME +ORDER BY USERID, NAME; + +SELECT MS_SEQ, MS_CARNUM, MS_MAINCODE +FROM MIN_USERINFO, + MIN_SIMSA_USER680, + MIN_SIMSA680 +WHERE USERID = MSU_USERID + AND MS_MAINCODE = MSU_MAINCODE + AND MSU_TEAM = '001' + --AND MS_CHASU = '"& rChaSu &"' + --AND MS_SDATE = '"& rStartDate &"' + --AND MS_EDATE = '"& rEndDate &"' +GROUP BY MS_CARNUM, MS_SEQ, MS_MAINCODE +ORDER BY MS_SEQ; + + +SELECT MSU_MAINCODE, + (SELECT CDNAME FROM MIN_MAINCODE WHERE C2 = '5' AND C3 = MSU_RESULT) MSURESULT, + (SELECT CDNAME FROM MIN_MAINCODE WHERE C2 = '5' AND C3 = MS_RESULT) MSRESULT +FROM MIN_USERINFO, + MIN_SIMSA_USER680, + MIN_SIMSA680 +WHERE USERID = MSU_USERID + AND MS_MAINCODE = MSU_MAINCODE + AND MSU_TEAM = '001' + --AND MS_SEQ = '"& rSEQ &"' + --AND MS_CARNUM = '"& rCarNum + --AND MS_CHASU = ' + --AND MS_SDATE = '"& rStartDate &"' + --AND MS_EDATE = '"& rEndDate &"' +ORDER BY USERID, NAME; + +-- excel +SELECT MS_SEQ, DECODE(MSU_RESULT, '2', 'O', '') BU, DECODE(MSU_RESULT, '1', 'O', '') MIBU, MSU_REASON +FROM MIN_USERINFO, + MIN_SIMSA_USER680, + MIN_SIMSA680 +WHERE USERID = MSU_USERID + AND MSU_MAINCODE = MS_MAINCODE + -- AND MS_CHASU = '"& rChaSu &"' + -- AND NAME = '"& rUserName &"' +ORDER BY MS_SEQ; \ No newline at end of file diff --git a/src/test/java/com/xit/biz/ctgy/repository/IMinJudge680RepositoryTest.java b/src/test/java/com/xit/biz/ctgy/repository/IMinJudge680RepositoryTest.java index d611dd8..a6f517b 100644 --- a/src/test/java/com/xit/biz/ctgy/repository/IMinJudge680RepositoryTest.java +++ b/src/test/java/com/xit/biz/ctgy/repository/IMinJudge680RepositoryTest.java @@ -1,6 +1,13 @@ package com.xit.biz.ctgy.repository; +import com.querydsl.core.BooleanBuilder; +import com.querydsl.core.QueryResults; +import com.querydsl.core.types.Projections; import com.querydsl.jpa.impl.JPAQueryFactory; +import com.xit.biz.ctgy.CtgyConstants; +import com.xit.biz.ctgy.dto.JudgeListDto; +import com.xit.biz.ctgy.entity.MinSimsa680; +import com.xit.core.util.Checks; import com.xit.core.util.DateUtil; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; @@ -8,6 +15,7 @@ import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.data.domain.PageImpl; import org.springframework.test.context.ActiveProfiles; import javax.persistence.EntityManager; @@ -17,8 +25,10 @@ import java.sql.Date; import java.time.LocalDate; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; +import java.util.List; import static com.xit.biz.ctgy.entity.QMinSimsa680.minSimsa680; +import static com.xit.biz.ctgy.entity.QMinSimsa680Sc.minSimsa680Sc; import static com.xit.biz.ctgy.entity.QMinSimsaUser680.minSimsaUser680; import static com.xit.biz.ctgy.entity.QMinUserinfo.minUserinfo; import static org.junit.jupiter.api.Assertions.*; @@ -62,8 +72,8 @@ class IMinJudge680RepositoryTest { .on(minSimsaUser680.msuUserid.eq(minUserinfo.userid)) .where(minSimsaUser680.msuTeam.eq(""), minSimsa680.msChasu.eq(1L), - minSimsa680.msSdate.eq(java.sql.Date.valueOf(now)), - minSimsa680.msEdate.eq(java.sql.Date.valueOf(now2))) + minSimsa680.msSdate.eq(now), + minSimsa680.msEdate.eq(now2)) .groupBy(minSimsa680.msCarnum, minSimsa680.msSeq, minSimsa680.msMaincode) @@ -72,15 +82,35 @@ class IMinJudge680RepositoryTest { .limit(10L) //, minSimsa680.msSdate.eq(java.sql.Date.valueOf(now))) .fetchResults(); -// jpaQueryFactory.selectFrom(minSimsa680) -// .leftJoin(minSimsa680.msMaincode, minSimsaUser680).fetchJoin() -// .groupBy(minSimsa680.msEdate, minSimsaUser680.msuTeam, qMinUserinfo.name) -// .orderBy(minSimsa680.msChasu.desc()) -// //.where(minSimsa680.name.eq(name)) - // .fetch(); } + @Test + void judgeDetailsTest() { + BooleanBuilder builder = new BooleanBuilder(); + builder.and(minSimsa680.msSdate.gt(DateUtil.parseLocalDate("2021-09-10")).or(minSimsa680.msSdate.eq(DateUtil.parseLocalDate("2021-09-10")))); + builder.and(minSimsa680.msEdate.lt(DateUtil.parseLocalDate("2021-09-11")).or(minSimsa680.msEdate.eq(DateUtil.parseLocalDate("2021-09-11")))); + + // builder.and(minSimsaUser680.msuTeam.eq(dto.getMsuTeam())); + List rslt = + queryFactory + .select(Projections.fields(MinSimsa680.class, + minSimsa680.msSeq, + minSimsa680.msCarnum, + minSimsa680.msMaincode)) + .from(minSimsaUser680) + .join(minSimsa680) + .on(minSimsa680.msMaincode.eq(minSimsaUser680.msuMaincode)) + .join(minUserinfo) + .on(minSimsaUser680.msuUserid.eq(minUserinfo.userid)) + .where(builder) + .groupBy(minSimsa680.msCarnum, + minSimsa680.msSeq, + minSimsa680.msMaincode) + .orderBy(minSimsa680.msSeq.asc()) + .fetch(); + + } // @BeforeAll // void beforeAll(){ diff --git a/src/test/java/com/xit/biz/ctgy/repository/RecallRepositoryTest.java b/src/test/java/com/xit/biz/ctgy/repository/RecallRepositoryTest.java index 16024f6..d6eb447 100644 --- a/src/test/java/com/xit/biz/ctgy/repository/RecallRepositoryTest.java +++ b/src/test/java/com/xit/biz/ctgy/repository/RecallRepositoryTest.java @@ -108,8 +108,8 @@ AND RC_IR_TRANSFER = '"& rstTrans &"' ORDER BY RC_SEQ .on(minSimsaUser680.msuUserid.eq(minUserinfo.userid)) .where(minSimsaUser680.msuTeam.eq(""), minSimsa680.msChasu.eq(1L), - minSimsa680.msSdate.eq(Date.valueOf(now)), - minSimsa680.msEdate.eq(Date.valueOf(now2))) + minSimsa680.msSdate.eq(now), + minSimsa680.msEdate.eq(now2)) .groupBy(minSimsa680.msCarnum, minSimsa680.msSeq, minSimsa680.msMaincode)