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 c8f33e3..2dcf18e 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 @@ -2,9 +2,11 @@ package com.xit.biz.ctgy.v2.repository; import com.xit.biz.ctgy.dto.*; import com.xit.core.config.database.BaseMpowerDaoSupport; +import com.xit.core.exception.CustomBaseException; import com.xit.core.oauth2.config.properties.MasterDatabaseProperties; import com.xit.core.oauth2.utils.HeaderUtil; import com.xit.core.support.sql.parser.QueryGenerator; +import lombok.extern.slf4j.Slf4j; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.stereotype.Repository; @@ -13,10 +15,12 @@ import javax.validation.constraints.NotNull; import java.time.LocalDate; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; +import java.util.Arrays; import java.util.List; import java.util.Map; @Repository +@Slf4j public class ParkingDao extends BaseMpowerDaoSupport { private static final String NAME_SPACE = "parking"; @@ -103,6 +107,7 @@ public class ParkingDao extends BaseMpowerDaoSupport { } public void updateMsResult(@NotNull final Long msMaincode, @NotNull final String msSeq, @NotNull final String msResult) { + final String sql = QueryGenerator.createNamedQuery(NAME_SPACE, "updateJudegResult") .setParameter("msMaincode", msMaincode) .setParameter("msSeq", msSeq) @@ -110,6 +115,16 @@ public class ParkingDao extends BaseMpowerDaoSupport { .getQueryString(); update(sql); + + final String mainCodeSql = QueryGenerator.createNamedQuery(NAME_SPACE, "selectRcMaincode") + .setParameter("msMaincode", msMaincode) + .getQueryString(); + selectOneColumn(mainCodeSql); + final List inParams = Arrays.asList("11680", "11", selectOneColumn(mainCodeSql), String.valueOf(msSeq), msResult); + final List outParams = Arrays.asList("result", "message"); + final String spSql = "SIMSA_EDIT_RESULT(?,?,?,?,?,?,?)"; + Map rslt = executeSp(spSql, inParams, outParams); + if(!"1".equals(rslt.get("result"))) throw new CustomBaseException(String.valueOf(rslt.get("message"))); } public List findParkingJudgeTargets(@NotNull final ParkingTargetDto dto) { 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 c20ecf9..2498c4e 100644 --- a/src/main/java/com/xit/core/config/database/BaseMpowerDaoSupport.java +++ b/src/main/java/com/xit/core/config/database/BaseMpowerDaoSupport.java @@ -35,7 +35,7 @@ public abstract class BaseMpowerDaoSupport { private int fileHostPort; @Value("${mpower.file.serviceName}") private String fileServiceName; - + // 주정차이미지경로 @Value("${mpower.file.parkingImagePath}") private String parkingImagePath; @@ -267,6 +267,46 @@ public abstract class BaseMpowerDaoSupport { } } + /** + * + * @param sql + * @param inParams + * @param outParams result, message... + */ + public Map executeSp(String sql, List inParams, List outParams){ + Objects.requireNonNull(sql, "SQL cannot be null"); + Map map = new HashMap<>(); + + Client client = null; + try { + client = getConnection(); + client.setInput("SQLXML", getSpQueryXml(sql, inParams, outParams)); + client.Request(); + //map.put("result", client.getString("result", 0, 0)); + + String result = client.getString("result", 0, 0); + + if(result.equals("true")) { + + for (int i = 0; i < client.getMaxCol("list1"); i++) { + map.put(outParams.get(i), client.getString("list1", 0, i)); + } + + }else{ + map.put(outParams.get(0), "-9999"); + map.put(outParams.get(1), result); + } + return map; + + }catch (MpowerException e){ + throw e; + }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<>(); @@ -360,6 +400,39 @@ public abstract class BaseMpowerDaoSupport { "\n]]>"); } + private String getSpQueryXml(String sql, List inParams, List outParams){ + log.info("\n{}",sql); + String str = String.format( + "%s%s%s%s%s%s%s", + "\n\n\n", + setSpParam(inParams, outParams), + "\n"); + log.info(str); + return str; + } + + private String setSpParam(List inParams, List outParams){ + StringBuilder sb = new StringBuilder(); + sb.append(""); + inParams.forEach((s) -> { + sb.append("\n"); + }); + outParams.forEach((s) -> { + sb.append("\n"); + }); + sb.append("\n"); + return sb.toString(); + } + + private Client getConnection(){ Client mpowerClient = null; try { diff --git a/src/main/resources/sql/parking-mapper.xml b/src/main/resources/sql/parking-mapper.xml index 18d7839..993ad0f 100644 --- a/src/main/resources/sql/parking-mapper.xml +++ b/src/main/resources/sql/parking-mapper.xml @@ -392,4 +392,10 @@ AND msu_userid = #{msuUserid} + + /* parking-mapper|selectRcMaincode|julim */ + SELECT rc_maincode + FROM tf680_recall + WHERE rc_code = #{msMaincode} + \ No newline at end of file