From c4a6e4acad75c2f3b1e8949d0b7f168eca272373 Mon Sep 17 00:00:00 2001 From: minuk926 Date: Fri, 1 Jul 2022 21:36:34 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=EC=A3=BC=EC=A0=95=EC=B0=A8=EC=9D=98?= =?UTF-8?q?=EA=B2=AC=EC=A7=84=EC=88=A0=20-=20=EC=8B=AC=EC=9D=98=EB=AA=A9?= =?UTF-8?q?=EB=A1=9D,=20=EC=8B=AC=EC=9D=98=EA=B2=B0=EA=B3=BC=20=EB=B0=98?= =?UTF-8?q?=EC=98=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ctgy/v2/controller/MinUserController.java | 4 +- .../ctgy/v2/controller/ParkingController.java | 2 +- .../ResidentAndDisabledController.java | 2 +- .../biz/ctgy/v2/repository/ParkingDao.java | 104 +++++++- .../v2/repository/ResidentAndDisabledDao.java | 6 +- .../ctgy/v2/service/impl/ParkingService.java | 12 +- .../config/database/BaseMpowerDaoSupport.java | 96 +++++-- .../support/LocalDateTimeConfiguration.java | 13 +- .../handling/CustomRestExceptionHandler.java | 3 +- .../sql/parser/sqlQuery/BasicSqlQuery.java | 17 ++ .../sql/parser/sqlQuery/EmptySqlQuery.java | 11 + .../support/sql/parser/sqlQuery/SqlQuery.java | 5 + .../util/{security => }/ConvertUtils.java | 9 +- src/main/java/com/xit/core/util/DBUtils.java | 1 + src/main/resources/sql/parking-mapper.xml | 237 ++++++++++++++++++ 15 files changed, 478 insertions(+), 44 deletions(-) rename src/main/java/com/xit/core/util/{security => }/ConvertUtils.java (86%) create mode 100644 src/main/resources/sql/parking-mapper.xml diff --git a/src/main/java/com/xit/biz/ctgy/v2/controller/MinUserController.java b/src/main/java/com/xit/biz/ctgy/v2/controller/MinUserController.java index c5a49b5..6299b86 100644 --- a/src/main/java/com/xit/biz/ctgy/v2/controller/MinUserController.java +++ b/src/main/java/com/xit/biz/ctgy/v2/controller/MinUserController.java @@ -1,8 +1,7 @@ package com.xit.biz.ctgy.v2.controller; import com.xit.biz.ctgy.dto.MinUserinfoDto; -import com.xit.biz.ctgy.dto.struct.MinUserinfoMapstruct; -import com.xit.biz.ctgy.service.IMinUserService; +import com.xit.biz.ctgy.v2.service.IMinUserService; import com.xit.core.annotation.Secured; import com.xit.core.annotation.SecurityPolicy; import com.xit.core.api.IRestResponse; @@ -13,7 +12,6 @@ import io.swagger.v3.oas.annotations.Parameters; import io.swagger.v3.oas.annotations.enums.ParameterIn; import io.swagger.v3.oas.annotations.tags.Tag; import lombok.RequiredArgsConstructor; -import org.mapstruct.factory.Mappers; import org.springframework.data.domain.Pageable; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; diff --git a/src/main/java/com/xit/biz/ctgy/v2/controller/ParkingController.java b/src/main/java/com/xit/biz/ctgy/v2/controller/ParkingController.java index 2d0cee3..44561da 100644 --- a/src/main/java/com/xit/biz/ctgy/v2/controller/ParkingController.java +++ b/src/main/java/com/xit/biz/ctgy/v2/controller/ParkingController.java @@ -4,7 +4,7 @@ import com.xit.biz.ctgy.dto.JudgeListDto; import com.xit.biz.ctgy.dto.ParkingTargetDto; import com.xit.biz.ctgy.dto.struct.JudgeListMapstruct; import com.xit.biz.ctgy.dto.struct.MinSimsa680Mapstruct; -import com.xit.biz.ctgy.service.IParkingService; +import com.xit.biz.ctgy.v2.service.IParkingService; import com.xit.core.annotation.Secured; import com.xit.core.annotation.SecurityPolicy; import com.xit.core.api.IRestResponse; diff --git a/src/main/java/com/xit/biz/ctgy/v2/controller/ResidentAndDisabledController.java b/src/main/java/com/xit/biz/ctgy/v2/controller/ResidentAndDisabledController.java index 32ac173..2c6d971 100644 --- a/src/main/java/com/xit/biz/ctgy/v2/controller/ResidentAndDisabledController.java +++ b/src/main/java/com/xit/biz/ctgy/v2/controller/ResidentAndDisabledController.java @@ -5,7 +5,7 @@ import com.xit.biz.ctgy.dto.JudgeListDto; import com.xit.biz.ctgy.dto.JudgeStdDto; import com.xit.biz.ctgy.dto.JudgeTargetDto; import com.xit.biz.ctgy.dto.struct.GnRecallScMapstruct; -import com.xit.biz.ctgy.service.IResidentAndDisabledService; +import com.xit.biz.ctgy.v2.service.IResidentAndDisabledService; import com.xit.core.annotation.Secured; import com.xit.core.annotation.SecurityPolicy; import com.xit.core.api.IRestResponse; diff --git a/src/main/java/com/xit/biz/ctgy/v2/repository/ParkingDao.java b/src/main/java/com/xit/biz/ctgy/v2/repository/ParkingDao.java index ebc4275..3775995 100644 --- a/src/main/java/com/xit/biz/ctgy/v2/repository/ParkingDao.java +++ b/src/main/java/com/xit/biz/ctgy/v2/repository/ParkingDao.java @@ -1,4 +1,106 @@ package com.xit.biz.ctgy.v2.repository; -public class ParkingDao { +import com.xit.biz.ctgy.dto.BoardDto; +import com.xit.biz.ctgy.dto.JudgeListDto; +import com.xit.biz.ctgy.dto.ParkingTargetDto; +import com.xit.core.config.database.BaseMpowerDaoSupport; +import com.xit.core.support.sql.parser.QueryGenerator; +import com.xit.core.util.ConvertUtils; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.format.annotation.DateTimeFormat; +import org.springframework.stereotype.Repository; + +import java.time.LocalDate; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +@Repository +public class ParkingDao extends BaseMpowerDaoSupport { + + public Page findParkings(JudgeListDto dto, Pageable pageable) { + final String cntSql = QueryGenerator.createNamedQuery("parking", "selectParkingListCnt") + .setParameter("msYear", dto.getMsYear()) + .setParameter("msChasu", dto.getMsChasu()) + .getQueryString(); + + final String listSql = QueryGenerator.createNamedQuery("parking", "selectParkingList") + .setParameter("msYear", dto.getMsYear()) + .setParameter("msChasu", dto.getMsChasu()) + .setParameter("page", pageable.getPageNumber()) + .setParameter("size", pageable.getPageSize()) + .getQueryString(); + final String fieldStrs = "msYear, msChasu, msSdate, msStartsi, msEdate, msCdate, msClosesi, cnt"; + + return selectList(JudgeListDto.class, listSql, cntSql, fieldStrs, pageable); + } + + public List> selectParkingJudgeTeamGroupByChasuAndTeamList(JudgeListDto dto) { + final String listSql = QueryGenerator.createNamedQuery("parking", "selectTotParkingJudgeResultGroupByTeamAndChasu") + .setParameter("msuTeam", dto.getMsuTeam()) + .setParameter("msChasu", dto.getMsChasu()) + .setParameter("msSdate", dto.getMsSdate()) + .setParameter("msEdate", dto.getMsEdate()) + .getQueryString(); + final String fieldStrs = "msuTeam, BU, SEO, MIBU, TOT, NAME"; + + return selectMapList(listSql, fieldStrs); + } + + public List> selectParkingJurgeResultGroupByCarnum(JudgeListDto dto) { + final String listSql = QueryGenerator.createNamedQuery("parking", "selectParkingJurgeResultGroupByCarnum") + .setParameter("msuTeam", dto.getMsuTeam()) + .setParameter("msChasu", dto.getMsChasu()) + .setParameter("msSdate", dto.getMsSdate()) + .setParameter("msEdate", dto.getMsEdate()) + .getQueryString(); + final String fieldsStrs = "msMaincode, msSeq, msCarnum"; + + return selectMapList(listSql, fieldsStrs); + } + + public List> selectTotParkingJudgeResultGroupByUser(JudgeListDto dto) { + final String listSql = QueryGenerator.createNamedQuery("parking", "selectTotParkingJudgeResultGroupByUser") + .setParameter("msuTeam", dto.getMsuTeam()) + .setParameter("msChasu", dto.getMsChasu()) + .setParameter("msSdate", dto.getMsSdate()) + .setParameter("msEdate", dto.getMsEdate()) + .getQueryString(); + final String fieldStrs = "BU, SEO, MIBU, TOT, NAME"; + + return selectMapList(listSql, fieldStrs); + } + + + + public List> selectParkingJudgeResultList(Map paramMap) { + final String listSql = QueryGenerator.createNamedQuery("parking", "selectParkingJudgeResultList") + .setParameter("msDatagb", String.valueOf(paramMap.get("msDatagb"))) + .setParameter("msuTeam", String.valueOf(paramMap.get("msuTeam"))) + .setParameter("msChasu", Long.parseLong(String.valueOf(paramMap.get("msChasu")))) + .setParameter("msSdate", (LocalDate)paramMap.get("msSdate")) + .setParameter("msEdate", (LocalDate) paramMap.get("msEdate")) + .setParameter("seqList", (List)paramMap.get("seqList")) + .setParameter("carnumList", (List)paramMap.get("carnumList")) + .getQueryString(); + final String fieldsStrs = "msMaincode, msSeq, msCarnum, NAME, msResult, msResultNm, msuResult"; + + return selectMapList(listSql, fieldsStrs); + } + +// public List findParkingJudgeTargets(ParkingTargetDto dto) { +// return null; +// } +// +// public List findAllMsMaincode(Long msChasu, LocalDate msSdate, LocalDate msEdate) { +// return null; +// } +// +// public void deleteById(Long msMaincode) { +// } +// +// public List findByUserJudges() { +// return null; +// } } diff --git a/src/main/java/com/xit/biz/ctgy/v2/repository/ResidentAndDisabledDao.java b/src/main/java/com/xit/biz/ctgy/v2/repository/ResidentAndDisabledDao.java index 7a92066..ebf2193 100644 --- a/src/main/java/com/xit/biz/ctgy/v2/repository/ResidentAndDisabledDao.java +++ b/src/main/java/com/xit/biz/ctgy/v2/repository/ResidentAndDisabledDao.java @@ -1,4 +1,8 @@ package com.xit.biz.ctgy.v2.repository; -public class ResidentAndDisabledDao { +import com.xit.core.config.database.BaseMpowerDaoSupport; +import org.springframework.stereotype.Repository; + +@Repository +public class ResidentAndDisabledDao extends BaseMpowerDaoSupport { } diff --git a/src/main/java/com/xit/biz/ctgy/v2/service/impl/ParkingService.java b/src/main/java/com/xit/biz/ctgy/v2/service/impl/ParkingService.java index a8bd99d..497fb26 100644 --- a/src/main/java/com/xit/biz/ctgy/v2/service/impl/ParkingService.java +++ b/src/main/java/com/xit/biz/ctgy/v2/service/impl/ParkingService.java @@ -11,6 +11,7 @@ import com.xit.biz.ctgy.repository.IMinUserRepository; import com.xit.biz.ctgy.repository.IParkingJudgeUserRepository; import com.xit.biz.ctgy.repository.IParkingRepository; import com.xit.biz.ctgy.repository.IRecallRepository; +import com.xit.biz.ctgy.v2.repository.ParkingDao; import com.xit.biz.ctgy.v2.service.IParkingService; import com.xit.core.constant.ErrorCode; import com.xit.core.exception.CustomBaseException; @@ -35,6 +36,7 @@ import java.util.stream.Collectors; public class ParkingService implements IParkingService { private final IParkingRepository repository; + private final ParkingDao parkingDao; private final IRecallRepository recallRepository; private final IMinUserRepository userRepository; private final IParkingJudgeUserRepository parkingJudgeUserRepository; @@ -43,7 +45,7 @@ public class ParkingService implements IParkingService { @Override @Transactional(readOnly = true) public Page findParkings(final JudgeListDto dto, Pageable pageable) { - return repository.findParkings(dto, pageable); + return parkingDao.findParkings(dto, pageable); } @Override @@ -56,16 +58,16 @@ public class ParkingService implements IParkingService { // List> totJudgeUserList = mapper.selectTotParkingJudgeResultGroupByUser(dto); // totJudgeUserList.add(teamMap); - List> teamList = mapper.selectParkingJudgeTeamGroupByChasuAndTeamList(dto); + List> teamList = parkingDao.selectParkingJudgeTeamGroupByChasuAndTeamList(dto); if (Checks.isEmpty(teamList) || teamList.size() == 0) throw new CustomBaseException(ErrorCode.DATA_NOT_FOUND); // 차수별 심사자별 심사결과 합산 dto.setMsuTeam(String.valueOf(teamList.get(0).get("msuTeam"))); - List> totJudgeUserList = mapper.selectTotParkingJudgeResultGroupByUser(dto); + List> totJudgeUserList = parkingDao.selectTotParkingJudgeResultGroupByUser(dto); totJudgeUserList.add(teamList.get(0)); // 심사대상 차량 목록 - List> judgeCarList = mapper.selectParkingJurgeResultGroupByCarnum(dto); + List> judgeCarList = parkingDao.selectParkingJurgeResultGroupByCarnum(dto); // 차량별 심사자 심사결과 목록 Map paramMap = new HashMap<>(); @@ -77,7 +79,7 @@ public class ParkingService implements IParkingService { paramMap.put("seqList", judgeCarList.stream().map(m -> m.get("msSeq")).collect(Collectors.toList())); paramMap.put("carnumList", judgeCarList.stream().map(m -> m.get("msCarnum")).collect(Collectors.toList())); - List> jurgeUserList = mapper.selectParkingJudgeResultList(paramMap); + List> jurgeUserList = parkingDao.selectParkingJudgeResultList(paramMap); // List> resultList = judgeCarList.stream().peek((m) -> { // paramMap.put("msSeq", m.get("msSeq")); // paramMap.put("msCarnum", m.get("msCarnum")); diff --git a/src/main/java/com/xit/core/config/database/BaseMpowerDaoSupport.java b/src/main/java/com/xit/core/config/database/BaseMpowerDaoSupport.java index ff5b4f6..962fc45 100644 --- a/src/main/java/com/xit/core/config/database/BaseMpowerDaoSupport.java +++ b/src/main/java/com/xit/core/config/database/BaseMpowerDaoSupport.java @@ -16,6 +16,7 @@ import java.io.IOException; import java.lang.reflect.Field; import java.lang.reflect.InvocationTargetException; import java.time.LocalDate; +import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; import java.util.*; @@ -162,6 +163,70 @@ public abstract class BaseMpowerDaoSupport { return dmlQuery(sql, "insert"); } + + public Map selectMapOne(String sql, String fieldStr){ + Objects.requireNonNull(sql, "SQL cannot be null"); + Map map = null; + + Client client = getConnection(); + client.setInput("SQLXML", getQueryXml("select", sql)); + try { + client.Request(); + + String result = client.getString("result", 0, 0); + + int row; + if (result.equals("true")){ + row = client.getMaxRow("list1"); + if(row > 1) throw new MpowerException("조회된 데이타가 단일행이 아닙니다"); + map = new HashMap<>(); + List fields = getFeilds(fieldStr); + for (int j = 0; j < fields.size(); j++) { + map.put(fields.get(j), client.getString("list1", 0, j)); + } + } + return map; + + }catch (Exception e){ + throw new MpowerException(ErrorCode.MPOWER_ERROR); + } finally { + disConnection(client); + } + } + + public List> selectMapList(String sql, String fieldStr){ + Objects.requireNonNull(sql, "SQL cannot be null"); + List> list = new ArrayList<>(); + + Client client = getConnection(); + client.setInput("SQLXML", getQueryXml("select", sql)); + try { + client.Request(); + String result = client.getString("result", 0, 0); + + int row; + if (result.equals("true")){ + row = client.getMaxRow("list1"); + List fields = getFeilds(fieldStr); + + for(int i = 0; i < row; i++) { + Map map = new HashMap<>(); + + for (int j = 0; j < fields.size(); j++) { + map.put(fields.get(j), client.getString("list1", i, j)); + } + list.add(map); + } + } + return list; + + }catch (Exception e){ + throw new MpowerException(ErrorCode.MPOWER_ERROR); + } finally { + disConnection(client); + } + } + private String getQueryXml(String syntax, String sql){ log.info(sql); return String.format( @@ -173,15 +238,6 @@ public abstract class BaseMpowerDaoSupport { "' BATCH='false'>\n"); -// return String.format( -// "%s%s%s%s%s%s%s", -// ""); } private Client getConnection(){ @@ -210,10 +266,8 @@ public abstract class BaseMpowerDaoSupport { client.setInput("SQLXML", getQueryXml(syntax, sql)); try { client.Request(); - String result = client.getString("result", 0, 0); - int row; if (result.equals("true")){ System.out.println("<<<<<<<<<<<<===========#$#$#$$##$#$$#$#$$$$$$$====>>>>>>>>>"); } @@ -251,8 +305,16 @@ public abstract class BaseMpowerDaoSupport { fd.set(instance, StringUtils.EMPTY.equals(value)? null : Integer.parseInt(value)); } else if (fd.getType() == Long.class || fd.getType() == Long.TYPE){ fd.set(instance, StringUtils.EMPTY.equals(value)? null : Long.parseLong(value)); + } else if (fd.getType() == LocalDateTime.class) { + //fd.set(instance, StringUtils.EMPTY.equals(value)? null : LocalDate.parse(value, DateTimeFormatter.ISO_DATE_TIME)); + fd.set(instance, StringUtils.EMPTY.equals(value)? null : LocalDateTime.parse(value, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))); + //} else if (fd.getType() == LocalDate.class) fd.set(instance, Long.parseLong(client.getString("list1", row, j))); + } else if (fd.getType() == LocalDate.class) { - fd.set(instance, StringUtils.EMPTY.equals(value)? null : LocalDate.parse(value, DateTimeFormatter.ISO_DATE)); + //fd.set(instance, StringUtils.EMPTY.equals(value)? null : LocalDate.parse(value, DateTimeFormatter.ISO_DATE_TIME)); + // TODO : mpower에서 String 형태로 넘어오는 포맷이 표준에 맞지 않아 아래와 같이 처리 + // 2022-01-01 13:15:30.0 + fd.set(instance, StringUtils.EMPTY.equals(value)? null : LocalDate.parse(value.split(" ")[0], DateTimeFormatter.ofPattern("yyyy-MM-dd"))); //} else if (fd.getType() == LocalDate.class) fd.set(instance, Long.parseLong(client.getString("list1", row, j))); } else { @@ -270,16 +332,6 @@ public abstract class BaseMpowerDaoSupport { return instance; } - -// private T getT(Class type, List fields, int row, Client client) { -// Map m = new HashMap<>(); -// -// for (int j = 0; j < fields.size(); j++) { -// m.put(fields.get(j), client.getString("list1", row, j)); -// } -// return DBUtils.convertToValueObject(m, type); -// } - private List getFeilds(String fields) { String[] strs = fields.split(","); List list = new ArrayList<>(); diff --git a/src/main/java/com/xit/core/config/support/LocalDateTimeConfiguration.java b/src/main/java/com/xit/core/config/support/LocalDateTimeConfiguration.java index b444b9a..30261b1 100644 --- a/src/main/java/com/xit/core/config/support/LocalDateTimeConfiguration.java +++ b/src/main/java/com/xit/core/config/support/LocalDateTimeConfiguration.java @@ -20,6 +20,7 @@ import java.io.IOException; import java.time.ZonedDateTime; import java.time.format.DateTimeFormatter; +//TODO :: 공통 framework에 반영 필요 /** * DTO LocalDate 필드의 아래의 선언 처리 * @JsonFormat(pattern="yyyy-MM-dd") @@ -29,7 +30,7 @@ import java.time.format.DateTimeFormatter; * Responst (서버 -> 클라이언트) 로 전달할 때에는 @JsonFormat * */ -//@Configuration +@Configuration @Slf4j public class LocalDateTimeConfiguration { private static final String DEFAULT_DATE_FMT = "yyyy-MM-dd"; @@ -60,7 +61,7 @@ public class LocalDateTimeConfiguration { @Override public LocalDateTime deserialize(JsonParser p, DeserializationContext ctxt) throws IOException, JsonProcessingException { log.info(">>>>>>>>>>>>>>>>>>>>>LocalDateTimeConfiguration::addDeserializer-LocalDateTime"); - return LocalDateTime.parse(p.getValueAsString(), DateTimeFormatter.ISO_LOCAL_DATE_TIME); + return LocalDateTime.parse(p.getValueAsString(), DateTimeFormatter.ISO_DATE_TIME); //return LocalDateTime.parse(p.getValueAsString(), DateTimeFormatter.ofPattern(DEFAULT_DATE_TIME_FMT)); } }); @@ -69,8 +70,8 @@ public class LocalDateTimeConfiguration { @Override public LocalDate deserialize(JsonParser p, DeserializationContext ctxt) throws IOException, JsonProcessingException { log.info(">>>>>>>>>>>>>>>>>>>>>LocalDateTimeConfiguration::addDeserializer-LocalDate"); - //return LocalDateTime.parse(p.getValueAsString(), DateTimeFormatter.ISO_DATE_TIME); - return LocalDate.parse(p.getValueAsString(), DateTimeFormatter.ofPattern(DEFAULT_DATE_FMT)); + return LocalDate.parse(p.getValueAsString(), DateTimeFormatter.ISO_DATE); + //return LocalDate.parse(p.getValueAsString(), DateTimeFormatter.ofPattern(DEFAULT_DATE_FMT)); } }); @@ -97,8 +98,8 @@ public class LocalDateTimeConfiguration { @Override public void serialize(LocalDate localDate, JsonGenerator gen, SerializerProvider serializers) throws IOException { log.info(">>>>>>>>>>>>>>>>>>>>>LocalDateTimeConfiguration::addSerializer-LocalDate"); - //gen.writeString(DateTimeFormatter.ISO_DATE_TIME.format(value)); - gen.writeString(localDate.format(DateTimeFormatter.ofPattern(DEFAULT_DATE_FMT))); + gen.writeString(DateTimeFormatter.ISO_DATE_TIME.format(localDate)); + //gen.writeString(localDate.format(DateTimeFormatter.ofPattern(DEFAULT_DATE_FMT))); } }); diff --git a/src/main/java/com/xit/core/exception/handling/CustomRestExceptionHandler.java b/src/main/java/com/xit/core/exception/handling/CustomRestExceptionHandler.java index 4b8311f..3a350f0 100644 --- a/src/main/java/com/xit/core/exception/handling/CustomRestExceptionHandler.java +++ b/src/main/java/com/xit/core/exception/handling/CustomRestExceptionHandler.java @@ -148,6 +148,7 @@ public class CustomRestExceptionHandler extends ResponseEntityExceptionHandler { } + //TODO :: 공통 framework에 반영 필요 /** * NoSuchElementException * @@ -220,7 +221,7 @@ public class CustomRestExceptionHandler extends ResponseEntityExceptionHandler { } /* - +//TODO :: 공통 framework에 반영 필요 javax.validation.constraints @NotNull diff --git a/src/main/java/com/xit/core/support/sql/parser/sqlQuery/BasicSqlQuery.java b/src/main/java/com/xit/core/support/sql/parser/sqlQuery/BasicSqlQuery.java index 8111478..d953c98 100644 --- a/src/main/java/com/xit/core/support/sql/parser/sqlQuery/BasicSqlQuery.java +++ b/src/main/java/com/xit/core/support/sql/parser/sqlQuery/BasicSqlQuery.java @@ -5,6 +5,7 @@ import com.xit.core.support.sql.parser.sqlNodes.SqlNode; import com.xit.core.util.Checks; import org.dom4j.Element; +import java.time.LocalDate; import java.util.List; import java.util.StringJoiner; @@ -45,6 +46,12 @@ public class BasicSqlQuery implements SqlQuery { return this; } + @Override + public SqlQuery setParameter(int pos, LocalDate value) { + this.parameterMap.put(pos, value == null? "''" : "'"+String.valueOf(value)+"'"); + return this; + } + @Override public SqlQuery setParameter(int pos, List list) { if (list == null) { @@ -89,6 +96,16 @@ public class BasicSqlQuery implements SqlQuery { return this; } + @Override + public SqlQuery setParameter(String key, LocalDate value) { + try { + this.parameterMap.put(key, value == null ? "''" : "'"+String.valueOf(value)+"'"); + }catch(Exception e){ + e.printStackTrace(); + } + return this; + } + @Override public SqlQuery setParameter(String key, List list) { if (list == null) { diff --git a/src/main/java/com/xit/core/support/sql/parser/sqlQuery/EmptySqlQuery.java b/src/main/java/com/xit/core/support/sql/parser/sqlQuery/EmptySqlQuery.java index c4cc6f0..c2db2b0 100644 --- a/src/main/java/com/xit/core/support/sql/parser/sqlQuery/EmptySqlQuery.java +++ b/src/main/java/com/xit/core/support/sql/parser/sqlQuery/EmptySqlQuery.java @@ -1,5 +1,6 @@ package com.xit.core.support.sql.parser.sqlQuery; +import java.time.LocalDate; import java.util.List; public class EmptySqlQuery implements SqlQuery { @@ -24,6 +25,11 @@ public class EmptySqlQuery implements SqlQuery { return null; } + @Override + public SqlQuery setParameter(int pos, LocalDate value) { + return null; + } + @Override public SqlQuery setParameter(int pos, List list) { return null; @@ -44,6 +50,11 @@ public class EmptySqlQuery implements SqlQuery { return this; } + @Override + public SqlQuery setParameter(String key, LocalDate value) { + return this; + } + @Override public SqlQuery setParameter(String key, int value) { return null; diff --git a/src/main/java/com/xit/core/support/sql/parser/sqlQuery/SqlQuery.java b/src/main/java/com/xit/core/support/sql/parser/sqlQuery/SqlQuery.java index bd1136b..c6f4768 100644 --- a/src/main/java/com/xit/core/support/sql/parser/sqlQuery/SqlQuery.java +++ b/src/main/java/com/xit/core/support/sql/parser/sqlQuery/SqlQuery.java @@ -1,5 +1,6 @@ package com.xit.core.support.sql.parser.sqlQuery; +import java.time.LocalDate; import java.util.List; public interface SqlQuery { @@ -10,6 +11,7 @@ public interface SqlQuery { SqlQuery setParameter(int pos, boolean value); SqlQuery setParameter(int pos, Long value); + SqlQuery setParameter(int pos, LocalDate value); SqlQuery setParameter(int pos, List list); @@ -20,6 +22,9 @@ public interface SqlQuery { SqlQuery setParameter(String key, int value); SqlQuery setParameter(String key, Long value); + + SqlQuery setParameter(String key, LocalDate value); + SqlQuery setParameter(String key, List list); String getQueryString(); diff --git a/src/main/java/com/xit/core/util/security/ConvertUtils.java b/src/main/java/com/xit/core/util/ConvertUtils.java similarity index 86% rename from src/main/java/com/xit/core/util/security/ConvertUtils.java rename to src/main/java/com/xit/core/util/ConvertUtils.java index cb7132e..10ec672 100644 --- a/src/main/java/com/xit/core/util/security/ConvertUtils.java +++ b/src/main/java/com/xit/core/util/ConvertUtils.java @@ -1,4 +1,4 @@ -package com.xit.core.util.security; +package com.xit.core.util; import com.xit.core.util.Checks; @@ -12,6 +12,9 @@ import java.time.LocalDateTime; import java.time.ZoneId; import java.time.format.DateTimeFormatter; +/** + * //TODO :: 공통 framework에 반영 필요 + */ public class ConvertUtils { private static final String DEFAULT_DATE_FMT = "yyyy-MM-dd"; private static final String DEFAULT_DATE_TIME_FMT = "yyyy-MM-dd HH:mm:ss"; @@ -26,12 +29,12 @@ public class ConvertUtils { return new SimpleDateFormat(format).format(date); } - public String getStringDateFromLocalDate(@NotNull LocalDate localDate, @Nullable String format) { + public static String getStringDateFromLocalDate(@NotNull LocalDate localDate, @Nullable String format) { if(Checks.isNull(format)) format = "DEFAULT_DATE_FMT"; return localDate.format(DateTimeFormatter.ofPattern(format)); } - public String getStringDateTimeFromLocalDate(@NotNull LocalDate localDate, @Nullable String format) { + public static String getStringDateTimeFromLocalDate(@NotNull LocalDate localDate, @Nullable String format) { if(Checks.isNull(format)) format = "DEFAULT_DATE_TIME_FMT"; return localDate.format(DateTimeFormatter.ofPattern(format)); } diff --git a/src/main/java/com/xit/core/util/DBUtils.java b/src/main/java/com/xit/core/util/DBUtils.java index a2d6ae6..b2e4b70 100644 --- a/src/main/java/com/xit/core/util/DBUtils.java +++ b/src/main/java/com/xit/core/util/DBUtils.java @@ -16,6 +16,7 @@ import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.*; +//TODO :: 공통 framework에 반영 필요 public class DBUtils { /** * diff --git a/src/main/resources/sql/parking-mapper.xml b/src/main/resources/sql/parking-mapper.xml new file mode 100644 index 0000000..62fc31e --- /dev/null +++ b/src/main/resources/sql/parking-mapper.xml @@ -0,0 +1,237 @@ + + + + + /* parking-mapper|selectParkingList|julim */ + SELECT ms_year, + ms_chasu, + ms_sdate, + ms_startsi, + ms_edate, + ms_cdate, + ms_closesi, + cnt + FROM ( + SELECT R.*, ROWNUM rn + FROM ( + SELECT ms_year, + ms_chasu, + ms_sdate, + ms_startsi, + ms_edate, + ms_cdate, + ms_closesi, + count(ms_maincode) AS cnt + FROM min_simsa680 + WHERE ms_year = #{msYear} + + AND ms_chasu = #{msChasu} + + GROUP BY ms_year, ms_chasu, ms_sdate, ms_startsi, ms_edate, ms_cdate, ms_closesi + ORDER BY ms_year DESC, ms_chasu DESC + ) R + WHERE ROWNUM <= (#{page} + 1) * #{size} + ) + WHERE rn > #{page} * #{size} + AND ROWNUM <= #{size} + + + + /* parking-mapper|selectParkingListCnt|julim */ + SELECT count(*) AS totalCount + FROM ( + SELECT ms_year + FROM min_simsa680 + WHERE ms_year = #{msYear} + + AND ms_chasu = #{msChasu} + + GROUP BY ms_year, ms_chasu, ms_sdate, ms_startsi, ms_edate, ms_cdate, ms_closesi + ) + + + + + /* parking-mapper|insertParkingJudgeTargetIntoSelect|julim */ + insert + into min_simsa680( + ms_maincode, + ms_seq, + ms_carnum, + ms_year, + ms_chasu, + ms_sdate, + ms_startsi, + ms_edate, + ms_cdate, + ms_closesi, + ms_wdate, + ms_pos, + ms_result, + ms_jbtime + ) select TR.rc_code, + TR.rc_seq, + TM.mm_ocarno, + #{msYear}, + #{msChasu}, + #{msSdate}, + #{msStartsi}, + #{msEdate}, + #{msCdate}, + #{msClosesi}, + TM.mm_wdate, + TD.do_bname||''||TJ.mj_pos, + #{msResult}, + TJ.mj_jbtime + from tf680_recall TR + join tf680_main TM on TR.rc_code = #{rcCode} + and TM.mm_code = TR.rc_maincode + and TR.rc_ir_transfer = '1' + and TR.rc_state = '0' + join tf680_jucha TJ on TM.mm_code = TJ.mj_code + join tf680_dong TD + on TJ.mj_dong = TD.do_code + + + + /* parking-mapper|selectTotParkingJudgeResultGroupByTeamAndChasu|julim */ + SELECT msu_team AS msuTeam + , NVL(SUM(DECODE(MS.ms_result, '2', 1, 0)), 0) bu + , 0 as seo + , NVL(SUM(DECODE(MS.ms_result, '1', 1, 0)), 0) mibu + , NVL(SUM(DECODE(MS.ms_result, '1', 1, '2', 1, 0)), 0) tot + , '결과' as name + FROM min_simsa680 MS + , msu680_view MV + WHERE MS.ms_maincode = MV.msu_maincode + + AND MV.msu_team = #{msuTeam} + + AND MS.ms_chasu = #{msChasu} + AND MS.ms_sdate = #{msSdate} + AND MS.ms_edate = #{msEdate} + GROUP BY MV.msu_team, MS.ms_chasu + + + + /* parking-mapper|selectParkingJudgeTeamGroupByChasuAndTeamList|julim */ + SELECT MV.msu_team AS msuTeam + , NVL(SUM(DECODE(MS.ms_result, '2', 1, 0)), 0) bu + , 0 as seo + , NVL(SUM(DECODE(MS.ms_result, '1', 1, 0)), 0) mibu + , NVL(SUM(DECODE(MS.ms_result, '1', 1, '2', 1, 0)), 0) tot + , '결과' as name + FROM min_simsa680 MS + , msu680_view MV + WHERE MS.ms_maincode = MV.msu_maincode + + AND MV.msu_team = #{msuTeam} + + AND MS.ms_chasu = #{msChasu} + AND MS.ms_sdate = #{msSdate} + AND MS.ms_edate = #{msEdate} + GROUP BY MS.ms_chasu, MV.msu_team + ORDER BY MS.ms_chasu, MV.msu_team + + + + /* parking-mapper|selectTotParkingJudgeResultByUser|julim */ + SELECT SUM(DECODE(MSU_RESULT, '2', 1, 0)) as bu + , 0 as seo + , SUM(DECODE(MSU_RESULT, '1', 1, 0)) as mibu + , SUM(DECODE(MSU_RESULT, '1', 1, '2', 1, 0)) as tot + , MU.name + FROM min_simsa680 MS + , min_simsa_user680 MSU + , min_userinfo MU + WHERE MS.ms_maincode = MSU.msu_maincode + AND MS.ms_chasu = #{msChasu} + AND MS.ms_sdate = #{msSdate} + AND MS.ms_edate = #{msEdate} + AND MSU.msu_userid = MU.userid + + AND MSU.msu_team = #{msuTeam} + + GROUP BY MSU.msu_userid, MU.name + ORDER BY MSU.msu_userid, MU.name + + + + /* parking-mapper|selectParkingJurgeResultGroupByCarnum|julim */ + SELECT MS.ms_maincode AS msMaincode + , MS.ms_seq AS msSeq + , MS.ms_carnum AS msCarnum + FROM min_simsa680 MS + , min_simsa_user680 MSU + WHERE MS.ms_maincode = MSU.msu_maincode + AND MS.ms_chasu = #{msChasu} + AND MS.ms_sdate = #{msSdate} + AND MS.ms_edate = #{msEdate} + + AND MSU.msu_team = #{msuTeam} + + GROUP BY MS.ms_maincode, MS.ms_seq, MS.ms_carnum + ORDER BY MS.ms_maincode, MS.ms_seq, MS.ms_carnum + + + + /* parking-mapper|selectParkingJudgeResultList|julim */ + SELECT MS.ms_maincode AS msMaincode + , MS.ms_seq AS msSeq + , MS.ms_carnum AS msCarnum + , MU.name + , MS.ms_result AS msResult + , (SELECT code_nm + FROM tb_cmm_code_s + WHERE code_grp_id = 'TRAFFIC' + AND code_lcd = 'GANGNAM_SIMSA' + AND code_mcd = 'RESULT' + AND code_cd = MS.ms_result) as msResultNm + , (SELECT code_nm + FROM tb_cmm_code_s + WHERE code_grp_id = 'TRAFFIC' + AND code_lcd = 'GANGNAM_SIMSA' + AND code_mcd = 'RESULT' + AND code_cd = MSU.msu_result) as msuResult + FROM min_simsa680 MS + , min_simsa_user680 MSU + , min_userinfo MU + WHERE MS.ms_maincode = MSU.msu_maincode + AND MS.ms_chasu = #{msChasu} + AND MS.ms_sdate = #{msSdate} + AND MS.ms_edate = #{msEdate} + AND MS.ms_seq in #{seqList} + AND MS.ms_carnum in #{carnumList} + + AND MSU.msu_team = #{msuTeam} + + AND MSU.msu_userid = MU.userid + ORDER BY MSU.msu_userid, MU.name, MS.ms_maincode, MS.ms_seq, MS.ms_carnum + + + + + /* parking-mapper|selectDashboardJudgeList|julim */ + SELECT MS.ms_edate + , MSU.msu_team + , MU.name + , SUM(DECODE(MSU.msu_result, 0, 0, 1)) jcnt + , COUNT(*) tcnt + FROM min_simsa680 MS + , min_simsa_user680 MSU + , min_userinfo MU + , (SELECT * + FROM (SELECT ms_edate + FROM min_simsa680 + WHERE MS_RESULT = '0' + ORDER BY ms_edate DESC) + WHERE ROWNUM = 1) T + WHERE MS.ms_maincode = MSU.msu_maincode + AND MS.ms_result = '0' + AND MSU.msu_userid = MU.userid + AND MS.ms_edate = T.ms_edate + GROUP BY MS.ms_edate, MSU.msu_team, MU.name + ORDER BY MSU.msu_team, MU.name + + + \ No newline at end of file