Compare commits
6 Commits
f5b30cc110
...
a0cb4ae2ee
| Author | SHA1 | Date |
|---|---|---|
|
|
a0cb4ae2ee | 6 days ago |
|
|
e6343ce179 | 6 days ago |
|
|
1bfa6a6ade | 6 days ago |
|
|
90c7688af1 | 6 days ago |
|
|
076efb2c76 | 6 days ago |
|
|
e47e7306e6 | 6 days ago |
@ -0,0 +1,2 @@
|
|||||||
|
MYSQL_DATABASE=data_admision
|
||||||
|
MYSQL_ALLOW_EMPTY_PASSWORD=yes
|
||||||
@ -0,0 +1,2 @@
|
|||||||
|
/mvnw text eol=lf
|
||||||
|
*.cmd text eol=crlf
|
||||||
@ -1,26 +1,33 @@
|
|||||||
# ---> Java
|
|
||||||
# Compiled class file
|
|
||||||
*.class
|
|
||||||
|
|
||||||
# Log file
|
|
||||||
*.log
|
|
||||||
|
|
||||||
# BlueJ files
|
*.class
|
||||||
*.ctxt
|
=======
|
||||||
|
HELP.md
|
||||||
# Mobile Tools for Java (J2ME)
|
target/
|
||||||
.mtj.tmp/
|
.mvn/wrapper/maven-wrapper.jar
|
||||||
|
!**/src/main/**/target/
|
||||||
|
!**/src/test/**/target/
|
||||||
|
|
||||||
# Package Files #
|
### STS ###
|
||||||
*.jar
|
.apt_generated
|
||||||
*.war
|
.classpath
|
||||||
*.nar
|
.factorypath
|
||||||
*.ear
|
.project
|
||||||
*.zip
|
.settings
|
||||||
*.tar.gz
|
.springBeans
|
||||||
*.rar
|
.sts4-cache
|
||||||
|
|
||||||
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
|
### IntelliJ IDEA ###
|
||||||
hs_err_pid*
|
.idea
|
||||||
replay_pid*
|
*.iws
|
||||||
|
*.iml
|
||||||
|
*.ipr
|
||||||
|
|
||||||
|
### NetBeans ###
|
||||||
|
/nbproject/private/
|
||||||
|
/nbbuild/
|
||||||
|
/dist/
|
||||||
|
/nbdist/
|
||||||
|
/.nb-gradle/
|
||||||
|
build/
|
||||||
|
!**/src/main/**/build/
|
||||||
|
!**/src/test/**/build/
|
||||||
|
|||||||
@ -0,0 +1,3 @@
|
|||||||
|
wrapperVersion=3.3.4
|
||||||
|
distributionType=only-script
|
||||||
|
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.12/apache-maven-3.9.12-bin.zip
|
||||||
@ -0,0 +1,9 @@
|
|||||||
|
FROM eclipse-temurin:25-jdk
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
COPY target/*.jar app.jar
|
||||||
|
|
||||||
|
EXPOSE 8080
|
||||||
|
|
||||||
|
ENTRYPOINT ["java","-jar","/app/app.jar"]
|
||||||
@ -0,0 +1,18 @@
|
|||||||
|
# Usa Maven y JDK para compilar y correr código
|
||||||
|
FROM eclipse-temurin:25-jdk
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
# Copia solo pom.xml primero para cache
|
||||||
|
COPY pom.xml .
|
||||||
|
|
||||||
|
# Pre-descarga dependencias
|
||||||
|
RUN mvn dependency:go-offline
|
||||||
|
|
||||||
|
# Copia el código fuente
|
||||||
|
COPY src ./src
|
||||||
|
|
||||||
|
EXPOSE 8080
|
||||||
|
|
||||||
|
# Ejecuta Spring Boot directamente (hot reload)
|
||||||
|
CMD ["mvn", "spring-boot:run"]
|
||||||
@ -1,2 +1,3 @@
|
|||||||
# service_Admision
|
|
||||||
|
|
||||||
|
fisrt_respositories
|
||||||
|
>>>>>>> 1b686e8 (Add initial README with repository name)
|
||||||
|
|||||||
@ -0,0 +1,34 @@
|
|||||||
|
services:
|
||||||
|
mysql:
|
||||||
|
image: mysql:8
|
||||||
|
container_name: mysql_admision_dev
|
||||||
|
environment:
|
||||||
|
MYSQL_DATABASE: admision_db
|
||||||
|
MYSQL_ALLOW_EMPTY_PASSWORD: "yes"
|
||||||
|
ports:
|
||||||
|
- "3306:3306"
|
||||||
|
volumes:
|
||||||
|
- mysql_data:/var/lib/mysql
|
||||||
|
restart: unless-stopped
|
||||||
|
|
||||||
|
backend:
|
||||||
|
build:
|
||||||
|
context: .
|
||||||
|
dockerfile: Dockerfile.dev # Dockerfile que corre mvn spring-boot:run
|
||||||
|
container_name: spring_admision_dev
|
||||||
|
depends_on:
|
||||||
|
- mysql
|
||||||
|
ports:
|
||||||
|
- "8080:8080"
|
||||||
|
volumes:
|
||||||
|
- .:/app # Monta tu código para ver cambios sin rebuild
|
||||||
|
- ~/.m2:/root/.m2 # Cache de Maven para no bajar deps siempre
|
||||||
|
environment:
|
||||||
|
SPRING_DATASOURCE_URL: jdbc:mysql://mysql:3306/admision_db?useSSL=false&serverTimezone=UTC
|
||||||
|
SPRING_DATASOURCE_USERNAME: root
|
||||||
|
SPRING_DATASOURCE_PASSWORD: ""
|
||||||
|
command: mvn spring-boot:run # Ejecuta Spring directamente
|
||||||
|
restart: unless-stopped
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
mysql_data:
|
||||||
@ -0,0 +1,27 @@
|
|||||||
|
version: "3.9"
|
||||||
|
|
||||||
|
services:
|
||||||
|
mysql:
|
||||||
|
image: mysql:8
|
||||||
|
container_name: mysql_admision
|
||||||
|
environment:
|
||||||
|
MYSQL_DATABASE: ${MYSQL_DATABASE}
|
||||||
|
MYSQL_ALLOW_EMPTY_PASSWORD: ${MYSQL_ALLOW_EMPTY_PASSWORD}
|
||||||
|
ports:
|
||||||
|
- "3306:3306"
|
||||||
|
restart: unless-stopped
|
||||||
|
|
||||||
|
backend:
|
||||||
|
build:
|
||||||
|
context: .
|
||||||
|
dockerfile: Dockerfile
|
||||||
|
container_name: spring_admision
|
||||||
|
depends_on:
|
||||||
|
- mysql
|
||||||
|
ports:
|
||||||
|
- "8080:8080"
|
||||||
|
environment:
|
||||||
|
SPRING_DATASOURCE_URL: jdbc:mysql://mysql:3306/${MYSQL_DATABASE}?useSSL=false&serverTimezone=UTC
|
||||||
|
SPRING_DATASOURCE_USERNAME: root
|
||||||
|
SPRING_DATASOURCE_PASSWORD: ""
|
||||||
|
restart: unless-stopped
|
||||||
@ -0,0 +1,295 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
# ----------------------------------------------------------------------------
|
||||||
|
# Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
# or more contributor license agreements. See the NOTICE file
|
||||||
|
# distributed with this work for additional information
|
||||||
|
# regarding copyright ownership. The ASF licenses this file
|
||||||
|
# to you under the Apache License, Version 2.0 (the
|
||||||
|
# "License"); you may not use this file except in compliance
|
||||||
|
# with the License. You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# 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
|
||||||
|
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
# KIND, either express or implied. See the License for the
|
||||||
|
# specific language governing permissions and limitations
|
||||||
|
# under the License.
|
||||||
|
# ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
# ----------------------------------------------------------------------------
|
||||||
|
# Apache Maven Wrapper startup batch script, version 3.3.4
|
||||||
|
#
|
||||||
|
# Optional ENV vars
|
||||||
|
# -----------------
|
||||||
|
# JAVA_HOME - location of a JDK home dir, required when download maven via java source
|
||||||
|
# MVNW_REPOURL - repo url base for downloading maven distribution
|
||||||
|
# MVNW_USERNAME/MVNW_PASSWORD - user and password for downloading maven
|
||||||
|
# MVNW_VERBOSE - true: enable verbose log; debug: trace the mvnw script; others: silence the output
|
||||||
|
# ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
set -euf
|
||||||
|
[ "${MVNW_VERBOSE-}" != debug ] || set -x
|
||||||
|
|
||||||
|
# OS specific support.
|
||||||
|
native_path() { printf %s\\n "$1"; }
|
||||||
|
case "$(uname)" in
|
||||||
|
CYGWIN* | MINGW*)
|
||||||
|
[ -z "${JAVA_HOME-}" ] || JAVA_HOME="$(cygpath --unix "$JAVA_HOME")"
|
||||||
|
native_path() { cygpath --path --windows "$1"; }
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
# set JAVACMD and JAVACCMD
|
||||||
|
set_java_home() {
|
||||||
|
# For Cygwin and MinGW, ensure paths are in Unix format before anything is touched
|
||||||
|
if [ -n "${JAVA_HOME-}" ]; then
|
||||||
|
if [ -x "$JAVA_HOME/jre/sh/java" ]; then
|
||||||
|
# IBM's JDK on AIX uses strange locations for the executables
|
||||||
|
JAVACMD="$JAVA_HOME/jre/sh/java"
|
||||||
|
JAVACCMD="$JAVA_HOME/jre/sh/javac"
|
||||||
|
else
|
||||||
|
JAVACMD="$JAVA_HOME/bin/java"
|
||||||
|
JAVACCMD="$JAVA_HOME/bin/javac"
|
||||||
|
|
||||||
|
if [ ! -x "$JAVACMD" ] || [ ! -x "$JAVACCMD" ]; then
|
||||||
|
echo "The JAVA_HOME environment variable is not defined correctly, so mvnw cannot run." >&2
|
||||||
|
echo "JAVA_HOME is set to \"$JAVA_HOME\", but \"\$JAVA_HOME/bin/java\" or \"\$JAVA_HOME/bin/javac\" does not exist." >&2
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
JAVACMD="$(
|
||||||
|
'set' +e
|
||||||
|
'unset' -f command 2>/dev/null
|
||||||
|
'command' -v java
|
||||||
|
)" || :
|
||||||
|
JAVACCMD="$(
|
||||||
|
'set' +e
|
||||||
|
'unset' -f command 2>/dev/null
|
||||||
|
'command' -v javac
|
||||||
|
)" || :
|
||||||
|
|
||||||
|
if [ ! -x "${JAVACMD-}" ] || [ ! -x "${JAVACCMD-}" ]; then
|
||||||
|
echo "The java/javac command does not exist in PATH nor is JAVA_HOME set, so mvnw cannot run." >&2
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# hash string like Java String::hashCode
|
||||||
|
hash_string() {
|
||||||
|
str="${1:-}" h=0
|
||||||
|
while [ -n "$str" ]; do
|
||||||
|
char="${str%"${str#?}"}"
|
||||||
|
h=$(((h * 31 + $(LC_CTYPE=C printf %d "'$char")) % 4294967296))
|
||||||
|
str="${str#?}"
|
||||||
|
done
|
||||||
|
printf %x\\n $h
|
||||||
|
}
|
||||||
|
|
||||||
|
verbose() { :; }
|
||||||
|
[ "${MVNW_VERBOSE-}" != true ] || verbose() { printf %s\\n "${1-}"; }
|
||||||
|
|
||||||
|
die() {
|
||||||
|
printf %s\\n "$1" >&2
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
trim() {
|
||||||
|
# MWRAPPER-139:
|
||||||
|
# Trims trailing and leading whitespace, carriage returns, tabs, and linefeeds.
|
||||||
|
# Needed for removing poorly interpreted newline sequences when running in more
|
||||||
|
# exotic environments such as mingw bash on Windows.
|
||||||
|
printf "%s" "${1}" | tr -d '[:space:]'
|
||||||
|
}
|
||||||
|
|
||||||
|
scriptDir="$(dirname "$0")"
|
||||||
|
scriptName="$(basename "$0")"
|
||||||
|
|
||||||
|
# parse distributionUrl and optional distributionSha256Sum, requires .mvn/wrapper/maven-wrapper.properties
|
||||||
|
while IFS="=" read -r key value; do
|
||||||
|
case "${key-}" in
|
||||||
|
distributionUrl) distributionUrl=$(trim "${value-}") ;;
|
||||||
|
distributionSha256Sum) distributionSha256Sum=$(trim "${value-}") ;;
|
||||||
|
esac
|
||||||
|
done <"$scriptDir/.mvn/wrapper/maven-wrapper.properties"
|
||||||
|
[ -n "${distributionUrl-}" ] || die "cannot read distributionUrl property in $scriptDir/.mvn/wrapper/maven-wrapper.properties"
|
||||||
|
|
||||||
|
case "${distributionUrl##*/}" in
|
||||||
|
maven-mvnd-*bin.*)
|
||||||
|
MVN_CMD=mvnd.sh _MVNW_REPO_PATTERN=/maven/mvnd/
|
||||||
|
case "${PROCESSOR_ARCHITECTURE-}${PROCESSOR_ARCHITEW6432-}:$(uname -a)" in
|
||||||
|
*AMD64:CYGWIN* | *AMD64:MINGW*) distributionPlatform=windows-amd64 ;;
|
||||||
|
:Darwin*x86_64) distributionPlatform=darwin-amd64 ;;
|
||||||
|
:Darwin*arm64) distributionPlatform=darwin-aarch64 ;;
|
||||||
|
:Linux*x86_64*) distributionPlatform=linux-amd64 ;;
|
||||||
|
*)
|
||||||
|
echo "Cannot detect native platform for mvnd on $(uname)-$(uname -m), use pure java version" >&2
|
||||||
|
distributionPlatform=linux-amd64
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
distributionUrl="${distributionUrl%-bin.*}-$distributionPlatform.zip"
|
||||||
|
;;
|
||||||
|
maven-mvnd-*) MVN_CMD=mvnd.sh _MVNW_REPO_PATTERN=/maven/mvnd/ ;;
|
||||||
|
*) MVN_CMD="mvn${scriptName#mvnw}" _MVNW_REPO_PATTERN=/org/apache/maven/ ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
# apply MVNW_REPOURL and calculate MAVEN_HOME
|
||||||
|
# maven home pattern: ~/.m2/wrapper/dists/{apache-maven-<version>,maven-mvnd-<version>-<platform>}/<hash>
|
||||||
|
[ -z "${MVNW_REPOURL-}" ] || distributionUrl="$MVNW_REPOURL$_MVNW_REPO_PATTERN${distributionUrl#*"$_MVNW_REPO_PATTERN"}"
|
||||||
|
distributionUrlName="${distributionUrl##*/}"
|
||||||
|
distributionUrlNameMain="${distributionUrlName%.*}"
|
||||||
|
distributionUrlNameMain="${distributionUrlNameMain%-bin}"
|
||||||
|
MAVEN_USER_HOME="${MAVEN_USER_HOME:-${HOME}/.m2}"
|
||||||
|
MAVEN_HOME="${MAVEN_USER_HOME}/wrapper/dists/${distributionUrlNameMain-}/$(hash_string "$distributionUrl")"
|
||||||
|
|
||||||
|
exec_maven() {
|
||||||
|
unset MVNW_VERBOSE MVNW_USERNAME MVNW_PASSWORD MVNW_REPOURL || :
|
||||||
|
exec "$MAVEN_HOME/bin/$MVN_CMD" "$@" || die "cannot exec $MAVEN_HOME/bin/$MVN_CMD"
|
||||||
|
}
|
||||||
|
|
||||||
|
if [ -d "$MAVEN_HOME" ]; then
|
||||||
|
verbose "found existing MAVEN_HOME at $MAVEN_HOME"
|
||||||
|
exec_maven "$@"
|
||||||
|
fi
|
||||||
|
|
||||||
|
case "${distributionUrl-}" in
|
||||||
|
*?-bin.zip | *?maven-mvnd-?*-?*.zip) ;;
|
||||||
|
*) die "distributionUrl is not valid, must match *-bin.zip or maven-mvnd-*.zip, but found '${distributionUrl-}'" ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
# prepare tmp dir
|
||||||
|
if TMP_DOWNLOAD_DIR="$(mktemp -d)" && [ -d "$TMP_DOWNLOAD_DIR" ]; then
|
||||||
|
clean() { rm -rf -- "$TMP_DOWNLOAD_DIR"; }
|
||||||
|
trap clean HUP INT TERM EXIT
|
||||||
|
else
|
||||||
|
die "cannot create temp dir"
|
||||||
|
fi
|
||||||
|
|
||||||
|
mkdir -p -- "${MAVEN_HOME%/*}"
|
||||||
|
|
||||||
|
# Download and Install Apache Maven
|
||||||
|
verbose "Couldn't find MAVEN_HOME, downloading and installing it ..."
|
||||||
|
verbose "Downloading from: $distributionUrl"
|
||||||
|
verbose "Downloading to: $TMP_DOWNLOAD_DIR/$distributionUrlName"
|
||||||
|
|
||||||
|
# select .zip or .tar.gz
|
||||||
|
if ! command -v unzip >/dev/null; then
|
||||||
|
distributionUrl="${distributionUrl%.zip}.tar.gz"
|
||||||
|
distributionUrlName="${distributionUrl##*/}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# verbose opt
|
||||||
|
__MVNW_QUIET_WGET=--quiet __MVNW_QUIET_CURL=--silent __MVNW_QUIET_UNZIP=-q __MVNW_QUIET_TAR=''
|
||||||
|
[ "${MVNW_VERBOSE-}" != true ] || __MVNW_QUIET_WGET='' __MVNW_QUIET_CURL='' __MVNW_QUIET_UNZIP='' __MVNW_QUIET_TAR=v
|
||||||
|
|
||||||
|
# normalize http auth
|
||||||
|
case "${MVNW_PASSWORD:+has-password}" in
|
||||||
|
'') MVNW_USERNAME='' MVNW_PASSWORD='' ;;
|
||||||
|
has-password) [ -n "${MVNW_USERNAME-}" ] || MVNW_USERNAME='' MVNW_PASSWORD='' ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
if [ -z "${MVNW_USERNAME-}" ] && command -v wget >/dev/null; then
|
||||||
|
verbose "Found wget ... using wget"
|
||||||
|
wget ${__MVNW_QUIET_WGET:+"$__MVNW_QUIET_WGET"} "$distributionUrl" -O "$TMP_DOWNLOAD_DIR/$distributionUrlName" || die "wget: Failed to fetch $distributionUrl"
|
||||||
|
elif [ -z "${MVNW_USERNAME-}" ] && command -v curl >/dev/null; then
|
||||||
|
verbose "Found curl ... using curl"
|
||||||
|
curl ${__MVNW_QUIET_CURL:+"$__MVNW_QUIET_CURL"} -f -L -o "$TMP_DOWNLOAD_DIR/$distributionUrlName" "$distributionUrl" || die "curl: Failed to fetch $distributionUrl"
|
||||||
|
elif set_java_home; then
|
||||||
|
verbose "Falling back to use Java to download"
|
||||||
|
javaSource="$TMP_DOWNLOAD_DIR/Downloader.java"
|
||||||
|
targetZip="$TMP_DOWNLOAD_DIR/$distributionUrlName"
|
||||||
|
cat >"$javaSource" <<-END
|
||||||
|
public class Downloader extends java.net.Authenticator
|
||||||
|
{
|
||||||
|
protected java.net.PasswordAuthentication getPasswordAuthentication()
|
||||||
|
{
|
||||||
|
return new java.net.PasswordAuthentication( System.getenv( "MVNW_USERNAME" ), System.getenv( "MVNW_PASSWORD" ).toCharArray() );
|
||||||
|
}
|
||||||
|
public static void main( String[] args ) throws Exception
|
||||||
|
{
|
||||||
|
setDefault( new Downloader() );
|
||||||
|
java.nio.file.Files.copy( java.net.URI.create( args[0] ).toURL().openStream(), java.nio.file.Paths.get( args[1] ).toAbsolutePath().normalize() );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
END
|
||||||
|
# For Cygwin/MinGW, switch paths to Windows format before running javac and java
|
||||||
|
verbose " - Compiling Downloader.java ..."
|
||||||
|
"$(native_path "$JAVACCMD")" "$(native_path "$javaSource")" || die "Failed to compile Downloader.java"
|
||||||
|
verbose " - Running Downloader.java ..."
|
||||||
|
"$(native_path "$JAVACMD")" -cp "$(native_path "$TMP_DOWNLOAD_DIR")" Downloader "$distributionUrl" "$(native_path "$targetZip")"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# If specified, validate the SHA-256 sum of the Maven distribution zip file
|
||||||
|
if [ -n "${distributionSha256Sum-}" ]; then
|
||||||
|
distributionSha256Result=false
|
||||||
|
if [ "$MVN_CMD" = mvnd.sh ]; then
|
||||||
|
echo "Checksum validation is not supported for maven-mvnd." >&2
|
||||||
|
echo "Please disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties." >&2
|
||||||
|
exit 1
|
||||||
|
elif command -v sha256sum >/dev/null; then
|
||||||
|
if echo "$distributionSha256Sum $TMP_DOWNLOAD_DIR/$distributionUrlName" | sha256sum -c - >/dev/null 2>&1; then
|
||||||
|
distributionSha256Result=true
|
||||||
|
fi
|
||||||
|
elif command -v shasum >/dev/null; then
|
||||||
|
if echo "$distributionSha256Sum $TMP_DOWNLOAD_DIR/$distributionUrlName" | shasum -a 256 -c >/dev/null 2>&1; then
|
||||||
|
distributionSha256Result=true
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "Checksum validation was requested but neither 'sha256sum' or 'shasum' are available." >&2
|
||||||
|
echo "Please install either command, or disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties." >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
if [ $distributionSha256Result = false ]; then
|
||||||
|
echo "Error: Failed to validate Maven distribution SHA-256, your Maven distribution might be compromised." >&2
|
||||||
|
echo "If you updated your Maven version, you need to update the specified distributionSha256Sum property." >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# unzip and move
|
||||||
|
if command -v unzip >/dev/null; then
|
||||||
|
unzip ${__MVNW_QUIET_UNZIP:+"$__MVNW_QUIET_UNZIP"} "$TMP_DOWNLOAD_DIR/$distributionUrlName" -d "$TMP_DOWNLOAD_DIR" || die "failed to unzip"
|
||||||
|
else
|
||||||
|
tar xzf${__MVNW_QUIET_TAR:+"$__MVNW_QUIET_TAR"} "$TMP_DOWNLOAD_DIR/$distributionUrlName" -C "$TMP_DOWNLOAD_DIR" || die "failed to untar"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Find the actual extracted directory name (handles snapshots where filename != directory name)
|
||||||
|
actualDistributionDir=""
|
||||||
|
|
||||||
|
# First try the expected directory name (for regular distributions)
|
||||||
|
if [ -d "$TMP_DOWNLOAD_DIR/$distributionUrlNameMain" ]; then
|
||||||
|
if [ -f "$TMP_DOWNLOAD_DIR/$distributionUrlNameMain/bin/$MVN_CMD" ]; then
|
||||||
|
actualDistributionDir="$distributionUrlNameMain"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# If not found, search for any directory with the Maven executable (for snapshots)
|
||||||
|
if [ -z "$actualDistributionDir" ]; then
|
||||||
|
# enable globbing to iterate over items
|
||||||
|
set +f
|
||||||
|
for dir in "$TMP_DOWNLOAD_DIR"/*; do
|
||||||
|
if [ -d "$dir" ]; then
|
||||||
|
if [ -f "$dir/bin/$MVN_CMD" ]; then
|
||||||
|
actualDistributionDir="$(basename "$dir")"
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
set -f
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "$actualDistributionDir" ]; then
|
||||||
|
verbose "Contents of $TMP_DOWNLOAD_DIR:"
|
||||||
|
verbose "$(ls -la "$TMP_DOWNLOAD_DIR")"
|
||||||
|
die "Could not find Maven distribution directory in extracted archive"
|
||||||
|
fi
|
||||||
|
|
||||||
|
verbose "Found extracted Maven distribution directory: $actualDistributionDir"
|
||||||
|
printf %s\\n "$distributionUrl" >"$TMP_DOWNLOAD_DIR/$actualDistributionDir/mvnw.url"
|
||||||
|
mv -- "$TMP_DOWNLOAD_DIR/$actualDistributionDir" "$MAVEN_HOME" || [ -d "$MAVEN_HOME" ] || die "fail to move MAVEN_HOME"
|
||||||
|
|
||||||
|
clean || :
|
||||||
|
exec_maven "$@"
|
||||||
@ -0,0 +1,189 @@
|
|||||||
|
<# : batch portion
|
||||||
|
@REM ----------------------------------------------------------------------------
|
||||||
|
@REM Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
@REM or more contributor license agreements. See the NOTICE file
|
||||||
|
@REM distributed with this work for additional information
|
||||||
|
@REM regarding copyright ownership. The ASF licenses this file
|
||||||
|
@REM to you under the Apache License, Version 2.0 (the
|
||||||
|
@REM "License"); you may not use this file except in compliance
|
||||||
|
@REM with the License. You may obtain a copy of the License at
|
||||||
|
@REM
|
||||||
|
@REM http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
@REM
|
||||||
|
@REM Unless required by applicable law or agreed to in writing,
|
||||||
|
@REM software distributed under the License is distributed on an
|
||||||
|
@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
@REM KIND, either express or implied. See the License for the
|
||||||
|
@REM specific language governing permissions and limitations
|
||||||
|
@REM under the License.
|
||||||
|
@REM ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
@REM ----------------------------------------------------------------------------
|
||||||
|
@REM Apache Maven Wrapper startup batch script, version 3.3.4
|
||||||
|
@REM
|
||||||
|
@REM Optional ENV vars
|
||||||
|
@REM MVNW_REPOURL - repo url base for downloading maven distribution
|
||||||
|
@REM MVNW_USERNAME/MVNW_PASSWORD - user and password for downloading maven
|
||||||
|
@REM MVNW_VERBOSE - true: enable verbose log; others: silence the output
|
||||||
|
@REM ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
@IF "%__MVNW_ARG0_NAME__%"=="" (SET __MVNW_ARG0_NAME__=%~nx0)
|
||||||
|
@SET __MVNW_CMD__=
|
||||||
|
@SET __MVNW_ERROR__=
|
||||||
|
@SET __MVNW_PSMODULEP_SAVE=%PSModulePath%
|
||||||
|
@SET PSModulePath=
|
||||||
|
@FOR /F "usebackq tokens=1* delims==" %%A IN (`powershell -noprofile "& {$scriptDir='%~dp0'; $script='%__MVNW_ARG0_NAME__%'; icm -ScriptBlock ([Scriptblock]::Create((Get-Content -Raw '%~f0'))) -NoNewScope}"`) DO @(
|
||||||
|
IF "%%A"=="MVN_CMD" (set __MVNW_CMD__=%%B) ELSE IF "%%B"=="" (echo %%A) ELSE (echo %%A=%%B)
|
||||||
|
)
|
||||||
|
@SET PSModulePath=%__MVNW_PSMODULEP_SAVE%
|
||||||
|
@SET __MVNW_PSMODULEP_SAVE=
|
||||||
|
@SET __MVNW_ARG0_NAME__=
|
||||||
|
@SET MVNW_USERNAME=
|
||||||
|
@SET MVNW_PASSWORD=
|
||||||
|
@IF NOT "%__MVNW_CMD__%"=="" ("%__MVNW_CMD__%" %*)
|
||||||
|
@echo Cannot start maven from wrapper >&2 && exit /b 1
|
||||||
|
@GOTO :EOF
|
||||||
|
: end batch / begin powershell #>
|
||||||
|
|
||||||
|
$ErrorActionPreference = "Stop"
|
||||||
|
if ($env:MVNW_VERBOSE -eq "true") {
|
||||||
|
$VerbosePreference = "Continue"
|
||||||
|
}
|
||||||
|
|
||||||
|
# calculate distributionUrl, requires .mvn/wrapper/maven-wrapper.properties
|
||||||
|
$distributionUrl = (Get-Content -Raw "$scriptDir/.mvn/wrapper/maven-wrapper.properties" | ConvertFrom-StringData).distributionUrl
|
||||||
|
if (!$distributionUrl) {
|
||||||
|
Write-Error "cannot read distributionUrl property in $scriptDir/.mvn/wrapper/maven-wrapper.properties"
|
||||||
|
}
|
||||||
|
|
||||||
|
switch -wildcard -casesensitive ( $($distributionUrl -replace '^.*/','') ) {
|
||||||
|
"maven-mvnd-*" {
|
||||||
|
$USE_MVND = $true
|
||||||
|
$distributionUrl = $distributionUrl -replace '-bin\.[^.]*$',"-windows-amd64.zip"
|
||||||
|
$MVN_CMD = "mvnd.cmd"
|
||||||
|
break
|
||||||
|
}
|
||||||
|
default {
|
||||||
|
$USE_MVND = $false
|
||||||
|
$MVN_CMD = $script -replace '^mvnw','mvn'
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# apply MVNW_REPOURL and calculate MAVEN_HOME
|
||||||
|
# maven home pattern: ~/.m2/wrapper/dists/{apache-maven-<version>,maven-mvnd-<version>-<platform>}/<hash>
|
||||||
|
if ($env:MVNW_REPOURL) {
|
||||||
|
$MVNW_REPO_PATTERN = if ($USE_MVND -eq $False) { "/org/apache/maven/" } else { "/maven/mvnd/" }
|
||||||
|
$distributionUrl = "$env:MVNW_REPOURL$MVNW_REPO_PATTERN$($distributionUrl -replace "^.*$MVNW_REPO_PATTERN",'')"
|
||||||
|
}
|
||||||
|
$distributionUrlName = $distributionUrl -replace '^.*/',''
|
||||||
|
$distributionUrlNameMain = $distributionUrlName -replace '\.[^.]*$','' -replace '-bin$',''
|
||||||
|
|
||||||
|
$MAVEN_M2_PATH = "$HOME/.m2"
|
||||||
|
if ($env:MAVEN_USER_HOME) {
|
||||||
|
$MAVEN_M2_PATH = "$env:MAVEN_USER_HOME"
|
||||||
|
}
|
||||||
|
|
||||||
|
if (-not (Test-Path -Path $MAVEN_M2_PATH)) {
|
||||||
|
New-Item -Path $MAVEN_M2_PATH -ItemType Directory | Out-Null
|
||||||
|
}
|
||||||
|
|
||||||
|
$MAVEN_WRAPPER_DISTS = $null
|
||||||
|
if ((Get-Item $MAVEN_M2_PATH).Target[0] -eq $null) {
|
||||||
|
$MAVEN_WRAPPER_DISTS = "$MAVEN_M2_PATH/wrapper/dists"
|
||||||
|
} else {
|
||||||
|
$MAVEN_WRAPPER_DISTS = (Get-Item $MAVEN_M2_PATH).Target[0] + "/wrapper/dists"
|
||||||
|
}
|
||||||
|
|
||||||
|
$MAVEN_HOME_PARENT = "$MAVEN_WRAPPER_DISTS/$distributionUrlNameMain"
|
||||||
|
$MAVEN_HOME_NAME = ([System.Security.Cryptography.SHA256]::Create().ComputeHash([byte[]][char[]]$distributionUrl) | ForEach-Object {$_.ToString("x2")}) -join ''
|
||||||
|
$MAVEN_HOME = "$MAVEN_HOME_PARENT/$MAVEN_HOME_NAME"
|
||||||
|
|
||||||
|
if (Test-Path -Path "$MAVEN_HOME" -PathType Container) {
|
||||||
|
Write-Verbose "found existing MAVEN_HOME at $MAVEN_HOME"
|
||||||
|
Write-Output "MVN_CMD=$MAVEN_HOME/bin/$MVN_CMD"
|
||||||
|
exit $?
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! $distributionUrlNameMain -or ($distributionUrlName -eq $distributionUrlNameMain)) {
|
||||||
|
Write-Error "distributionUrl is not valid, must end with *-bin.zip, but found $distributionUrl"
|
||||||
|
}
|
||||||
|
|
||||||
|
# prepare tmp dir
|
||||||
|
$TMP_DOWNLOAD_DIR_HOLDER = New-TemporaryFile
|
||||||
|
$TMP_DOWNLOAD_DIR = New-Item -Itemtype Directory -Path "$TMP_DOWNLOAD_DIR_HOLDER.dir"
|
||||||
|
$TMP_DOWNLOAD_DIR_HOLDER.Delete() | Out-Null
|
||||||
|
trap {
|
||||||
|
if ($TMP_DOWNLOAD_DIR.Exists) {
|
||||||
|
try { Remove-Item $TMP_DOWNLOAD_DIR -Recurse -Force | Out-Null }
|
||||||
|
catch { Write-Warning "Cannot remove $TMP_DOWNLOAD_DIR" }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
New-Item -Itemtype Directory -Path "$MAVEN_HOME_PARENT" -Force | Out-Null
|
||||||
|
|
||||||
|
# Download and Install Apache Maven
|
||||||
|
Write-Verbose "Couldn't find MAVEN_HOME, downloading and installing it ..."
|
||||||
|
Write-Verbose "Downloading from: $distributionUrl"
|
||||||
|
Write-Verbose "Downloading to: $TMP_DOWNLOAD_DIR/$distributionUrlName"
|
||||||
|
|
||||||
|
$webclient = New-Object System.Net.WebClient
|
||||||
|
if ($env:MVNW_USERNAME -and $env:MVNW_PASSWORD) {
|
||||||
|
$webclient.Credentials = New-Object System.Net.NetworkCredential($env:MVNW_USERNAME, $env:MVNW_PASSWORD)
|
||||||
|
}
|
||||||
|
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
|
||||||
|
$webclient.DownloadFile($distributionUrl, "$TMP_DOWNLOAD_DIR/$distributionUrlName") | Out-Null
|
||||||
|
|
||||||
|
# If specified, validate the SHA-256 sum of the Maven distribution zip file
|
||||||
|
$distributionSha256Sum = (Get-Content -Raw "$scriptDir/.mvn/wrapper/maven-wrapper.properties" | ConvertFrom-StringData).distributionSha256Sum
|
||||||
|
if ($distributionSha256Sum) {
|
||||||
|
if ($USE_MVND) {
|
||||||
|
Write-Error "Checksum validation is not supported for maven-mvnd. `nPlease disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties."
|
||||||
|
}
|
||||||
|
Import-Module $PSHOME\Modules\Microsoft.PowerShell.Utility -Function Get-FileHash
|
||||||
|
if ((Get-FileHash "$TMP_DOWNLOAD_DIR/$distributionUrlName" -Algorithm SHA256).Hash.ToLower() -ne $distributionSha256Sum) {
|
||||||
|
Write-Error "Error: Failed to validate Maven distribution SHA-256, your Maven distribution might be compromised. If you updated your Maven version, you need to update the specified distributionSha256Sum property."
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# unzip and move
|
||||||
|
Expand-Archive "$TMP_DOWNLOAD_DIR/$distributionUrlName" -DestinationPath "$TMP_DOWNLOAD_DIR" | Out-Null
|
||||||
|
|
||||||
|
# Find the actual extracted directory name (handles snapshots where filename != directory name)
|
||||||
|
$actualDistributionDir = ""
|
||||||
|
|
||||||
|
# First try the expected directory name (for regular distributions)
|
||||||
|
$expectedPath = Join-Path "$TMP_DOWNLOAD_DIR" "$distributionUrlNameMain"
|
||||||
|
$expectedMvnPath = Join-Path "$expectedPath" "bin/$MVN_CMD"
|
||||||
|
if ((Test-Path -Path $expectedPath -PathType Container) -and (Test-Path -Path $expectedMvnPath -PathType Leaf)) {
|
||||||
|
$actualDistributionDir = $distributionUrlNameMain
|
||||||
|
}
|
||||||
|
|
||||||
|
# If not found, search for any directory with the Maven executable (for snapshots)
|
||||||
|
if (!$actualDistributionDir) {
|
||||||
|
Get-ChildItem -Path "$TMP_DOWNLOAD_DIR" -Directory | ForEach-Object {
|
||||||
|
$testPath = Join-Path $_.FullName "bin/$MVN_CMD"
|
||||||
|
if (Test-Path -Path $testPath -PathType Leaf) {
|
||||||
|
$actualDistributionDir = $_.Name
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$actualDistributionDir) {
|
||||||
|
Write-Error "Could not find Maven distribution directory in extracted archive"
|
||||||
|
}
|
||||||
|
|
||||||
|
Write-Verbose "Found extracted Maven distribution directory: $actualDistributionDir"
|
||||||
|
Rename-Item -Path "$TMP_DOWNLOAD_DIR/$actualDistributionDir" -NewName $MAVEN_HOME_NAME | Out-Null
|
||||||
|
try {
|
||||||
|
Move-Item -Path "$TMP_DOWNLOAD_DIR/$MAVEN_HOME_NAME" -Destination $MAVEN_HOME_PARENT | Out-Null
|
||||||
|
} catch {
|
||||||
|
if (! (Test-Path -Path "$MAVEN_HOME" -PathType Container)) {
|
||||||
|
Write-Error "fail to move MAVEN_HOME"
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
try { Remove-Item $TMP_DOWNLOAD_DIR -Recurse -Force | Out-Null }
|
||||||
|
catch { Write-Warning "Cannot remove $TMP_DOWNLOAD_DIR" }
|
||||||
|
}
|
||||||
|
|
||||||
|
Write-Output "MVN_CMD=$MAVEN_HOME/bin/$MVN_CMD"
|
||||||
@ -0,0 +1,119 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<parent>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-parent</artifactId>
|
||||||
|
<version>4.0.3</version>
|
||||||
|
<relativePath/> <!-- lookup parent from repository -->
|
||||||
|
</parent>
|
||||||
|
<groupId>com.service</groupId>
|
||||||
|
<artifactId>ingresantes</artifactId>
|
||||||
|
<version>0.0.1-SNAPSHOT</version>
|
||||||
|
<name>ingresantes</name>
|
||||||
|
<description>Demo project for Spring Boot</description>
|
||||||
|
<url/>
|
||||||
|
<licenses>
|
||||||
|
<license/>
|
||||||
|
</licenses>
|
||||||
|
<developers>
|
||||||
|
<developer/>
|
||||||
|
</developers>
|
||||||
|
<scm>
|
||||||
|
<connection/>
|
||||||
|
<developerConnection/>
|
||||||
|
<tag/>
|
||||||
|
<url/>
|
||||||
|
</scm>
|
||||||
|
<properties>
|
||||||
|
<java.version>25</java.version>
|
||||||
|
</properties>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-data-jpa</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<!-- <dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-security</artifactId>
|
||||||
|
</dependency> -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-webmvc</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-devtools</artifactId>
|
||||||
|
<scope>runtime</scope>
|
||||||
|
<optional>true</optional>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.mysql</groupId>
|
||||||
|
<artifactId>mysql-connector-j</artifactId>
|
||||||
|
<version>8.1.0</version> <!-- usa la última versión estable -->
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.poi</groupId>
|
||||||
|
<artifactId>poi</artifactId>
|
||||||
|
<version>5.2.3</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.poi</groupId>
|
||||||
|
<artifactId>poi-ooxml</artifactId>
|
||||||
|
<version>5.2.3</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.projectlombok</groupId>
|
||||||
|
<artifactId>lombok</artifactId>
|
||||||
|
<optional>true</optional>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-data-jpa-test</artifactId>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<!-- <dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-security-test</artifactId>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency> -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-webmvc-test</artifactId>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<configuration>
|
||||||
|
<annotationProcessorPaths>
|
||||||
|
<path>
|
||||||
|
<groupId>org.projectlombok</groupId>
|
||||||
|
<artifactId>lombok</artifactId>
|
||||||
|
</path>
|
||||||
|
</annotationProcessorPaths>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||||
|
<configuration>
|
||||||
|
<excludes>
|
||||||
|
<exclude>
|
||||||
|
<groupId>org.projectlombok</groupId>
|
||||||
|
<artifactId>lombok</artifactId>
|
||||||
|
</exclude>
|
||||||
|
</excludes>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
|
||||||
|
</project>
|
||||||
@ -0,0 +1,13 @@
|
|||||||
|
package com.service.ingresantes;
|
||||||
|
|
||||||
|
import org.springframework.boot.SpringApplication;
|
||||||
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
|
||||||
|
@SpringBootApplication
|
||||||
|
public class IngresantesApplication {
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
SpringApplication.run(IngresantesApplication.class, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,31 @@
|
|||||||
|
package com.service.ingresantes.controller;
|
||||||
|
|
||||||
|
import com.service.ingresantes.service.CalificacionCursoService;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/api/calificacion")
|
||||||
|
public class CalificacionController {
|
||||||
|
|
||||||
|
private final CalificacionCursoService calificacionCursoService;
|
||||||
|
|
||||||
|
public CalificacionController(CalificacionCursoService calificacionCursoService) {
|
||||||
|
this.calificacionCursoService = calificacionCursoService;
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/calificar/{procesoId}")
|
||||||
|
public Map<String, Object> calificarCursos(@PathVariable Long procesoId) {
|
||||||
|
|
||||||
|
int registros = calificacionCursoService.calificarCursos(procesoId);
|
||||||
|
|
||||||
|
Map<String, Object> response = new HashMap<>();
|
||||||
|
response.put("mensaje", "Calificación por asignaturas completada");
|
||||||
|
response.put("proceso", procesoId);
|
||||||
|
response.put("registros_generados", registros);
|
||||||
|
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,44 @@
|
|||||||
|
package com.service.ingresantes.controller;
|
||||||
|
|
||||||
|
import com.service.ingresantes.service.CarpetaExamenService;
|
||||||
|
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/api/examen")
|
||||||
|
@CrossOrigin("*")
|
||||||
|
public class CarpetaExamenController {
|
||||||
|
|
||||||
|
private final CarpetaExamenService carpetaService;
|
||||||
|
|
||||||
|
public CarpetaExamenController(CarpetaExamenService carpetaService) {
|
||||||
|
this.carpetaService = carpetaService;
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/upload")
|
||||||
|
public ResponseEntity<?> subirArchivo(
|
||||||
|
@RequestParam("file") MultipartFile file,
|
||||||
|
@RequestParam("tipo") String tipo,
|
||||||
|
@RequestParam("procesoId") Long procesoId,
|
||||||
|
@RequestParam("areaId") Long areaId) {
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
|
if (file.isEmpty()) {
|
||||||
|
return ResponseEntity.badRequest().body("Archivo vacío");
|
||||||
|
}
|
||||||
|
|
||||||
|
carpetaService.subirArchivo(file, tipo, procesoId, areaId);
|
||||||
|
|
||||||
|
return ResponseEntity.ok("Archivo .dat subido correctamente");
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
|
||||||
|
return ResponseEntity
|
||||||
|
.badRequest()
|
||||||
|
.body("Error al subir archivo: " + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,34 @@
|
|||||||
|
package com.service.ingresantes.controller;
|
||||||
|
|
||||||
|
import com.service.ingresantes.service.ClaveExamenService;
|
||||||
|
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/api/claves")
|
||||||
|
@CrossOrigin("*")
|
||||||
|
public class ClaveExamenController {
|
||||||
|
|
||||||
|
private final ClaveExamenService claveService;
|
||||||
|
|
||||||
|
public ClaveExamenController(ClaveExamenService claveService) {
|
||||||
|
this.claveService = claveService;
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/procesar")
|
||||||
|
public ResponseEntity<?> procesarClaves(
|
||||||
|
@RequestParam("procesoId") Long procesoId,
|
||||||
|
@RequestParam("areaId") Long areaId) {
|
||||||
|
|
||||||
|
try {
|
||||||
|
int guardadas = claveService.procesarClaves(procesoId, areaId);
|
||||||
|
return ResponseEntity.ok("Claves procesadas y guardadas correctamente: " + guardadas);
|
||||||
|
} catch (Exception e) {
|
||||||
|
return ResponseEntity
|
||||||
|
.badRequest()
|
||||||
|
.body("Error al procesar claves: " + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,41 @@
|
|||||||
|
package com.service.ingresantes.controller;
|
||||||
|
|
||||||
|
import com.service.ingresantes.service.ExcelService;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/api/excel")
|
||||||
|
@CrossOrigin(origins = "*")
|
||||||
|
public class ExcelController {
|
||||||
|
|
||||||
|
private final ExcelService excelService;
|
||||||
|
|
||||||
|
public ExcelController(ExcelService excelService) {
|
||||||
|
this.excelService = excelService;
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/upload")
|
||||||
|
public ResponseEntity<String> uploadExcel(@RequestParam("file") MultipartFile file) {
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (file == null || file.isEmpty()) {
|
||||||
|
return ResponseEntity.badRequest().body("No se recibió ningún archivo.");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
String resultado = excelService.importarExcel(file);
|
||||||
|
return ResponseEntity.ok(resultado);
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return ResponseEntity.badRequest().body("Error al procesar el archivo: " + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/ping")
|
||||||
|
public ResponseEntity<String> ping() {
|
||||||
|
return ResponseEntity.ok("API funcionando correctamente");
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,46 @@
|
|||||||
|
package com.service.ingresantes.controller;
|
||||||
|
|
||||||
|
import com.service.ingresantes.service.ExcelResultadoService;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/api/excel")
|
||||||
|
@CrossOrigin("*")
|
||||||
|
public class ExcelResultadoController {
|
||||||
|
|
||||||
|
private final ExcelResultadoService excelResultadoService;
|
||||||
|
|
||||||
|
public ExcelResultadoController(ExcelResultadoService excelResultadoService) {
|
||||||
|
this.excelResultadoService = excelResultadoService;
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/upload-resultados")
|
||||||
|
public ResponseEntity<String> uploadResultados(
|
||||||
|
@RequestParam("file") MultipartFile file,
|
||||||
|
@RequestParam("dia") Integer dia) {
|
||||||
|
|
||||||
|
if (file.isEmpty()) {
|
||||||
|
return ResponseEntity.badRequest().body("El archivo está vacío");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dia == null || dia < 1) {
|
||||||
|
return ResponseEntity.badRequest()
|
||||||
|
.body("El parámetro 'dia' es requerido y debe ser >= 1");
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
// 🔥 AQUÍ CAPTURAS EL RESUMEN
|
||||||
|
String resultado = excelResultadoService.importarExcelResultados(file, dia);
|
||||||
|
|
||||||
|
return ResponseEntity.ok(
|
||||||
|
"Archivo del día " + dia + " procesado correctamente\n\n" + resultado
|
||||||
|
);
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
return ResponseEntity.badRequest()
|
||||||
|
.body("Error al procesar el archivo: " + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,5 @@
|
|||||||
|
package com.service.ingresantes.controller;
|
||||||
|
|
||||||
|
public class InscripcionController {
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,5 @@
|
|||||||
|
package com.service.ingresantes.controller;
|
||||||
|
|
||||||
|
public class PostulanteController {
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,52 @@
|
|||||||
|
package com.service.ingresantes.controller;
|
||||||
|
|
||||||
|
import com.service.ingresantes.entity.ResultadoExamen;
|
||||||
|
import com.service.ingresantes.service.ResultadoService;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/api/resultados")
|
||||||
|
@CrossOrigin("*")
|
||||||
|
public class ResultadoController {
|
||||||
|
|
||||||
|
private final ResultadoService resultadoService;
|
||||||
|
|
||||||
|
public ResultadoController(ResultadoService resultadoService) {
|
||||||
|
this.resultadoService = resultadoService;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Buscar resultado por DNI, proceso y día
|
||||||
|
@GetMapping("/{dni}/{procesoId}/{dia}")
|
||||||
|
public ResponseEntity<?> obtenerResultado(
|
||||||
|
@PathVariable String dni,
|
||||||
|
@PathVariable Long procesoId,
|
||||||
|
@PathVariable Integer dia) {
|
||||||
|
|
||||||
|
Optional<ResultadoExamen> resultado =
|
||||||
|
resultadoService.obtenerResultado(dni, procesoId, dia);
|
||||||
|
|
||||||
|
if (resultado.isEmpty()) {
|
||||||
|
|
||||||
|
return ResponseEntity
|
||||||
|
.badRequest()
|
||||||
|
.body("No se encontró resultado para ese DNI, proceso y día");
|
||||||
|
}
|
||||||
|
|
||||||
|
return ResponseEntity.ok(resultado.get());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ranking del proceso
|
||||||
|
@GetMapping("/ranking/{procesoId}")
|
||||||
|
public ResponseEntity<List<ResultadoExamen>> ranking(
|
||||||
|
@PathVariable Long procesoId) {
|
||||||
|
|
||||||
|
List<ResultadoExamen> ranking =
|
||||||
|
resultadoService.obtenerRanking(procesoId);
|
||||||
|
|
||||||
|
return ResponseEntity.ok(ranking);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,5 @@
|
|||||||
|
package com.service.ingresantes.dto;
|
||||||
|
|
||||||
|
public class PostulanteExcelDTO {
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,19 @@
|
|||||||
|
package com.service.ingresantes.entity;
|
||||||
|
|
||||||
|
import jakarta.persistence.*;
|
||||||
|
import lombok.*;
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
@Table(name = "areas")
|
||||||
|
@Data
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@Builder
|
||||||
|
public class Area {
|
||||||
|
|
||||||
|
@Id
|
||||||
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
private String nombre;
|
||||||
|
}
|
||||||
@ -0,0 +1,32 @@
|
|||||||
|
package com.service.ingresantes.entity;
|
||||||
|
|
||||||
|
import jakarta.persistence.*;
|
||||||
|
import lombok.*;
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
@Table(name = "asignaturas")
|
||||||
|
@Data
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@Builder
|
||||||
|
public class Asignatura {
|
||||||
|
|
||||||
|
@Id
|
||||||
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
private Integer codigo;
|
||||||
|
|
||||||
|
private String nombre;
|
||||||
|
|
||||||
|
private Integer cantidadPreguntas;
|
||||||
|
|
||||||
|
private Double ponderacion;
|
||||||
|
|
||||||
|
// Nuevo campo: puntaje por pregunta
|
||||||
|
private Double puntajePorPregunta;
|
||||||
|
|
||||||
|
@ManyToOne
|
||||||
|
@JoinColumn(name = "area_id")
|
||||||
|
private Area area;
|
||||||
|
}
|
||||||
@ -0,0 +1,29 @@
|
|||||||
|
package com.service.ingresantes.entity;
|
||||||
|
|
||||||
|
import jakarta.persistence.*;
|
||||||
|
import lombok.*;
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
@Table(name = "carpeta_examen")
|
||||||
|
@Data
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@Builder
|
||||||
|
public class CarpetaExamen {
|
||||||
|
|
||||||
|
@Id
|
||||||
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
private String tipo; // claves, ids, respuestas
|
||||||
|
|
||||||
|
private String ruta;
|
||||||
|
|
||||||
|
@ManyToOne
|
||||||
|
@JoinColumn(name = "proceso_id")
|
||||||
|
private Proceso proceso;
|
||||||
|
|
||||||
|
@ManyToOne
|
||||||
|
@JoinColumn(name = "area_id")
|
||||||
|
private Area area;
|
||||||
|
}
|
||||||
@ -0,0 +1,35 @@
|
|||||||
|
package com.service.ingresantes.entity;
|
||||||
|
|
||||||
|
import jakarta.persistence.*;
|
||||||
|
import lombok.*;
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
@Table(name = "clave_examen")
|
||||||
|
@Data
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@Builder
|
||||||
|
public class ClaveExamen {
|
||||||
|
|
||||||
|
@Id
|
||||||
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
@Column(name = "id_examen")
|
||||||
|
private String idExamen;
|
||||||
|
|
||||||
|
private String tipo;
|
||||||
|
|
||||||
|
@Column(columnDefinition = "TEXT")
|
||||||
|
private String clave;
|
||||||
|
|
||||||
|
@ManyToOne
|
||||||
|
@JoinColumn(name = "proceso_id")
|
||||||
|
private Proceso proceso;
|
||||||
|
|
||||||
|
@ManyToOne
|
||||||
|
@JoinColumn(name = "area_id")
|
||||||
|
private Area area;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,42 @@
|
|||||||
|
package com.service.ingresantes.entity;
|
||||||
|
|
||||||
|
import jakarta.persistence.*;
|
||||||
|
import lombok.Data;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Entity
|
||||||
|
@Table(
|
||||||
|
name = "inscripciones",
|
||||||
|
uniqueConstraints = @UniqueConstraint(columnNames = {"postulante_id","proceso_id"})
|
||||||
|
)
|
||||||
|
public class Inscripcion {
|
||||||
|
|
||||||
|
@Id
|
||||||
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
@Column(name = "fecha_inscripcion")
|
||||||
|
private LocalDateTime fechaInscripcion;
|
||||||
|
|
||||||
|
// POSTULANTE
|
||||||
|
@ManyToOne
|
||||||
|
@JoinColumn(name = "postulante_id", nullable = false)
|
||||||
|
private Postulante postulante;
|
||||||
|
|
||||||
|
// PROCESO
|
||||||
|
@ManyToOne
|
||||||
|
@JoinColumn(name = "proceso_id", nullable = false)
|
||||||
|
private Proceso proceso;
|
||||||
|
|
||||||
|
// PROGRAMA
|
||||||
|
@ManyToOne
|
||||||
|
@JoinColumn(name = "programa_id")
|
||||||
|
private ProgramaEstudio programa;
|
||||||
|
|
||||||
|
// MODALIDAD
|
||||||
|
@ManyToOne
|
||||||
|
@JoinColumn(name = "modalidad_id")
|
||||||
|
private Modalidad modalidad;
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,19 @@
|
|||||||
|
package com.service.ingresantes.entity;
|
||||||
|
|
||||||
|
import jakarta.persistence.*;
|
||||||
|
import lombok.*;
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
@Table(name = "modalidades")
|
||||||
|
@Data
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@Builder
|
||||||
|
public class Modalidad {
|
||||||
|
|
||||||
|
@Id
|
||||||
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
private String nombre;
|
||||||
|
}
|
||||||
@ -0,0 +1,58 @@
|
|||||||
|
package com.service.ingresantes.entity;
|
||||||
|
|
||||||
|
import jakarta.persistence.*;
|
||||||
|
import lombok.Data;
|
||||||
|
import java.time.LocalDate;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Entity
|
||||||
|
@Table(name = "postulante")
|
||||||
|
public class Postulante {
|
||||||
|
|
||||||
|
@Id
|
||||||
|
@Column(length = 8)
|
||||||
|
private String dni;
|
||||||
|
|
||||||
|
private String paterno;
|
||||||
|
private String materno;
|
||||||
|
private String nombres;
|
||||||
|
|
||||||
|
private String sexo;
|
||||||
|
|
||||||
|
@Column(name = "fecha_nacimiento")
|
||||||
|
private LocalDate fechaNacimiento;
|
||||||
|
|
||||||
|
private Integer edad;
|
||||||
|
|
||||||
|
@Column(name = "ubigeo_residencia")
|
||||||
|
private String ubigeoResidencia;
|
||||||
|
|
||||||
|
@Column(name = "departamento_residencia")
|
||||||
|
private String departamentoResidencia;
|
||||||
|
|
||||||
|
@Column(name = "provincia_residencia")
|
||||||
|
private String provinciaResidencia;
|
||||||
|
|
||||||
|
@Column(name = "distrito_residencia")
|
||||||
|
private String distritoResidencia;
|
||||||
|
|
||||||
|
private Integer egreso;
|
||||||
|
|
||||||
|
@Column(name = "cod_modular")
|
||||||
|
private String codModular;
|
||||||
|
|
||||||
|
@Column(name = "ubigeo_colegio")
|
||||||
|
private String ubigeoColegio;
|
||||||
|
|
||||||
|
@Column(name = "departamento_colegio")
|
||||||
|
private String departamentoColegio;
|
||||||
|
|
||||||
|
@Column(name = "provincia_colegio")
|
||||||
|
private String provinciaColegio;
|
||||||
|
|
||||||
|
@Column(name = "distrito_colegio")
|
||||||
|
private String distritoColegio;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -0,0 +1,21 @@
|
|||||||
|
package com.service.ingresantes.entity;
|
||||||
|
|
||||||
|
import jakarta.persistence.*;
|
||||||
|
import lombok.*;
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
@Table(name = "procesos")
|
||||||
|
@Data
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@Builder
|
||||||
|
public class Proceso {
|
||||||
|
|
||||||
|
@Id
|
||||||
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
private String nombre;
|
||||||
|
|
||||||
|
private Integer anio;
|
||||||
|
}
|
||||||
@ -0,0 +1,23 @@
|
|||||||
|
package com.service.ingresantes.entity;
|
||||||
|
|
||||||
|
import jakarta.persistence.*;
|
||||||
|
import lombok.*;
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
@Table(name = "programas")
|
||||||
|
@Data
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@Builder
|
||||||
|
public class ProgramaEstudio {
|
||||||
|
|
||||||
|
@Id
|
||||||
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
private String nombre;
|
||||||
|
|
||||||
|
@ManyToOne
|
||||||
|
@JoinColumn(name = "area_id")
|
||||||
|
private Area area;
|
||||||
|
}
|
||||||
@ -0,0 +1,44 @@
|
|||||||
|
package com.service.ingresantes.entity;
|
||||||
|
|
||||||
|
import jakarta.persistence.*;
|
||||||
|
import lombok.*;
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
@Table(name = "resultado_asignatura")
|
||||||
|
@Data
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@Builder
|
||||||
|
public class ResultadoAsignatura {
|
||||||
|
|
||||||
|
@Id
|
||||||
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
// resultado del examen
|
||||||
|
@ManyToOne
|
||||||
|
@JoinColumn(name = "resultado_examen_id", nullable = false)
|
||||||
|
private ResultadoExamen resultadoExamen;
|
||||||
|
|
||||||
|
// proceso
|
||||||
|
@ManyToOne
|
||||||
|
@JoinColumn(name = "proceso_id", nullable = false)
|
||||||
|
private Proceso proceso;
|
||||||
|
|
||||||
|
// área
|
||||||
|
@ManyToOne
|
||||||
|
@JoinColumn(name = "area_id", nullable = false)
|
||||||
|
private Area area;
|
||||||
|
|
||||||
|
// curso
|
||||||
|
@ManyToOne
|
||||||
|
@JoinColumn(name = "asignatura_id", nullable = false)
|
||||||
|
private Asignatura asignatura;
|
||||||
|
|
||||||
|
// estadísticas
|
||||||
|
private Integer correctas;
|
||||||
|
private Integer incorrectas;
|
||||||
|
private Integer blanco;
|
||||||
|
|
||||||
|
private Double puntaje;
|
||||||
|
}
|
||||||
@ -0,0 +1,59 @@
|
|||||||
|
package com.service.ingresantes.entity;
|
||||||
|
|
||||||
|
import jakarta.persistence.*;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Entity
|
||||||
|
@Table(
|
||||||
|
name = "resultado_examen",
|
||||||
|
uniqueConstraints = {
|
||||||
|
@UniqueConstraint(columnNames = {"inscripcion_id", "dia"})
|
||||||
|
}
|
||||||
|
)
|
||||||
|
public class ResultadoExamen {
|
||||||
|
|
||||||
|
@Id
|
||||||
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
@ManyToOne
|
||||||
|
@JoinColumn(name = "inscripcion_id", nullable = false)
|
||||||
|
private Inscripcion inscripcion;
|
||||||
|
|
||||||
|
@ManyToOne
|
||||||
|
@JoinColumn(name = "proceso_id", nullable = false)
|
||||||
|
private Proceso proceso;
|
||||||
|
|
||||||
|
@Column(nullable = false)
|
||||||
|
private Integer dia;
|
||||||
|
|
||||||
|
private Double puntaje;
|
||||||
|
|
||||||
|
@Column(name = "vocacional", nullable = true)
|
||||||
|
private Double vocacional; // ← NUEVO, puede ser null
|
||||||
|
|
||||||
|
@Column(length = 2)
|
||||||
|
private String apto;
|
||||||
|
|
||||||
|
private String obs;
|
||||||
|
|
||||||
|
@Column(name = "id_examen")
|
||||||
|
private String idExamen;
|
||||||
|
|
||||||
|
private String litho;
|
||||||
|
|
||||||
|
@Column(name = "num_lectura")
|
||||||
|
private String numLectura;
|
||||||
|
|
||||||
|
private String tipo;
|
||||||
|
|
||||||
|
private String calificar;
|
||||||
|
|
||||||
|
private String aula;
|
||||||
|
|
||||||
|
@Column(columnDefinition = "TEXT")
|
||||||
|
private String respuestas;
|
||||||
|
|
||||||
|
private Integer puesto;
|
||||||
|
}
|
||||||
@ -0,0 +1,7 @@
|
|||||||
|
package com.service.ingresantes.repository;
|
||||||
|
|
||||||
|
import com.service.ingresantes.entity.Area;
|
||||||
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
|
||||||
|
public interface AreaRepository extends JpaRepository<Area, Long> {
|
||||||
|
}
|
||||||
@ -0,0 +1,12 @@
|
|||||||
|
package com.service.ingresantes.repository;
|
||||||
|
|
||||||
|
import com.service.ingresantes.entity.Asignatura;
|
||||||
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface AsignaturaRepository extends JpaRepository<Asignatura, Long> {
|
||||||
|
|
||||||
|
List<Asignatura> findByAreaIdOrderByCodigo(Long areaId);
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,19 @@
|
|||||||
|
package com.service.ingresantes.repository;
|
||||||
|
|
||||||
|
import com.service.ingresantes.entity.CarpetaExamen;
|
||||||
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
public interface CarpetaExamenRepository extends JpaRepository<CarpetaExamen, Long> {
|
||||||
|
|
||||||
|
List<CarpetaExamen> findByProcesoIdAndAreaId(Long procesoId, Long areaId);
|
||||||
|
|
||||||
|
Optional<CarpetaExamen> findByProcesoIdAndAreaIdAndTipo(
|
||||||
|
Long procesoId,
|
||||||
|
Long areaId,
|
||||||
|
String tipo
|
||||||
|
);
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,20 @@
|
|||||||
|
package com.service.ingresantes.repository;
|
||||||
|
|
||||||
|
import com.service.ingresantes.entity.ClaveExamen;
|
||||||
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
public interface ClaveExamenRepository extends JpaRepository<ClaveExamen, Long> {
|
||||||
|
|
||||||
|
// Busca una clave por proceso, área e idExamen
|
||||||
|
Optional<ClaveExamen> findByProcesoIdAndAreaIdAndIdExamen(Long procesoId, Long areaId, String idExamen);
|
||||||
|
Optional<ClaveExamen> findByProcesoIdAndAreaIdAndTipo(
|
||||||
|
Long procesoId,
|
||||||
|
Long areaId,
|
||||||
|
String tipo
|
||||||
|
);
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,21 @@
|
|||||||
|
package com.service.ingresantes.repository;
|
||||||
|
|
||||||
|
import com.service.ingresantes.entity.Inscripcion;
|
||||||
|
import com.service.ingresantes.entity.Postulante;
|
||||||
|
import com.service.ingresantes.entity.Proceso;
|
||||||
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
public interface InscripcionRepository extends JpaRepository<Inscripcion, Long> {
|
||||||
|
|
||||||
|
// Verifica si ya existe inscripción de un postulante a un proceso
|
||||||
|
boolean existsByPostulanteAndProceso(Postulante postulante, Proceso proceso);
|
||||||
|
|
||||||
|
// Buscar inscripción por postulante y proceso
|
||||||
|
Optional<Inscripcion> findByPostulanteAndProceso(Postulante postulante, Proceso proceso);
|
||||||
|
|
||||||
|
// Buscar inscripción directamente por DNI y proceso
|
||||||
|
Optional<Inscripcion> findByPostulanteDniAndProcesoId(String dni, Long procesoId);
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,7 @@
|
|||||||
|
package com.service.ingresantes.repository;
|
||||||
|
|
||||||
|
import com.service.ingresantes.entity.Modalidad;
|
||||||
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
|
||||||
|
public interface ModalidadRepository extends JpaRepository<Modalidad, Long> {
|
||||||
|
}
|
||||||
@ -0,0 +1,11 @@
|
|||||||
|
package com.service.ingresantes.repository;
|
||||||
|
|
||||||
|
import com.service.ingresantes.entity.Postulante;
|
||||||
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
public interface PostulanteRepository extends JpaRepository<Postulante, String> {
|
||||||
|
|
||||||
|
Optional<Postulante> findByDni(String dni);
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,7 @@
|
|||||||
|
package com.service.ingresantes.repository;
|
||||||
|
|
||||||
|
import com.service.ingresantes.entity.Proceso;
|
||||||
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
|
||||||
|
public interface ProcesoRepository extends JpaRepository<Proceso, Long> {
|
||||||
|
}
|
||||||
@ -0,0 +1,11 @@
|
|||||||
|
package com.service.ingresantes.repository;
|
||||||
|
|
||||||
|
import com.service.ingresantes.entity.ProgramaEstudio;
|
||||||
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface ProgramaRepository extends JpaRepository<ProgramaEstudio, Long> {
|
||||||
|
|
||||||
|
List<ProgramaEstudio> findByAreaId(Long areaId);
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,10 @@
|
|||||||
|
package com.service.ingresantes.repository;
|
||||||
|
|
||||||
|
import com.service.ingresantes.entity.ResultadoAsignatura;
|
||||||
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
|
||||||
|
public interface ResultadoAsignaturaRepository extends JpaRepository<ResultadoAsignatura, Long> {
|
||||||
|
|
||||||
|
boolean existsByProcesoId(Long procesoId);
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,33 @@
|
|||||||
|
package com.service.ingresantes.repository;
|
||||||
|
|
||||||
|
import com.service.ingresantes.entity.ResultadoExamen;
|
||||||
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
import org.springframework.data.jpa.repository.Query;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
public interface ResultadoExamenRepository extends JpaRepository<ResultadoExamen, Long> {
|
||||||
|
|
||||||
|
boolean existsByInscripcionIdAndDia(Long inscripcionId, Integer dia);
|
||||||
|
|
||||||
|
@Query("""
|
||||||
|
SELECT r FROM ResultadoExamen r
|
||||||
|
JOIN r.inscripcion i
|
||||||
|
JOIN i.postulante p
|
||||||
|
WHERE p.dni = :dni
|
||||||
|
AND i.proceso.id = :procesoId
|
||||||
|
AND r.dia = :dia
|
||||||
|
""")
|
||||||
|
Optional<ResultadoExamen> findByDniAndProcesoAndDia(String dni, Long procesoId, Integer dia);
|
||||||
|
|
||||||
|
@Query("""
|
||||||
|
SELECT r FROM ResultadoExamen r
|
||||||
|
JOIN r.inscripcion i
|
||||||
|
WHERE i.proceso.id = :procesoId
|
||||||
|
ORDER BY r.puntaje DESC
|
||||||
|
""")
|
||||||
|
List<ResultadoExamen> findRankingByProceso(Long procesoId);
|
||||||
|
|
||||||
|
List<ResultadoExamen> findByProcesoId(Long procesoId);
|
||||||
|
}
|
||||||
@ -0,0 +1,128 @@
|
|||||||
|
package com.service.ingresantes.service;
|
||||||
|
|
||||||
|
import com.service.ingresantes.entity.*;
|
||||||
|
import com.service.ingresantes.repository.*;
|
||||||
|
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
@Transactional
|
||||||
|
public class CalificacionCursoService {
|
||||||
|
|
||||||
|
private final ResultadoExamenRepository resultadoRepo;
|
||||||
|
private final ClaveExamenRepository claveRepo;
|
||||||
|
private final AsignaturaRepository asignaturaRepo;
|
||||||
|
private final ResultadoAsignaturaRepository resultadoAsignaturaRepo;
|
||||||
|
|
||||||
|
public CalificacionCursoService(
|
||||||
|
ResultadoExamenRepository resultadoRepo,
|
||||||
|
ClaveExamenRepository claveRepo,
|
||||||
|
AsignaturaRepository asignaturaRepo,
|
||||||
|
ResultadoAsignaturaRepository resultadoAsignaturaRepo) {
|
||||||
|
|
||||||
|
this.resultadoRepo = resultadoRepo;
|
||||||
|
this.claveRepo = claveRepo;
|
||||||
|
this.asignaturaRepo = asignaturaRepo;
|
||||||
|
this.resultadoAsignaturaRepo = resultadoAsignaturaRepo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int calificarCursos(Long procesoId) {
|
||||||
|
|
||||||
|
|
||||||
|
if (resultadoAsignaturaRepo.existsByProcesoId(procesoId)) {
|
||||||
|
throw new RuntimeException("Este proceso ya fue calificado por cursos");
|
||||||
|
}
|
||||||
|
|
||||||
|
List<ResultadoExamen> resultados = resultadoRepo.findByProcesoId(procesoId);
|
||||||
|
|
||||||
|
List<ResultadoAsignatura> listaGuardar = new ArrayList<>();
|
||||||
|
|
||||||
|
for (ResultadoExamen resultado : resultados) {
|
||||||
|
|
||||||
|
String respuestas = resultado.getRespuestas();
|
||||||
|
|
||||||
|
if (respuestas == null || respuestas.isEmpty())
|
||||||
|
continue;
|
||||||
|
|
||||||
|
Long areaId = Long.parseLong(resultado.getIdExamen());
|
||||||
|
String tipo = resultado.getTipo();
|
||||||
|
|
||||||
|
Optional<ClaveExamen> claveOpt =
|
||||||
|
claveRepo.findByProcesoIdAndAreaIdAndTipo(
|
||||||
|
procesoId,
|
||||||
|
areaId,
|
||||||
|
tipo
|
||||||
|
);
|
||||||
|
|
||||||
|
if (claveOpt.isEmpty())
|
||||||
|
continue;
|
||||||
|
|
||||||
|
String clave = claveOpt.get().getClave();
|
||||||
|
|
||||||
|
List<Asignatura> asignaturas =
|
||||||
|
asignaturaRepo.findByAreaIdOrderByCodigo(areaId);
|
||||||
|
|
||||||
|
int pos = 0;
|
||||||
|
|
||||||
|
for (Asignatura asignatura : asignaturas) {
|
||||||
|
|
||||||
|
int preguntas = asignatura.getCantidadPreguntas();
|
||||||
|
int fin = pos + preguntas;
|
||||||
|
|
||||||
|
if (fin > respuestas.length())
|
||||||
|
break;
|
||||||
|
|
||||||
|
String resp = respuestas.substring(pos, fin);
|
||||||
|
String cla = clave.substring(pos, fin);
|
||||||
|
|
||||||
|
int correctas = 0;
|
||||||
|
int incorrectas = 0;
|
||||||
|
int blanco = 0;
|
||||||
|
|
||||||
|
for (int i = 0; i < resp.length(); i++) {
|
||||||
|
|
||||||
|
char r = resp.charAt(i);
|
||||||
|
char c = cla.charAt(i);
|
||||||
|
|
||||||
|
if (r == ' ' || r == '0') {
|
||||||
|
blanco++;
|
||||||
|
}
|
||||||
|
else if (r == c) {
|
||||||
|
correctas++;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
incorrectas++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
double ponderacion = asignatura.getPonderacion();
|
||||||
|
|
||||||
|
double puntaje =
|
||||||
|
(correctas * 10 * ponderacion) +
|
||||||
|
(blanco * 2 * ponderacion);
|
||||||
|
|
||||||
|
ResultadoAsignatura resultadoAsignatura = ResultadoAsignatura.builder()
|
||||||
|
.resultadoExamen(resultado)
|
||||||
|
.proceso(resultado.getProceso())
|
||||||
|
.area(asignatura.getArea())
|
||||||
|
.asignatura(asignatura)
|
||||||
|
.correctas(correctas)
|
||||||
|
.incorrectas(incorrectas)
|
||||||
|
.blanco(blanco)
|
||||||
|
.puntaje(puntaje)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
listaGuardar.add(resultadoAsignatura);
|
||||||
|
|
||||||
|
pos = fin;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
resultadoAsignaturaRepo.saveAll(listaGuardar);
|
||||||
|
|
||||||
|
return listaGuardar.size();
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,68 @@
|
|||||||
|
package com.service.ingresantes.service;
|
||||||
|
|
||||||
|
import com.service.ingresantes.entity.Area;
|
||||||
|
import com.service.ingresantes.entity.CarpetaExamen;
|
||||||
|
import com.service.ingresantes.entity.Proceso;
|
||||||
|
import com.service.ingresantes.repository.AreaRepository;
|
||||||
|
import com.service.ingresantes.repository.CarpetaExamenRepository;
|
||||||
|
import com.service.ingresantes.repository.ProcesoRepository;
|
||||||
|
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class CarpetaExamenService {
|
||||||
|
|
||||||
|
private final CarpetaExamenRepository carpetaRepo;
|
||||||
|
private final ProcesoRepository procesoRepo;
|
||||||
|
private final AreaRepository areaRepo;
|
||||||
|
|
||||||
|
public CarpetaExamenService(
|
||||||
|
CarpetaExamenRepository carpetaRepo,
|
||||||
|
ProcesoRepository procesoRepo,
|
||||||
|
AreaRepository areaRepo) {
|
||||||
|
|
||||||
|
this.carpetaRepo = carpetaRepo;
|
||||||
|
this.procesoRepo = procesoRepo;
|
||||||
|
this.areaRepo = areaRepo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void subirArchivo(
|
||||||
|
MultipartFile file,
|
||||||
|
String tipo,
|
||||||
|
Long procesoId,
|
||||||
|
Long areaId) throws Exception {
|
||||||
|
|
||||||
|
Proceso proceso = procesoRepo.findById(procesoId)
|
||||||
|
.orElseThrow(() -> new RuntimeException("Proceso no existe"));
|
||||||
|
|
||||||
|
Area area = areaRepo.findById(areaId)
|
||||||
|
.orElseThrow(() -> new RuntimeException("Area no existe"));
|
||||||
|
|
||||||
|
String rutaBase = System.getProperty("user.dir") +
|
||||||
|
"/examenes/" + procesoId + "/" + areaId + "/";
|
||||||
|
|
||||||
|
File carpeta = new File(rutaBase);
|
||||||
|
|
||||||
|
if (!carpeta.exists()) {
|
||||||
|
carpeta.mkdirs();
|
||||||
|
}
|
||||||
|
|
||||||
|
String nombreArchivo = file.getOriginalFilename();
|
||||||
|
|
||||||
|
File destino = new File(rutaBase + nombreArchivo);
|
||||||
|
|
||||||
|
file.transferTo(destino);
|
||||||
|
|
||||||
|
CarpetaExamen carpetaExamen = CarpetaExamen.builder()
|
||||||
|
.tipo(tipo)
|
||||||
|
.ruta(destino.getAbsolutePath())
|
||||||
|
.proceso(proceso)
|
||||||
|
.area(area)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
carpetaRepo.save(carpetaExamen);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,223 @@
|
|||||||
|
package com.service.ingresantes.service;
|
||||||
|
|
||||||
|
import com.service.ingresantes.entity.Inscripcion;
|
||||||
|
import com.service.ingresantes.entity.ResultadoExamen;
|
||||||
|
import com.service.ingresantes.repository.InscripcionRepository;
|
||||||
|
import com.service.ingresantes.repository.ResultadoExamenRepository;
|
||||||
|
|
||||||
|
import org.apache.poi.ss.usermodel.*;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
import jakarta.transaction.Transactional;
|
||||||
|
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class ExcelResultadoService {
|
||||||
|
|
||||||
|
private final InscripcionRepository inscripcionRepo;
|
||||||
|
private final ResultadoExamenRepository resultadoRepo;
|
||||||
|
|
||||||
|
public ExcelResultadoService(
|
||||||
|
InscripcionRepository inscripcionRepo,
|
||||||
|
ResultadoExamenRepository resultadoRepo) {
|
||||||
|
this.inscripcionRepo = inscripcionRepo;
|
||||||
|
this.resultadoRepo = resultadoRepo;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getCellString(Cell cell) {
|
||||||
|
if (cell == null) return "";
|
||||||
|
switch (cell.getCellType()) {
|
||||||
|
case STRING:
|
||||||
|
return cell.getStringCellValue().trim();
|
||||||
|
case NUMERIC:
|
||||||
|
return String.valueOf((long) cell.getNumericCellValue());
|
||||||
|
default:
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Double getCellDouble(Cell cell) {
|
||||||
|
if (cell == null) return null;
|
||||||
|
if (cell.getCellType() == CellType.NUMERIC) return cell.getNumericCellValue();
|
||||||
|
if (cell.getCellType() == CellType.STRING) {
|
||||||
|
try {
|
||||||
|
return Double.parseDouble(cell.getStringCellValue());
|
||||||
|
} catch (Exception e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Integer getCellInteger(Cell cell) {
|
||||||
|
if (cell == null) return null;
|
||||||
|
if (cell.getCellType() == CellType.NUMERIC) return (int) cell.getNumericCellValue();
|
||||||
|
if (cell.getCellType() == CellType.STRING) {
|
||||||
|
try {
|
||||||
|
return Integer.parseInt(cell.getStringCellValue());
|
||||||
|
} catch (Exception e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void incrementar(Map<String, Integer> mapa, String clave) {
|
||||||
|
mapa.put(clave, mapa.getOrDefault(clave, 0) + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
public String importarExcelResultados(MultipartFile file, Integer dia) throws Exception {
|
||||||
|
|
||||||
|
int totalFilas = 0;
|
||||||
|
int guardados = 0;
|
||||||
|
int omitidos = 0;
|
||||||
|
int errores = 0;
|
||||||
|
|
||||||
|
int dniVacio = 0;
|
||||||
|
int procesoVacio = 0;
|
||||||
|
int inscripcionNoExiste = 0;
|
||||||
|
int duplicado = 0;
|
||||||
|
|
||||||
|
Map<String, Integer> omitidasPorCausa = new TreeMap<>();
|
||||||
|
|
||||||
|
// 🔥 NUEVO: lista de detalles de omitidos
|
||||||
|
List<String> detalleOmitidos = new ArrayList<>();
|
||||||
|
|
||||||
|
try (InputStream is = file.getInputStream();
|
||||||
|
Workbook workbook = WorkbookFactory.create(is)) {
|
||||||
|
|
||||||
|
Sheet sheet = workbook.getSheetAt(0);
|
||||||
|
|
||||||
|
for (Row row : sheet) {
|
||||||
|
|
||||||
|
if (row.getRowNum() == 0) continue;
|
||||||
|
|
||||||
|
totalFilas++;
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
|
String dni = getCellString(row.getCell(0));
|
||||||
|
String procesoStr = getCellString(row.getCell(1));
|
||||||
|
|
||||||
|
if (dni.isEmpty()) {
|
||||||
|
omitidos++;
|
||||||
|
dniVacio++;
|
||||||
|
detalleOmitidos.add("Fila " + (row.getRowNum()+1) + " -> DNI vacío");
|
||||||
|
incrementar(omitidasPorCausa, "DNI vacío");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (procesoStr.isEmpty()) {
|
||||||
|
omitidos++;
|
||||||
|
procesoVacio++;
|
||||||
|
detalleOmitidos.add("DNI: " + dni + " -> Proceso vacío");
|
||||||
|
incrementar(omitidasPorCausa, "Proceso vacío");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
Long procesoId;
|
||||||
|
try {
|
||||||
|
procesoId = Long.parseLong(procesoStr);
|
||||||
|
} catch (Exception e) {
|
||||||
|
omitidos++;
|
||||||
|
procesoVacio++;
|
||||||
|
detalleOmitidos.add("DNI: " + dni + " -> Proceso inválido: " + procesoStr);
|
||||||
|
incrementar(omitidasPorCausa, "Proceso inválido");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
Optional<Inscripcion> inscripcionOpt =
|
||||||
|
inscripcionRepo.findByPostulanteDniAndProcesoId(dni, procesoId);
|
||||||
|
|
||||||
|
if (inscripcionOpt.isEmpty()) {
|
||||||
|
omitidos++;
|
||||||
|
inscripcionNoExiste++;
|
||||||
|
detalleOmitidos.add("DNI: " + dni + " | Proceso: " + procesoId + " -> NO EXISTE INSCRIPCIÓN");
|
||||||
|
incrementar(omitidasPorCausa, "Inscripción no existe");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
Inscripcion inscripcion = inscripcionOpt.get();
|
||||||
|
|
||||||
|
if (resultadoRepo.existsByInscripcionIdAndDia(inscripcion.getId(), dia)) {
|
||||||
|
omitidos++;
|
||||||
|
duplicado++;
|
||||||
|
detalleOmitidos.add("DNI: " + dni + " | Proceso: " + procesoId + " -> DUPLICADO");
|
||||||
|
incrementar(omitidasPorCausa, "Resultado duplicado");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
Double puntaje = getCellDouble(row.getCell(2));
|
||||||
|
Double vocacional = getCellDouble(row.getCell(3));
|
||||||
|
String apto = getCellString(row.getCell(4));
|
||||||
|
String obs = getCellString(row.getCell(5));
|
||||||
|
String idExamen = getCellString(row.getCell(6));
|
||||||
|
String litho = getCellString(row.getCell(7));
|
||||||
|
String numLectura = getCellString(row.getCell(8));
|
||||||
|
String tipo = getCellString(row.getCell(9));
|
||||||
|
String calificar = getCellString(row.getCell(10));
|
||||||
|
String aula = getCellString(row.getCell(11));
|
||||||
|
String respuestas = getCellString(row.getCell(12));
|
||||||
|
Integer puesto = getCellInteger(row.getCell(13));
|
||||||
|
|
||||||
|
ResultadoExamen resultado = new ResultadoExamen();
|
||||||
|
resultado.setInscripcion(inscripcion);
|
||||||
|
resultado.setProceso(inscripcion.getProceso());
|
||||||
|
resultado.setDia(dia);
|
||||||
|
resultado.setPuntaje(puntaje);
|
||||||
|
resultado.setVocacional(vocacional);
|
||||||
|
resultado.setApto(apto);
|
||||||
|
resultado.setObs(obs);
|
||||||
|
resultado.setIdExamen(idExamen);
|
||||||
|
resultado.setLitho(litho);
|
||||||
|
resultado.setNumLectura(numLectura);
|
||||||
|
resultado.setTipo(tipo);
|
||||||
|
resultado.setCalificar(calificar);
|
||||||
|
resultado.setAula(aula);
|
||||||
|
resultado.setRespuestas(respuestas);
|
||||||
|
resultado.setPuesto(puesto);
|
||||||
|
|
||||||
|
resultadoRepo.save(resultado);
|
||||||
|
guardados++;
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
errores++;
|
||||||
|
detalleOmitidos.add("Fila " + (row.getRowNum()+1) + " -> ERROR: " + e.getMessage());
|
||||||
|
incrementar(omitidasPorCausa, "Error interno");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
|
||||||
|
sb.append("IMPORTACIÓN RESULTADOS\n");
|
||||||
|
sb.append("Total filas: ").append(totalFilas).append("\n");
|
||||||
|
sb.append("Guardados: ").append(guardados).append("\n");
|
||||||
|
sb.append("Omitidos: ").append(omitidos).append("\n");
|
||||||
|
sb.append("Errores: ").append(errores).append("\n\n");
|
||||||
|
|
||||||
|
sb.append("DETALLE:\n");
|
||||||
|
sb.append("- DNI vacío: ").append(dniVacio).append("\n");
|
||||||
|
sb.append("- Proceso vacío/inválido: ").append(procesoVacio).append("\n");
|
||||||
|
sb.append("- Inscripción no existe: ").append(inscripcionNoExiste).append("\n");
|
||||||
|
sb.append("- Resultado duplicado: ").append(duplicado).append("\n\n");
|
||||||
|
|
||||||
|
sb.append("CAUSAS AGRUPADAS:\n");
|
||||||
|
for (Map.Entry<String, Integer> entry : omitidasPorCausa.entrySet()) {
|
||||||
|
sb.append("- ").append(entry.getKey()).append(": ")
|
||||||
|
.append(entry.getValue()).append("\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 🔥 NUEVO BLOQUE
|
||||||
|
sb.append("\nDETALLE DE DNIs OMITIDOS:\n");
|
||||||
|
for (String d : detalleOmitidos) {
|
||||||
|
sb.append("- ").append(d).append("\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,432 @@
|
|||||||
|
package com.service.ingresantes.service;
|
||||||
|
|
||||||
|
import com.service.ingresantes.entity.Inscripcion;
|
||||||
|
import com.service.ingresantes.entity.Modalidad;
|
||||||
|
import com.service.ingresantes.entity.Postulante;
|
||||||
|
import com.service.ingresantes.entity.Proceso;
|
||||||
|
import com.service.ingresantes.entity.ProgramaEstudio;
|
||||||
|
import com.service.ingresantes.repository.InscripcionRepository;
|
||||||
|
import com.service.ingresantes.repository.ModalidadRepository;
|
||||||
|
import com.service.ingresantes.repository.PostulanteRepository;
|
||||||
|
import com.service.ingresantes.repository.ProcesoRepository;
|
||||||
|
import com.service.ingresantes.repository.ProgramaRepository;
|
||||||
|
import jakarta.transaction.Transactional;
|
||||||
|
import org.apache.poi.ss.usermodel.*;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.time.ZoneId;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.TreeMap;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class ExcelService {
|
||||||
|
|
||||||
|
private final PostulanteRepository postulanteRepo;
|
||||||
|
private final ProcesoRepository procesoRepo;
|
||||||
|
private final ProgramaRepository programaRepo;
|
||||||
|
private final ModalidadRepository modalidadRepo;
|
||||||
|
private final InscripcionRepository inscripcionRepo;
|
||||||
|
|
||||||
|
public ExcelService(PostulanteRepository postulanteRepo,
|
||||||
|
ProcesoRepository procesoRepo,
|
||||||
|
ProgramaRepository programaRepo,
|
||||||
|
ModalidadRepository modalidadRepo,
|
||||||
|
InscripcionRepository inscripcionRepo) {
|
||||||
|
this.postulanteRepo = postulanteRepo;
|
||||||
|
this.procesoRepo = procesoRepo;
|
||||||
|
this.programaRepo = programaRepo;
|
||||||
|
this.modalidadRepo = modalidadRepo;
|
||||||
|
this.inscripcionRepo = inscripcionRepo;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getCellStringValue(Cell cell) {
|
||||||
|
if (cell == null) return "";
|
||||||
|
|
||||||
|
try {
|
||||||
|
return switch (cell.getCellType()) {
|
||||||
|
case STRING -> cell.getStringCellValue().trim();
|
||||||
|
|
||||||
|
case NUMERIC -> {
|
||||||
|
if (DateUtil.isCellDateFormatted(cell)) {
|
||||||
|
yield cell.getLocalDateTimeCellValue().toLocalDate().toString();
|
||||||
|
} else {
|
||||||
|
double value = cell.getNumericCellValue();
|
||||||
|
long longValue = (long) value;
|
||||||
|
if (value == longValue) {
|
||||||
|
yield String.valueOf(longValue);
|
||||||
|
} else {
|
||||||
|
yield String.valueOf(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
case BOOLEAN -> String.valueOf(cell.getBooleanCellValue());
|
||||||
|
|
||||||
|
case FORMULA -> {
|
||||||
|
try {
|
||||||
|
FormulaEvaluator evaluator = cell.getSheet()
|
||||||
|
.getWorkbook()
|
||||||
|
.getCreationHelper()
|
||||||
|
.createFormulaEvaluator();
|
||||||
|
|
||||||
|
CellValue cellValue = evaluator.evaluate(cell);
|
||||||
|
|
||||||
|
yield switch (cellValue.getCellType()) {
|
||||||
|
case STRING -> cellValue.getStringValue().trim();
|
||||||
|
case NUMERIC -> {
|
||||||
|
double value = cellValue.getNumberValue();
|
||||||
|
long longValue = (long) value;
|
||||||
|
if (value == longValue) {
|
||||||
|
yield String.valueOf(longValue);
|
||||||
|
} else {
|
||||||
|
yield String.valueOf(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
case BOOLEAN -> String.valueOf(cellValue.getBooleanValue());
|
||||||
|
default -> "";
|
||||||
|
};
|
||||||
|
} catch (Exception e) {
|
||||||
|
yield "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
case BLANK -> "";
|
||||||
|
default -> "";
|
||||||
|
};
|
||||||
|
} catch (Exception e) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private LocalDate getCellLocalDate(Cell cell) {
|
||||||
|
if (cell == null) return null;
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (cell.getCellType() == CellType.NUMERIC && DateUtil.isCellDateFormatted(cell)) {
|
||||||
|
return cell.getDateCellValue()
|
||||||
|
.toInstant()
|
||||||
|
.atZone(ZoneId.systemDefault())
|
||||||
|
.toLocalDate();
|
||||||
|
}
|
||||||
|
|
||||||
|
String value = getCellStringValue(cell);
|
||||||
|
if (value == null || value.isBlank()) return null;
|
||||||
|
|
||||||
|
return LocalDate.parse(value.trim());
|
||||||
|
} catch (Exception e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private LocalDateTime getCellLocalDateTime(Cell cell) {
|
||||||
|
if (cell == null) return null;
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (cell.getCellType() == CellType.NUMERIC && DateUtil.isCellDateFormatted(cell)) {
|
||||||
|
return cell.getDateCellValue()
|
||||||
|
.toInstant()
|
||||||
|
.atZone(ZoneId.systemDefault())
|
||||||
|
.toLocalDateTime();
|
||||||
|
}
|
||||||
|
|
||||||
|
String value = getCellStringValue(cell);
|
||||||
|
if (value == null || value.isBlank()) return null;
|
||||||
|
|
||||||
|
try {
|
||||||
|
return LocalDateTime.parse(value.trim().replace(" ", "T"));
|
||||||
|
} catch (Exception e) {
|
||||||
|
try {
|
||||||
|
return LocalDate.parse(value.trim()).atStartOfDay();
|
||||||
|
} catch (Exception ex) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Integer parseInteger(String value) {
|
||||||
|
try {
|
||||||
|
if (value == null || value.isBlank()) return null;
|
||||||
|
return Integer.parseInt(value.trim());
|
||||||
|
} catch (Exception e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Long parseLong(String value) {
|
||||||
|
try {
|
||||||
|
if (value == null || value.isBlank()) return null;
|
||||||
|
return Long.parseLong(value.trim());
|
||||||
|
} catch (Exception e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void incrementar(Map<String, Integer> mapa, String clave) {
|
||||||
|
mapa.put(clave, mapa.getOrDefault(clave, 0) + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
public String importarExcel(MultipartFile file) throws Exception {
|
||||||
|
int totalFilas = 0;
|
||||||
|
int postulantesCreados = 0;
|
||||||
|
int inscripcionesGuardadas = 0;
|
||||||
|
int filasOmitidas = 0;
|
||||||
|
int errores = 0;
|
||||||
|
|
||||||
|
int dniVacio = 0;
|
||||||
|
int procesoVacio = 0;
|
||||||
|
int procesoInvalido = 0;
|
||||||
|
int procesoNoEncontrado = 0;
|
||||||
|
int programaInvalido = 0;
|
||||||
|
int programaNoEncontrado = 0;
|
||||||
|
int modalidadInvalida = 0;
|
||||||
|
int modalidadNoEncontrada = 0;
|
||||||
|
int inscripcionDuplicada = 0;
|
||||||
|
|
||||||
|
Map<String, Integer> omitidasPorProceso = new TreeMap<>();
|
||||||
|
Map<String, Integer> omitidasPorPrograma = new TreeMap<>();
|
||||||
|
Map<String, Integer> omitidasPorModalidad = new TreeMap<>();
|
||||||
|
Map<String, Integer> omitidasPorProcesoModalidad = new TreeMap<>();
|
||||||
|
Map<String, Integer> omitidasPorCausa = new TreeMap<>();
|
||||||
|
|
||||||
|
try (InputStream is = file.getInputStream();
|
||||||
|
Workbook workbook = WorkbookFactory.create(is)) {
|
||||||
|
|
||||||
|
Sheet sheet = workbook.getSheetAt(0);
|
||||||
|
|
||||||
|
for (Row row : sheet) {
|
||||||
|
if (row.getRowNum() == 0) continue;
|
||||||
|
totalFilas++;
|
||||||
|
|
||||||
|
String dni = getCellStringValue(row.getCell(0));
|
||||||
|
String procesoStr = getCellStringValue(row.getCell(18));
|
||||||
|
String programaStr = getCellStringValue(row.getCell(19));
|
||||||
|
String modalidadStr = getCellStringValue(row.getCell(20));
|
||||||
|
|
||||||
|
String procesoKey = procesoStr.isBlank() ? "SIN_PROCESO" : "Proceso " + procesoStr;
|
||||||
|
String programaKey = programaStr.isBlank() ? "SIN_PROGRAMA" : "Programa " + programaStr;
|
||||||
|
String modalidadKey = modalidadStr.isBlank() ? "SIN_MODALIDAD" : "Modalidad " + modalidadStr;
|
||||||
|
String procesoModalidadKey = procesoKey + " | " + modalidadKey;
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (dni.isBlank()) {
|
||||||
|
filasOmitidas++;
|
||||||
|
dniVacio++;
|
||||||
|
incrementar(omitidasPorProceso, procesoKey);
|
||||||
|
incrementar(omitidasPorPrograma, programaKey);
|
||||||
|
incrementar(omitidasPorModalidad, modalidadKey);
|
||||||
|
incrementar(omitidasPorProcesoModalidad, procesoModalidadKey);
|
||||||
|
incrementar(omitidasPorCausa, "DNI vacío");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
Postulante postulante = postulanteRepo.findById(dni).orElse(null);
|
||||||
|
|
||||||
|
if (postulante == null) {
|
||||||
|
postulante = new Postulante();
|
||||||
|
postulante.setDni(dni);
|
||||||
|
postulante.setPaterno(getCellStringValue(row.getCell(1)));
|
||||||
|
postulante.setMaterno(getCellStringValue(row.getCell(2)));
|
||||||
|
postulante.setNombres(getCellStringValue(row.getCell(3)));
|
||||||
|
postulante.setSexo(getCellStringValue(row.getCell(4)));
|
||||||
|
|
||||||
|
LocalDate fechaNacimiento = getCellLocalDate(row.getCell(5));
|
||||||
|
if (fechaNacimiento != null) postulante.setFechaNacimiento(fechaNacimiento);
|
||||||
|
|
||||||
|
Integer edad = parseInteger(getCellStringValue(row.getCell(6)));
|
||||||
|
if (edad != null) postulante.setEdad(edad);
|
||||||
|
|
||||||
|
postulante.setUbigeoResidencia(getCellStringValue(row.getCell(7)));
|
||||||
|
postulante.setDepartamentoResidencia(getCellStringValue(row.getCell(8)));
|
||||||
|
postulante.setProvinciaResidencia(getCellStringValue(row.getCell(9)));
|
||||||
|
postulante.setDistritoResidencia(getCellStringValue(row.getCell(10)));
|
||||||
|
|
||||||
|
Integer egreso = parseInteger(getCellStringValue(row.getCell(11)));
|
||||||
|
if (egreso != null) postulante.setEgreso(egreso);
|
||||||
|
|
||||||
|
postulante.setCodModular(getCellStringValue(row.getCell(12)));
|
||||||
|
postulante.setUbigeoColegio(getCellStringValue(row.getCell(13)));
|
||||||
|
postulante.setDepartamentoColegio(getCellStringValue(row.getCell(14)));
|
||||||
|
postulante.setProvinciaColegio(getCellStringValue(row.getCell(15)));
|
||||||
|
postulante.setDistritoColegio(getCellStringValue(row.getCell(16)));
|
||||||
|
|
||||||
|
postulante = postulanteRepo.save(postulante);
|
||||||
|
postulantesCreados++;
|
||||||
|
}
|
||||||
|
|
||||||
|
LocalDateTime fechaInscripcion = getCellLocalDateTime(row.getCell(17));
|
||||||
|
if (fechaInscripcion == null) {
|
||||||
|
fechaInscripcion = LocalDateTime.now();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (procesoStr.isBlank()) {
|
||||||
|
filasOmitidas++;
|
||||||
|
procesoVacio++;
|
||||||
|
incrementar(omitidasPorProceso, procesoKey);
|
||||||
|
incrementar(omitidasPorPrograma, programaKey);
|
||||||
|
incrementar(omitidasPorModalidad, modalidadKey);
|
||||||
|
incrementar(omitidasPorProcesoModalidad, procesoModalidadKey);
|
||||||
|
incrementar(omitidasPorCausa, "Proceso vacío");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
Long procesoId = parseLong(procesoStr);
|
||||||
|
if (procesoId == null) {
|
||||||
|
filasOmitidas++;
|
||||||
|
procesoInvalido++;
|
||||||
|
incrementar(omitidasPorProceso, procesoKey);
|
||||||
|
incrementar(omitidasPorPrograma, programaKey);
|
||||||
|
incrementar(omitidasPorModalidad, modalidadKey);
|
||||||
|
incrementar(omitidasPorProcesoModalidad, procesoModalidadKey);
|
||||||
|
incrementar(omitidasPorCausa, "Proceso inválido");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
Optional<Proceso> procesoOpt = procesoRepo.findById(procesoId);
|
||||||
|
if (procesoOpt.isEmpty()) {
|
||||||
|
filasOmitidas++;
|
||||||
|
procesoNoEncontrado++;
|
||||||
|
incrementar(omitidasPorProceso, procesoKey);
|
||||||
|
incrementar(omitidasPorPrograma, programaKey);
|
||||||
|
incrementar(omitidasPorModalidad, modalidadKey);
|
||||||
|
incrementar(omitidasPorProcesoModalidad, procesoModalidadKey);
|
||||||
|
incrementar(omitidasPorCausa, "Proceso no encontrado");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
Proceso proceso = procesoOpt.get();
|
||||||
|
|
||||||
|
Long programaId = parseLong(programaStr);
|
||||||
|
if (programaId == null) {
|
||||||
|
filasOmitidas++;
|
||||||
|
programaInvalido++;
|
||||||
|
incrementar(omitidasPorProceso, procesoKey);
|
||||||
|
incrementar(omitidasPorPrograma, programaKey);
|
||||||
|
incrementar(omitidasPorModalidad, modalidadKey);
|
||||||
|
incrementar(omitidasPorProcesoModalidad, procesoModalidadKey);
|
||||||
|
incrementar(omitidasPorCausa, "Programa inválido");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
Optional<ProgramaEstudio> programaOpt = programaRepo.findById(programaId);
|
||||||
|
if (programaOpt.isEmpty()) {
|
||||||
|
filasOmitidas++;
|
||||||
|
programaNoEncontrado++;
|
||||||
|
incrementar(omitidasPorProceso, procesoKey);
|
||||||
|
incrementar(omitidasPorPrograma, programaKey);
|
||||||
|
incrementar(omitidasPorModalidad, modalidadKey);
|
||||||
|
incrementar(omitidasPorProcesoModalidad, procesoModalidadKey);
|
||||||
|
incrementar(omitidasPorCausa, "Programa no encontrado");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
ProgramaEstudio programa = programaOpt.get();
|
||||||
|
|
||||||
|
Long modalidadId = parseLong(modalidadStr);
|
||||||
|
if (modalidadId == null) {
|
||||||
|
filasOmitidas++;
|
||||||
|
modalidadInvalida++;
|
||||||
|
incrementar(omitidasPorProceso, procesoKey);
|
||||||
|
incrementar(omitidasPorPrograma, programaKey);
|
||||||
|
incrementar(omitidasPorModalidad, modalidadKey);
|
||||||
|
incrementar(omitidasPorProcesoModalidad, procesoModalidadKey);
|
||||||
|
incrementar(omitidasPorCausa, "Modalidad inválida");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
Optional<Modalidad> modalidadOpt = modalidadRepo.findById(modalidadId);
|
||||||
|
if (modalidadOpt.isEmpty()) {
|
||||||
|
filasOmitidas++;
|
||||||
|
modalidadNoEncontrada++;
|
||||||
|
incrementar(omitidasPorProceso, procesoKey);
|
||||||
|
incrementar(omitidasPorPrograma, programaKey);
|
||||||
|
incrementar(omitidasPorModalidad, modalidadKey);
|
||||||
|
incrementar(omitidasPorProcesoModalidad, procesoModalidadKey);
|
||||||
|
incrementar(omitidasPorCausa, "Modalidad no encontrada");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
Modalidad modalidad = modalidadOpt.get();
|
||||||
|
|
||||||
|
boolean existe = inscripcionRepo.existsByPostulanteAndProceso(postulante, proceso);
|
||||||
|
if (existe) {
|
||||||
|
filasOmitidas++;
|
||||||
|
inscripcionDuplicada++;
|
||||||
|
incrementar(omitidasPorProceso, procesoKey);
|
||||||
|
incrementar(omitidasPorPrograma, programaKey);
|
||||||
|
incrementar(omitidasPorModalidad, modalidadKey);
|
||||||
|
incrementar(omitidasPorProcesoModalidad, procesoModalidadKey);
|
||||||
|
incrementar(omitidasPorCausa, "Inscripción duplicada");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
Inscripcion inscripcion = new Inscripcion();
|
||||||
|
inscripcion.setFechaInscripcion(fechaInscripcion);
|
||||||
|
inscripcion.setPostulante(postulante);
|
||||||
|
inscripcion.setProceso(proceso);
|
||||||
|
inscripcion.setPrograma(programa);
|
||||||
|
inscripcion.setModalidad(modalidad);
|
||||||
|
inscripcionRepo.save(inscripcion);
|
||||||
|
inscripcionesGuardadas++;
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
errores++;
|
||||||
|
incrementar(omitidasPorCausa, "Error interno");
|
||||||
|
System.out.println("Fila " + (row.getRowNum() + 1) + ": ERROR -> " + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
sb.append("Importación finalizada.\n");
|
||||||
|
sb.append("Total filas: ").append(totalFilas).append("\n");
|
||||||
|
sb.append("Postulantes creados: ").append(postulantesCreados).append("\n");
|
||||||
|
sb.append("Inscripciones guardadas: ").append(inscripcionesGuardadas).append("\n");
|
||||||
|
sb.append("Filas omitidas: ").append(filasOmitidas).append("\n");
|
||||||
|
sb.append("Errores: ").append(errores).append("\n\n");
|
||||||
|
|
||||||
|
sb.append("DETALLE POR CAUSA:\n");
|
||||||
|
sb.append("- DNI vacío: ").append(dniVacio).append("\n");
|
||||||
|
sb.append("- Proceso vacío: ").append(procesoVacio).append("\n");
|
||||||
|
sb.append("- Proceso inválido: ").append(procesoInvalido).append("\n");
|
||||||
|
sb.append("- Proceso no encontrado: ").append(procesoNoEncontrado).append("\n");
|
||||||
|
sb.append("- Programa inválido: ").append(programaInvalido).append("\n");
|
||||||
|
sb.append("- Programa no encontrado: ").append(programaNoEncontrado).append("\n");
|
||||||
|
sb.append("- Modalidad inválida: ").append(modalidadInvalida).append("\n");
|
||||||
|
sb.append("- Modalidad no encontrada: ").append(modalidadNoEncontrada).append("\n");
|
||||||
|
sb.append("- Inscripción duplicada: ").append(inscripcionDuplicada).append("\n\n");
|
||||||
|
|
||||||
|
sb.append("OMITIDAS POR PROCESO:\n");
|
||||||
|
for (Map.Entry<String, Integer> entry : omitidasPorProceso.entrySet()) {
|
||||||
|
sb.append("- ").append(entry.getKey()).append(": ").append(entry.getValue()).append("\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
sb.append("\nOMITIDAS POR PROGRAMA:\n");
|
||||||
|
for (Map.Entry<String, Integer> entry : omitidasPorPrograma.entrySet()) {
|
||||||
|
sb.append("- ").append(entry.getKey()).append(": ").append(entry.getValue()).append("\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
sb.append("\nOMITIDAS POR MODALIDAD:\n");
|
||||||
|
for (Map.Entry<String, Integer> entry : omitidasPorModalidad.entrySet()) {
|
||||||
|
sb.append("- ").append(entry.getKey()).append(": ").append(entry.getValue()).append("\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
sb.append("\nOMITIDAS POR PROCESO Y MODALIDAD:\n");
|
||||||
|
for (Map.Entry<String, Integer> entry : omitidasPorProcesoModalidad.entrySet()) {
|
||||||
|
sb.append("- ").append(entry.getKey()).append(": ").append(entry.getValue()).append("\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
sb.append("\nRESUMEN DE CAUSAS AGRUPADAS:\n");
|
||||||
|
for (Map.Entry<String, Integer> entry : omitidasPorCausa.entrySet()) {
|
||||||
|
sb.append("- ").append(entry.getKey()).append(": ").append(entry.getValue()).append("\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,5 @@
|
|||||||
|
package com.service.ingresantes.service;
|
||||||
|
|
||||||
|
public class InscripcionService {
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,5 @@
|
|||||||
|
package com.service.ingresantes.service;
|
||||||
|
|
||||||
|
public class PostulanteService {
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,30 @@
|
|||||||
|
package com.service.ingresantes.service;
|
||||||
|
|
||||||
|
import com.service.ingresantes.entity.ResultadoExamen;
|
||||||
|
import com.service.ingresantes.repository.ResultadoExamenRepository;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class ResultadoService {
|
||||||
|
|
||||||
|
private final ResultadoExamenRepository resultadoRepo;
|
||||||
|
|
||||||
|
public ResultadoService(ResultadoExamenRepository resultadoRepo) {
|
||||||
|
this.resultadoRepo = resultadoRepo;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Buscar resultado por DNI, proceso y día
|
||||||
|
public Optional<ResultadoExamen> obtenerResultado(String dni, Long procesoId, Integer dia) {
|
||||||
|
|
||||||
|
return resultadoRepo.findByDniAndProcesoAndDia(dni, procesoId, dia);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ranking por proceso
|
||||||
|
public List<ResultadoExamen> obtenerRanking(Long procesoId) {
|
||||||
|
|
||||||
|
return resultadoRepo.findRankingByProceso(procesoId);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,34 @@
|
|||||||
|
# spring.application.name=ingresantes
|
||||||
|
|
||||||
|
# spring.datasource.url=jdbc:postgresql://localhost:5432/data_admision
|
||||||
|
# spring.datasource.username=postgres
|
||||||
|
# spring.datasource.password=1234
|
||||||
|
# spring.datasource.driver-class-name=org.postgresql.Driver
|
||||||
|
|
||||||
|
|
||||||
|
# spring.jpa.database-platform=org.hibernate.dialect.PostgreSQLDialect
|
||||||
|
# spring.jpa.hibernate.ddl-auto=update
|
||||||
|
|
||||||
|
# spring.jpa.show-sql=true
|
||||||
|
# spring.jpa.properties.hibernate.format_sql=true
|
||||||
|
|
||||||
|
# con docker
|
||||||
|
|
||||||
|
spring.application.name=ingresantes
|
||||||
|
|
||||||
|
spring.datasource.url=${SPRING_DATASOURCE_URL:jdbc:mysql://localhost:3306/data_admision?useSSL=false&serverTimezone=UTC}
|
||||||
|
spring.datasource.username=${SPRING_DATASOURCE_USERNAME:root}
|
||||||
|
spring.datasource.password=${SPRING_DATASOURCE_PASSWORD:}
|
||||||
|
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
|
||||||
|
|
||||||
|
spring.jpa.database-platform=org.hibernate.dialect.MySQLDialect
|
||||||
|
spring.jpa.hibernate.ddl-auto=update
|
||||||
|
spring.jpa.show-sql=true
|
||||||
|
spring.jpa.properties.hibernate.format_sql=true
|
||||||
|
|
||||||
|
# Habilitar subida de archivos
|
||||||
|
spring.servlet.multipart.enabled=true
|
||||||
|
|
||||||
|
# Tamaño máximo de archivo y request
|
||||||
|
spring.servlet.multipart.max-file-size=10MB
|
||||||
|
spring.servlet.multipart.max-request-size=10MB
|
||||||
@ -0,0 +1,13 @@
|
|||||||
|
package com.service.ingresantes;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
|
|
||||||
|
@SpringBootTest
|
||||||
|
class IngresantesApplicationTests {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void contextLoads() {
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue