Compare commits
64 Commits
feat/infer
...
fad797eea4
| Author | SHA1 | Date | |
|---|---|---|---|
| fad797eea4 | |||
| 9ee1ec94c0 | |||
| 670cedda59 | |||
| 3683c193d4 | |||
| a2293ad1ab | |||
| 78fe7f013b | |||
| 22c3b28237 | |||
| 48fa13615e | |||
| 8d7ddc4c33 | |||
| 1f9d6861a0 | |||
| b859a56ab0 | |||
| 84b2149f78 | |||
| 4b04fb64ec | |||
| df0c689243 | |||
| 827f701186 | |||
| db897268de | |||
| 4dc5c196ca | |||
| ea74203667 | |||
| 9421df2b9b | |||
| 2a3bf9852d | |||
| 3f1bb8f082 | |||
| 21ac562fd5 | |||
| 778e87383c | |||
| aac8c91cd0 | |||
| 38c4fbf4e5 | |||
| b8fc314bff | |||
| 4e2e5c0b1d | |||
| fd1ba1ef3b | |||
| 6b65dbdc75 | |||
| 2d2b55efcd | |||
| ac13f36663 | |||
| 82f08c4240 | |||
| e15b35943b | |||
| 8bdccfdce6 | |||
| e209eeb826 | |||
| 3aca011104 | |||
| 2c320194b4 | |||
| 3f6737706a | |||
| 0df7d7c5cf | |||
| 3724528ea9 | |||
| 9885c19b50 | |||
| 079a899822 | |||
| 5b09b2e29a | |||
| 58a73de9ab | |||
| 4cbd2b8d76 | |||
| f4a890bec8 | |||
| 89504e4156 | |||
| 783609b015 | |||
| 5d33190c31 | |||
| 92232e13f1 | |||
| 81b0b55d57 | |||
| 83ef7e36ed | |||
| 0d13e6989f | |||
| 4342df9bf5 | |||
| 8f9585b516 | |||
| 43b5a79031 | |||
| 3ba3b05f2f | |||
| fffc2efd96 | |||
| 82e3250fd4 | |||
| 470f2191b7 | |||
| c127531412 | |||
| 61cfd8240a | |||
| 54b6712273 | |||
| b2141e98c0 |
@@ -1,8 +1,12 @@
|
||||
# 1단계에서 만든 로컬 베이스 이미지를 사용
|
||||
FROM 192.168.2.73:18082/kamco-cd/base-java21-gdal:1.0
|
||||
FROM 192.168.2.73:18082/kamco-cd/base-java21-gdal:1.0
|
||||
# Stage 1: Build stage (gradle build는 Jenkins에서 이미 수행)
|
||||
FROM eclipse-temurin:21-jre-jammy
|
||||
|
||||
# GDAL 설치
|
||||
RUN apt-get update && apt-get install -y \
|
||||
gdal-bin \
|
||||
libgdal-dev \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# 사용자 설정 (앱 별로 다를 수 있으므로 여기에 유지)
|
||||
ARG UID=1000
|
||||
ARG GID=1000
|
||||
|
||||
@@ -19,6 +23,7 @@ COPY build/libs/ROOT.jar app.jar
|
||||
|
||||
# 포트 노출
|
||||
EXPOSE 8080
|
||||
|
||||
# 애플리케이션 실행
|
||||
# dev 프로파일로 실행
|
||||
ENTRYPOINT ["java", "-jar", "-Dspring.profiles.active=prod", "app.jar"]
|
||||
|
||||
23
Dockerfile-prod_bak
Normal file
23
Dockerfile-prod_bak
Normal file
@@ -0,0 +1,23 @@
|
||||
# Stage 1: Build stage (gradle build는 Jenkins에서 이미 수행)
|
||||
FROM kamco-java-gdal:21
|
||||
|
||||
ARG UID=1000
|
||||
ARG GID=1000
|
||||
|
||||
RUN groupadd -g ${GID} kcomu \
|
||||
&& useradd -u ${UID} -g ${GID} -m kcomu
|
||||
|
||||
USER kcomu
|
||||
|
||||
# 작업 디렉토리 설정
|
||||
WORKDIR /app
|
||||
|
||||
# JAR 파일 복사 (Jenkins에서 빌드된 ROOT.jar)
|
||||
COPY build/libs/ROOT.jar app.jar
|
||||
|
||||
# 포트 노출
|
||||
EXPOSE 8080
|
||||
|
||||
# 애플리케이션 실행
|
||||
# dev 프로파일로 실행
|
||||
ENTRYPOINT ["java", "-jar", "-Dspring.profiles.active=prod", "app.jar"]
|
||||
@@ -15,10 +15,6 @@ services:
|
||||
- SPRING_PROFILES_ACTIVE=dev
|
||||
- TZ=Asia/Seoul
|
||||
volumes:
|
||||
- /mnt/nfs_share/images:/app/original-images
|
||||
- /mnt/nfs_share/model_output:/app/model-outputs
|
||||
- /mnt/nfs_share/train_dataset:/app/train-dataset
|
||||
- /mnt/nfs_share/tmp:/app/tmp
|
||||
- /kamco-nfs:/kamco-nfs
|
||||
networks:
|
||||
- kamco-cds
|
||||
|
||||
@@ -1,25 +1,40 @@
|
||||
services:
|
||||
kamco-changedetection-api:
|
||||
nginx:
|
||||
image: nginx:alpine
|
||||
container_name: kamco-cd-api-nginx
|
||||
ports:
|
||||
- "12013:443"
|
||||
volumes:
|
||||
- ./nginx/nginx.conf:/etc/nginx/nginx.conf:ro
|
||||
- ./nginx/conf.d:/etc/nginx/conf.d:ro
|
||||
- /etc/ssl/certs/globalsign:/etc/ssl/certs/globalsign:ro
|
||||
networks:
|
||||
- kamco-cds
|
||||
restart: unless-stopped
|
||||
depends_on:
|
||||
- kamco-cd-api
|
||||
healthcheck:
|
||||
test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://localhost/health"]
|
||||
interval: 10s
|
||||
timeout: 5s
|
||||
retries: 5
|
||||
start_period: 10s
|
||||
|
||||
kamco-cd-api:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile-prod
|
||||
args:
|
||||
UID: 1000 # manager01 UID
|
||||
GID: 1000 # manager01 GID
|
||||
image: kamco-changedetection-api:${IMAGE_TAG:-latest}
|
||||
container_name: kamco-changedetection-api
|
||||
image: kamco-cd-api:${IMAGE_TAG:-latest}
|
||||
container_name: kamco-cd-api
|
||||
user: "1000:1000"
|
||||
ports:
|
||||
- "7100:8080"
|
||||
environment:
|
||||
- SPRING_PROFILES_ACTIVE=dev
|
||||
- SPRING_PROFILES_ACTIVE=prod
|
||||
- TZ=Asia/Seoul
|
||||
volumes:
|
||||
- /mnt/nfs_share/images:/app/original-images
|
||||
- /mnt/nfs_share/model_output:/app/model-outputs
|
||||
- /mnt/nfs_share/train_dataset:/app/train-dataset
|
||||
- /mnt/nfs_share/tmp:/app/tmp
|
||||
- /kamco-nfs:/kamco-nfs
|
||||
- /data:/kamco-nfs
|
||||
networks:
|
||||
- kamco-cds
|
||||
restart: unless-stopped
|
||||
|
||||
122
nginx/README.md
Normal file
122
nginx/README.md
Normal file
@@ -0,0 +1,122 @@
|
||||
# Nginx HTTPS Configuration for KAMCO Change Detection API
|
||||
|
||||
## SSL Certificate Setup
|
||||
|
||||
### Required Files
|
||||
GlobalSign SSL 인증서 파일들을 서버의 `/etc/ssl/certs/globalsign/` 디렉토리에 배치해야 합니다:
|
||||
|
||||
```
|
||||
/etc/ssl/certs/globalsign/
|
||||
├── certificate.crt # SSL 인증서 파일
|
||||
├── private.key # 개인 키 파일
|
||||
└── ca-bundle.crt # CA 번들 파일 (중간 인증서)
|
||||
```
|
||||
|
||||
### Certificate Installation Steps
|
||||
|
||||
1. **디렉토리 생성**
|
||||
```bash
|
||||
sudo mkdir -p /etc/ssl/certs/globalsign
|
||||
sudo chmod 755 /etc/ssl/certs/globalsign
|
||||
```
|
||||
|
||||
2. **인증서 파일 복사**
|
||||
```bash
|
||||
sudo cp your-certificate.crt /etc/ssl/certs/globalsign/certificate.crt
|
||||
sudo cp your-private.key /etc/ssl/certs/globalsign/private.key
|
||||
sudo cp ca-bundle.crt /etc/ssl/certs/globalsign/ca-bundle.crt
|
||||
```
|
||||
|
||||
3. **파일 권한 설정**
|
||||
```bash
|
||||
sudo chmod 644 /etc/ssl/certs/globalsign/certificate.crt
|
||||
sudo chmod 600 /etc/ssl/certs/globalsign/private.key
|
||||
sudo chmod 644 /etc/ssl/certs/globalsign/ca-bundle.crt
|
||||
```
|
||||
|
||||
## Configuration Overview
|
||||
|
||||
### Service Architecture
|
||||
```
|
||||
Internet (HTTPS:12013)
|
||||
↓
|
||||
nginx (443 in container)
|
||||
↓
|
||||
kamco-changedetection-api (8080 in container)
|
||||
```
|
||||
|
||||
### Key Features
|
||||
- **HTTPS/TLS**: TLSv1.2, TLSv1.3 지원
|
||||
- **Port**: 외부 12013 → 내부 443 (nginx)
|
||||
- **Domain**: aicd-api.e-kamco.com:12013
|
||||
- **Reverse Proxy**: kamco-changedetection-api:8080으로 프록시
|
||||
- **Security Headers**: HSTS, X-Frame-Options, X-Content-Type-Options 등
|
||||
- **Health Check**: /health 엔드포인트
|
||||
|
||||
## Deployment
|
||||
|
||||
### Start Services
|
||||
```bash
|
||||
docker-compose -f docker-compose-prod.yml up -d
|
||||
```
|
||||
|
||||
### Check Logs
|
||||
```bash
|
||||
# Nginx logs
|
||||
docker logs kamco-cd-nginx
|
||||
|
||||
# API logs
|
||||
docker logs kamco-changedetection-api
|
||||
```
|
||||
|
||||
### Verify Configuration
|
||||
```bash
|
||||
# Test nginx configuration
|
||||
docker exec kamco-cd-nginx nginx -t
|
||||
|
||||
# Check SSL certificate
|
||||
docker exec kamco-cd-nginx openssl s_client -connect localhost:443 -servername aicd-api.e-kamco.com
|
||||
```
|
||||
|
||||
### Access Service
|
||||
```bash
|
||||
# HTTPS Access
|
||||
curl -k https://aicd-api.e-kamco.com:12013/monitor/health
|
||||
|
||||
# Health Check
|
||||
curl -k https://aicd-api.e-kamco.com:12013/health
|
||||
```
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### Certificate Issues
|
||||
인증서 파일이 제대로 마운트되었는지 확인:
|
||||
```bash
|
||||
docker exec kamco-cd-nginx ls -la /etc/ssl/certs/globalsign/
|
||||
```
|
||||
|
||||
### Nginx Configuration Test
|
||||
```bash
|
||||
docker exec kamco-cd-nginx nginx -t
|
||||
```
|
||||
|
||||
### Connection Test
|
||||
```bash
|
||||
# Check if nginx is listening
|
||||
docker exec kamco-cd-nginx netstat -tlnp | grep 443
|
||||
|
||||
# Check backend connection
|
||||
docker exec kamco-cd-nginx wget --spider http://kamco-changedetection-api:8080/monitor/health
|
||||
```
|
||||
|
||||
## Configuration Files
|
||||
|
||||
- `nginx/nginx.conf`: Main nginx configuration
|
||||
- `nginx/conf.d/default.conf`: Server block with SSL and proxy settings
|
||||
- `docker-compose-prod.yml`: Docker compose with nginx service
|
||||
|
||||
## Notes
|
||||
|
||||
- 인증서 파일명이 다를 경우 `nginx/conf.d/default.conf`에서 경로를 수정하세요
|
||||
- 인증서 갱신 시 nginx 컨테이너를 재시작하세요: `docker restart kamco-cd-nginx`
|
||||
- 포트 12013이 방화벽에서 허용되어 있는지 확인하세요
|
||||
60
nginx/conf.d/default.conf
Normal file
60
nginx/conf.d/default.conf
Normal file
@@ -0,0 +1,60 @@
|
||||
upstream kamco_api {
|
||||
server kamco-cd-api:8080;
|
||||
}
|
||||
|
||||
server {
|
||||
listen 443 ssl http2;
|
||||
server_name aicd-api.e-kamco.com;
|
||||
|
||||
# GlobalSign SSL Certificate
|
||||
ssl_certificate /etc/ssl/certs/globalsign/certificate.crt;
|
||||
ssl_certificate_key /etc/ssl/certs/globalsign/private.key;
|
||||
|
||||
# SSL Configuration
|
||||
ssl_protocols TLSv1.2 TLSv1.3;
|
||||
ssl_ciphers HIGH:!aNULL:!MD5;
|
||||
ssl_prefer_server_ciphers on;
|
||||
ssl_session_cache shared:SSL:10m;
|
||||
ssl_session_timeout 10m;
|
||||
|
||||
# Security Headers
|
||||
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
|
||||
add_header X-Frame-Options "SAMEORIGIN" always;
|
||||
add_header X-Content-Type-Options "nosniff" always;
|
||||
add_header X-XSS-Protection "1; mode=block" always;
|
||||
|
||||
# Client Body Size
|
||||
client_max_body_size 100M;
|
||||
|
||||
# Proxy Settings
|
||||
location / {
|
||||
proxy_pass http://kamco_api;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
proxy_set_header X-Forwarded-Host $host;
|
||||
proxy_set_header X-Forwarded-Port $server_port;
|
||||
|
||||
# Timeouts
|
||||
proxy_connect_timeout 60s;
|
||||
proxy_send_timeout 60s;
|
||||
proxy_read_timeout 60s;
|
||||
|
||||
# WebSocket Support (if needed)
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "upgrade";
|
||||
}
|
||||
|
||||
# Health Check Endpoint
|
||||
location /health {
|
||||
access_log off;
|
||||
return 200 "OK";
|
||||
add_header Content-Type text/plain;
|
||||
}
|
||||
|
||||
# Access and Error Logs
|
||||
access_log /var/log/nginx/kamco-api-access.log;
|
||||
error_log /var/log/nginx/kamco-api-error.log;
|
||||
}
|
||||
33
nginx/nginx.conf
Normal file
33
nginx/nginx.conf
Normal file
@@ -0,0 +1,33 @@
|
||||
user nginx;
|
||||
worker_processes auto;
|
||||
|
||||
error_log /var/log/nginx/error.log warn;
|
||||
pid /var/run/nginx.pid;
|
||||
|
||||
events {
|
||||
worker_connections 1024;
|
||||
}
|
||||
|
||||
http {
|
||||
include /etc/nginx/mime.types;
|
||||
default_type application/octet-stream;
|
||||
|
||||
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
|
||||
'$status $body_bytes_sent "$http_referer" '
|
||||
'"$http_user_agent" "$http_x_forwarded_for"';
|
||||
|
||||
access_log /var/log/nginx/access.log main;
|
||||
|
||||
sendfile on;
|
||||
tcp_nopush on;
|
||||
tcp_nodelay on;
|
||||
keepalive_timeout 65;
|
||||
types_hash_max_size 2048;
|
||||
|
||||
gzip on;
|
||||
gzip_vary on;
|
||||
gzip_min_length 1024;
|
||||
gzip_types text/plain text/css text/xml text/javascript application/x-javascript application/xml+rss application/json;
|
||||
|
||||
include /etc/nginx/conf.d/*.conf;
|
||||
}
|
||||
@@ -18,12 +18,13 @@ import org.springframework.web.filter.OncePerRequestFilter;
|
||||
@RequiredArgsConstructor
|
||||
public class JwtAuthenticationFilter extends OncePerRequestFilter {
|
||||
|
||||
private final JwtTokenProvider jwtTokenProvider;
|
||||
private final UserDetailsService userDetailsService;
|
||||
private static final AntPathMatcher PATH_MATCHER = new AntPathMatcher();
|
||||
private static final String[] EXCLUDE_PATHS = {
|
||||
"/api/auth/signin", "/api/auth/refresh", "/api/auth/logout", "/api/members/*/password"
|
||||
// "/api/auth/signin", "/api/auth/refresh", "/api/auth/logout", "/api/members/*/password"
|
||||
"/api/auth/signin", "/api/auth/refresh", "/api/auth/logout"
|
||||
};
|
||||
private final JwtTokenProvider jwtTokenProvider;
|
||||
private final UserDetailsService userDetailsService;
|
||||
|
||||
@Override
|
||||
protected void doFilterInternal(
|
||||
|
||||
@@ -0,0 +1,92 @@
|
||||
package com.kamco.cd.kamcoback.common.download;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.kamco.cd.kamcoback.common.download.dto.DownloadAuditEvent;
|
||||
import com.kamco.cd.kamcoback.menu.dto.MenuDto;
|
||||
import com.kamco.cd.kamcoback.menu.service.MenuService;
|
||||
import com.kamco.cd.kamcoback.postgres.entity.AuditLogEntity;
|
||||
import com.kamco.cd.kamcoback.postgres.repository.log.AuditLogRepository;
|
||||
import java.util.Comparator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.context.event.EventListener;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.transaction.annotation.Propagation;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
public class DownloadAuditEventListener {
|
||||
|
||||
private final AuditLogRepository auditLogRepository;
|
||||
private final MenuService menuService;
|
||||
private final ObjectMapper objectMapper;
|
||||
|
||||
@Async("auditLogExecutor")
|
||||
@Transactional(propagation = Propagation.REQUIRES_NEW)
|
||||
@EventListener
|
||||
public void onDownloadAudit(DownloadAuditEvent ev) {
|
||||
try {
|
||||
String menuUid = resolveMenuUid(ev.normalizedUri());
|
||||
if (menuUid == null) {
|
||||
// menuUid null 불가 -> 스킵
|
||||
log.warn(
|
||||
"MenuUid not resolved. skip audit. uri={}, normalized={}",
|
||||
ev.requestUri(),
|
||||
ev.normalizedUri());
|
||||
return;
|
||||
}
|
||||
|
||||
AuditLogEntity logEntity =
|
||||
AuditLogEntity.forFileDownload(
|
||||
ev.userId(), ev.requestUri(), menuUid, ev.ip(), ev.status(), ev.downloadUuid());
|
||||
|
||||
auditLogRepository.save(logEntity);
|
||||
|
||||
} catch (Exception e) {
|
||||
// 본 요청과 분리되어야 함
|
||||
log.warn("Download audit save failed. uri={}, err={}", ev.requestUri(), e.toString());
|
||||
}
|
||||
}
|
||||
|
||||
private String resolveMenuUid(String normalizedUri) {
|
||||
try {
|
||||
List<?> list = menuService.getFindAll();
|
||||
|
||||
List<MenuDto.Basic> basics =
|
||||
list.stream()
|
||||
.map(
|
||||
item -> {
|
||||
if (item instanceof LinkedHashMap<?, ?> map) {
|
||||
return objectMapper.convertValue(map, MenuDto.Basic.class);
|
||||
} else if (item instanceof MenuDto.Basic dto) {
|
||||
return dto;
|
||||
}
|
||||
return null;
|
||||
})
|
||||
.filter(Objects::nonNull)
|
||||
.toList();
|
||||
|
||||
MenuDto.Basic basic =
|
||||
basics.stream()
|
||||
.filter(m -> m.getMenuUrl() != null && normalizedUri.startsWith(m.getMenuUrl()))
|
||||
.max(Comparator.comparingInt(m -> m.getMenuUrl().length()))
|
||||
.orElse(null);
|
||||
|
||||
if (basic == null) return null;
|
||||
|
||||
String menuUidStr = basic.getMenuUid(); // ← String
|
||||
if (menuUidStr == null || menuUidStr.isBlank()) return null;
|
||||
|
||||
return menuUidStr; // ← Long 변환
|
||||
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
package com.kamco.cd.kamcoback.common.download;
|
||||
|
||||
import com.kamco.cd.kamcoback.common.download.dto.DownloadSpec;
|
||||
import com.kamco.cd.kamcoback.common.utils.UserUtil;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.nio.file.Files;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.servlet.mvc.method.annotation.StreamingResponseBody;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class DownloadExecutor {
|
||||
|
||||
private final UserUtil userUtil;
|
||||
|
||||
public ResponseEntity<StreamingResponseBody> stream(DownloadSpec spec) throws IOException {
|
||||
|
||||
if (!Files.isReadable(spec.filePath())) {
|
||||
return ResponseEntity.notFound().build();
|
||||
}
|
||||
|
||||
StreamingResponseBody body =
|
||||
os -> {
|
||||
try (InputStream in = Files.newInputStream(spec.filePath())) {
|
||||
in.transferTo(os);
|
||||
os.flush();
|
||||
} catch (Exception e) {
|
||||
// 고용량은 중간 끊김 흔하니까 throw 금지
|
||||
}
|
||||
};
|
||||
|
||||
String fileName =
|
||||
spec.downloadName() != null
|
||||
? spec.downloadName()
|
||||
: spec.filePath().getFileName().toString();
|
||||
|
||||
return ResponseEntity.ok()
|
||||
.contentType(
|
||||
spec.contentType() != null ? spec.contentType() : MediaType.APPLICATION_OCTET_STREAM)
|
||||
.header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"" + fileName + "\"")
|
||||
.body(body);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
package com.kamco.cd.kamcoback.common.download;
|
||||
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.List;
|
||||
import org.springframework.core.io.FileSystemResource;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.core.io.support.ResourceRegion;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpRange;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class RangeDownloadResponder {
|
||||
|
||||
public ResponseEntity<?> buildZipResponse(
|
||||
Path filePath, String downloadFileName, HttpServletRequest request) throws IOException {
|
||||
|
||||
if (!Files.isRegularFile(filePath)) {
|
||||
return ResponseEntity.notFound().build();
|
||||
}
|
||||
|
||||
long totalSize = Files.size(filePath);
|
||||
Resource resource = new FileSystemResource(filePath);
|
||||
|
||||
String disposition = "attachment; filename=\"" + downloadFileName + "\"";
|
||||
String rangeHeader = request.getHeader(HttpHeaders.RANGE);
|
||||
|
||||
// 🔥 공통 헤더 (여기 고정)
|
||||
ResponseEntity.BodyBuilder base =
|
||||
ResponseEntity.ok()
|
||||
.contentType(MediaType.APPLICATION_OCTET_STREAM)
|
||||
.header(HttpHeaders.CONTENT_DISPOSITION, disposition)
|
||||
.header(HttpHeaders.ACCEPT_RANGES, "bytes")
|
||||
.header("X-Accel-Buffering", "no");
|
||||
|
||||
if (rangeHeader == null || rangeHeader.isBlank()) {
|
||||
return base.contentLength(totalSize).body(resource);
|
||||
}
|
||||
|
||||
List<HttpRange> ranges;
|
||||
try {
|
||||
ranges = HttpRange.parseRanges(rangeHeader);
|
||||
} catch (IllegalArgumentException ex) {
|
||||
return ResponseEntity.status(416)
|
||||
.header(HttpHeaders.CONTENT_RANGE, "bytes */" + totalSize)
|
||||
.header("X-Accel-Buffering", "no")
|
||||
.build();
|
||||
}
|
||||
|
||||
HttpRange range = ranges.get(0);
|
||||
|
||||
long start = range.getRangeStart(totalSize);
|
||||
long end = range.getRangeEnd(totalSize);
|
||||
|
||||
if (start >= totalSize) {
|
||||
return ResponseEntity.status(416)
|
||||
.header(HttpHeaders.CONTENT_RANGE, "bytes */" + totalSize)
|
||||
.header("X-Accel-Buffering", "no")
|
||||
.build();
|
||||
}
|
||||
|
||||
long regionLength = end - start + 1;
|
||||
ResourceRegion region = new ResourceRegion(resource, start, regionLength);
|
||||
|
||||
return ResponseEntity.status(206)
|
||||
.contentType(MediaType.APPLICATION_OCTET_STREAM)
|
||||
.header(HttpHeaders.CONTENT_DISPOSITION, disposition)
|
||||
.header(HttpHeaders.ACCEPT_RANGES, "bytes")
|
||||
.header("X-Accel-Buffering", "no")
|
||||
.header(HttpHeaders.CONTENT_RANGE, "bytes " + start + "-" + end + "/" + totalSize)
|
||||
.contentLength(regionLength)
|
||||
.body(region);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.kamco.cd.kamcoback.common.download.dto;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public record DownloadAuditEvent(
|
||||
Long userId,
|
||||
String requestUri,
|
||||
String normalizedUri,
|
||||
String ip,
|
||||
int status,
|
||||
UUID downloadUuid) {}
|
||||
@@ -1,12 +0,0 @@
|
||||
package com.kamco.cd.kamcoback.common.download.dto;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.util.UUID;
|
||||
import org.springframework.http.MediaType;
|
||||
|
||||
public record DownloadSpec(
|
||||
UUID uuid, // 다운로드 식별(로그/정책용)
|
||||
Path filePath, // 실제 파일 경로
|
||||
String downloadName, // 사용자에게 보일 파일명
|
||||
MediaType contentType // 보통 OCTET_STREAM
|
||||
) {}
|
||||
@@ -27,4 +27,10 @@ public class CustomApiException extends RuntimeException {
|
||||
this.codeName = errorCode.getCode();
|
||||
this.status = errorCode.getStatus();
|
||||
}
|
||||
|
||||
public CustomApiException(String codeName, HttpStatus status, Throwable cause) {
|
||||
super(codeName, cause);
|
||||
this.codeName = codeName;
|
||||
this.status = status;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,11 +7,14 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Log4j2
|
||||
@Component
|
||||
public class ExternalJarRunner {
|
||||
@Value("${spring.profiles.active}")
|
||||
private String profile;
|
||||
|
||||
private static final long TIMEOUT_MINUTES = TimeUnit.DAYS.toMinutes(3);
|
||||
|
||||
@@ -40,7 +43,7 @@ public class ExternalJarRunner {
|
||||
if (mode != null && !mode.isEmpty()) {
|
||||
addArg(args, "converter.mode", mode);
|
||||
}
|
||||
|
||||
addArg(args, "spring.profiles.active", profile);
|
||||
execJar(jarPath, args);
|
||||
}
|
||||
|
||||
@@ -57,6 +60,7 @@ public class ExternalJarRunner {
|
||||
addArg(args, "upload-shp", register);
|
||||
// addArg(args, "layer", layer);
|
||||
|
||||
addArg(args, "spring.profiles.active", profile);
|
||||
execJar(jarPath, args);
|
||||
}
|
||||
|
||||
|
||||
@@ -300,10 +300,12 @@ public class FIleChecker {
|
||||
String parentPath = path.getParent().toString();
|
||||
String fullPath = path.toAbsolutePath().toString();
|
||||
|
||||
boolean isValid =
|
||||
!NameValidator.containsKorean(folderNm)
|
||||
&& !NameValidator.containsWhitespaceRegex(folderNm)
|
||||
&& !parentFolderNm.equals("kamco-nfs");
|
||||
boolean isShowHide =
|
||||
!parentFolderNm.equals("kamco-nfs"); // 폴더 리스트에 kamco-nfs 하위만 나오도록 처리
|
||||
// boolean isValid =
|
||||
// !NameValidator.containsKorean(folderNm)
|
||||
// && !NameValidator.containsWhitespaceRegex(folderNm)
|
||||
// && !parentFolderNm.equals("kamco-nfs");
|
||||
|
||||
File file = new File(fullPath);
|
||||
int childCnt = getChildFolderCount(file);
|
||||
@@ -317,7 +319,7 @@ public class FIleChecker {
|
||||
depth,
|
||||
childCnt,
|
||||
lastModified,
|
||||
isValid);
|
||||
isShowHide);
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
|
||||
|
||||
@@ -1,98 +1,64 @@
|
||||
package com.kamco.cd.kamcoback.config;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.kamco.cd.kamcoback.common.utils.HeaderUtil;
|
||||
import com.kamco.cd.kamcoback.common.download.dto.DownloadAuditEvent;
|
||||
import com.kamco.cd.kamcoback.common.utils.UserUtil;
|
||||
import com.kamco.cd.kamcoback.config.api.ApiLogFunction;
|
||||
import com.kamco.cd.kamcoback.menu.dto.MenuDto;
|
||||
import com.kamco.cd.kamcoback.menu.service.MenuService;
|
||||
import com.kamco.cd.kamcoback.postgres.entity.AuditLogEntity;
|
||||
import com.kamco.cd.kamcoback.postgres.repository.log.AuditLogRepository;
|
||||
import jakarta.servlet.DispatcherType;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import java.util.Comparator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.ApplicationEventPublisher;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.servlet.HandlerInterceptor;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
public class FileDownloadInteceptor implements HandlerInterceptor {
|
||||
|
||||
private final AuditLogRepository auditLogRepository;
|
||||
private final MenuService menuService;
|
||||
private final ApplicationEventPublisher publisher;
|
||||
private final UserUtil userUtil;
|
||||
|
||||
@Autowired private ObjectMapper objectMapper;
|
||||
|
||||
public FileDownloadInteceptor(
|
||||
AuditLogRepository auditLogRepository, MenuService menuService, UserUtil userUtil) {
|
||||
this.auditLogRepository = auditLogRepository;
|
||||
this.menuService = menuService;
|
||||
this.userUtil = userUtil;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean preHandle(
|
||||
HttpServletRequest request, HttpServletResponse response, Object handler) {
|
||||
public void afterCompletion(
|
||||
HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) {
|
||||
|
||||
if (!request.getRequestURI().contains("/download")) return true;
|
||||
String uri = request.getRequestURI();
|
||||
if (uri == null || !uri.contains("/download")) return;
|
||||
if (request.getDispatcherType() != DispatcherType.REQUEST) return;
|
||||
|
||||
if (request.getDispatcherType() != jakarta.servlet.DispatcherType.REQUEST) {
|
||||
return true;
|
||||
}
|
||||
|
||||
saveLog(request, response);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void saveLog(HttpServletRequest request, HttpServletResponse response) {
|
||||
// 파일 다운로드 API만 필터링
|
||||
if (!request.getRequestURI().contains("/download")) {
|
||||
Long userId;
|
||||
try {
|
||||
userId = userUtil.getId();
|
||||
if (userId == null) return; // userId null 불가면 스킵
|
||||
} catch (Exception e) {
|
||||
log.warn("Download audit userId resolve failed. uri={}, err={}", uri, e.toString());
|
||||
return;
|
||||
}
|
||||
|
||||
Long userId = userUtil.getId();
|
||||
String ip = ApiLogFunction.getClientIp(request);
|
||||
int status = response.getStatus();
|
||||
String normalizedUri = uri.replace("/api", "");
|
||||
|
||||
List<?> list = menuService.getFindAll();
|
||||
List<MenuDto.Basic> result =
|
||||
list.stream()
|
||||
.map(
|
||||
item -> {
|
||||
if (item instanceof LinkedHashMap<?, ?> map) {
|
||||
return objectMapper.convertValue(map, MenuDto.Basic.class);
|
||||
} else if (item instanceof MenuDto.Basic dto) {
|
||||
return dto;
|
||||
} else {
|
||||
throw new IllegalStateException("Unsupported cache type: " + item.getClass());
|
||||
}
|
||||
})
|
||||
.toList();
|
||||
UUID downloadUuid = extractUuidFromUri(uri);
|
||||
if (downloadUuid == null) {
|
||||
log.warn("Download UUID parse failed. uri={}", uri);
|
||||
return; // downloadUuid null 불가 -> 스킵
|
||||
}
|
||||
|
||||
String normalizedUri = request.getRequestURI().replace("/api", "");
|
||||
MenuDto.Basic basic =
|
||||
result.stream()
|
||||
.filter(
|
||||
menu -> menu.getMenuUrl() != null && normalizedUri.startsWith(menu.getMenuUrl()))
|
||||
.max(Comparator.comparingInt(m -> m.getMenuUrl().length()))
|
||||
.orElse(null);
|
||||
publisher.publishEvent(
|
||||
new DownloadAuditEvent(userId, uri, normalizedUri, ip, status, downloadUuid));
|
||||
}
|
||||
|
||||
AuditLogEntity log =
|
||||
AuditLogEntity.forFileDownload(
|
||||
userId,
|
||||
request.getRequestURI(),
|
||||
Objects.requireNonNull(basic).getMenuUid(),
|
||||
ip,
|
||||
response.getStatus(),
|
||||
UUID.fromString(HeaderUtil.get(request, "kamco-download-uuid")));
|
||||
|
||||
auditLogRepository.save(log);
|
||||
private UUID extractUuidFromUri(String uri) {
|
||||
try {
|
||||
String[] parts = uri.split("/");
|
||||
String last = parts[parts.length - 1];
|
||||
return UUID.fromString(last);
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -95,9 +95,9 @@ public class SecurityConfig {
|
||||
"/api/auth/refresh",
|
||||
"/api/auth/logout",
|
||||
"/swagger-ui/**",
|
||||
"/api/members/*/password",
|
||||
"/v3/api-docs/**",
|
||||
"/chunk_upload_test.html",
|
||||
"/download_progress_test.html",
|
||||
"/api/model/file-chunk-upload",
|
||||
"/api/upload/file-chunk-upload",
|
||||
"/api/upload/chunk-upload-complete",
|
||||
@@ -112,6 +112,7 @@ public class SecurityConfig {
|
||||
"/api/user/**",
|
||||
"/api/my/menus",
|
||||
"/api/common-code/**",
|
||||
"/api/members/*/password",
|
||||
"/api/training-data/label/**",
|
||||
"/api/training-data/review/**")
|
||||
.authenticated()
|
||||
|
||||
@@ -128,7 +128,7 @@ public class GukYuinApiController {
|
||||
})
|
||||
public ApiResponseDto<ChngDetectMastDto.ResultDto> selectChangeDetectionDtctIdList(
|
||||
@RequestParam(required = false) String chnDtctId) {
|
||||
return ApiResponseDto.ok(gukYuinApiService.listChnDtctId(chnDtctId));
|
||||
return ApiResponseDto.ok(gukYuinApiService.listChnDtctId(chnDtctId, ""));
|
||||
}
|
||||
|
||||
@Operation(summary = "탐지결과 등록목록 조회(1건 조회)", description = "탐지결과 등록목록 조회")
|
||||
@@ -192,7 +192,7 @@ public class GukYuinApiController {
|
||||
@PathVariable String chnDtctId,
|
||||
@RequestParam(defaultValue = "0") Integer pageIndex,
|
||||
@RequestParam(defaultValue = "10") Integer pageSize) {
|
||||
return ApiResponseDto.ok(gukYuinApiService.findChnContList(chnDtctId, pageIndex, pageSize));
|
||||
return ApiResponseDto.ok(gukYuinApiService.findChnContList(chnDtctId, pageIndex, pageSize, ""));
|
||||
}
|
||||
|
||||
@Operation(summary = "탐지객체 조회 (탐지객체 1건 조회)", description = "탐지객체 조회 (탐지객체 1건 조회)")
|
||||
@@ -272,7 +272,8 @@ public class GukYuinApiController {
|
||||
@PostMapping("/rlb/objt/{chnDtctObjtId}/lbl/{lblYn}")
|
||||
public ApiResponseDto<ChngDetectContDto.ResultLabelDto> updateChnDtctObjtLabelingYn(
|
||||
@PathVariable String chnDtctObjtId, @PathVariable String lblYn) {
|
||||
return ApiResponseDto.ok(gukYuinApiService.updateChnDtctObjtLabelingYn(chnDtctObjtId, lblYn));
|
||||
return ApiResponseDto.ok(
|
||||
gukYuinApiService.updateChnDtctObjtLabelingYn(chnDtctObjtId, lblYn, ""));
|
||||
}
|
||||
|
||||
@Operation(summary = "국유in연동 등록", description = "국유in연동 등록")
|
||||
@@ -309,7 +310,7 @@ public class GukYuinApiController {
|
||||
@PathVariable String chnDtctId,
|
||||
@Parameter(description = "날짜(기본은 어제 날짜)") @RequestParam(defaultValue = "20260205")
|
||||
String yyyymmdd) {
|
||||
return ApiResponseDto.ok(gukYuinApiService.findRlbDtctList(chnDtctId, yyyymmdd));
|
||||
return ApiResponseDto.ok(gukYuinApiService.findRlbDtctList(chnDtctId, yyyymmdd, ""));
|
||||
}
|
||||
|
||||
@Operation(summary = "탐지객체 적합여부 조회 (객체별 조회)", description = "탐지객체 적합여부 조회 (객체별 조회)")
|
||||
|
||||
@@ -259,7 +259,8 @@ public class GukYuinApiService {
|
||||
}
|
||||
|
||||
// 탐지객체 리스트 조회
|
||||
public ResultContDto findChnContList(String chnDtctId, Integer pageIndex, Integer pageSize) {
|
||||
public ResultContDto findChnContList(
|
||||
String chnDtctId, Integer pageIndex, Integer pageSize, String batchYn) {
|
||||
|
||||
String url =
|
||||
gukyuinCdiUrl
|
||||
@@ -272,7 +273,7 @@ public class GukYuinApiService {
|
||||
+ "&reqIp="
|
||||
+ myip
|
||||
+ "&reqEpno="
|
||||
+ userUtil.getEmployeeNo();
|
||||
+ ("Y".equals(batchYn) ? "BATCH" : userUtil.getEmployeeNo());
|
||||
|
||||
ExternalCallResult<ChngDetectContDto.ResultContDto> result =
|
||||
externalHttpClient.call(
|
||||
@@ -334,12 +335,12 @@ public class GukYuinApiService {
|
||||
}
|
||||
|
||||
public ChngDetectContDto.ResultLabelDto updateChnDtctObjtLabelingYn(
|
||||
String chnDtctObjtId, String lblYn) {
|
||||
String chnDtctObjtId, String lblYn, String batchYn) {
|
||||
String url = gukyuinCdiUrl + "/rlb/objt/" + chnDtctObjtId + "/lbl/" + lblYn;
|
||||
|
||||
ReqInfo info = new ReqInfo();
|
||||
info.setReqIp(myip);
|
||||
info.setReqEpno(userUtil.getEmployeeNo());
|
||||
info.setReqEpno("Y".equals(batchYn) ? "BATCH" : userUtil.getEmployeeNo());
|
||||
|
||||
ExternalCallResult<ChngDetectContDto.ResultLabelDto> result =
|
||||
externalHttpClient.call(
|
||||
@@ -391,7 +392,7 @@ public class GukYuinApiService {
|
||||
return result.body();
|
||||
}
|
||||
|
||||
public ResultDto listChnDtctId(String chnDtctId) {
|
||||
public ResultDto listChnDtctId(String chnDtctId, String batchYn) {
|
||||
String url =
|
||||
gukyuinCdiUrl
|
||||
+ "/chn/mast/"
|
||||
@@ -399,7 +400,7 @@ public class GukYuinApiService {
|
||||
+ "?reqIp="
|
||||
+ myip
|
||||
+ "&reqEpno="
|
||||
+ userUtil.getEmployeeNo();
|
||||
+ ("Y".equals(batchYn) ? "BATCH" : userUtil.getEmployeeNo());
|
||||
|
||||
ExternalCallResult<ChngDetectMastDto.ResultDto> result =
|
||||
externalHttpClient.call(
|
||||
@@ -528,7 +529,8 @@ public class GukYuinApiService {
|
||||
return result.body();
|
||||
}
|
||||
|
||||
public ChngDetectMastDto.RlbDtctDto findRlbDtctList(String chnDtctId, String yyyymmdd) {
|
||||
public ChngDetectMastDto.RlbDtctDto findRlbDtctList(
|
||||
String chnDtctId, String yyyymmdd, String batchYn) {
|
||||
|
||||
String url =
|
||||
gukyuinCdiUrl
|
||||
@@ -537,7 +539,7 @@ public class GukYuinApiService {
|
||||
+ "?reqIp="
|
||||
+ myip
|
||||
+ "&reqEpno="
|
||||
+ userUtil.getEmployeeNo()
|
||||
+ ("Y".equals(batchYn) ? "BATCH" : userUtil.getEmployeeNo())
|
||||
+ "&yyyymmdd="
|
||||
+ yyyymmdd;
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.kamco.cd.kamcoback.inference;
|
||||
|
||||
import com.kamco.cd.kamcoback.common.download.DownloadExecutor;
|
||||
import com.kamco.cd.kamcoback.common.download.dto.DownloadSpec;
|
||||
import com.kamco.cd.kamcoback.common.download.RangeDownloadResponder;
|
||||
import com.kamco.cd.kamcoback.common.exception.CustomApiException;
|
||||
import com.kamco.cd.kamcoback.config.api.ApiResponseDto;
|
||||
import com.kamco.cd.kamcoback.inference.dto.InferenceDetailDto;
|
||||
@@ -26,6 +25,7 @@ import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import io.swagger.v3.oas.annotations.responses.ApiResponse;
|
||||
import io.swagger.v3.oas.annotations.responses.ApiResponses;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.validation.Valid;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Path;
|
||||
@@ -34,8 +34,8 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
@@ -45,9 +45,9 @@ import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.servlet.mvc.method.annotation.StreamingResponseBody;
|
||||
|
||||
@Tag(name = "추론관리", description = "추론관리 API")
|
||||
@Log4j2
|
||||
@RequestMapping("/api/inference")
|
||||
@RequiredArgsConstructor
|
||||
@RestController
|
||||
@@ -56,7 +56,7 @@ public class InferenceResultApiController {
|
||||
private final InferenceResultService inferenceResultService;
|
||||
private final MapSheetMngService mapSheetMngService;
|
||||
private final ModelMngService modelMngService;
|
||||
private final DownloadExecutor downloadExecutor;
|
||||
private final RangeDownloadResponder rangeDownloadResponder;
|
||||
|
||||
@Operation(summary = "추론관리 목록", description = "어드민 홈 > 추론관리 > 추론관리 > 추론관리 목록")
|
||||
@ApiResponses(
|
||||
@@ -195,7 +195,7 @@ public class InferenceResultApiController {
|
||||
LocalDate endDttm,
|
||||
@Parameter(description = "키워드 (모델버전)", example = "M1.H1.E28") @RequestParam(required = false)
|
||||
String searchVal,
|
||||
@Parameter(description = "타입", example = "M1") @RequestParam(required = false)
|
||||
@Parameter(description = "타입", example = "G1") @RequestParam(required = false)
|
||||
String modelType,
|
||||
@RequestParam(defaultValue = "0") int page,
|
||||
@RequestParam(defaultValue = "20") int size) {
|
||||
@@ -356,9 +356,8 @@ public class InferenceResultApiController {
|
||||
@ApiResponse(responseCode = "404", description = "파일 없음", content = @Content),
|
||||
@ApiResponse(responseCode = "500", description = "서버 오류", content = @Content)
|
||||
})
|
||||
@GetMapping(value = "/download/{uuid}")
|
||||
public ResponseEntity<StreamingResponseBody> download(
|
||||
@Parameter(example = "69c4e56c-e0bf-4742-9225-bba9aae39052") @PathVariable UUID uuid)
|
||||
@GetMapping("/download/{uuid}")
|
||||
public ResponseEntity<?> download(@PathVariable UUID uuid, HttpServletRequest request)
|
||||
throws IOException {
|
||||
|
||||
String path;
|
||||
@@ -374,8 +373,8 @@ public class InferenceResultApiController {
|
||||
|
||||
Path zipPath = Path.of(path);
|
||||
|
||||
return downloadExecutor.stream(
|
||||
new DownloadSpec(uuid, zipPath, uid + ".zip", MediaType.APPLICATION_OCTET_STREAM));
|
||||
// Range + 200/206/416 공통 처리 (추가 헤더 포함)
|
||||
return rangeDownloadResponder.buildZipResponse(zipPath, uid + ".zip", request);
|
||||
}
|
||||
|
||||
@Operation(summary = "shp 파일 다운로드 이력 조회", description = "추론관리 분석결과 shp 파일 다운로드 이력 조회")
|
||||
@@ -415,7 +414,7 @@ public class InferenceResultApiController {
|
||||
downloadReq.setStartDate(strtDttm);
|
||||
downloadReq.setEndDate(endDttm);
|
||||
downloadReq.setSearchValue(searchValue);
|
||||
downloadReq.setRequestUri("/api/inference/download-audit/download/" + uuid);
|
||||
downloadReq.setRequestUri("/api/inference/download/" + uuid);
|
||||
|
||||
return ApiResponseDto.ok(inferenceResultService.getDownloadAudit(searchReq, downloadReq));
|
||||
}
|
||||
|
||||
@@ -246,15 +246,15 @@ public class InferenceResultDto {
|
||||
@NotBlank
|
||||
private String title;
|
||||
|
||||
@Schema(description = "M1", example = "b40e0f68-c1d8-49fc-93f9-a36270093861")
|
||||
@Schema(description = "G1", example = "b40e0f68-c1d8-49fc-93f9-a36270093861")
|
||||
@NotNull
|
||||
private UUID model1Uuid;
|
||||
|
||||
@Schema(description = "M2", example = "ec92b7d2-b5a3-4915-9bdf-35fb3ca8ad27")
|
||||
@Schema(description = "G2", example = "ec92b7d2-b5a3-4915-9bdf-35fb3ca8ad27")
|
||||
@NotNull
|
||||
private UUID model2Uuid;
|
||||
|
||||
@Schema(description = "M3", example = "37f45782-8ccf-4cf6-911c-a055a1510d39")
|
||||
@Schema(description = "G3", example = "37f45782-8ccf-4cf6-911c-a055a1510d39")
|
||||
@NotNull
|
||||
private UUID model3Uuid;
|
||||
|
||||
@@ -297,6 +297,30 @@ public class InferenceResultDto {
|
||||
@Schema(name = "InferenceStatusDetailDto", description = "추론(변화탐지) 진행상태")
|
||||
public static class InferenceStatusDetailDto {
|
||||
|
||||
@Schema(description = "모델1 사용시간 시작일시")
|
||||
@JsonFormatDttm
|
||||
ZonedDateTime m1ModelStartDttm;
|
||||
|
||||
@Schema(description = "모델2 사용시간 시작일시")
|
||||
@JsonFormatDttm
|
||||
ZonedDateTime m2ModelStartDttm;
|
||||
|
||||
@Schema(description = "모델3 사용시간 시작일시")
|
||||
@JsonFormatDttm
|
||||
ZonedDateTime m3ModelStartDttm;
|
||||
|
||||
@Schema(description = "모델1 사용시간 종료일시")
|
||||
@JsonFormatDttm
|
||||
ZonedDateTime m1ModelEndDttm;
|
||||
|
||||
@Schema(description = "모델2 사용시간 종료일시")
|
||||
@JsonFormatDttm
|
||||
ZonedDateTime m2ModelEndDttm;
|
||||
|
||||
@Schema(description = "모델3 사용시간 종료일시")
|
||||
@JsonFormatDttm
|
||||
ZonedDateTime m3ModelEndDttm;
|
||||
|
||||
@Schema(description = "탐지대상 도엽수")
|
||||
private Long detectingCnt;
|
||||
|
||||
@@ -336,30 +360,6 @@ public class InferenceResultDto {
|
||||
@Schema(description = "모델3 분석 실패")
|
||||
private Integer m3FailedJobs;
|
||||
|
||||
@Schema(description = "모델1 사용시간 시작일시")
|
||||
@JsonFormatDttm
|
||||
ZonedDateTime m1ModelStartDttm;
|
||||
|
||||
@Schema(description = "모델2 사용시간 시작일시")
|
||||
@JsonFormatDttm
|
||||
ZonedDateTime m2ModelStartDttm;
|
||||
|
||||
@Schema(description = "모델3 사용시간 시작일시")
|
||||
@JsonFormatDttm
|
||||
ZonedDateTime m3ModelStartDttm;
|
||||
|
||||
@Schema(description = "모델1 사용시간 종료일시")
|
||||
@JsonFormatDttm
|
||||
ZonedDateTime m1ModelEndDttm;
|
||||
|
||||
@Schema(description = "모델2 사용시간 종료일시")
|
||||
@JsonFormatDttm
|
||||
ZonedDateTime m2ModelEndDttm;
|
||||
|
||||
@Schema(description = "모델3 사용시간 종료일시")
|
||||
@JsonFormatDttm
|
||||
ZonedDateTime m3ModelEndDttm;
|
||||
|
||||
@Schema(description = "변화탐지 제목")
|
||||
private String title;
|
||||
|
||||
@@ -496,19 +496,19 @@ public class InferenceResultDto {
|
||||
return MapSheetScope.getDescByCode(this.mapSheetScope);
|
||||
}
|
||||
|
||||
@Schema(description = "M1 사용시간")
|
||||
@Schema(description = "G1 사용시간")
|
||||
@JsonProperty("m1ElapsedTim")
|
||||
public String getM1ElapsedTime() {
|
||||
return formatElapsedTime(this.m1ModelStartDttm, this.m1ModelEndDttm);
|
||||
}
|
||||
|
||||
@Schema(description = "M2 사용시간")
|
||||
@Schema(description = "G2 사용시간")
|
||||
@JsonProperty("m2ElapsedTim")
|
||||
public String getM2ElapsedTime() {
|
||||
return formatElapsedTime(this.m2ModelStartDttm, this.m2ModelEndDttm);
|
||||
}
|
||||
|
||||
@Schema(description = "M3 사용시간")
|
||||
@Schema(description = "G3 사용시간")
|
||||
@JsonProperty("m3ElapsedTim")
|
||||
public String getM3ElapsedTime() {
|
||||
return formatElapsedTime(this.m3ModelStartDttm, this.m3ModelEndDttm);
|
||||
|
||||
@@ -248,7 +248,7 @@ public class InferenceResultService {
|
||||
saveInferenceAiDto.setUuid(uuid);
|
||||
saveInferenceAiDto.setBatchId(batchId);
|
||||
saveInferenceAiDto.setStatus(Status.IN_PROGRESS.getId());
|
||||
saveInferenceAiDto.setType("M1");
|
||||
saveInferenceAiDto.setType(ModelType.G1.getId());
|
||||
saveInferenceAiDto.setInferStartDttm(ZonedDateTime.now());
|
||||
saveInferenceAiDto.setModelComparePath(modelComparePath.getFilePath());
|
||||
saveInferenceAiDto.setModelTargetPath(modelTargetPath.getFilePath());
|
||||
@@ -414,12 +414,12 @@ public class InferenceResultService {
|
||||
|
||||
String modelType = "";
|
||||
|
||||
if (modelInfo.getModelType().equals(ModelType.M1.getId())) {
|
||||
modelType = "G1";
|
||||
} else if (modelInfo.getModelType().equals(ModelType.M2.getId())) {
|
||||
modelType = "G2";
|
||||
if (modelInfo.getModelType().equals(ModelType.G1.getId())) {
|
||||
modelType = ModelType.G1.getId();
|
||||
} else if (modelInfo.getModelType().equals(ModelType.G2.getId())) {
|
||||
modelType = ModelType.G2.getId();
|
||||
} else {
|
||||
modelType = "G3";
|
||||
modelType = ModelType.G3.getId();
|
||||
}
|
||||
|
||||
InferenceSendDto sendDto = new InferenceSendDto();
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.kamco.cd.kamcoback.label;
|
||||
|
||||
import com.kamco.cd.kamcoback.common.download.DownloadExecutor;
|
||||
import com.kamco.cd.kamcoback.common.download.dto.DownloadSpec;
|
||||
import com.kamco.cd.kamcoback.common.download.RangeDownloadResponder;
|
||||
import com.kamco.cd.kamcoback.config.api.ApiResponseDto;
|
||||
import com.kamco.cd.kamcoback.label.dto.LabelAllocateDto;
|
||||
import com.kamco.cd.kamcoback.label.dto.LabelAllocateDto.InferenceDetail;
|
||||
@@ -23,10 +22,13 @@ import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import io.swagger.v3.oas.annotations.responses.ApiResponse;
|
||||
import io.swagger.v3.oas.annotations.responses.ApiResponses;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.validation.Valid;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@@ -34,7 +36,6 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.coyote.BadRequestException;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
@@ -43,7 +44,6 @@ import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.servlet.mvc.method.annotation.StreamingResponseBody;
|
||||
|
||||
@Slf4j
|
||||
@Tag(name = "라벨링 작업 관리", description = "라벨링 작업 배정 및 통계 조회 API")
|
||||
@@ -53,7 +53,7 @@ import org.springframework.web.servlet.mvc.method.annotation.StreamingResponseBo
|
||||
public class LabelAllocateApiController {
|
||||
|
||||
private final LabelAllocateService labelAllocateService;
|
||||
private final DownloadExecutor downloadExecutor;
|
||||
private final RangeDownloadResponder rangeDownloadResponder;
|
||||
|
||||
@Value("${file.dataset-response}")
|
||||
private String responsePath;
|
||||
@@ -382,19 +382,17 @@ public class LabelAllocateApiController {
|
||||
@ApiResponse(responseCode = "500", description = "서버 오류", content = @Content)
|
||||
})
|
||||
@GetMapping("/download/{uuid}")
|
||||
public ResponseEntity<StreamingResponseBody> download(
|
||||
@Parameter(example = "6d8d49dc-0c9d-4124-adc7-b9ca610cc394") @PathVariable UUID uuid)
|
||||
public ResponseEntity<?> download(@PathVariable UUID uuid, HttpServletRequest request)
|
||||
throws IOException {
|
||||
|
||||
if (!labelAllocateService.isDownloadable(uuid)) {
|
||||
throw new BadRequestException();
|
||||
}
|
||||
|
||||
String uid = labelAllocateService.findLearnUid(uuid);
|
||||
Path zipPath = Paths.get(responsePath).resolve(uid + ".zip");
|
||||
|
||||
return downloadExecutor.stream(
|
||||
new DownloadSpec(uuid, zipPath, uid + ".zip", MediaType.APPLICATION_OCTET_STREAM));
|
||||
if (!Files.isRegularFile(zipPath)) {
|
||||
throw new BadRequestException();
|
||||
}
|
||||
|
||||
return rangeDownloadResponder.buildZipResponse(zipPath, uid + ".zip", request);
|
||||
}
|
||||
|
||||
@Operation(summary = "라벨 파일 다운로드 이력 조회", description = "라벨 파일 다운로드 이력 조회")
|
||||
@@ -461,4 +459,43 @@ public class LabelAllocateApiController {
|
||||
UUID uuid) {
|
||||
return ApiResponseDto.ok(labelAllocateService.isDownloadable(uuid));
|
||||
}
|
||||
|
||||
@Operation(
|
||||
summary = "라벨링작업 관리 > 추가 작업 배정(실태조사 추가되면)",
|
||||
description = "라벨링작업 관리 > 추가 작업 배정(실태조사 추가되면)")
|
||||
@ApiResponses(
|
||||
value = {
|
||||
@ApiResponse(
|
||||
responseCode = "201",
|
||||
description = "등록 성공",
|
||||
content =
|
||||
@Content(
|
||||
mediaType = "application/json",
|
||||
schema = @Schema(implementation = Long.class))),
|
||||
@ApiResponse(responseCode = "400", description = "잘못된 요청 데이터", content = @Content),
|
||||
@ApiResponse(responseCode = "404", description = "코드를 찾을 수 없음", content = @Content),
|
||||
@ApiResponse(responseCode = "500", description = "서버 오류", content = @Content)
|
||||
})
|
||||
@PostMapping("/allocate-add-stblt")
|
||||
public ApiResponseDto<ApiResponseDto.ResponseObj> labelAllocateAddStblt(
|
||||
@RequestBody @Valid LabelAllocateDto.AllocateAddStbltDto dto) {
|
||||
|
||||
return ApiResponseDto.okObject(
|
||||
labelAllocateService.allocateAddStbltYn(
|
||||
dto.getTotalCnt(), dto.getUuid(), dto.getLabelers(), dto.getBaseDate()));
|
||||
}
|
||||
|
||||
@Operation(summary = "라벨링 추가 할당 가능한 건수", description = "라벨링 추가 할당 가능한 건수 API")
|
||||
@ApiResponses(
|
||||
value = {
|
||||
@ApiResponse(responseCode = "200", description = "조회 성공"),
|
||||
@ApiResponse(responseCode = "404", description = "코드를 찾을 수 없음"),
|
||||
@ApiResponse(responseCode = "500", description = "서버 오류")
|
||||
})
|
||||
@GetMapping("/allocate-add-cnt")
|
||||
public ApiResponseDto<Long> allocateAddCnt(
|
||||
@RequestParam UUID uuid, @RequestParam LocalDate baseDate) {
|
||||
|
||||
return ApiResponseDto.ok(labelAllocateService.findAllocateAddCnt(uuid, baseDate));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.kamco.cd.kamcoback.label.dto;
|
||||
import com.kamco.cd.kamcoback.common.utils.enums.CodeExpose;
|
||||
import com.kamco.cd.kamcoback.common.utils.enums.EnumType;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import java.time.LocalDate;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
@@ -365,9 +366,35 @@ public class LabelAllocateDto {
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public static class InferenceLearnDto {
|
||||
|
||||
private UUID analUuid;
|
||||
private String learnUid;
|
||||
private String analState;
|
||||
private Long analId;
|
||||
}
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
public static class AllocateAddStbltDto {
|
||||
|
||||
@Schema(description = "총 잔여 건수", example = "179")
|
||||
private Integer totalCnt;
|
||||
|
||||
@Schema(
|
||||
description = "추가할당할 라벨러",
|
||||
example =
|
||||
"""
|
||||
[
|
||||
"123454", "654321", "222233", "777222"
|
||||
]
|
||||
""")
|
||||
private List<String> labelers;
|
||||
|
||||
@Schema(description = "회차 마스터 key", example = "c0e77cc7-8c28-46ba-9ca4-11e90246ab44")
|
||||
private UUID uuid;
|
||||
|
||||
@Schema(description = "기준일자", example = "2026-02-20")
|
||||
private LocalDate baseDate;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ import com.kamco.cd.kamcoback.log.dto.AuditLogDto;
|
||||
import com.kamco.cd.kamcoback.log.dto.AuditLogDto.DownloadReq;
|
||||
import com.kamco.cd.kamcoback.postgres.core.AuditLogCoreService;
|
||||
import com.kamco.cd.kamcoback.postgres.core.LabelAllocateCoreService;
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
@@ -27,11 +28,12 @@ import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Propagation;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
@Transactional
|
||||
@Transactional(readOnly = true)
|
||||
@RequiredArgsConstructor
|
||||
public class LabelAllocateService {
|
||||
|
||||
@@ -276,6 +278,7 @@ public class LabelAllocateService {
|
||||
return labelAllocateCoreService.findLabelingIngProcessCnt();
|
||||
}
|
||||
|
||||
@Transactional(propagation = Propagation.NOT_SUPPORTED)
|
||||
public String findLearnUid(UUID uuid) {
|
||||
return labelAllocateCoreService.findLearnUid(uuid);
|
||||
}
|
||||
@@ -300,4 +303,52 @@ public class LabelAllocateService {
|
||||
public boolean isDownloadable(UUID uuid) {
|
||||
return labelAllocateCoreService.isDownloadable(uuid);
|
||||
}
|
||||
|
||||
/**
|
||||
* 실태조사가 값 들어온 기간만큼 할당하는 로직 (최초 할당 이후 작업)
|
||||
*
|
||||
* @param uuid
|
||||
* @param targetUsers
|
||||
* @return
|
||||
*/
|
||||
@Transactional
|
||||
public ApiResponseDto.ResponseObj allocateAddStbltYn(
|
||||
Integer totalCnt, UUID uuid, List<String> targetUsers, LocalDate baseDate) {
|
||||
|
||||
int userCount = targetUsers.size();
|
||||
if (userCount == 0) {
|
||||
return new ApiResponseDto.ResponseObj(ApiResponseCode.BAD_REQUEST, "추가 할당할 라벨러를 선택해주세요.");
|
||||
}
|
||||
|
||||
int base = totalCnt / userCount;
|
||||
int remainder = totalCnt % userCount;
|
||||
Long lastId = null;
|
||||
List<AllocateInfoDto> allIds =
|
||||
labelAllocateCoreService.fetchNextIdsAddStbltYn(
|
||||
uuid, baseDate, lastId, totalCnt.longValue());
|
||||
|
||||
// MapSheetAnalInferenceEntity analUid 가져오기
|
||||
Long analUid = labelAllocateCoreService.findMapSheetAnalInferenceUid(uuid);
|
||||
|
||||
int index = 0;
|
||||
for (int i = 0; i < userCount; i++) {
|
||||
int assignCount = base;
|
||||
// 마지막 사람에게 나머지 몰아주기
|
||||
if (i == userCount - 1) {
|
||||
assignCount += remainder;
|
||||
}
|
||||
|
||||
int end = index + assignCount;
|
||||
List<AllocateInfoDto> sub = allIds.subList(index, end);
|
||||
|
||||
labelAllocateCoreService.assignOwner(sub, targetUsers.get(i), analUid);
|
||||
index = end;
|
||||
}
|
||||
|
||||
return new ApiResponseDto.ResponseObj(ApiResponseCode.OK, "추가 할당이 완료되었습니다.");
|
||||
}
|
||||
|
||||
public Long findAllocateAddCnt(UUID uuid, LocalDate baseDate) {
|
||||
return labelAllocateCoreService.findAllocateAddCnt(uuid, baseDate);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -134,7 +134,6 @@ public class MapSheetMngService {
|
||||
}
|
||||
|
||||
MngDto mngDto = mapSheetMngCoreService.findMapSheetMng(errDto.getMngYyyy());
|
||||
String targetYearDir = mngDto.getMngPath();
|
||||
|
||||
// 중복체크 -> 도엽50k/uuid 경로에 업로드 할 거라 overwrite 되지 않음
|
||||
// if (!overwrite) {
|
||||
|
||||
@@ -41,21 +41,6 @@ public class ModelMngApiController {
|
||||
|
||||
private final ModelMngService modelMngService;
|
||||
|
||||
@Value("${file.sync-root-dir}")
|
||||
private String syncRootDir;
|
||||
|
||||
@Value("${file.sync-tmp-dir}")
|
||||
private String syncTmpDir;
|
||||
|
||||
@Value("${file.sync-file-extention}")
|
||||
private String syncFileExtention;
|
||||
|
||||
@Value("${file.dataset-dir}")
|
||||
private String datasetDir;
|
||||
|
||||
@Value("${file.dataset-tmp-dir}")
|
||||
private String datasetTmpDir;
|
||||
|
||||
@Value("${file.model-dir}")
|
||||
private String modelDir;
|
||||
|
||||
|
||||
@@ -21,9 +21,9 @@ public class ModelMngDto {
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum ModelType implements EnumType {
|
||||
M1("모델 M1"),
|
||||
M2("모델 M2"),
|
||||
M3("모델 M3");
|
||||
G1("G1"),
|
||||
G2("G2"),
|
||||
G3("G3");
|
||||
|
||||
private final String desc;
|
||||
|
||||
|
||||
@@ -35,27 +35,6 @@ public class ModelMngService {
|
||||
|
||||
private final UploadService uploadService;
|
||||
|
||||
@Value("${file.sync-root-dir}")
|
||||
private String syncRootDir;
|
||||
|
||||
@Value("${file.sync-tmp-dir}")
|
||||
private String syncTmpDir;
|
||||
|
||||
@Value("${file.sync-file-extention}")
|
||||
private String syncFileExtention;
|
||||
|
||||
@Value("${file.dataset-dir}")
|
||||
private String datasetDir;
|
||||
|
||||
@Value("${file.dataset-tmp-dir}")
|
||||
private String datasetTmpDir;
|
||||
|
||||
@Value("${file.model-dir}")
|
||||
private String modelDir;
|
||||
|
||||
@Value("${file.model-tmp-dir}")
|
||||
private String modelTmpDir;
|
||||
|
||||
@Value("${file.pt-path}")
|
||||
private String ptPath;
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@ import com.kamco.cd.kamcoback.inference.dto.InferenceResultDto.ResultList;
|
||||
import com.kamco.cd.kamcoback.inference.dto.InferenceResultDto.SaveInferenceAiDto;
|
||||
import com.kamco.cd.kamcoback.inference.dto.InferenceResultsTestingDto;
|
||||
import com.kamco.cd.kamcoback.mapsheet.dto.MapSheetMngDto.MngListDto;
|
||||
import com.kamco.cd.kamcoback.model.dto.ModelMngDto.ModelType;
|
||||
import com.kamco.cd.kamcoback.postgres.entity.InferenceResultsTestingEntity;
|
||||
import com.kamco.cd.kamcoback.postgres.entity.MapInkx5kEntity;
|
||||
import com.kamco.cd.kamcoback.postgres.entity.MapSheetAnalDataInferenceEntity;
|
||||
@@ -110,7 +111,7 @@ public class InferenceResultCoreService {
|
||||
|
||||
MapSheetLearnEntity mapSheetLearnEntity = new MapSheetLearnEntity();
|
||||
mapSheetLearnEntity.setTitle(req.getTitle());
|
||||
mapSheetLearnEntity.setRunningModelType("M1");
|
||||
mapSheetLearnEntity.setRunningModelType(ModelType.G1.getId());
|
||||
mapSheetLearnEntity.setM1ModelUuid(req.getModel1Uuid());
|
||||
mapSheetLearnEntity.setM2ModelUuid(req.getModel2Uuid());
|
||||
mapSheetLearnEntity.setM3ModelUuid(req.getModel3Uuid());
|
||||
@@ -301,7 +302,7 @@ public class InferenceResultCoreService {
|
||||
|
||||
private void applyModelUpdate(MapSheetLearnEntity entity, SaveInferenceAiDto request) {
|
||||
switch (request.getType()) {
|
||||
case "M1" ->
|
||||
case "G1" ->
|
||||
applyModelFields(
|
||||
request,
|
||||
entity::setM1ModelBatchId,
|
||||
@@ -311,7 +312,7 @@ public class InferenceResultCoreService {
|
||||
entity::setM1RunningJobs,
|
||||
entity::setM1CompletedJobs,
|
||||
entity::setM1FailedJobs);
|
||||
case "M2" ->
|
||||
case "G2" ->
|
||||
applyModelFields(
|
||||
request,
|
||||
entity::setM2ModelBatchId,
|
||||
@@ -321,7 +322,7 @@ public class InferenceResultCoreService {
|
||||
entity::setM2RunningJobs,
|
||||
entity::setM2CompletedJobs,
|
||||
entity::setM2FailedJobs);
|
||||
case "M3" ->
|
||||
case "G3" ->
|
||||
applyModelFields(
|
||||
request,
|
||||
entity::setM3ModelBatchId,
|
||||
|
||||
@@ -257,16 +257,20 @@ public class LabelAllocateCoreService {
|
||||
|
||||
// 파일이 있는지만 확인
|
||||
Path path = Paths.get(responsePath).resolve(dto.getLearnUid() + ".zip");
|
||||
|
||||
if (!Files.exists(path) || !Files.isRegularFile(path)) {
|
||||
// 실제 파일만 true (디렉터리는 제외)
|
||||
return false;
|
||||
if (!Files.isRegularFile(path)) {
|
||||
return false; // exists 포함
|
||||
}
|
||||
|
||||
// 다운로드 확인할 학습데이터가 라벨링중인 경우 파일 생성여부가 정상인지 확인
|
||||
if (dto.getAnalState().equals(LabelMngState.ASSIGNED.getId())
|
||||
|| dto.getAnalState().equals(LabelMngState.ING.getId())) {
|
||||
return batchStepHistoryRepository.isDownloadable(dto.getAnalId());
|
||||
String state = dto.getAnalState();
|
||||
boolean isLabelingIng =
|
||||
LabelMngState.ASSIGNED.getId().equals(state) || LabelMngState.ING.getId().equals(state);
|
||||
|
||||
if (isLabelingIng) {
|
||||
Long analId = dto.getAnalId();
|
||||
if (analId == null) {
|
||||
return false;
|
||||
}
|
||||
return batchStepHistoryRepository.isDownloadable(analId);
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -277,4 +281,13 @@ public class LabelAllocateCoreService {
|
||||
.findLearnUid(uuid)
|
||||
.orElseThrow(() -> new CustomApiException("NOT_FOUND_DATA", HttpStatus.NOT_FOUND));
|
||||
}
|
||||
|
||||
public List<AllocateInfoDto> fetchNextIdsAddStbltYn(
|
||||
UUID uuid, LocalDate baseDate, Long lastId, Long totalCnt) {
|
||||
return labelAllocateRepository.fetchNextIdsAddStbltYn(uuid, baseDate, lastId, totalCnt);
|
||||
}
|
||||
|
||||
public Long findAllocateAddCnt(UUID uuid, LocalDate baseDate) {
|
||||
return labelAllocateRepository.findAllocateAddCnt(uuid, baseDate);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -283,11 +283,19 @@ public class MapSheetMngCoreService {
|
||||
|
||||
// 4) 파일 생성
|
||||
try {
|
||||
log.info("create Directories outputPath: {}", outputPath);
|
||||
log.info(
|
||||
"activeEnv={}, inferenceDir={}, targetDir={}, filename={}",
|
||||
activeEnv,
|
||||
inferenceDir,
|
||||
targetDir,
|
||||
filename);
|
||||
log.info("outputPath={}, parent={}", outputPath.toAbsolutePath(), outputPath.getParent());
|
||||
Files.createDirectories(outputPath.getParent());
|
||||
|
||||
new GeoJsonFileWriter()
|
||||
.exportToFile(sceneInference, "scene_inference_" + yyyy, 5186, outputPath.toString());
|
||||
|
||||
log.info("GeoJsonFileWriter: {}", "scene_inference_" + yyyy);
|
||||
Scene scene = new Scene();
|
||||
scene.setFeatures(sceneInference);
|
||||
scene.setFilePath(outputPath.toString());
|
||||
@@ -297,7 +305,7 @@ public class MapSheetMngCoreService {
|
||||
} catch (IOException e) {
|
||||
log.error(
|
||||
"FAIL_CREATE_MAP_SHEET_FILE: yyyy={}, isAll={}, path={}", yyyy, isAll, outputPath, e);
|
||||
throw new CustomApiException("FAIL_CREATE_MAP_SHEET_FILE", HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
throw new CustomApiException("INTERNAL_SERVER_ERROR", HttpStatus.INTERNAL_SERVER_ERROR, e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -35,17 +35,17 @@ public class MapSheetLearn5kRepositoryImpl implements MapSheetLearn5kRepositoryC
|
||||
final StringPath errorMsgPath;
|
||||
|
||||
switch (type) {
|
||||
case "M1" -> {
|
||||
case "G1" -> {
|
||||
failPath = mapSheetLearn5kEntity.isM1Fail;
|
||||
jobIdPath = mapSheetLearn5kEntity.m1JobId;
|
||||
errorMsgPath = mapSheetLearn5kEntity.m1ErrorMessage;
|
||||
}
|
||||
case "M2" -> {
|
||||
case "G2" -> {
|
||||
failPath = mapSheetLearn5kEntity.isM2Fail;
|
||||
jobIdPath = mapSheetLearn5kEntity.m2JobId;
|
||||
errorMsgPath = mapSheetLearn5kEntity.m2ErrorMessage;
|
||||
}
|
||||
case "M3" -> {
|
||||
case "G3" -> {
|
||||
failPath = mapSheetLearn5kEntity.isM3Fail;
|
||||
jobIdPath = mapSheetLearn5kEntity.m3JobId;
|
||||
errorMsgPath = mapSheetLearn5kEntity.m3ErrorMessage;
|
||||
@@ -85,15 +85,15 @@ public class MapSheetLearn5kRepositoryImpl implements MapSheetLearn5kRepositoryC
|
||||
final StringPath errorMsgPath;
|
||||
|
||||
switch (type) {
|
||||
case "M1" -> {
|
||||
case "G1" -> {
|
||||
failPath = mapSheetLearn5kEntity.isM1Fail;
|
||||
jobIdPath = mapSheetLearn5kEntity.m1JobId;
|
||||
}
|
||||
case "M2" -> {
|
||||
case "G2" -> {
|
||||
failPath = mapSheetLearn5kEntity.isM2Fail;
|
||||
jobIdPath = mapSheetLearn5kEntity.m2JobId;
|
||||
}
|
||||
case "M3" -> {
|
||||
case "G3" -> {
|
||||
failPath = mapSheetLearn5kEntity.isM3Fail;
|
||||
jobIdPath = mapSheetLearn5kEntity.m3JobId;
|
||||
}
|
||||
@@ -135,15 +135,15 @@ public class MapSheetLearn5kRepositoryImpl implements MapSheetLearn5kRepositoryC
|
||||
BooleanPath failPath;
|
||||
|
||||
switch (type) {
|
||||
case "M1" -> {
|
||||
case "G1" -> {
|
||||
jobIdPath = mapSheetLearn5kEntity.m1JobId;
|
||||
failPath = mapSheetLearn5kEntity.isM1Fail;
|
||||
}
|
||||
case "M2" -> {
|
||||
case "G2" -> {
|
||||
jobIdPath = mapSheetLearn5kEntity.m2JobId;
|
||||
failPath = mapSheetLearn5kEntity.isM2Fail;
|
||||
}
|
||||
case "M3" -> {
|
||||
case "G3" -> {
|
||||
jobIdPath = mapSheetLearn5kEntity.m3JobId;
|
||||
failPath = mapSheetLearn5kEntity.isM3Fail;
|
||||
}
|
||||
@@ -180,13 +180,13 @@ public class MapSheetLearn5kRepositoryImpl implements MapSheetLearn5kRepositoryC
|
||||
BooleanPath failPath;
|
||||
|
||||
switch (type) {
|
||||
case "M1" -> {
|
||||
case "G1" -> {
|
||||
jobIdPath = mapSheetLearn5kEntity.m1JobId;
|
||||
}
|
||||
case "M2" -> {
|
||||
case "G2" -> {
|
||||
jobIdPath = mapSheetLearn5kEntity.m2JobId;
|
||||
}
|
||||
case "M3" -> {
|
||||
case "G3" -> {
|
||||
jobIdPath = mapSheetLearn5kEntity.m3JobId;
|
||||
}
|
||||
default -> {
|
||||
|
||||
@@ -110,4 +110,9 @@ public interface LabelAllocateRepositoryCustom {
|
||||
InferenceLearnDto findLabelingIngProcessId(UUID uuid);
|
||||
|
||||
Optional<String> findLearnUid(UUID uuid);
|
||||
|
||||
List<AllocateInfoDto> fetchNextIdsAddStbltYn(
|
||||
UUID uuid, LocalDate baseDate, Long lastId, Long totalCnt);
|
||||
|
||||
Long findAllocateAddCnt(UUID uuid, LocalDate baseDate);
|
||||
}
|
||||
|
||||
@@ -1856,4 +1856,56 @@ public class LabelAllocateRepositoryImpl implements LabelAllocateRepositoryCusto
|
||||
.where(mapSheetAnalInferenceEntity.uuid.eq(uuid))
|
||||
.fetchOne());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AllocateInfoDto> fetchNextIdsAddStbltYn(
|
||||
UUID uuid, LocalDate baseDate, Long lastId, Long totalCnt) {
|
||||
ZoneId zone = ZoneId.of("Asia/Seoul"); // 기준 타임존 명확히
|
||||
ZonedDateTime nextDayStart = baseDate.plusDays(1).atStartOfDay(zone);
|
||||
|
||||
return queryFactory
|
||||
.select(
|
||||
Projections.constructor(
|
||||
AllocateInfoDto.class,
|
||||
mapSheetAnalDataInferenceGeomEntity.geoUid,
|
||||
mapSheetAnalDataInferenceGeomEntity.mapSheetNum,
|
||||
mapSheetAnalDataInferenceGeomEntity.pnu))
|
||||
.from(mapSheetAnalInferenceEntity)
|
||||
.innerJoin(mapSheetAnalDataInferenceEntity)
|
||||
.on(mapSheetAnalInferenceEntity.id.eq(mapSheetAnalDataInferenceEntity.analUid))
|
||||
.innerJoin(mapSheetAnalDataInferenceGeomEntity)
|
||||
.on(
|
||||
mapSheetAnalDataInferenceEntity.id.eq(mapSheetAnalDataInferenceGeomEntity.dataUid),
|
||||
mapSheetAnalDataInferenceGeomEntity.pnu.gt(0),
|
||||
mapSheetAnalDataInferenceGeomEntity.fitState.eq(ImageryFitStatus.UNFIT.getId()),
|
||||
mapSheetAnalDataInferenceGeomEntity.fitStateDttm.lt(nextDayStart),
|
||||
mapSheetAnalDataInferenceGeomEntity.labelState.isNull())
|
||||
.where(
|
||||
mapSheetAnalInferenceEntity.uuid.eq(uuid),
|
||||
lastId == null ? null : mapSheetAnalDataInferenceGeomEntity.geoUid.gt(lastId))
|
||||
.orderBy(mapSheetAnalDataInferenceGeomEntity.mapSheetNum.asc())
|
||||
.limit(totalCnt)
|
||||
.fetch();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long findAllocateAddCnt(UUID uuid, LocalDate baseDate) {
|
||||
ZoneId zone = ZoneId.of("Asia/Seoul"); // 기준 타임존 명확히
|
||||
ZonedDateTime nextDayStart = baseDate.plusDays(1).atStartOfDay(zone);
|
||||
|
||||
return queryFactory
|
||||
.select(mapSheetAnalDataInferenceGeomEntity.geoUid.count())
|
||||
.from(mapSheetAnalInferenceEntity)
|
||||
.innerJoin(mapSheetAnalDataInferenceEntity)
|
||||
.on(mapSheetAnalInferenceEntity.id.eq(mapSheetAnalDataInferenceEntity.analUid))
|
||||
.innerJoin(mapSheetAnalDataInferenceGeomEntity)
|
||||
.on(
|
||||
mapSheetAnalDataInferenceEntity.id.eq(mapSheetAnalDataInferenceGeomEntity.dataUid),
|
||||
mapSheetAnalDataInferenceGeomEntity.pnu.gt(0),
|
||||
mapSheetAnalDataInferenceGeomEntity.fitState.eq(ImageryFitStatus.UNFIT.getId()),
|
||||
mapSheetAnalDataInferenceGeomEntity.fitStateDttm.lt(nextDayStart),
|
||||
mapSheetAnalDataInferenceGeomEntity.labelState.isNull())
|
||||
.where(mapSheetAnalInferenceEntity.uuid.eq(uuid))
|
||||
.fetchOne();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import static com.kamco.cd.kamcoback.postgres.entity.QMapSheetLearnEntity.mapShe
|
||||
|
||||
import com.kamco.cd.kamcoback.label.dto.LabelAllocateDto.InspectState;
|
||||
import com.kamco.cd.kamcoback.label.dto.LabelAllocateDto.LabelMngState;
|
||||
import com.kamco.cd.kamcoback.model.dto.ModelMngDto.ModelType;
|
||||
import com.kamco.cd.kamcoback.postgres.entity.LabelingAssignmentEntity;
|
||||
import com.kamco.cd.kamcoback.scheduler.dto.TrainingDataReviewJobDto.AnalCntInfo;
|
||||
import com.kamco.cd.kamcoback.scheduler.dto.TrainingDataReviewJobDto.AnalMapSheetList;
|
||||
@@ -58,10 +59,10 @@ public class TrainingDataReviewJobRepositoryImpl extends QuerydslRepositorySuppo
|
||||
Properties.class,
|
||||
new CaseBuilder()
|
||||
.when(mapSheetLearnDataGeomEntity.classAfterCd.in("building", "container"))
|
||||
.then("M1")
|
||||
.then(ModelType.G1.getId())
|
||||
.when(mapSheetLearnDataGeomEntity.classAfterCd.eq("waste"))
|
||||
.then("M2")
|
||||
.otherwise("M3"),
|
||||
.then(ModelType.G2.getId())
|
||||
.otherwise(ModelType.G3.getId()),
|
||||
mapSheetLearnDataGeomEntity.classBeforeCd,
|
||||
mapSheetLearnDataGeomEntity.classAfterCd)))
|
||||
.from(labelingAssignmentEntity)
|
||||
|
||||
@@ -120,6 +120,7 @@ public class TrainingDataLabelRepositoryImpl extends QuerydslRepositorySupport
|
||||
.orderBy(
|
||||
mapSheetAnalInferenceEntity.targetYyyy.asc(),
|
||||
mapSheetAnalInferenceEntity.compareYyyy.asc(),
|
||||
labelingAssignmentEntity.assignGroupId.asc(),
|
||||
labelingAssignmentEntity.createdDate.asc(),
|
||||
labelingAssignmentEntity.inferenceGeomUid.asc())
|
||||
.fetch();
|
||||
@@ -653,6 +654,7 @@ public class TrainingDataLabelRepositoryImpl extends QuerydslRepositorySupport
|
||||
queryFactory
|
||||
.select(
|
||||
labelingAssignmentEntity.assignmentUid,
|
||||
labelingAssignmentEntity.assignGroupId,
|
||||
labelingAssignmentEntity.createdDate,
|
||||
labelingAssignmentEntity.inferenceGeomUid,
|
||||
mapSheetAnalInferenceEntity.targetYyyy,
|
||||
@@ -671,6 +673,7 @@ public class TrainingDataLabelRepositoryImpl extends QuerydslRepositorySupport
|
||||
.orderBy(
|
||||
mapSheetAnalInferenceEntity.targetYyyy.asc(),
|
||||
mapSheetAnalInferenceEntity.compareYyyy.asc(),
|
||||
labelingAssignmentEntity.assignGroupId.asc(),
|
||||
labelingAssignmentEntity.createdDate.asc(),
|
||||
labelingAssignmentEntity.inferenceGeomUid.asc())
|
||||
.limit(1)
|
||||
@@ -685,6 +688,7 @@ public class TrainingDataLabelRepositoryImpl extends QuerydslRepositorySupport
|
||||
Long inferenceGeomUid = firstAssigned.get(labelingAssignmentEntity.inferenceGeomUid);
|
||||
Integer targetYyyy = firstAssigned.get(mapSheetAnalInferenceEntity.targetYyyy);
|
||||
Integer compareYyyy = firstAssigned.get(mapSheetAnalInferenceEntity.compareYyyy);
|
||||
String assignGroupId = firstAssigned.get(labelingAssignmentEntity.assignGroupId);
|
||||
|
||||
BooleanExpression beforeCondition =
|
||||
mapSheetAnalInferenceEntity
|
||||
@@ -700,12 +704,20 @@ public class TrainingDataLabelRepositoryImpl extends QuerydslRepositorySupport
|
||||
.targetYyyy
|
||||
.eq(targetYyyy)
|
||||
.and(mapSheetAnalInferenceEntity.compareYyyy.eq(compareYyyy))
|
||||
.and(labelingAssignmentEntity.assignGroupId.lt(assignGroupId)))
|
||||
.or(
|
||||
mapSheetAnalInferenceEntity
|
||||
.targetYyyy
|
||||
.eq(targetYyyy)
|
||||
.and(mapSheetAnalInferenceEntity.compareYyyy.eq(compareYyyy))
|
||||
.and(labelingAssignmentEntity.assignGroupId.eq(assignGroupId))
|
||||
.and(labelingAssignmentEntity.createdDate.lt(createdDttm)))
|
||||
.or(
|
||||
mapSheetAnalInferenceEntity
|
||||
.targetYyyy
|
||||
.eq(targetYyyy)
|
||||
.and(mapSheetAnalInferenceEntity.compareYyyy.eq(compareYyyy))
|
||||
.and(labelingAssignmentEntity.assignGroupId.eq(assignGroupId))
|
||||
.and(labelingAssignmentEntity.createdDate.eq(createdDttm))
|
||||
.and(labelingAssignmentEntity.inferenceGeomUid.lt(inferenceGeomUid)));
|
||||
|
||||
|
||||
@@ -60,10 +60,10 @@ select msldge1_0.geo_uid,
|
||||
st_asgeojson(msldge1_0.geom),
|
||||
case
|
||||
when (msldge1_0.class_after_cd in ('building', 'container'))
|
||||
then cast('M1' as varchar)
|
||||
then cast('G1' as varchar)
|
||||
when (msldge1_0.class_after_cd = 'waste')
|
||||
then cast('M2' as varchar)
|
||||
else 'M3'
|
||||
then cast('G2' as varchar)
|
||||
else 'G3'
|
||||
end,
|
||||
msldge1_0.class_before_cd,
|
||||
msldge1_0.class_after_cd
|
||||
|
||||
@@ -20,4 +20,15 @@ public class AsyncConfig {
|
||||
ex.initialize();
|
||||
return ex;
|
||||
}
|
||||
|
||||
@Bean(name = "auditLogExecutor")
|
||||
public Executor auditLogExecutor() {
|
||||
ThreadPoolTaskExecutor exec = new ThreadPoolTaskExecutor();
|
||||
exec.setCorePoolSize(2);
|
||||
exec.setMaxPoolSize(8);
|
||||
exec.setQueueCapacity(2000);
|
||||
exec.setThreadNamePrefix("auditlog-");
|
||||
exec.initialize();
|
||||
return exec;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ public class GukYuinApiLabelJobService {
|
||||
|
||||
for (GeomUidDto gto : list) {
|
||||
ChngDetectContDto.ResultLabelDto dto =
|
||||
gukYuinApiService.updateChnDtctObjtLabelingYn(gto.getResultUid(), "Y");
|
||||
gukYuinApiService.updateChnDtctObjtLabelingYn(gto.getResultUid(), "Y", "Y");
|
||||
if (dto.getSuccess()) {
|
||||
// inference_geom 에 label_send_dttm 업데이트 하기
|
||||
gukYuinLabelJobCoreService.updateAnalDataInferenceGeomSendDttm(gto.getGeoUid());
|
||||
|
||||
@@ -63,7 +63,7 @@ public class GukYuinApiPnuJobService {
|
||||
}
|
||||
|
||||
private void processUid(String chnDtctId, String uid) {
|
||||
ResultDto result = gukYuinApiService.listChnDtctId(chnDtctId);
|
||||
ResultDto result = gukYuinApiService.listChnDtctId(chnDtctId, "Y");
|
||||
if (result == null || result.getResult() == null || result.getResult().isEmpty()) {
|
||||
return;
|
||||
}
|
||||
@@ -85,7 +85,7 @@ public class GukYuinApiPnuJobService {
|
||||
}
|
||||
|
||||
private void processPage(String uid, int page, int pageSize) {
|
||||
ResultContDto resContList = gukYuinApiService.findChnContList(uid, page, pageSize);
|
||||
ResultContDto resContList = gukYuinApiService.findChnContList(uid, page, pageSize, "Y");
|
||||
|
||||
if (resContList.getResult() == null || resContList.getResult().isEmpty()) {
|
||||
return; // 외부 API 이상 방어
|
||||
|
||||
@@ -48,7 +48,7 @@ public class GukYuinApiStatusJobService {
|
||||
|
||||
for (LearnKeyDto dto : list) {
|
||||
try {
|
||||
ChngDetectMastDto.ResultDto result = gukYuinApiService.listChnDtctId(dto.getUid());
|
||||
ChngDetectMastDto.ResultDto result = gukYuinApiService.listChnDtctId(dto.getUid(), "Y");
|
||||
|
||||
if (result == null || result.getResult() == null || result.getResult().isEmpty()) {
|
||||
log.warn("[GUKYUIN] empty result chnDtctMstId={}", dto.getChnDtctMstId());
|
||||
|
||||
@@ -59,7 +59,7 @@ public class GukYuinApiStbltJobService {
|
||||
LocalDate.now(ZoneId.of("Asia/Seoul"))
|
||||
.minusDays(1)
|
||||
.format(DateTimeFormatter.ofPattern("yyyyMMdd"));
|
||||
RlbDtctDto result = gukYuinApiService.findRlbDtctList(dto.getUid(), yesterday);
|
||||
RlbDtctDto result = gukYuinApiService.findRlbDtctList(dto.getUid(), yesterday, "Y");
|
||||
|
||||
if (result == null || result.getResult() == null || result.getResult().isEmpty()) {
|
||||
log.warn("[GUKYUIN] empty result chnDtctMstId={}", dto.getChnDtctMstId());
|
||||
|
||||
@@ -11,6 +11,7 @@ import com.kamco.cd.kamcoback.inference.dto.InferenceProgressDto;
|
||||
import com.kamco.cd.kamcoback.inference.dto.InferenceResultDto.SaveInferenceAiDto;
|
||||
import com.kamco.cd.kamcoback.inference.dto.InferenceResultDto.Status;
|
||||
import com.kamco.cd.kamcoback.inference.dto.InferenceSendDto;
|
||||
import com.kamco.cd.kamcoback.model.dto.ModelMngDto.ModelType;
|
||||
import com.kamco.cd.kamcoback.postgres.core.InferenceResultCoreService;
|
||||
import com.kamco.cd.kamcoback.scheduler.dto.BatchStatusDto;
|
||||
import com.kamco.cd.kamcoback.scheduler.dto.JobStatusDto;
|
||||
@@ -122,7 +123,7 @@ public class MapSheetInferenceJobService {
|
||||
* @return
|
||||
*/
|
||||
private Long resolveBatchId(InferenceBatchSheet sheet) {
|
||||
// M3 > M2 > M1
|
||||
// G3 > G2 > G1
|
||||
if (sheet.getM3BatchId() != null) {
|
||||
return sheet.getM3BatchId();
|
||||
}
|
||||
@@ -216,12 +217,12 @@ public class MapSheetInferenceJobService {
|
||||
updateProcessingEndTimeByModel(job, sheet.getUuid(), now, currentType);
|
||||
|
||||
// M3이면 전체 종료
|
||||
if ("M3".equals(currentType)) {
|
||||
if (ModelType.G3.getId().equals(currentType)) {
|
||||
endAll(sheet, now);
|
||||
return;
|
||||
}
|
||||
|
||||
// 다음 모델 실행 (M1->M2, M2->M3)
|
||||
// 다음 모델 실행 (G1->G2, G2->G3)
|
||||
String nextType = nextModelType(currentType);
|
||||
UUID nextModelUuid = resolveModelUuid(sheet, nextType);
|
||||
|
||||
@@ -240,7 +241,7 @@ public class MapSheetInferenceJobService {
|
||||
save.setUuid(sheet.getUuid());
|
||||
save.setStatus(Status.END.getId());
|
||||
save.setInferEndDttm(now);
|
||||
save.setType("M3"); // 마지막 모델 기준
|
||||
save.setType(ModelType.G3.getId()); // 마지막 모델 기준
|
||||
inferenceResultCoreService.update(save);
|
||||
|
||||
// 추론 종료일때 geom 데이터 저장
|
||||
@@ -266,11 +267,11 @@ public class MapSheetInferenceJobService {
|
||||
* @return
|
||||
*/
|
||||
private String nextModelType(String currentType) {
|
||||
if ("M1".equals(currentType)) {
|
||||
return "M2";
|
||||
if (ModelType.G1.getId().equals(currentType)) {
|
||||
return ModelType.G2.getId();
|
||||
}
|
||||
if ("M2".equals(currentType)) {
|
||||
return "M3";
|
||||
if (ModelType.G2.getId().equals(currentType)) {
|
||||
return ModelType.G3.getId();
|
||||
}
|
||||
throw new IllegalArgumentException("Unknown runningModelType: " + currentType);
|
||||
}
|
||||
@@ -283,13 +284,13 @@ public class MapSheetInferenceJobService {
|
||||
* @return
|
||||
*/
|
||||
private UUID resolveModelUuid(InferenceBatchSheet sheet, String type) {
|
||||
if ("M1".equals(type)) {
|
||||
if (ModelType.G1.getId().equals(type)) {
|
||||
return sheet.getM1ModelUuid();
|
||||
}
|
||||
if ("M2".equals(type)) {
|
||||
if (ModelType.G2.getId().equals(type)) {
|
||||
return sheet.getM2ModelUuid();
|
||||
}
|
||||
if ("M3".equals(type)) {
|
||||
if (ModelType.G3.getId().equals(type)) {
|
||||
return sheet.getM3ModelUuid();
|
||||
}
|
||||
throw new IllegalArgumentException("Unknown type: " + type);
|
||||
@@ -332,9 +333,6 @@ public class MapSheetInferenceJobService {
|
||||
InferenceProgressDto progressDto =
|
||||
inferenceResultCoreService.getInferenceAiResultById(id, modelUuid);
|
||||
|
||||
// ai 에 맞는 모델 명으로 변경
|
||||
String inferenceType = modelToInferenceType(type);
|
||||
|
||||
InferenceSendDto.pred_requests_areas predRequestsAreas =
|
||||
new InferenceSendDto.pred_requests_areas();
|
||||
predRequestsAreas.setInput1_year(progressDto.getPred_requests_areas().getInput1_year());
|
||||
@@ -355,7 +353,7 @@ public class MapSheetInferenceJobService {
|
||||
m.setCls_model_path(
|
||||
Paths.get(progressDto.getCdModelClsPath(), progressDto.getCdModelClsFileName()).toString());
|
||||
m.setCls_model_version(progressDto.getClsModelVersion());
|
||||
m.setCd_model_type(inferenceType);
|
||||
m.setCd_model_type(type);
|
||||
m.setPriority(progressDto.getPriority());
|
||||
|
||||
// log.info("InferenceSendDto={}", m);
|
||||
@@ -372,25 +370,6 @@ public class MapSheetInferenceJobService {
|
||||
inferenceResultCoreService.update(saveInferenceAiDto);
|
||||
}
|
||||
|
||||
/**
|
||||
* ai 에 맞는 모델 명으로 변경
|
||||
*
|
||||
* @param type 모델 타입
|
||||
* @return String
|
||||
*/
|
||||
private String modelToInferenceType(String type) {
|
||||
if ("M1".equals(type)) {
|
||||
return "G1";
|
||||
}
|
||||
if ("M2".equals(type)) {
|
||||
return "G2";
|
||||
}
|
||||
if ("M3".equals(type)) {
|
||||
return "G3";
|
||||
}
|
||||
throw new IllegalArgumentException("Unknown type: " + type);
|
||||
}
|
||||
|
||||
/**
|
||||
* api 호출
|
||||
*
|
||||
|
||||
@@ -29,27 +29,12 @@ public class UploadApiController {
|
||||
|
||||
private final UploadService uploadService;
|
||||
|
||||
@Value("${file.sync-root-dir}")
|
||||
private String syncRootDir;
|
||||
|
||||
@Value("${file.sync-tmp-dir}")
|
||||
private String syncTmpDir;
|
||||
|
||||
@Value("${file.sync-file-extention}")
|
||||
private String syncFileExtention;
|
||||
|
||||
@Value("${file.dataset-dir}")
|
||||
private String datasetDir;
|
||||
|
||||
@Value("${file.dataset-tmp-dir}")
|
||||
private String datasetTmpDir;
|
||||
|
||||
@Value("${file.model-dir}")
|
||||
private String modelDir;
|
||||
|
||||
@Value("${file.model-tmp-dir}")
|
||||
private String modelTmpDir;
|
||||
|
||||
/*
|
||||
@Operation(summary = "데이터셋 대용량 업로드 세션 시작", description = "데이터셋 대용량 파일 업로드 세션을 시작합니다.")
|
||||
@ApiResponses(
|
||||
|
||||
@@ -16,6 +16,10 @@ spring:
|
||||
format_sql: true # ⚠️ 선택 - SQL 포맷팅 (가독성)
|
||||
jdbc:
|
||||
batch_size: 1000 # ✅ 추가 (JDBC batch)
|
||||
open-in-view: false
|
||||
mvc:
|
||||
async:
|
||||
request-timeout: 300s # 5분 (예: 30s, 120s, 10m 등도 가능)
|
||||
|
||||
datasource:
|
||||
url: jdbc:postgresql://192.168.2.127:15432/kamco_cds
|
||||
@@ -83,24 +87,25 @@ mapsheet:
|
||||
upload:
|
||||
skipGdalValidation: true
|
||||
shp:
|
||||
baseurl: /app/tmp/detect/result
|
||||
baseurl: /app/tmp/detect/result #현재사용안함
|
||||
|
||||
|
||||
|
||||
file:
|
||||
#sync-root-dir: D:/kamco-nfs/images/
|
||||
sync-root-dir: /kamco-nfs/images/
|
||||
sync-tmp-dir: ${file.sync-root-dir}/tmp
|
||||
sync-tmp-dir: /kamco-nfs/requests/temp # image upload temp dir
|
||||
#sync-tmp-dir: ${file.sync-root-dir}/tmp
|
||||
sync-file-extention: tfw,tif
|
||||
sync-auto-exception-start-year: 2024
|
||||
sync-auto-exception-before-year-cnt: 3
|
||||
|
||||
#dataset-dir: D:/kamco-nfs/dataset/
|
||||
dataset-dir: /kamco-nfs/dataset/export/
|
||||
#dataset-dir: D:/kamco-nfs/model_output/
|
||||
dataset-dir: /kamco-nfs/model_output/export/ # 마운트경로 AI 추론결과
|
||||
dataset-tmp-dir: ${file.dataset-dir}tmp/
|
||||
|
||||
#model-dir: D:/kamco-nfs/ckpt/model/
|
||||
model-dir: /kamco-nfs/ckpt/model/
|
||||
model-dir: /kamco-nfs/ckpt/model/ # 학습서버에서 트레이닝한 모델업로드경로
|
||||
model-tmp-dir: ${file.model-dir}tmp/
|
||||
model-file-extention: pth,json,py
|
||||
|
||||
@@ -112,8 +117,8 @@ file:
|
||||
inference:
|
||||
url: http://192.168.2.183:8000/jobs
|
||||
batch-url: http://192.168.2.183:8000/batches
|
||||
geojson-dir: /kamco-nfs/requests/
|
||||
jar-path: /kamco-nfs/dataset/shp/shp-exporter.jar
|
||||
geojson-dir: /kamco-nfs/requests/ # 추론실행을 위한 파일생성경로
|
||||
jar-path: /kamco-nfs/repo/jar/shp-exporter.jar
|
||||
inference-server-name: server1,server2,server3,server4
|
||||
|
||||
gukyuin:
|
||||
@@ -122,10 +127,12 @@ gukyuin:
|
||||
cdi: ${gukyuin.url}/api/kcd/cdi
|
||||
|
||||
training-data:
|
||||
geojson-dir: /kamco-nfs/model_output/labeling/
|
||||
geojson-dir: /kamco-nfs/dataset/request/
|
||||
|
||||
layer:
|
||||
geoserver-url: https://kamco.geo-dev.gs.dabeeo.com
|
||||
wms-path: geoserver/cd
|
||||
wmts-path: geoserver/cd/gwc/service
|
||||
workspace: cd
|
||||
|
||||
|
||||
|
||||
@@ -18,12 +18,38 @@ spring:
|
||||
batch_size: 1000 # ✅ 추가 (JDBC batch)
|
||||
|
||||
datasource:
|
||||
url: jdbc:postgresql://10.100.0.10:25432/temp
|
||||
username: temp
|
||||
password: temp123!
|
||||
url: jdbc:postgresql://kamco-cd-postgis:5432/kamco_cds
|
||||
#url: jdbc:postgresql://localhost:15432/kamco_cds
|
||||
username: kamco_cds
|
||||
password: kamco_cds_Q!W@E#R$
|
||||
hikari:
|
||||
minimum-idle: 10
|
||||
maximum-pool-size: 20
|
||||
connection-timeout: 60000 # 60초 연결 타임아웃
|
||||
idle-timeout: 300000 # 5분 유휴 타임아웃
|
||||
max-lifetime: 1800000 # 30분 최대 수명
|
||||
leak-detection-threshold: 60000 # 연결 누수 감지
|
||||
|
||||
transaction:
|
||||
default-timeout: 300 # 5분 트랜잭션 타임아웃
|
||||
|
||||
data:
|
||||
redis:
|
||||
host: 127.0.0.1
|
||||
port: 16379
|
||||
password: kamco
|
||||
|
||||
servlet:
|
||||
multipart:
|
||||
enabled: true
|
||||
max-file-size: 4GB
|
||||
max-request-size: 4GB
|
||||
file-size-threshold: 10MB
|
||||
|
||||
server:
|
||||
tomcat:
|
||||
max-swallow-size: 4GB
|
||||
max-http-form-post-size: 4GB
|
||||
|
||||
jwt:
|
||||
secret: "kamco_token_9b71e778-19a3-4c1d-97bf-2d687de17d5b"
|
||||
@@ -34,50 +60,63 @@ token:
|
||||
refresh-cookie-name: kamco # 개발용 쿠키 이름
|
||||
refresh-cookie-secure: true # 로컬 http 테스트면 false
|
||||
|
||||
springdoc:
|
||||
swagger-ui:
|
||||
persist-authorization: true # 스웨거 새로고침해도 토큰 유지, 로컬스토리지에 저장
|
||||
|
||||
logging:
|
||||
level:
|
||||
root: INFO
|
||||
org.springframework.web: INFO
|
||||
org.springframework.security: INFO
|
||||
|
||||
# 헬스체크 노이즈 핵심만 다운
|
||||
org.springframework.security.web.FilterChainProxy: INFO
|
||||
org.springframework.security.web.authentication.AnonymousAuthenticationFilter: INFO
|
||||
org.springframework.security.web.authentication.Http403ForbiddenEntryPoint: INFO
|
||||
org.springframework.web.servlet.DispatcherServlet: INFO
|
||||
|
||||
|
||||
mapsheet:
|
||||
upload:
|
||||
skipGdalValidation: true
|
||||
shp:
|
||||
baseurl: /app/detect/result
|
||||
|
||||
|
||||
baseurl: /app/detect/result #현재사용안함
|
||||
|
||||
file:
|
||||
#sync-root-dir: D:/kamco-nfs/images/
|
||||
sync-root-dir: /kamco-nfs/images/
|
||||
sync-tmp-dir: ${file.sync-root-dir}/tmp
|
||||
sync-tmp-dir: ${file.sync-root-dir}/tmp # image upload temp dir
|
||||
sync-file-extention: tfw,tif
|
||||
sync-auto-exception-start-year: 2025
|
||||
sync-auto-exception-before-year-cnt: 3
|
||||
|
||||
#dataset-dir: D:/kamco-nfs/dataset/
|
||||
dataset-dir: /kamco-nfs/dataset/export/
|
||||
#dataset-dir: D:/kamco-nfs/model_output/ #변경 model_output
|
||||
dataset-dir: /kamco-nfs/model_output/export/ # 마운트경로 AI 추론결과
|
||||
dataset-tmp-dir: ${file.dataset-dir}tmp/
|
||||
|
||||
#model-dir: D:/kamco-nfs/ckpt/model/
|
||||
model-dir: /kamco-nfs/ckpt/model/
|
||||
model-dir: /kamco-nfs/ckpt/model/ # 학습서버에서 트레이닝한 모델업로드경로
|
||||
model-tmp-dir: ${file.model-dir}tmp/
|
||||
model-file-extention: pth,json,py
|
||||
|
||||
pt-path: /kamco-nfs/ckpt/model/v6-cls-checkpoints/
|
||||
pt-path: /kamco-nfs/ckpt/v6-cls-checkpoints/
|
||||
pt-FileName: yolov8_6th-6m.pt
|
||||
|
||||
dataset-response: /kamco-nfs/dataset/response/
|
||||
|
||||
inference:
|
||||
url: http://192.168.2.183:8000/jobs
|
||||
batch-url: http://192.168.2.183:8000/batches
|
||||
geojson-dir: /kamco-nfs/requests/
|
||||
jar-path: /kamco-nfs/dataset/shp/shp-exporter.jar
|
||||
url: http://127.0.0.1:8000/jobs
|
||||
batch-url: http://127.0.0.1:8000/batches
|
||||
geojson-dir: /kamco-nfs/requests/ # 학습서버에서 트레이닝한 모델업로드경로
|
||||
jar-path: /kamco-nfs/repo/jar/shp-exporter.jar # 추론실행을 위한 파일생성경로
|
||||
inference-server-name: server1,server2,server3,server4
|
||||
|
||||
gukyuin:
|
||||
#url: http://localhost:8080
|
||||
url: http://192.168.2.129:5301
|
||||
url: http://127.0.0.1:5301
|
||||
cdi: ${gukyuin.url}/api/kcd/cdi
|
||||
|
||||
training-data:
|
||||
geojson-dir: /kamco-nfs/model_output/labeling/
|
||||
geojson-dir: /kamco-nfs/dataset/request/
|
||||
|
||||
layer:
|
||||
geoserver-url: https://kamco.geo-dev.gs.dabeeo.com
|
||||
|
||||
120
src/main/resources/application-prod.yml_bak
Normal file
120
src/main/resources/application-prod.yml_bak
Normal file
@@ -0,0 +1,120 @@
|
||||
spring:
|
||||
config:
|
||||
activate:
|
||||
on-profile: prod
|
||||
|
||||
jpa:
|
||||
show-sql: true
|
||||
hibernate:
|
||||
ddl-auto: validate
|
||||
properties:
|
||||
hibernate:
|
||||
default_batch_fetch_size: 100 # ✅ 성능 - N+1 쿼리 방지
|
||||
order_updates: true # ✅ 성능 - 업데이트 순서 정렬로 데드락 방지
|
||||
order_inserts: true
|
||||
use_sql_comments: true # ⚠️ 선택 - SQL에 주석 추가 (디버깅용)
|
||||
format_sql: true # ⚠️ 선택 - SQL 포맷팅 (가독성)
|
||||
jdbc:
|
||||
batch_size: 1000 # ✅ 추가 (JDBC batch)
|
||||
|
||||
datasource:
|
||||
url: jdbc:postgresql://kamco-cd-postgis:5432/kamco_cds
|
||||
#url: jdbc:postgresql://localhost:15432/kamco_cds
|
||||
username: kamco_cds
|
||||
password: kamco_cds_Q!W@E#R$
|
||||
hikari:
|
||||
minimum-idle: 10
|
||||
maximum-pool-size: 20
|
||||
connection-timeout: 60000 # 60초 연결 타임아웃
|
||||
idle-timeout: 300000 # 5분 유휴 타임아웃
|
||||
max-lifetime: 1800000 # 30분 최대 수명
|
||||
leak-detection-threshold: 60000 # 연결 누수 감지
|
||||
|
||||
transaction:
|
||||
default-timeout: 300 # 5분 트랜잭션 타임아웃
|
||||
|
||||
data:
|
||||
redis:
|
||||
host: 127.0.0.1
|
||||
port: 16379
|
||||
password: kamco
|
||||
|
||||
servlet:
|
||||
multipart:
|
||||
enabled: true
|
||||
max-file-size: 4GB
|
||||
max-request-size: 4GB
|
||||
file-size-threshold: 10MB
|
||||
|
||||
server:
|
||||
tomcat:
|
||||
max-swallow-size: 4GB
|
||||
max-http-form-post-size: 4GB
|
||||
|
||||
jwt:
|
||||
secret: "kamco_token_9b71e778-19a3-4c1d-97bf-2d687de17d5b"
|
||||
access-token-validity-in-ms: 86400000 # 1일
|
||||
refresh-token-validity-in-ms: 604800000 # 7일
|
||||
|
||||
token:
|
||||
refresh-cookie-name: kamco # 개발용 쿠키 이름
|
||||
refresh-cookie-secure: true # 로컬 http 테스트면 false
|
||||
|
||||
logging:
|
||||
level:
|
||||
root: INFO
|
||||
org.springframework.web: INFO
|
||||
org.springframework.security: INFO
|
||||
|
||||
# 헬스체크 노이즈 핵심만 다운
|
||||
org.springframework.security.web.FilterChainProxy: INFO
|
||||
org.springframework.security.web.authentication.AnonymousAuthenticationFilter: INFO
|
||||
org.springframework.security.web.authentication.Http403ForbiddenEntryPoint: INFO
|
||||
org.springframework.web.servlet.DispatcherServlet: INFO
|
||||
|
||||
|
||||
mapsheet:
|
||||
upload:
|
||||
skipGdalValidation: true
|
||||
shp:
|
||||
baseurl: /app/detect/result #현재사용안함
|
||||
|
||||
file:
|
||||
#sync-root-dir: D:/kamco-nfs/images/
|
||||
sync-root-dir: /kamco-nfs/images/
|
||||
sync-tmp-dir: ${file.sync-root-dir}/tmp # image upload temp dir
|
||||
sync-file-extention: tfw,tif
|
||||
sync-auto-exception-start-year: 2025
|
||||
sync-auto-exception-before-year-cnt: 3
|
||||
|
||||
#dataset-dir: D:/kamco-nfs/model_output/ #변경 model_output
|
||||
dataset-dir: /kamco-nfs/model_output/export/ # 마운트경로 AI 추론결과
|
||||
dataset-tmp-dir: ${file.dataset-dir}tmp/
|
||||
|
||||
#model-dir: D:/kamco-nfs/ckpt/model/
|
||||
model-dir: /kamco-nfs/ckpt/model/ # 학습서버에서 트레이닝한 모델업로드경로
|
||||
model-tmp-dir: ${file.model-dir}tmp/
|
||||
model-file-extention: pth,json,py
|
||||
|
||||
pt-path: /kamco-nfs/ckpt/model/v6-cls-checkpoints/
|
||||
pt-FileName: yolov8_6th-6m.pt
|
||||
|
||||
inference:
|
||||
url: http://127.0.0.1:8000/jobs
|
||||
batch-url: http://127.0.0.1:8000/batches
|
||||
geojson-dir: /kamco-nfs/requests/ # 학습서버에서 트레이닝한 모델업로드경로
|
||||
jar-path: /kamco-nfs/repo/jar/shp-exporter.jar # 추론실행을 위한 파일생성경로
|
||||
inference-server-name: server1,server2,server3,server4
|
||||
|
||||
gukyuin:
|
||||
url: http://127.0.0.1:5301
|
||||
cdi: ${gukyuin.url}/api/kcd/cdi
|
||||
|
||||
training-data:
|
||||
geojson-dir: /kamco-nfs/dataset/request/
|
||||
|
||||
layer:
|
||||
geoserver-url: https://kamco.geo-dev.gs.dabeeo.com
|
||||
wms-path: geoserver/cd
|
||||
wmts-path: geoserver/cd/gwc/service
|
||||
workspace: cd
|
||||
83
src/main/resources/static/download_progress_test.html
Normal file
83
src/main/resources/static/download_progress_test.html
Normal file
@@ -0,0 +1,83 @@
|
||||
<!doctype html>
|
||||
<html lang="ko">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>라벨 ZIP 다운로드</title>
|
||||
</head>
|
||||
<body>
|
||||
<h3>라벨 ZIP 다운로드</h3>
|
||||
|
||||
UUID:
|
||||
<input id="uuid" value="6d8d49dc-0c9d-4124-adc7-b9ca610cc394" />
|
||||
<br><br>
|
||||
|
||||
JWT Token:
|
||||
<input id="token" style="width:600px;" placeholder="Bearer 토큰 붙여넣기" />
|
||||
<br><br>
|
||||
|
||||
<button onclick="download()">다운로드</button>
|
||||
|
||||
<br><br>
|
||||
<progress id="bar" value="0" max="100" style="width:400px;"></progress>
|
||||
<div id="status"></div>
|
||||
|
||||
<script>
|
||||
async function download() {
|
||||
const uuid = document.getElementById("uuid").value.trim();
|
||||
const token = document.getElementById("token").value.trim();
|
||||
|
||||
if (!uuid) {
|
||||
alert("UUID 입력하세요");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!token) {
|
||||
alert("토큰 입력하세요");
|
||||
return;
|
||||
}
|
||||
|
||||
const url = `/api/training-data/stage/download/${uuid}`;
|
||||
|
||||
const res = await fetch(url, {
|
||||
headers: {
|
||||
"Authorization": token.startsWith("Bearer ")
|
||||
? token
|
||||
: `Bearer ${token}`,
|
||||
"kamco-download-uuid": uuid
|
||||
}
|
||||
});
|
||||
|
||||
if (!res.ok) {
|
||||
document.getElementById("status").innerText =
|
||||
"실패: " + res.status;
|
||||
return;
|
||||
}
|
||||
|
||||
const total = parseInt(res.headers.get("Content-Length") || "0", 10);
|
||||
const reader = res.body.getReader();
|
||||
const chunks = [];
|
||||
let received = 0;
|
||||
|
||||
while (true) {
|
||||
const { done, value } = await reader.read();
|
||||
if (done) break;
|
||||
chunks.push(value);
|
||||
received += value.length;
|
||||
|
||||
if (total) {
|
||||
document.getElementById("bar").value =
|
||||
(received / total) * 100;
|
||||
}
|
||||
}
|
||||
|
||||
const blob = new Blob(chunks);
|
||||
const a = document.createElement("a");
|
||||
a.href = URL.createObjectURL(blob);
|
||||
a.download = uuid + ".zip";
|
||||
a.click();
|
||||
|
||||
document.getElementById("status").innerText = "완료 ✅";
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user