diff --git a/mvnw b/mvnw index 66df285..41c0f0c 100644 --- a/mvnw +++ b/mvnw @@ -8,7 +8,7 @@ # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at # -# https://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an @@ -19,7 +19,7 @@ # ---------------------------------------------------------------------------- # ---------------------------------------------------------------------------- -# Apache Maven Wrapper startup batch script, version 3.2.0 +# Maven Start Up Batch script # # Required ENV vars: # ------------------ @@ -27,6 +27,7 @@ # # Optional ENV vars # ----------------- +# M2_HOME - location of maven2's installed home dir # MAVEN_OPTS - parameters passed to the Java VM when running Maven # e.g. to debug Maven itself, use # set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 @@ -35,10 +36,6 @@ if [ -z "$MAVEN_SKIP_RC" ] ; then - if [ -f /usr/local/etc/mavenrc ] ; then - . /usr/local/etc/mavenrc - fi - if [ -f /etc/mavenrc ] ; then . /etc/mavenrc fi @@ -53,7 +50,7 @@ fi cygwin=false; darwin=false; mingw=false -case "$(uname)" in +case "`uname`" in CYGWIN*) cygwin=true ;; MINGW*) mingw=true;; Darwin*) darwin=true @@ -61,9 +58,9 @@ case "$(uname)" in # See https://developer.apple.com/library/mac/qa/qa1170/_index.html if [ -z "$JAVA_HOME" ]; then if [ -x "/usr/libexec/java_home" ]; then - JAVA_HOME="$(/usr/libexec/java_home)"; export JAVA_HOME + export JAVA_HOME="`/usr/libexec/java_home`" else - JAVA_HOME="/Library/Java/Home"; export JAVA_HOME + export JAVA_HOME="/Library/Java/Home" fi fi ;; @@ -71,38 +68,68 @@ esac if [ -z "$JAVA_HOME" ] ; then if [ -r /etc/gentoo-release ] ; then - JAVA_HOME=$(java-config --jre-home) + JAVA_HOME=`java-config --jre-home` fi fi +if [ -z "$M2_HOME" ] ; then + ## resolve links - $0 may be a link to maven's home + PRG="$0" + + # need this for relative symlinks + while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG="`dirname "$PRG"`/$link" + fi + done + + saveddir=`pwd` + + M2_HOME=`dirname "$PRG"`/.. + + # make it fully qualified + M2_HOME=`cd "$M2_HOME" && pwd` + + cd "$saveddir" + # echo Using m2 at $M2_HOME +fi + # For Cygwin, ensure paths are in UNIX format before anything is touched if $cygwin ; then + [ -n "$M2_HOME" ] && + M2_HOME=`cygpath --unix "$M2_HOME"` [ -n "$JAVA_HOME" ] && - JAVA_HOME=$(cygpath --unix "$JAVA_HOME") + JAVA_HOME=`cygpath --unix "$JAVA_HOME"` [ -n "$CLASSPATH" ] && - CLASSPATH=$(cygpath --path --unix "$CLASSPATH") + CLASSPATH=`cygpath --path --unix "$CLASSPATH"` fi # For Mingw, ensure paths are in UNIX format before anything is touched if $mingw ; then - [ -n "$JAVA_HOME" ] && [ -d "$JAVA_HOME" ] && - JAVA_HOME="$(cd "$JAVA_HOME" || (echo "cannot cd into $JAVA_HOME."; exit 1); pwd)" + [ -n "$M2_HOME" ] && + M2_HOME="`(cd "$M2_HOME"; pwd)`" + [ -n "$JAVA_HOME" ] && + JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" fi if [ -z "$JAVA_HOME" ]; then - javaExecutable="$(which javac)" - if [ -n "$javaExecutable" ] && ! [ "$(expr "\"$javaExecutable\"" : '\([^ ]*\)')" = "no" ]; then + javaExecutable="`which javac`" + if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then # readlink(1) is not available as standard on Solaris 10. - readLink=$(which readlink) - if [ ! "$(expr "$readLink" : '\([^ ]*\)')" = "no" ]; then + readLink=`which readlink` + if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then if $darwin ; then - javaHome="$(dirname "\"$javaExecutable\"")" - javaExecutable="$(cd "\"$javaHome\"" && pwd -P)/javac" + javaHome="`dirname \"$javaExecutable\"`" + javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" else - javaExecutable="$(readlink -f "\"$javaExecutable\"")" + javaExecutable="`readlink -f \"$javaExecutable\"`" fi - javaHome="$(dirname "\"$javaExecutable\"")" - javaHome=$(expr "$javaHome" : '\(.*\)/bin') + javaHome="`dirname \"$javaExecutable\"`" + javaHome=`expr "$javaHome" : '\(.*\)/bin'` JAVA_HOME="$javaHome" export JAVA_HOME fi @@ -118,7 +145,7 @@ if [ -z "$JAVACMD" ] ; then JAVACMD="$JAVA_HOME/bin/java" fi else - JAVACMD="$(\unset -f command 2>/dev/null; \command -v java)" + JAVACMD="`which java`" fi fi @@ -132,9 +159,12 @@ if [ -z "$JAVA_HOME" ] ; then echo "Warning: JAVA_HOME environment variable is not set." fi +CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher + # traverses directory structure from process work directory to filesystem root # first directory with .mvn subdirectory is considered project base directory find_maven_basedir() { + if [ -z "$1" ] then echo "Path not specified to find_maven_basedir" @@ -150,99 +180,96 @@ find_maven_basedir() { fi # workaround for JBEAP-8937 (on Solaris 10/Sparc) if [ -d "${wdir}" ]; then - wdir=$(cd "$wdir/.." || exit 1; pwd) + wdir=`cd "$wdir/.."; pwd` fi # end of workaround done - printf '%s' "$(cd "$basedir" || exit 1; pwd)" + echo "${basedir}" } # concatenates all lines of a file concat_lines() { if [ -f "$1" ]; then - # Remove \r in case we run on Windows within Git Bash - # and check out the repository with auto CRLF management - # enabled. Otherwise, we may read lines that are delimited with - # \r\n and produce $'-Xarg\r' rather than -Xarg due to word - # splitting rules. - tr -s '\r\n' ' ' < "$1" - fi -} - -log() { - if [ "$MVNW_VERBOSE" = true ]; then - printf '%s\n' "$1" + echo "$(tr -s '\n' ' ' < "$1")" fi } -BASE_DIR=$(find_maven_basedir "$(dirname "$0")") +BASE_DIR=`find_maven_basedir "$(pwd)"` if [ -z "$BASE_DIR" ]; then exit 1; fi -MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"}; export MAVEN_PROJECTBASEDIR -log "$MAVEN_PROJECTBASEDIR" - ########################################################################################## # Extension to allow automatically downloading the maven-wrapper.jar from Maven-central # This allows using the maven wrapper in projects that prohibit checking in binary data. ########################################################################################## -wrapperJarPath="$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" -if [ -r "$wrapperJarPath" ]; then - log "Found $wrapperJarPath" +if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found .mvn/wrapper/maven-wrapper.jar" + fi else - log "Couldn't find $wrapperJarPath, downloading it ..." - + if [ "$MVNW_VERBOSE" = true ]; then + echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..." + fi if [ -n "$MVNW_REPOURL" ]; then - wrapperUrl="$MVNW_REPOURL/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar" + jarUrl="$MVNW_REPOURL/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" else - wrapperUrl="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar" + jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" fi - while IFS="=" read -r key value; do - # Remove '\r' from value to allow usage on windows as IFS does not consider '\r' as a separator ( considers space, tab, new line ('\n'), and custom '=' ) - safeValue=$(echo "$value" | tr -d '\r') - case "$key" in (wrapperUrl) wrapperUrl="$safeValue"; break ;; + while IFS="=" read key value; do + case "$key" in (wrapperUrl) jarUrl="$value"; break ;; esac - done < "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.properties" - log "Downloading from: $wrapperUrl" - + done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties" + if [ "$MVNW_VERBOSE" = true ]; then + echo "Downloading from: $jarUrl" + fi + wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" if $cygwin; then - wrapperJarPath=$(cygpath --path --windows "$wrapperJarPath") + wrapperJarPath=`cygpath --path --windows "$wrapperJarPath"` fi if command -v wget > /dev/null; then - log "Found wget ... using wget" - [ "$MVNW_VERBOSE" = true ] && QUIET="" || QUIET="--quiet" + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found wget ... using wget" + fi if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then - wget $QUIET "$wrapperUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath" + wget "$jarUrl" -O "$wrapperJarPath" else - wget $QUIET --http-user="$MVNW_USERNAME" --http-password="$MVNW_PASSWORD" "$wrapperUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath" + wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath" fi elif command -v curl > /dev/null; then - log "Found curl ... using curl" - [ "$MVNW_VERBOSE" = true ] && QUIET="" || QUIET="--silent" + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found curl ... using curl" + fi if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then - curl $QUIET -o "$wrapperJarPath" "$wrapperUrl" -f -L || rm -f "$wrapperJarPath" + curl -o "$wrapperJarPath" "$jarUrl" -f else - curl $QUIET --user "$MVNW_USERNAME:$MVNW_PASSWORD" -o "$wrapperJarPath" "$wrapperUrl" -f -L || rm -f "$wrapperJarPath" + curl --user $MVNW_USERNAME:$MVNW_PASSWORD -o "$wrapperJarPath" "$jarUrl" -f fi + else - log "Falling back to using Java to download" - javaSource="$MAVEN_PROJECTBASEDIR/.mvn/wrapper/MavenWrapperDownloader.java" - javaClass="$MAVEN_PROJECTBASEDIR/.mvn/wrapper/MavenWrapperDownloader.class" + if [ "$MVNW_VERBOSE" = true ]; then + echo "Falling back to using Java to download" + fi + javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java" # For Cygwin, switch paths to Windows format before running javac if $cygwin; then - javaSource=$(cygpath --path --windows "$javaSource") - javaClass=$(cygpath --path --windows "$javaClass") + javaClass=`cygpath --path --windows "$javaClass"` fi - if [ -e "$javaSource" ]; then - if [ ! -e "$javaClass" ]; then - log " - Compiling MavenWrapperDownloader.java ..." - ("$JAVA_HOME/bin/javac" "$javaSource") + if [ -e "$javaClass" ]; then + if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then + if [ "$MVNW_VERBOSE" = true ]; then + echo " - Compiling MavenWrapperDownloader.java ..." + fi + # Compiling the Java class + ("$JAVA_HOME/bin/javac" "$javaClass") fi - if [ -e "$javaClass" ]; then - log " - Running MavenWrapperDownloader.java ..." - ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$wrapperUrl" "$wrapperJarPath") || rm -f "$wrapperJarPath" + if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then + # Running the downloader + if [ "$MVNW_VERBOSE" = true ]; then + echo " - Running MavenWrapperDownloader.java ..." + fi + ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR") fi fi fi @@ -251,58 +278,33 @@ fi # End of extension ########################################################################################## -# If specified, validate the SHA-256 sum of the Maven wrapper jar file -wrapperSha256Sum="" -while IFS="=" read -r key value; do - case "$key" in (wrapperSha256Sum) wrapperSha256Sum=$value; break ;; - esac -done < "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.properties" -if [ -n "$wrapperSha256Sum" ]; then - wrapperSha256Result=false - if command -v sha256sum > /dev/null; then - if echo "$wrapperSha256Sum $wrapperJarPath" | sha256sum -c > /dev/null 2>&1; then - wrapperSha256Result=true - fi - elif command -v shasum > /dev/null; then - if echo "$wrapperSha256Sum $wrapperJarPath" | shasum -a 256 -c > /dev/null 2>&1; then - wrapperSha256Result=true - fi - else - echo "Checksum validation was requested but neither 'sha256sum' or 'shasum' are available." - echo "Please install either command, or disable validation by removing 'wrapperSha256Sum' from your maven-wrapper.properties." - exit 1 - fi - if [ $wrapperSha256Result = false ]; then - echo "Error: Failed to validate Maven wrapper SHA-256, your Maven wrapper might be compromised." >&2 - echo "Investigate or delete $wrapperJarPath to attempt a clean download." >&2 - echo "If you updated your Maven version, you need to update the specified wrapperSha256Sum property." >&2 - exit 1 - fi +export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} +if [ "$MVNW_VERBOSE" = true ]; then + echo $MAVEN_PROJECTBASEDIR fi - MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" # For Cygwin, switch paths to Windows format before running java if $cygwin; then + [ -n "$M2_HOME" ] && + M2_HOME=`cygpath --path --windows "$M2_HOME"` [ -n "$JAVA_HOME" ] && - JAVA_HOME=$(cygpath --path --windows "$JAVA_HOME") + JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` [ -n "$CLASSPATH" ] && - CLASSPATH=$(cygpath --path --windows "$CLASSPATH") + CLASSPATH=`cygpath --path --windows "$CLASSPATH"` [ -n "$MAVEN_PROJECTBASEDIR" ] && - MAVEN_PROJECTBASEDIR=$(cygpath --path --windows "$MAVEN_PROJECTBASEDIR") + MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"` fi # Provide a "standardized" way to retrieve the CLI args that will # work with both Windows and non-Windows executions. -MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $*" +MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@" export MAVEN_CMD_LINE_ARGS WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain -# shellcheck disable=SC2086 # safe args exec "$JAVACMD" \ $MAVEN_OPTS \ - $MAVEN_DEBUG_OPTS \ -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ - "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ + "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" diff --git a/src/main/java/com/batch/config/MatchingExtraProcessorAuto.java b/src/main/java/com/batch/config/MatchingExtraProcessorAuto.java index d0ef9db..03b14f9 100644 --- a/src/main/java/com/batch/config/MatchingExtraProcessorAuto.java +++ b/src/main/java/com/batch/config/MatchingExtraProcessorAuto.java @@ -42,12 +42,14 @@ public class MatchingExtraProcessorAuto { String sAccnutYm = (String) paramRec.get("accnut_ym"); String sCprCode = (String) paramRec.get("cpr_code"); String sPartCpr = (String) paramRec.get("partn_cpr"); + String sDelngCrncy = (String) paramRec.get("delng_crncy"); String sConds = (String) paramRec.get("conds"); //작업시작 Map mParam = new HashMap(); mParam.put("sysSe", sSysSe); mParam.put("accnutYm", sAccnutYm); + mParam.put("delngCurncy", sDelngCrncy); mParam.put("conds", sConds); //---------------------------------------------------------------------------- diff --git a/src/main/java/com/batch/controller/JobController.java b/src/main/java/com/batch/controller/JobController.java index 3e81e97..7849330 100644 --- a/src/main/java/com/batch/controller/JobController.java +++ b/src/main/java/com/batch/controller/JobController.java @@ -8,6 +8,7 @@ import java.util.Map; import java.util.UUID; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; @@ -20,6 +21,7 @@ import com.batch.config.MatchingSetup.Matching; import com.batch.mapper.primary.MatchingInnerDelingMapper; import com.batch.service.JobService; import com.batch.util.FileUtil; +import com.batch.util.JsonUtil; import com.google.gson.JsonObject; import lombok.extern.slf4j.Slf4j; @@ -33,6 +35,12 @@ public class JobController { private JobService jobService; @Autowired private MatchingInnerDelingMapper matchingInnerDelingMapper; + @Value("${thread.ai.count.rowmax}") + BigDecimal bdAiAsyncMaxRowCount; + @Value("${thread.ai.processing.wait}") + BigDecimal bdAiAsyncWaitTime; + @Value("${thread.ai.processing.wait.total}") + BigDecimal bdAiAsyncTotalWaitTime; @@ -67,9 +75,9 @@ public class JobController { UUID uuid = UUID.randomUUID(); String sJobGroup = uuid.toString(); - log.debug("Start Create Job"); + log.info("Start Create Job"); jobService.createData(sJobGroup, params); - log.debug("End Create Job"); + log.info("End Create Job"); Map rtnMap = new HashMap(); rtnMap.put("jobGroupId", sJobGroup); @@ -94,9 +102,9 @@ public class JobController { UUID uuid = UUID.randomUUID(); String sJobGroup = uuid.toString(); - log.debug("Start Matching Job"); + log.info("Start Matching Job"); jobService.matchingJob(sJobGroup, params); - log.debug("End Matching Job"); + log.info("End Matching Job"); Map rtnMap = new HashMap(); rtnMap.put("jobGroupId", sJobGroup); @@ -122,7 +130,8 @@ public class JobController { UUID uuid = UUID.randomUUID(); String sJobGroup = uuid.toString(); - log.debug("Start Extra Matching Job"); + log.info("Start Extra Matching Job"); + params.put("asCurrency", "Y"); List retData = matchingInnerDelingMapper.getCustomItemReadData(params); // 수익/비용 @@ -140,7 +149,7 @@ public class JobController { jobService.extraJobSub(sJobGroup, cParams); } - log.debug("End Extra Matching Job"); + log.info("End Extra Matching Job"); Map rtnMap = new HashMap(); rtnMap.put("jobGroupId", sJobGroup); @@ -166,7 +175,7 @@ public class JobController { UUID uuid = UUID.randomUUID(); String sJobGroup = uuid.toString(); - log.debug("Start AI Sub Matching Job"); + log.info("Start AI Sub Matching Job"); List retData = matchingInnerDelingMapper.getAiSubReadData(params); //AI의 경우 수익비용만 매칭하고 있음 @@ -178,7 +187,7 @@ public class JobController { jobService.aiSubJobSub(sJobGroup, cParams); } - log.debug("End Extra Matching Job"); + log.info("End Extra Matching Job"); Map rtnMap = new HashMap(); rtnMap.put("jobGroupId", sJobGroup); @@ -200,19 +209,49 @@ public class JobController { * "error_range": "0" * } */ - //Job Create Log + //Job Create LogmatchingInnerDelingMapper UUID uuid = UUID.randomUUID(); String sJobGroup = uuid.toString(); - log.debug("Start AI Matching Job"); + log.info("Start AI Matching Job"); List retData = matchingInnerDelingMapper.getAiReadData(params); + BigDecimal bdCurrentRowCount = BigDecimal.ZERO; for(Map curMap : retData) { Map curMParams = new HashMap(); curMParams.putAll(curMap); curMParams.put("error_range", params.get("error_range")); + + BigDecimal bdCntAll = new BigDecimal(String.valueOf(curMap.get("cnt_all"))); + bdCurrentRowCount = bdCurrentRowCount.add(bdCntAll); + log.info("Call Matching Job (" + JsonUtil.objectToString(curMap) + ")"); jobService.aiJobSub(sJobGroup, curMParams); + + //전체카운트가 처리가능카운트를 넘어설때 + if (bdCurrentRowCount.compareTo(bdAiAsyncMaxRowCount) > -1) { + bdCurrentRowCount = BigDecimal.ZERO; + + //현재 작업그룹이 종료가 되었는지 체크해서 종료시 카운트 초기화 하고 다음작업을 한다. + boolean blnStatus = true; + Integer iTotalWait = 0; + Integer iWaitTime = bdAiAsyncWaitTime.intValue() * 1000; //밀리초 + do { + Map mParam = new HashMap(); + mParam.put("userJobGroup", sJobGroup); + List lmJob = matchingInnerDelingMapper.getUserJobStatus(mParam); + for (Map curJob : lmJob) { + String ScurStatus = (String) curJob.get("status"); + if (!"Finished".equalsIgnoreCase(ScurStatus)) { + blnStatus = false; + Thread.sleep(iWaitTime); + iTotalWait = iTotalWait + iWaitTime; + break; + } + } + } while (!blnStatus && iTotalWait < bdAiAsyncTotalWaitTime.intValue()); //전체 기다리는 시간까지 체크 + log.info("Next Thread Group Processing"); + } } - log.debug("End AI Matching Job"); + log.info("End AI Matching Job"); Map rtnMap = new HashMap(); rtnMap.put("jobGroupId", sJobGroup); @@ -233,9 +272,9 @@ public class JobController { UUID uuid = UUID.randomUUID(); String sJobGroup = uuid.toString(); - log.debug("Start Return Job"); + log.info("Start Return Job"); jobService.returnRwsultData(sJobGroup, params); - log.debug("End Return Job"); + log.info("End Return Job"); Map rtnMap = new HashMap(); rtnMap.put("jobGroupId", sJobGroup); @@ -311,6 +350,34 @@ public class JobController { return rtnVal; } + + + @PostMapping("/callAsyncJob") + public Map callAsyncJob( @RequestBody Map params) throws Exception { + + /* + * { + * "PrgName": "cmd", + * "PrgParams": "/C dir /w", + * } + */ + //Job Create Log + UUID uuid = UUID.randomUUID(); + String sJobGroup = uuid.toString(); + + log.info("Start AI Sub Matching Job"); + + //OS Command Line 수행 + jobService.callAsyncJobSub(sJobGroup, params); + + log.info("End Extra Matching Job"); + + Map rtnMap = new HashMap(); + rtnMap.put("jobGroupId", sJobGroup); + rtnMap.put("jobMessage", "OS Command 작업을 시작합니다. 작업이 끝난후 작업결과는 별도로 확인 바랍니다."); + + return rtnMap; + } } diff --git a/src/main/java/com/batch/service/JobService.java b/src/main/java/com/batch/service/JobService.java index 9e81339..c6af035 100644 --- a/src/main/java/com/batch/service/JobService.java +++ b/src/main/java/com/batch/service/JobService.java @@ -36,7 +36,7 @@ import com.batch.config.MatchingSetup.Matching; import com.batch.mapper.primary.MatchingInnerDelingMapper; import com.batch.mapper.secondary.OracleMapper; import com.batch.util.FileUtil; - +import com.batch.util.StringUtil; import com.batch.service.JobService; import lombok.extern.slf4j.Slf4j; @@ -49,6 +49,9 @@ public class JobService { @Value("${python.ai.target}") String sPythonAiTarget; + + @Value("${matching.auto.exceptListByComma}") + String sExceptMatchType; @Autowired private JobLauncher jobLauncher; @@ -102,8 +105,18 @@ public class JobService { } } - for (String sJobType : lJobType) { + if (!matchingSetup.getMatching(sJobType).getActive()) { + log.info("[" + sThreadName + "]JobType(" + sJobType + " is Disabled"); + continue; + }; + + List lExceptMatchType = StringUtil.StringToArrayList(sExceptMatchType); + if (lExceptMatchType.indexOf(sJobType) > -1) { + log.info("[" + sThreadName + "]JobType(" + sJobType + " is Excepted"); + continue; + }; + log.info("[" + sThreadName + "]Current running job type: " + sJobType); JobExecution jobExe = invokeJob("matchingInnerDelng", sJobType, params); if (!jobExe.getStatus().equals(BatchStatus.COMPLETED)) { @@ -143,7 +156,7 @@ public class JobService { String sThreadName = Thread.currentThread().getName(); long startTime = System.currentTimeMillis(); log.info("extra [" + sThreadName + "]Job Started : " + startTime); - log.debug("extra [" + sThreadName + "]params=" + paramRec.toString()); + log.info("extra [" + sThreadName + "]params=" + paramRec.toString()); MatchingExtraProcessorAuto matchingExtraProcessorAuto = new MatchingExtraProcessorAuto(matchingInnerDelingMapper); @@ -468,5 +481,60 @@ public class JobService { paramLog.put("exit_message", ""); matchingInnerDelingMapper.finishUserJob(paramLog); - } + } + + + @SuppressWarnings("rawtypes") + @Async("commAsync") + public void callAsyncJobSub(String jobGroupId, Map paramRec) throws Exception { + + + //Job Create Log + UUID uuid = UUID.randomUUID(); + HashMap mt = new HashMap(); + SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd-hh-mm-ss"); + String sDate = dateFormat.format(new Date()) + ":" + uuid.toString(); + + Map paramLog = new HashMap(); + paramLog.put("user_job_group", jobGroupId); + paramLog.put("user_job_id", sDate); + paramLog.put("user_job_name", "OS Command Run(" + paramRec.toString() + ")"); + matchingInnerDelingMapper.createUserJob(paramLog); + + + long startTime = System.currentTimeMillis(); + log.info("OS Command Run Started : " + startTime); + log.info("OS Command Run params=" + paramRec.toString()); + + String sPrgName = (String) paramRec.get("PrgName"); + String sPrgParam = (String) paramRec.get("PrgParams"); + List lParams = StringUtil.StringToArrayList(sPrgParam, " "); + + ArrayList lcmd = new ArrayList(); + lcmd.add(sPrgName); + lcmd.addAll(lParams); + lcmd.add(jobGroupId); + + new ProcessExecutor() + .command(lcmd) + .redirectOutput(new LogOutputStream() { + @Override + protected void processLine(String line) { + log.info(line); + } + }) + .execute(); + + long endTime = System.currentTimeMillis(); + log.info("OS Command Run Ended: " + endTime); + log.info("OS Command Running Time : " + (endTime - startTime) + "ms"); + + +// //작업종료에 대한 로그 업데이트 +// paramLog.put("exit_code", "0"); +// paramLog.put("exit_message", ""); +// matchingInnerDelingMapper.finishUserJob(paramLog); + + } + } diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 66666e4..d2f4594 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -18,14 +18,14 @@ spring.datasource.hikari.primary.username=account spring.datasource.hikari.primary.password=daeucna10! # secondary -#spring.datasource.hikari.secondary.driver-class-name=oracle.jdbc.driver.OracleDriver -#spring.datasource.hikari.secondary.jdbc-url=jdbc:oracle:thin:@vanguardlab.kr:63522/CONFINAS19C -#spring.datasource.hikari.secondary.username=ai -#spring.datasource.hikari.secondary.password=ai spring.datasource.hikari.secondary.driver-class-name=oracle.jdbc.driver.OracleDriver -spring.datasource.hikari.secondary.jdbc-url=jdbc:oracle:thin:@daeuserver2.iptime.org:1521/orcl -spring.datasource.hikari.secondary.username=CONFINAS3 -spring.datasource.hikari.secondary.password=CONFINAS3 +spring.datasource.hikari.secondary.jdbc-url=jdbc:oracle:thin:@vanguardlab.kr:63522/CONFINAS19C +spring.datasource.hikari.secondary.username=ai +spring.datasource.hikari.secondary.password=ai +#spring.datasource.hikari.secondary.driver-class-name=oracle.jdbc.driver.OracleDriver +#spring.datasource.hikari.secondary.jdbc-url=jdbc:oracle:thin:@daeuserver2.iptime.org:1521/orcl +#spring.datasource.hikari.secondary.username=CONFINAS3 +#spring.datasource.hikari.secondary.password=CONFINAS3 @@ -52,7 +52,13 @@ logging.level.p6spy=off thread.comm.count=10 thread.ext.count=50 thread.ai.count=50 +thread.ai.count.rowmax=500 +thread.ai.processing.wait=15 +thread.ai.processing.wait.total=3600 #Python 프로퍼티 설정 pytyon.path=D:\\Programs\\devp\\python-3.12.2\\python.exe -python.ai.target=D:\\Working\\Python\\Test1.py \ No newline at end of file +python.ai.target=D:\\Working\\Python\\Test1.py + +#Auto Matching 제외 +matching.auto.exceptListByComma=C-A-ROUND(-2) \ No newline at end of file diff --git a/src/main/resources/matchingSetup.json b/src/main/resources/matchingSetup.json index 0022081..e3249c5 100644 --- a/src/main/resources/matchingSetup.json +++ b/src/main/resources/matchingSetup.json @@ -289,6 +289,54 @@ }, + + { + "active": true, + "type": "C-A-ROUND(-2)", + "typeName": "자기수익(전표번호,거래통화),상대비용(전표번호,거래통화),비교(년월,거래통화,거래금액)", + + "condOne": { + "cond": [ + "dta_ty in ('11','21','41')", + "mtch_ty is null", + "chit_no is not null", + "chit_no != ''" + ], + "makeCompareKey": [ + "chit_no", + "delng_crncy" + ] + }, + "condTwo": { + "cond": [ + "dta_ty in ('12','22','42')", + "mtch_ty is null", + "chit_no is not null", + "chit_no != ''" + ], + "makeCompareKey": [ + "chit_no", + "delng_crncy" + ] + }, + "uniqueKey": [ + "sys_se", + "accnut_ym", + "sn" + ], + "compareKey": "compare_ky", + "currencyField": "delng_crncy", + "amtField": "round(sum(delng_amt), -2) as delng_amt", + "compareField": [ + "accnut_ym", + "delng_crncy", + "delng_amt" + ], + "matchingType": "mtch_ty", + "matchingTypeName": "mtch_ty_nm", + "matchingNumber": "mtch_ky" + }, + diff --git a/src/main/resources/mybatis/primaryMapper/MatchingInnerDelingMapper.xml b/src/main/resources/mybatis/primaryMapper/MatchingInnerDelingMapper.xml index 4a2b5d7..2a569a1 100644 --- a/src/main/resources/mybatis/primaryMapper/MatchingInnerDelingMapper.xml +++ b/src/main/resources/mybatis/primaryMapper/MatchingInnerDelingMapper.xml @@ -9,6 +9,9 @@ , accnut_ym , cpr_code , partn_cpr + + , delng_crncy + FROM ( SELECT @@ -16,6 +19,9 @@ , accnut_ym , cpr_code , partn_cpr + + , delng_crncy + , case when count(*) > 0 then 1 else 0 end as cnt FROM public.batch_tbcr_inner_delng @@ -35,12 +41,18 @@ , accnut_ym , cpr_code , partn_cpr + + , delng_crncy + union all SELECT sys_se , accnut_ym , partn_cpr as cpr_code , cpr_code as partn_cpr + + , delng_crncy + , case when count(*) > 0 then 1 else 0 end as cnt FROM public.batch_tbcr_inner_delng @@ -60,12 +72,18 @@ , accnut_ym , cpr_code , partn_cpr + + , delng_crncy + ) m GROUP BY sys_se , accnut_ym , cpr_code , partn_cpr + + , delng_crncy + HAVING sum(cnt) > 1 @@ -457,6 +475,7 @@ and accnut_ym = #{accnutYm} and cpr_code = #{cprCode} and partn_cpr = #{partnCpr} + and delng_crncy = #{delngCurncy} and mtch_ky is null and dta_ty in ('11','21','41') @@ -485,6 +504,7 @@ and accnut_ym = #{accnutYm} and cpr_code = #{cprCode} and partn_cpr = #{partnCpr} + and delng_crncy = #{delngCurncy} and mtch_ky is null and dta_ty in ('12','22','42') @@ -548,6 +568,8 @@ , partn_cpr , tb_ty , delng_crncy + , sum(cnt) as cnt + , max(cnt_all) as cnt_all FROM ( SELECT @@ -558,6 +580,7 @@ , delng_crncy , case when dta_ty in ('11','21','41') then 'T' else 'B' end tb_ty , case when count(*) > 0 then 1 else 0 end as cnt + , count(*) as cnt_all FROM public.batch_tbcr_inner_delng WHERE @@ -587,6 +610,7 @@ , delng_crncy , case when dta_ty in ('12','22','42') then 'T' else 'B' end as tb_ty , case when count(*) > 0 then 1 else 0 end as cnt + , count(*) as cnt_all FROM public.batch_tbcr_inner_delng WHERE @@ -616,6 +640,7 @@ , delng_crncy , tb_ty HAVING sum(cnt) > 1 + ORDER BY cnt_all diff --git a/src/main/resources/mybatis/secondaryMapper/OracleMapper.xml b/src/main/resources/mybatis/secondaryMapper/OracleMapper.xml index 07aacd4..9cf4580 100644 --- a/src/main/resources/mybatis/secondaryMapper/OracleMapper.xml +++ b/src/main/resources/mybatis/secondaryMapper/OracleMapper.xml @@ -7,10 +7,19 @@ WITH COMP_INFO AS ( SELECT DISTINCT COMP_CODE AS COMP_CODE - , COMP_KR_NAME AS COMP_NAME + , ( + SELECT + COMP_NAME_0 + FROM TBBC_COMPANY_CODE_NLS + WHERE + SESSION_ID = A.SESSION_ID + AND COMP_CODE = A.COMP_CODE + AND #{accnutYm} BETWEEN START_YYMM AND END_YYMM + AND ROWNUM = 1 + ) AS COMP_NAME , BOOK_CURRENCY AS COMP_CURRENCY , COMP_COA AS COMP_COA - FROM TBBC_COMPANY_CODE + FROM TBBC_COMPANY_CODE A WHERE #{accnutYm} BETWEEN START_YYMM AND END_YYMM ) @@ -28,7 +37,7 @@ A.COMP_ACCT_CODE, ( SELECT DISTINCT - COMP_ACCT_NAME + COMP_ACCT_CODE FROM TBBC_COMP_ACCT_CODE WHERE FS_TYPE = '1' @@ -36,7 +45,7 @@ AND COMP_ACCT_CODE = A.COMP_ACCT_CODE AND #{accnutYm} BETWEEN START_YYMM AND END_YYMM AND ROWNUM = 1 - ) AS COMP_ACCT_NAME, + ) AS COMP_ACCT_NAME, A.COMP_PROD_CODE, A.RECON_KEY, A.TRAN_DATE, @@ -50,13 +59,13 @@ A.CONS_ACCT_CODE, ( SELECT - CONS_ACCT_KR_NAME - FROM TBBC_ACCT_CODE + CONS_ACCT_NAME_0 + FROM TBBC_ACCT_CODE_NLS WHERE CONS_ACCT_CODE = A.CONS_ACCT_CODE - AND CONS_COA = 'GOV_I_COA' + AND CONS_COA = 'LS_COA' AND FS_TYPE = '1' - AND TO_CHAR(SYSDATE, 'YYYYMM') BETWEEN START_YYMM AND END_YYMM + AND #{accnutYm} BETWEEN START_YYMM AND END_YYMM AND ROWNUM = 1 ) AS CONS_ACCT_NAME, A.PROD_CODE, @@ -75,8 +84,8 @@ A.OWN_BIZ_NO, A.PARTNER_BIZ_NO, A.ACCT_DATE, - NULL AS CREATION_DIV_CODE, - NULL AS COST_MAT_KEY + A.CREATION_DIV_CODE, + A.COST_MAT_KEY FROM TBCR_TRANSACTION_HISTORY A INNER JOIN COMP_INFO B @@ -98,7 +107,10 @@ FROM TBCR_MATCHING A, TBCR_MATCHING_DETAIL B WHERE - A.MATCH_KEY = B.MATCH_KEY + A.SESSION_ID = B.SESSION_ID + AND A.CONS_GROUP = B.CONS_GROUP + AND A.LEDGER = B.LEDGER + AND A.MATCH_KEY = B.MATCH_KEY AND A.ACCOUNT_PERIOD = B.ACCOUNT_PERIOD AND A.CONS_GROUP = #{sysSe} AND A.ACCOUNT_PERIOD = #{accnutYm} diff --git a/src/main/resources/schema.sql b/src/main/resources/schema.sql index 1b7856d..5458b4b 100644 --- a/src/main/resources/schema.sql +++ b/src/main/resources/schema.sql @@ -33,11 +33,11 @@ CREATE TABLE IF NOT EXISTS batch_tbcr_inner_delng sumry character varying(500), org_mtch_ty character varying(10), org_mtch_ky numeric(10,0), - new_mtch_ty character varying(10), + new_mtch_ty character varying(50), new_mtch_ky numeric(10,0), compare_ky character varying(100), mtch_sys character varying(10), - mtch_ty character varying(10), + mtch_ty character varying(50), mtch_ty_nm character varying(100), mtch_ky bigint DEFAULT 0, creation_div_code character varying(3), diff --git a/사용법.md b/사용법.md index d57022e..a4e7ce6 100644 --- a/사용법.md +++ b/사용법.md @@ -90,3 +90,11 @@ http://localhost:8080/api/job/return #작업진행결과 http://localhost:8080/api/job/userJobInfo/JOB그룹id + +#Async Job 호출 +http://localhost:8080/api/job/callAsyncJob +{ + "PrgName": "cmd", + "PrgParams": "/C dir /w" +} + -- libgit2 0.21.4