From 0459af84b0190e4b3db295aa78f6b5f70a019ca9 Mon Sep 17 00:00:00 2001 From: Lim Jonguk Date: Mon, 11 Apr 2022 01:47:47 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=EA=B1=B0=EC=A3=BC=EC=9E=90=20/=20?= =?UTF-8?q?=EC=9E=A5=EC=95=A0=EC=9D=B8=20=EC=9D=98=EA=B2=AC=EC=A7=84?= =?UTF-8?q?=EC=88=A0=20=EC=83=81=EC=84=B8=20=EC=A7=84=ED=96=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../resources/data/sql/거주자심의상세.sql | 73 +++++++++++++++++++ .../resources/data/sql/주정차심의상세.sql | 67 +++++++++++++++++ .../IMinJudge680RepositoryTest.java | 46 ++++++++++-- .../ctgy/repository/RecallRepositoryTest.java | 4 +- 4 files changed, 180 insertions(+), 10 deletions(-) create mode 100644 src/main/resources/data/sql/거주자심의상세.sql create mode 100644 src/main/resources/data/sql/주정차심의상세.sql 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)