commit
This commit is contained in:
146
.gitignore
vendored
Normal file
146
.gitignore
vendored
Normal file
@@ -0,0 +1,146 @@
|
||||
# ---> Java
|
||||
# Compiled class file
|
||||
*.class
|
||||
|
||||
# Log file
|
||||
*.log
|
||||
|
||||
# BlueJ files
|
||||
*.ctxt
|
||||
|
||||
# Mobile Tools for Java (J2ME)
|
||||
.mtj.tmp/
|
||||
|
||||
# Package Files #
|
||||
# *.jar
|
||||
*.war
|
||||
*.nar
|
||||
*.ear
|
||||
*.zip
|
||||
*.tar.gz
|
||||
*.rar
|
||||
|
||||
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
|
||||
hs_err_pid*
|
||||
|
||||
# Created by https://www.toptal.com/developers/gitignore/api/eclipse
|
||||
# Edit at https://www.toptal.com/developers/gitignore?templates=eclipse
|
||||
|
||||
### Eclipse ###
|
||||
.metadata
|
||||
bin/
|
||||
tmp/
|
||||
*.tmp
|
||||
*.bak
|
||||
*.swp
|
||||
*~.nib
|
||||
local.properties
|
||||
.settings/
|
||||
.loadpath
|
||||
.recommenders
|
||||
|
||||
# External tool builders
|
||||
.externalToolBuilders/
|
||||
|
||||
# Locally stored "Eclipse launch configurations"
|
||||
*.launch
|
||||
|
||||
# PyDev specific (Python IDE for Eclipse)
|
||||
*.pydevproject
|
||||
|
||||
# CDT-specific (C/C++ Development Tooling)
|
||||
.cproject
|
||||
|
||||
# CDT- autotools
|
||||
.autotools
|
||||
|
||||
# Java annotation processor (APT)
|
||||
.factorypath
|
||||
|
||||
# PDT-specific (PHP Development Tools)
|
||||
.buildpath
|
||||
|
||||
# sbteclipse plugin
|
||||
.target
|
||||
|
||||
# Tern plugin
|
||||
.tern-project
|
||||
|
||||
# TeXlipse plugin
|
||||
.texlipse
|
||||
|
||||
# STS (Spring Tool Suite)
|
||||
.springBeans
|
||||
|
||||
# Code Recommenders
|
||||
.recommenders/
|
||||
|
||||
# Annotation Processing
|
||||
.apt_generated/
|
||||
.apt_generated_test/
|
||||
|
||||
# Scala IDE specific (Scala & Java development for Eclipse)
|
||||
.cache-main
|
||||
.scala_dependencies
|
||||
.worksheet
|
||||
|
||||
### Eclipse Patch ###
|
||||
# Eclipse Core
|
||||
.project
|
||||
|
||||
# JDT-specific (Eclipse Java Development Tools)
|
||||
.classpath
|
||||
|
||||
# Annotation Processing
|
||||
.apt_generated
|
||||
|
||||
.sts4-cache/
|
||||
|
||||
### Git ###
|
||||
# Created by git for backups. To disable backups in Git:
|
||||
# $ git config --global mergetool.keepBackup false
|
||||
*.orig
|
||||
|
||||
# Created by git when using merge tools for conflicts
|
||||
*.BACKUP.*
|
||||
*.BASE.*
|
||||
*.LOCAL.*
|
||||
*.REMOTE.*
|
||||
*_BACKUP_*.txt
|
||||
*_BASE_*.txt
|
||||
*_LOCAL_*.txt
|
||||
*_REMOTE_*.txt
|
||||
|
||||
### Maven ###
|
||||
target/
|
||||
release.properties
|
||||
dependency-reduced-pom.xml
|
||||
buildNumber.properties
|
||||
.mvn/timing.properties
|
||||
.mvn/wrapper/maven-wrapper.jar
|
||||
|
||||
### Windows ###
|
||||
# Windows thumbnail cache files
|
||||
Thumbs.db
|
||||
Thumbs.db:encryptable
|
||||
ehthumbs.db
|
||||
ehthumbs_vista.db
|
||||
|
||||
# Dump file
|
||||
*.stackdump
|
||||
|
||||
# Folder config file
|
||||
[Dd]esktop.ini
|
||||
|
||||
# Recycle Bin used on file shares
|
||||
$RECYCLE.BIN/
|
||||
|
||||
# Windows Installer files
|
||||
*.cab
|
||||
*.msi
|
||||
*.msix
|
||||
*.msm
|
||||
*.msp
|
||||
|
||||
# Windows shortcuts
|
||||
*.lnk
|
||||
34
Dockerfile
Normal file
34
Dockerfile
Normal file
@@ -0,0 +1,34 @@
|
||||
#FROM skti-etrm-registry.cloudzcp.io/cloudzcp/maven:3.5.2-jdk-8-libuuid
|
||||
FROM skti-etrm-registry.cloudzcp.io/cloudzcp/openjdk:8-jdk
|
||||
|
||||
ADD target/skti-nets-0.0.1-SNAPSHOT.jar app.jar
|
||||
|
||||
COPY sapjco3.jar /usr/lib
|
||||
COPY libsapjco3.so /usr/lib
|
||||
RUN chmod 755 /usr/lib/libsapjco3.so
|
||||
|
||||
ENV JVM_OPTS -XX:MetaspaceSize=200m -XX:MaxMetaspaceSize=250m -Xms2048m -Xmx3072m
|
||||
#ENV JVM_OPTS -XX:MetaspaceSize=200m -XX:MaxMetaspaceSize=250m -Xms2048m -Xmx3072m -javaagent:/whatap/whatap.agent-2.1.1.jar
|
||||
|
||||
#ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom ${JVM_OPTS}","-jar","/app.jar"]
|
||||
#ENTRYPOINT ["sh", "-c", "java -Djava.security.egd=file:/dev/./urandom ${JVM_OPTS} -jar /app.jar"]
|
||||
#ENTRYPOINT ["sh", "-c", "java -Djava.library.path=/usr/lib -Djava.security.egd=file:/dev/./urandom ${JVM_OPTS} -jar /app.jar"]
|
||||
ENTRYPOINT ["sh", "-c", "java -Dloader.path=/usr/lib -Djava.library.path=/usr/lib -Djava.security.egd=file:/dev/./urandom ${JVM_OPTS} -jar /app.jar"]
|
||||
|
||||
#4performance test -- start
|
||||
## RUN mkdir /whatap
|
||||
## COPY whatap/paramkey.txt /whatap
|
||||
## COPY whatap/ping.bat /whatap
|
||||
## COPY whatap/ping.sh /whatap
|
||||
## COPY whatap/proxy.bat /whatap
|
||||
## COPY whatap/proxy.sh /whatap
|
||||
## COPY whatap/resmon.bat /whatap
|
||||
## COPY whatap/resmon.sh /whatap
|
||||
## COPY whatap/whatap.agent.proxy-2.1.1.jar /whatap
|
||||
## COPY whatap/whatap.agent-2.0_57.jar_org /whatap
|
||||
## COPY whatap/whatap.agent-2.1.1.jar /whatap
|
||||
## COPY whatap/whatap.conf /whatap
|
||||
## COPY whatap/whatap-logsink-lz4-1.7.0.jar /whatap
|
||||
|
||||
## ENTRYPOINT ["sh", "-c", "java -Dloader.path=/usr/lib -Djava.library.path=/usr/lib -Djava.security.egd=file:/dev/./urandom ${JVM_OPTS} -jar /app.jar"]
|
||||
#4performance test -- end
|
||||
50
jenkins-pipeline/deploy-pipeline
Normal file
50
jenkins-pipeline/deploy-pipeline
Normal file
@@ -0,0 +1,50 @@
|
||||
@Library('retort-lib') _
|
||||
def label = "jenkins-${UUID.randomUUID().toString()}"
|
||||
|
||||
def ZCP_USERID = 'netsdev'
|
||||
def DOCKER_IMAGE = 'nets-dev/skti-nets'
|
||||
def K8S_NAMESPACE = 'nets-dev'
|
||||
def VERSION = 'develop'
|
||||
|
||||
timestamps {
|
||||
podTemplate(label:label,
|
||||
serviceAccount: "zcp-system-sa-${ZCP_USERID}",
|
||||
containers: [
|
||||
containerTemplate(name: 'jnlp', image: 'skti-etrm-registry.cloudzcp.io/cloudzcp/jnlp-slave:alpine', args:'${computer.jnlpmac} ${computer.name}'),
|
||||
containerTemplate(name: 'maven', image: 'skti-etrm-registry.cloudzcp.io/cloudzcp/maven:3.5.2-jdk-8-alpine', ttyEnabled: true, command: 'cat'),
|
||||
containerTemplate(name: 'docker', image: 'skti-etrm-registry.cloudzcp.io/cloudzcp/docker:17-dind', ttyEnabled: true, command: 'dockerd-entrypoint.sh', privileged: true),
|
||||
containerTemplate(name: 'kubectl', image: 'skti-etrm-registry.cloudzcp.io/cloudzcp/k8s-kubectl:v1.13.6', ttyEnabled: true, command: 'cat')
|
||||
],
|
||||
volumes: [
|
||||
persistentVolumeClaim(mountPath: '/root/.m2', claimName: 'zcp-jenkins-mvn-repo')
|
||||
]) {
|
||||
|
||||
node(label) {
|
||||
stage('SOURCE CHECKOUT') {
|
||||
def repo = checkout scm
|
||||
}
|
||||
|
||||
stage('BUILD MAVEN') {
|
||||
container('maven') {
|
||||
mavenBuild goal: '-Pdev clean generate-sources package -U -Dmaven.test.skip=true', systemProperties:['maven.repo.local':"/root/.m2/${JOB_NAME}"], globalSettingsID: 'MAVEN_GLOBAL_SETTINGS'
|
||||
}
|
||||
}
|
||||
|
||||
stage('BUILD DOCKER IMAGE') {
|
||||
container('docker') {
|
||||
dockerCmd.build tag: "${HARBOR_REGISTRY}/${DOCKER_IMAGE}:${BUILD_NUMBER}"
|
||||
dockerCmd.push registry: HARBOR_REGISTRY, imageName: DOCKER_IMAGE, imageVersion: BUILD_NUMBER, credentialsId: "HARBOR_CREDENTIALS"
|
||||
}
|
||||
}
|
||||
|
||||
stage('DEPLOY') {
|
||||
container('kubectl') {
|
||||
kubeCmd.apply file: 'k8s/service.yaml', namespace: K8S_NAMESPACE
|
||||
kubeCmd.apply file: 'k8s/ingress.yaml', namespace: K8S_NAMESPACE
|
||||
yaml.update file: 'k8s/deployment.yaml', update: ['.spec.template.spec.containers[0].image': "${HARBOR_REGISTRY}/${DOCKER_IMAGE}:${BUILD_NUMBER}"]
|
||||
kubeCmd.apply file: 'k8s/deployment.yaml', wait: 1200, recoverOnFail: false, namespace: K8S_NAMESPACE
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
50
jenkins-pipeline/prd/deploy-pipeline
Normal file
50
jenkins-pipeline/prd/deploy-pipeline
Normal file
@@ -0,0 +1,50 @@
|
||||
@Library('retort-lib') _
|
||||
def label = "jenkins-${UUID.randomUUID().toString()}"
|
||||
|
||||
def ZCP_USERID = 'netsdev'
|
||||
def DOCKER_IMAGE = 'nets-dev/skti-nets'
|
||||
def K8S_NAMESPACE = 'nets-prd'
|
||||
def VERSION = 'prod'
|
||||
|
||||
timestamps {
|
||||
podTemplate(label:label,
|
||||
serviceAccount: "zcp-system-sa-${ZCP_USERID}",
|
||||
containers: [
|
||||
containerTemplate(name: 'jnlp', image: 'skti-etrm-registry.cloudzcp.io/cloudzcp/jnlp-slave:alpine', args:'${computer.jnlpmac} ${computer.name}'),
|
||||
containerTemplate(name: 'maven', image: 'skti-etrm-registry.cloudzcp.io/cloudzcp/maven:3.5.2-jdk-8-alpine', ttyEnabled: true, command: 'cat'),
|
||||
containerTemplate(name: 'docker', image: 'skti-etrm-registry.cloudzcp.io/cloudzcp/docker:17-dind', ttyEnabled: true, command: 'dockerd-entrypoint.sh', privileged: true),
|
||||
containerTemplate(name: 'kubectl', image: 'skti-etrm-registry.cloudzcp.io/cloudzcp/k8s-kubectl:v1.13.6', ttyEnabled: true, command: 'cat')
|
||||
],
|
||||
volumes: [
|
||||
persistentVolumeClaim(mountPath: '/root/.m2', claimName: 'zcp-jenkins-mvn-repo')
|
||||
]) {
|
||||
|
||||
node(label) {
|
||||
stage('SOURCE CHECKOUT') {
|
||||
def repo = checkout scm
|
||||
}
|
||||
|
||||
stage('BUILD MAVEN') {
|
||||
container('maven') {
|
||||
mavenBuild goal: '-Pprd clean generate-sources package -U -Dmaven.test.skip=true', systemProperties:['maven.repo.local':"/root/.m2/${JOB_NAME}"], globalSettingsID: 'MAVEN_GLOBAL_SETTINGS'
|
||||
}
|
||||
}
|
||||
|
||||
stage('BUILD DOCKER IMAGE') {
|
||||
container('docker') {
|
||||
dockerCmd.build tag: "${HARBOR_REGISTRY}/${DOCKER_IMAGE}:PRD-${BUILD_NUMBER}"
|
||||
dockerCmd.push registry: HARBOR_REGISTRY, imageName: DOCKER_IMAGE, imageVersion: "PRD-${BUILD_NUMBER}", credentialsId: "HARBOR_CREDENTIALS"
|
||||
}
|
||||
}
|
||||
|
||||
stage('DEPLOY') {
|
||||
container('kubectl') {
|
||||
kubeCmd.apply file: 'k8s/prd/service.yaml', namespace: K8S_NAMESPACE
|
||||
kubeCmd.apply file: 'k8s/prd/ingress.yaml', namespace: K8S_NAMESPACE
|
||||
yaml.update file: 'k8s/prd/deployment.yaml', update: ['.spec.template.spec.containers[0].image': "${HARBOR_REGISTRY}/${DOCKER_IMAGE}:PRD-${BUILD_NUMBER}"]
|
||||
kubeCmd.apply file: 'k8s/prd/deployment.yaml', wait: 1200, recoverOnFail: false, namespace: K8S_NAMESPACE
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
64
k8s/deployment-redis.yaml
Normal file
64
k8s/deployment-redis.yaml
Normal file
@@ -0,0 +1,64 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
labels:
|
||||
app: redis
|
||||
name: redis-deployment
|
||||
namespace: nets-dev
|
||||
spec:
|
||||
progressDeadlineSeconds: 600
|
||||
replicas: 1
|
||||
revisionHistoryLimit: 10
|
||||
selector:
|
||||
matchLabels:
|
||||
app: redis
|
||||
strategy:
|
||||
rollingUpdate:
|
||||
maxSurge: 1
|
||||
maxUnavailable: 1
|
||||
type: RollingUpdate
|
||||
template:
|
||||
metadata:
|
||||
creationTimestamp: null
|
||||
labels:
|
||||
app: redis
|
||||
spec:
|
||||
tolerations:
|
||||
- effect: NoSchedule
|
||||
key: worker-role
|
||||
operator: Equal
|
||||
value: "dev"
|
||||
affinity:
|
||||
nodeAffinity:
|
||||
requiredDuringSchedulingIgnoredDuringExecution:
|
||||
nodeSelectorTerms:
|
||||
- matchExpressions:
|
||||
- key: worker-role
|
||||
operator: In
|
||||
values:
|
||||
- dev
|
||||
containers:
|
||||
- env:
|
||||
- name: REDIS_PASSWORD
|
||||
value: UUaqsrzV3i
|
||||
image: skti-etrm-registry.cloudzcp.io/nets-public/redis:latest
|
||||
imagePullPolicy: Always
|
||||
name: redis
|
||||
ports:
|
||||
- containerPort: 6379
|
||||
name: redis-port
|
||||
protocol: TCP
|
||||
resources:
|
||||
limits:
|
||||
cpu: "1"
|
||||
memory: 1Gi
|
||||
requests:
|
||||
cpu: 500m
|
||||
memory: 256Mi
|
||||
terminationMessagePath: /dev/termination-log
|
||||
terminationMessagePolicy: File
|
||||
dnsPolicy: ClusterFirst
|
||||
restartPolicy: Always
|
||||
schedulerName: default-scheduler
|
||||
securityContext: {}
|
||||
terminationGracePeriodSeconds: 30
|
||||
99
k8s/deployment.yaml
Normal file
99
k8s/deployment.yaml
Normal file
@@ -0,0 +1,99 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
labels:
|
||||
app: skti-nets
|
||||
name: skti-nets
|
||||
namespace: nets-dev
|
||||
spec:
|
||||
progressDeadlineSeconds: 1200
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
app: skti-nets
|
||||
strategy:
|
||||
type: RollingUpdate
|
||||
rollingUpdate:
|
||||
maxSurge: 1
|
||||
maxUnavailable: 1
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: skti-nets
|
||||
annotations:
|
||||
prometheus.io/scrape: "true"
|
||||
prometheus.io/port: "8090"
|
||||
prometheus.io/path: /prometheus
|
||||
spec:
|
||||
imagePullSecrets:
|
||||
- name: harbor-secret
|
||||
volumes:
|
||||
- name: uploadpath
|
||||
persistentVolumeClaim:
|
||||
claimName: nets-dev-nfs-pvc
|
||||
hostAliases:
|
||||
- hostnames:
|
||||
- apiportal.skinnovation.com
|
||||
- api.skinnovation.com
|
||||
ip: 10.178.229.94
|
||||
- hostnames:
|
||||
- sso.skcorp.com
|
||||
ip: 168.154.6.203
|
||||
tolerations:
|
||||
- effect: NoSchedule
|
||||
key: worker-role
|
||||
operator: Equal
|
||||
value: "dev"
|
||||
affinity:
|
||||
nodeAffinity:
|
||||
requiredDuringSchedulingIgnoredDuringExecution:
|
||||
nodeSelectorTerms:
|
||||
- matchExpressions:
|
||||
- key: worker-role
|
||||
operator: In
|
||||
values:
|
||||
- dev
|
||||
containers:
|
||||
- name: skti-nets
|
||||
image: skti-etrm-registry.cloudzcp.io/nets-dev/skti-nets:latest
|
||||
ports:
|
||||
- containerPort: 8080
|
||||
name: tomcat
|
||||
- containerPort: 8090
|
||||
name: actuator
|
||||
imagePullPolicy: Always
|
||||
readinessProbe:
|
||||
failureThreshold: 10
|
||||
httpGet:
|
||||
path: /view/check
|
||||
port: 8080
|
||||
scheme: HTTP
|
||||
initialDelaySeconds: 720
|
||||
periodSeconds: 10
|
||||
successThreshold: 1
|
||||
timeoutSeconds: 30
|
||||
livenessProbe:
|
||||
failureThreshold: 5
|
||||
httpGet:
|
||||
path: /view/check
|
||||
port: 8080
|
||||
scheme: HTTP
|
||||
initialDelaySeconds: 720
|
||||
periodSeconds: 10
|
||||
successThreshold: 1
|
||||
timeoutSeconds: 30
|
||||
resources:
|
||||
limits:
|
||||
cpu: 1500m
|
||||
memory: 4Gi
|
||||
requests:
|
||||
cpu: 500m
|
||||
memory: 2Gi
|
||||
env:
|
||||
- name: JVM_OPTS
|
||||
value: "-Doracle.jdbc.fanEnabled=false -XX:MetaspaceSize=200m -XX:MaxMetaspaceSize=250m -Xms3072m -Xmx3072m"
|
||||
- name: TZ
|
||||
value: Asia/Seoul
|
||||
volumeMounts:
|
||||
- name: uploadpath
|
||||
mountPath: /nets-storage
|
||||
53
k8s/ingress.yaml
Normal file
53
k8s/ingress.yaml
Normal file
@@ -0,0 +1,53 @@
|
||||
apiVersion: extensions/v1beta1
|
||||
kind: Ingress
|
||||
metadata:
|
||||
annotations:
|
||||
kubernetes.io/ingress.class: private-nginx2
|
||||
nginx.ingress.kubernetes.io/proxy-body-size: 500m
|
||||
nginx.ingress.kubernetes.io/proxy-connect-timeout: "60"
|
||||
nginx.ingress.kubernetes.io/proxy-read-timeout: "120"
|
||||
name: skti-nets-ing
|
||||
namespace: nets-dev
|
||||
spec:
|
||||
ingressClassName: private-nginx2
|
||||
rules:
|
||||
- host: nets-dev.cloudzcp.io
|
||||
http:
|
||||
paths:
|
||||
- backend:
|
||||
serviceName: skti-nets-svc
|
||||
servicePort: 80
|
||||
path: /
|
||||
pathType: ImplementationSpecific
|
||||
- host: netsd.sktinets.com
|
||||
http:
|
||||
paths:
|
||||
- backend:
|
||||
serviceName: skti-nets-svc
|
||||
servicePort: 80
|
||||
path: /
|
||||
pathType: ImplementationSpecific
|
||||
- host: netsad.sktinets.com
|
||||
http:
|
||||
paths:
|
||||
- backend:
|
||||
serviceName: skti-nets-svc
|
||||
servicePort: 80
|
||||
path: /
|
||||
pathType: ImplementationSpecific
|
||||
- host: thord.sktistorm.com
|
||||
http:
|
||||
paths:
|
||||
- backend:
|
||||
serviceName: skti-nets-svc
|
||||
servicePort: 80
|
||||
path: /
|
||||
pathType: ImplementationSpecific
|
||||
- host: thorad.sktistorm.com
|
||||
http:
|
||||
paths:
|
||||
- backend:
|
||||
serviceName: skti-nets-svc
|
||||
servicePort: 80
|
||||
path: /
|
||||
pathType: ImplementationSpecific
|
||||
20
k8s/nfs-pv.yaml
Normal file
20
k8s/nfs-pv.yaml
Normal file
@@ -0,0 +1,20 @@
|
||||
apiVersion: v1
|
||||
kind: PersistentVolume
|
||||
metadata:
|
||||
name: nets-dev-nfs-pv
|
||||
spec:
|
||||
accessModes:
|
||||
- ReadWriteMany
|
||||
capacity:
|
||||
storage: 500Gi
|
||||
claimRef:
|
||||
apiVersion: v1
|
||||
kind: PersistentVolumeClaim
|
||||
name: nets-dev-nfs-pvc
|
||||
namespace: nets-dev
|
||||
nfs:
|
||||
path: /ZCP_NFS_DEV
|
||||
server: 168.154.25.48
|
||||
persistentVolumeReclaimPolicy: Retain
|
||||
storageClassName: manual-dev
|
||||
volumeMode: Filesystem
|
||||
14
k8s/nfs-pvc.yaml
Normal file
14
k8s/nfs-pvc.yaml
Normal file
@@ -0,0 +1,14 @@
|
||||
apiVersion: v1
|
||||
kind: PersistentVolumeClaim
|
||||
metadata:
|
||||
name: nets-dev-nfs-pvc
|
||||
namespace: nets-dev
|
||||
spec:
|
||||
accessModes:
|
||||
- ReadWriteMany
|
||||
resources:
|
||||
requests:
|
||||
storage: 500Gi
|
||||
storageClassName: manual-dev
|
||||
volumeMode: Filesystem
|
||||
volumeName: nets-dev-nfs-pv
|
||||
50
k8s/prd/deployment-redis.yaml
Normal file
50
k8s/prd/deployment-redis.yaml
Normal file
@@ -0,0 +1,50 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
labels:
|
||||
app: redis
|
||||
name: redis-deployment
|
||||
namespace: nets-prd
|
||||
spec:
|
||||
progressDeadlineSeconds: 600
|
||||
replicas: 1
|
||||
revisionHistoryLimit: 10
|
||||
selector:
|
||||
matchLabels:
|
||||
app: redis
|
||||
strategy:
|
||||
rollingUpdate:
|
||||
maxSurge: 1
|
||||
maxUnavailable: 1
|
||||
type: RollingUpdate
|
||||
template:
|
||||
metadata:
|
||||
creationTimestamp: null
|
||||
labels:
|
||||
app: redis
|
||||
spec:
|
||||
containers:
|
||||
- env:
|
||||
- name: REDIS_PASSWORD
|
||||
value: UUaqsrzV3i
|
||||
image: skti-etrm-registry.cloudzcp.io/nets-public/redis:latest
|
||||
imagePullPolicy: Always
|
||||
name: redis
|
||||
ports:
|
||||
- containerPort: 6379
|
||||
name: redis-port
|
||||
protocol: TCP
|
||||
resources:
|
||||
limits:
|
||||
cpu: 2000m
|
||||
memory: 2Gi
|
||||
requests:
|
||||
cpu: 2000m
|
||||
memory: 2Gi
|
||||
terminationMessagePath: /dev/termination-log
|
||||
terminationMessagePolicy: File
|
||||
dnsPolicy: ClusterFirst
|
||||
restartPolicy: Always
|
||||
schedulerName: default-scheduler
|
||||
securityContext: {}
|
||||
terminationGracePeriodSeconds: 30
|
||||
100
k8s/prd/deployment.yaml
Normal file
100
k8s/prd/deployment.yaml
Normal file
@@ -0,0 +1,100 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
labels:
|
||||
app: skti-nets
|
||||
name: skti-nets
|
||||
namespace: nets-prd
|
||||
spec:
|
||||
replicas: 3
|
||||
selector:
|
||||
matchLabels:
|
||||
app: skti-nets
|
||||
strategy:
|
||||
type: RollingUpdate
|
||||
rollingUpdate:
|
||||
maxSurge: 1
|
||||
maxUnavailable: 1
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: skti-nets
|
||||
annotations:
|
||||
prometheus.io/scrape: "true"
|
||||
prometheus.io/port: "8090"
|
||||
prometheus.io/path: /prometheus
|
||||
spec:
|
||||
dnsPolicy: ClusterFirst
|
||||
imagePullSecrets:
|
||||
- name: harbor-secret
|
||||
volumes:
|
||||
- name: uploadpath
|
||||
persistentVolumeClaim:
|
||||
claimName: nets-prd-nfs-pvc
|
||||
hostAliases:
|
||||
- ip: "10.178.89.70"
|
||||
hostnames:
|
||||
- "apiportal.skinnovation.com"
|
||||
- "api.skinnovation.com"
|
||||
- ip: "168.154.6.203"
|
||||
hostnames:
|
||||
- "sso.skcorp.com"
|
||||
- ip: "10.178.78.245"
|
||||
hostnames:
|
||||
- "thor.sktistorm.com"
|
||||
affinity:
|
||||
podAntiAffinity:
|
||||
preferredDuringSchedulingIgnoredDuringExecution:
|
||||
- podAffinityTerm:
|
||||
labelSelector:
|
||||
matchExpressions:
|
||||
- key: worker-role
|
||||
operator: In
|
||||
values:
|
||||
- prod
|
||||
topologyKey: "kubernetes.io/hostname"
|
||||
weight: 100
|
||||
containers:
|
||||
- name: skti-nets
|
||||
image: skti-etrm-registry.cloudzcp.io/nets-dev/skti-nets:latest
|
||||
ports:
|
||||
- containerPort: 8080
|
||||
name: tomcat
|
||||
- containerPort: 8090
|
||||
name: actuator
|
||||
imagePullPolicy: Always
|
||||
readinessProbe:
|
||||
failureThreshold: 10
|
||||
httpGet:
|
||||
path: /view/check
|
||||
port: 8080
|
||||
scheme: HTTP
|
||||
initialDelaySeconds: 540
|
||||
periodSeconds: 10
|
||||
successThreshold: 1
|
||||
timeoutSeconds: 30
|
||||
livenessProbe:
|
||||
failureThreshold: 5
|
||||
httpGet:
|
||||
path: /view/check
|
||||
port: 8080
|
||||
scheme: HTTP
|
||||
initialDelaySeconds: 540
|
||||
periodSeconds: 10
|
||||
successThreshold: 1
|
||||
timeoutSeconds: 30
|
||||
resources:
|
||||
limits:
|
||||
cpu: 3500m
|
||||
memory: 12Gi
|
||||
requests:
|
||||
cpu: 1000m
|
||||
memory: 2Gi
|
||||
env:
|
||||
- name: JVM_OPTS
|
||||
value: "-Doracle.jdbc.fanEnabled=false -XX:MetaspaceSize=200m -XX:MaxMetaspaceSize=250m -Xms4096m -Xmx10240m"
|
||||
- name: TZ
|
||||
value: Asia/Seoul
|
||||
volumeMounts:
|
||||
- name: uploadpath
|
||||
mountPath: /nets-storage
|
||||
45
k8s/prd/ingress.yaml
Normal file
45
k8s/prd/ingress.yaml
Normal file
@@ -0,0 +1,45 @@
|
||||
apiVersion: extensions/v1beta1
|
||||
kind: Ingress
|
||||
metadata:
|
||||
annotations:
|
||||
kubernetes.io/ingress.class: private-nginx2
|
||||
nginx.ingress.kubernetes.io/proxy-body-size: 500m
|
||||
nginx.ingress.kubernetes.io/proxy-connect-timeout: "60"
|
||||
nginx.ingress.kubernetes.io/proxy-read-timeout: "120"
|
||||
name: skti-nets-ing
|
||||
namespace: nets-prd
|
||||
spec:
|
||||
ingressClassName: private-nginx2
|
||||
rules:
|
||||
- host: nets.sktinets.com
|
||||
http:
|
||||
paths:
|
||||
- backend:
|
||||
serviceName: skti-nets-svc
|
||||
servicePort: 80
|
||||
path: /
|
||||
pathType: ImplementationSpecific
|
||||
- host: netsa.sktinets.com
|
||||
http:
|
||||
paths:
|
||||
- backend:
|
||||
serviceName: skti-nets-svc
|
||||
servicePort: 80
|
||||
path: /
|
||||
pathType: ImplementationSpecific
|
||||
- host: thor.sktistorm.com
|
||||
http:
|
||||
paths:
|
||||
- backend:
|
||||
serviceName: skti-nets-svc
|
||||
servicePort: 80
|
||||
path: /
|
||||
pathType: ImplementationSpecific
|
||||
- host: thora.sktistorm.com
|
||||
http:
|
||||
paths:
|
||||
- backend:
|
||||
serviceName: skti-nets-svc
|
||||
servicePort: 80
|
||||
path: /
|
||||
pathType: ImplementationSpecific
|
||||
20
k8s/prd/nfs-pv.yaml
Normal file
20
k8s/prd/nfs-pv.yaml
Normal file
@@ -0,0 +1,20 @@
|
||||
apiVersion: v1
|
||||
kind: PersistentVolume
|
||||
metadata:
|
||||
name: nets-prd-nfs-pv
|
||||
spec:
|
||||
accessModes:
|
||||
- ReadWriteMany
|
||||
capacity:
|
||||
storage: 1536Gi
|
||||
claimRef:
|
||||
apiVersion: v1
|
||||
kind: PersistentVolumeClaim
|
||||
name: nets-prd-nfs-pvc
|
||||
namespace: nets-prd
|
||||
nfs:
|
||||
path: /ZCP_NFS_PRD
|
||||
server: 168.154.25.48
|
||||
persistentVolumeReclaimPolicy: Retain
|
||||
storageClassName: manual-prd
|
||||
volumeMode: Filesystem
|
||||
14
k8s/prd/nfs-pvc.yaml
Normal file
14
k8s/prd/nfs-pvc.yaml
Normal file
@@ -0,0 +1,14 @@
|
||||
apiVersion: v1
|
||||
kind: PersistentVolumeClaim
|
||||
metadata:
|
||||
name: nets-prd-nfs-pvc
|
||||
namespace: nets-prd
|
||||
spec:
|
||||
accessModes:
|
||||
- ReadWriteMany
|
||||
resources:
|
||||
requests:
|
||||
storage: 1536Gi
|
||||
storageClassName: manual-prd
|
||||
volumeMode: Filesystem
|
||||
volumeName: nets-prd-nfs-pv
|
||||
15
k8s/prd/service-redis.yaml
Normal file
15
k8s/prd/service-redis.yaml
Normal file
@@ -0,0 +1,15 @@
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: skti-redis-svc
|
||||
namespace: nets-prd
|
||||
spec:
|
||||
ports:
|
||||
- name: redis
|
||||
port: 6379
|
||||
protocol: TCP
|
||||
targetPort: redis-port
|
||||
selector:
|
||||
app: redis
|
||||
sessionAffinity: None
|
||||
type: ClusterIP
|
||||
13
k8s/prd/service.yaml
Normal file
13
k8s/prd/service.yaml
Normal file
@@ -0,0 +1,13 @@
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: skti-nets-svc
|
||||
namespace: nets-prd
|
||||
spec:
|
||||
ports:
|
||||
- name: http
|
||||
port: 80
|
||||
protocol: TCP
|
||||
targetPort: 8080
|
||||
selector:
|
||||
app: skti-nets
|
||||
15
k8s/service-redis.yaml
Normal file
15
k8s/service-redis.yaml
Normal file
@@ -0,0 +1,15 @@
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: skti-redis-svc
|
||||
namespace: nets-dev
|
||||
spec:
|
||||
ports:
|
||||
- name: redis
|
||||
port: 6379
|
||||
protocol: TCP
|
||||
targetPort: redis-port
|
||||
selector:
|
||||
app: redis
|
||||
sessionAffinity: None
|
||||
type: ClusterIP
|
||||
13
k8s/service.yaml
Normal file
13
k8s/service.yaml
Normal file
@@ -0,0 +1,13 @@
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: skti-nets-svc
|
||||
namespace: nets-dev
|
||||
spec:
|
||||
ports:
|
||||
- name: http
|
||||
port: 80
|
||||
protocol: TCP
|
||||
targetPort: 8080
|
||||
selector:
|
||||
app: skti-nets
|
||||
BIN
lib/com/sap/sapjco/3.1.4/libsapjco3.so
Normal file
BIN
lib/com/sap/sapjco/3.1.4/libsapjco3.so
Normal file
Binary file not shown.
BIN
lib/com/sap/sapjco/3.1.4/sapjco3.dll
Normal file
BIN
lib/com/sap/sapjco/3.1.4/sapjco3.dll
Normal file
Binary file not shown.
BIN
lib/com/sap/sapjco/3.1.4/sapjco3.jar
Normal file
BIN
lib/com/sap/sapjco/3.1.4/sapjco3.jar
Normal file
Binary file not shown.
0
lib/com/sap/sapjco/3.1.4/sapjco3.pom
Normal file
0
lib/com/sap/sapjco/3.1.4/sapjco3.pom
Normal file
478
pom.xml
Normal file
478
pom.xml
Normal file
@@ -0,0 +1,478 @@
|
||||
<?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 http://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>1.5.15.RELEASE</version>
|
||||
<relativePath /> <!-- lookup parent from repository -->
|
||||
</parent>
|
||||
|
||||
<groupId>com.skti</groupId>
|
||||
<artifactId>skti-nets</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>SKTI NETS</name>
|
||||
<description>SK Innovation New Energy Trading System</description>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
<java.version>1.8</java.version>
|
||||
<hibernate.version>5.2.10.Final</hibernate.version>
|
||||
<project.lib.path>${basedir}/src/main/resources/lib</project.lib.path>
|
||||
</properties>
|
||||
|
||||
<distributionManagement>
|
||||
<repository>
|
||||
<id>releases</id>
|
||||
<name>releases</name>
|
||||
<url>https://nexus.cloudzcp.io/repository/maven-ski-ertm-releases/</url>
|
||||
</repository>
|
||||
<snapshotRepository>
|
||||
<id>snapshots</id>
|
||||
<name>snapshots</name>
|
||||
<url>https://nexus.cloudzcp.io/repository/maven-ski-etrm-snapshots/</url>
|
||||
</snapshotRepository>
|
||||
</distributionManagement>
|
||||
|
||||
<!-- <repositories> -->
|
||||
<!-- <repository> -->
|
||||
<!-- <id>nets-project</id> -->
|
||||
<!-- <name>external jars</name> -->
|
||||
<!-- <url>file://${project.basedir}/src/main/resources/lib</url> -->
|
||||
<!-- </repository> -->
|
||||
|
||||
<!-- <repository> -->
|
||||
<!-- <id>nets-jenkins</id> -->
|
||||
<!-- <name>external-jar-jenkins</name> -->
|
||||
<!-- <url>file://${JENKINS_HOME}/jobs/${JOB_NAME}/workspace/lib</url> -->
|
||||
<!-- </repository> -->
|
||||
<!-- </repositories> -->
|
||||
|
||||
<dependencies>
|
||||
<!-- Spring Boot -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-configuration-processor</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
<!-- AOP -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-aop</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- Validation -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-validation</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- Spring Security -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-security</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- SSO -->
|
||||
<!-- 이 라이브러리는 maven central에서는 제공하지 않고 있기 때문에, 별도nexus에 등록하여 제공받아야함. -->
|
||||
<dependency>
|
||||
<groupId>jsso</groupId>
|
||||
<artifactId>nsso-domain-15</artifactId>
|
||||
<version>6.7.0-SNAPSHOT</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.lib.path}/nsso-domain-15-6.7.0-SNAPSHOT.jar</systemPath>
|
||||
</dependency>
|
||||
|
||||
<!-- jdbc -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-jdbc</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- h2database -->
|
||||
<dependency>
|
||||
<groupId>com.h2database</groupId>
|
||||
<artifactId>h2</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- Mybatis -->
|
||||
<dependency>
|
||||
<groupId>org.mybatis.spring.boot</groupId>
|
||||
<artifactId>mybatis-spring-boot-starter</artifactId>
|
||||
<version>1.3.2</version>
|
||||
</dependency>
|
||||
|
||||
<!-- JPA -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-jpa</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- JPA - Date json format 변경을 위해 사용 -->
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.datatype</groupId>
|
||||
<artifactId>jackson-datatype-jsr310</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.jaxrs</groupId>
|
||||
<artifactId>jackson-jaxrs-json-provider</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- JPA - toString 순환참조 방지 -->
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
<version>3.7</version>
|
||||
</dependency>
|
||||
|
||||
<!-- JPA - Native Query Mapper -->
|
||||
<dependency>
|
||||
<groupId>ch.simas.qlrm</groupId>
|
||||
<artifactId>qlrm</artifactId>
|
||||
<version>1.7.1</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Model Mapper : 사용예 )DTO 를 Entity 로 변환 -->
|
||||
<dependency>
|
||||
<groupId>org.modelmapper</groupId>
|
||||
<artifactId>modelmapper</artifactId>
|
||||
<version>2.1.0</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Thymeleaf -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-thymeleaf</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- Swagger 2 -->
|
||||
<dependency>
|
||||
<groupId>io.springfox</groupId>
|
||||
<artifactId>springfox-swagger2</artifactId>
|
||||
<version>2.9.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.springfox</groupId>
|
||||
<artifactId>springfox-swagger-ui</artifactId>
|
||||
<version>2.9.2</version>
|
||||
</dependency>
|
||||
|
||||
<!-- CUID -->
|
||||
<dependency>
|
||||
<groupId>cool.graph</groupId>
|
||||
<artifactId>cuid-java</artifactId>
|
||||
<version>0.1.1</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Time 관련 -->
|
||||
<dependency>
|
||||
<groupId>joda-time</groupId>
|
||||
<artifactId>joda-time</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- Lombok -->
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- jdbc -->
|
||||
<!-- 이 라이브러리는 maven central에서는 제공하지 않고 있기 때문에, 별도nexus에 등록하여 제공받아야함. -->
|
||||
<dependency>
|
||||
<groupId>com.oracle.database.jdbc</groupId>
|
||||
<artifactId>ojdbc8</artifactId>
|
||||
<version>12.2.0.1</version>
|
||||
</dependency>
|
||||
|
||||
<!-- 이 라이브러리는 maven central에서는 제공하지 않고 있기 때문에, 별도nexus에 등록하여 제공받아야함. -->
|
||||
<!-- <dependency> -->
|
||||
<!-- <groupId>com.microsoft.sqlserver</groupId> -->
|
||||
<!-- <artifactId>sqljdbc4</artifactId> -->
|
||||
<!-- <version>4.0</version> -->
|
||||
<!-- </dependency> -->
|
||||
|
||||
<!-- 암호화 - RSA -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.security</groupId>
|
||||
<artifactId>spring-security-rsa</artifactId>
|
||||
<version>1.0.7.RELEASE</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Redis -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-redis</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- Redis Session -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.session</groupId>
|
||||
<artifactId>spring-session-data-redis</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- EhCache -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-cache</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.sf.ehcache</groupId>
|
||||
<artifactId>ehcache</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- XSS -->
|
||||
<dependency>
|
||||
<groupId>com.navercorp.lucy</groupId>
|
||||
<artifactId>lucy-xss</artifactId>
|
||||
<version>1.6.3</version>
|
||||
</dependency>
|
||||
|
||||
<!-- JSP -->
|
||||
<!-- JSP 설정 가이드 -->
|
||||
<!-- <dependency> -->
|
||||
<!-- <groupId>org.apache.tomcat.embed</groupId> -->
|
||||
<!-- <artifactId>tomcat-embed-jasper</artifactId> -->
|
||||
<!-- </dependency> -->
|
||||
<!-- <dependency> -->
|
||||
<!-- <groupId>javax.servlet</groupId> -->
|
||||
<!-- <artifactId>jstl</artifactId> -->
|
||||
<!-- </dependency> -->
|
||||
|
||||
<!-- Apache CXF -->
|
||||
<dependency>
|
||||
<groupId>org.apache.cxf</groupId>
|
||||
<artifactId>cxf-spring-boot-starter-jaxws</artifactId>
|
||||
<version>3.2.7</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.cxf</groupId>
|
||||
<artifactId>cxf-rt-frontend-jaxws</artifactId>
|
||||
<version>3.2.7</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.cxf</groupId>
|
||||
<artifactId>cxf-spring-boot-starter-jaxrs</artifactId>
|
||||
<version>3.2.7</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.cxf</groupId>
|
||||
<artifactId>cxf-rt-transports-http</artifactId>
|
||||
<version>3.2.7</version>
|
||||
</dependency>
|
||||
<!-- Apache POI -->
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi</artifactId>
|
||||
<version>4.1.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi-ooxml</artifactId>
|
||||
<version>4.1.2</version>
|
||||
</dependency>
|
||||
|
||||
<!-- QueryDls -->
|
||||
<dependency>
|
||||
<groupId>com.querydsl</groupId>
|
||||
<artifactId>querydsl-apt</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.querydsl</groupId>
|
||||
<artifactId>querydsl-jpa</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.querydsl</groupId>
|
||||
<artifactId>querydsl-sql-spring</artifactId>
|
||||
<version>${querydsl.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.hibernate</groupId>
|
||||
<artifactId>hibernate-validator</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.hibernate</groupId>
|
||||
<artifactId>hibernate-java8</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>springloaded</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- SMTP 메일 발송 -->
|
||||
<dependency>
|
||||
<groupId>com.sun.mail</groupId>
|
||||
<artifactId>javax.mail</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- @see: http://nexus.skinnovation.com:8987/#browse/search=keyword%3D%22com%5C%2Fsap%5C%2Fsapjco%5C%2F3%5C.0%5C.11%5C%2Fsapjco%5C-3%5C.0%5C.11%5C.jar%22:4b378653591c67220a3dffdedfdf40ef -->
|
||||
<dependency>
|
||||
<groupId>com.sap</groupId>
|
||||
<artifactId>sapjco</artifactId>
|
||||
<version>3.1.4</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.lib.path}/sapjco3.jar</systemPath>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>local</id>
|
||||
<activation>
|
||||
<activeByDefault>true</activeByDefault>
|
||||
</activation>
|
||||
<properties>
|
||||
<build.profile.id>local</build.profile.id>
|
||||
<profileActive>local</profileActive>
|
||||
<maven.test.skip>true</maven.test.skip>
|
||||
</properties>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>dev</id>
|
||||
<properties>
|
||||
<build.profile.id>dev</build.profile.id>
|
||||
<profileActive>dev</profileActive>
|
||||
<maven.test.skip>true</maven.test.skip>
|
||||
</properties>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>prd</id>
|
||||
<properties>
|
||||
<build.profile.id>prd</build.profile.id>
|
||||
<profileActive>prd</profileActive>
|
||||
<maven.test.skip>true</maven.test.skip>
|
||||
</properties>
|
||||
</profile>
|
||||
</profiles>
|
||||
|
||||
<build>
|
||||
<finalName>skti-nets-${project.version}</finalName>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<configuration>
|
||||
<layout>ZIP</layout>
|
||||
<includeSystemScope>true</includeSystemScope>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<!-- LICENSE -->
|
||||
<plugin>
|
||||
<groupId>com.mycila</groupId>
|
||||
<artifactId>license-maven-plugin</artifactId>
|
||||
<version>3.0</version>
|
||||
<configuration>
|
||||
<header>src/main/resources/config/license-header.txt</header>
|
||||
<includes>
|
||||
<include>src/main/java/**/*.java</include>
|
||||
<include>src/test/java/**/*.java</include>
|
||||
<include>src/main/resources/**/*.css</include>
|
||||
<include>src/main/resources/**/*.js</include>
|
||||
<include>src/main/resources/**/*.html</include>
|
||||
</includes>
|
||||
<excludes>
|
||||
<exclude>src/main/resources/static/skiaf/alopex/**</exclude>
|
||||
<exclude>src/main/resources/static/skiaf/script/jquery/**</exclude>
|
||||
</excludes>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>check</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>com.mysema.maven</groupId>
|
||||
<artifactId>apt-maven-plugin</artifactId>
|
||||
<version>1.1.3</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>process</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<outputDirectory>target/generated-sources/java</outputDirectory>
|
||||
<processor>com.querydsl.apt.jpa.JPAAnnotationProcessor</processor>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<encoding>UTF-8</encoding>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<!-- <plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-install-plugin</artifactId>
|
||||
<version>2.5.2</version>
|
||||
<configuration>
|
||||
<file>${project.basedir}/lib/com/sap/sapjco/3.1.4/sapjco3.jar</file>
|
||||
<groupId>com.sap</groupId>
|
||||
<artifactId>sapjco</artifactId>
|
||||
<version>1.0</version>
|
||||
<packaging>jar</packaging>
|
||||
<file>${project.basedir}/src/main/resources/lib/sapjco3.jar</file>
|
||||
<generatePom>true</generatePom>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>inst_sapjco</id>
|
||||
<goals>
|
||||
<goal>install-file</goal>
|
||||
</goals>
|
||||
<phase>install</phase>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin> -->
|
||||
|
||||
<!-- <plugin> -->
|
||||
<!-- <groupId>org.hibernate.orm.tooling</groupId> -->
|
||||
<!-- <artifactId>hibernate-enhance-maven-plugin</artifactId> -->
|
||||
<!-- <version>${hibernate.version}</version> -->
|
||||
<!-- <executions> -->
|
||||
<!-- <execution> -->
|
||||
<!-- <configuration> -->
|
||||
<!-- <enableLazyInitialization>true</enableLazyInitialization> -->
|
||||
<!-- </configuration> -->
|
||||
<!-- <goals> -->
|
||||
<!-- <goal>enhance</goal> -->
|
||||
<!-- </goals> -->
|
||||
<!-- </execution> -->
|
||||
<!-- </executions> -->
|
||||
<!-- </plugin> -->
|
||||
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
||||
28
sql/FN_CXL_GEN_INDICATOR_VALUE_oracle.sql
Normal file
28
sql/FN_CXL_GEN_INDICATOR_VALUE_oracle.sql
Normal file
@@ -0,0 +1,28 @@
|
||||
|
||||
/*
|
||||
|
||||
select FN_CXL_GEN_INDICATOR_VALUE('stl_event_type_ind', '14')
|
||||
|
||||
*/
|
||||
-- =============================================
|
||||
CREATE OR REPLACE FUNCTION [FN_CXL_GEN_INDICATOR_VALUE]
|
||||
(
|
||||
P_IND_NAME NVARCHAR2
|
||||
,P_IND_VALUE NVARCHAR2
|
||||
)
|
||||
RETURN VARCHAR2
|
||||
AS
|
||||
BEGIN
|
||||
RET_VALUE VARCHAR2(50) := ''
|
||||
|
||||
IF P_IND_VALUE IS NOT NULL AND P_IND_VALUE <> '' THEN
|
||||
SELECT ind_value_name
|
||||
INTO RET_VALUE
|
||||
FROM GEN_INDICATOR_VALUE
|
||||
WHERE ind_name = P_IND_NAME
|
||||
AND ind_value = P_IND_VALUE;
|
||||
END IF;
|
||||
RETURN RET_VALUE;
|
||||
|
||||
END
|
||||
/
|
||||
153
sql/NewSmallFunctions.sql
Normal file
153
sql/NewSmallFunctions.sql
Normal file
@@ -0,0 +1,153 @@
|
||||
CREATE OR REPLACE FUNCTION getFX_VALUE(
|
||||
P_CURR_CD VARCHAR2
|
||||
, P_INVOICE_DT DATE /* NULL 인 경우 EXTENDED FX VALUE */
|
||||
)
|
||||
RETURN NUMBER
|
||||
IS
|
||||
RET_VALUE NUMBER := 0;
|
||||
BEGIN
|
||||
IF (P_INVOICE_DT IS NULL) THEN
|
||||
SELECT FX_VALUE INTO RET_VALUE
|
||||
FROM MKT_FX_QUOTE FQ
|
||||
INNER JOIN MKT_FX_QUOTE_DEFINITION FQD ON FQ.FX_QUOTE_DEF_NUM = FQD.FX_QUOTE_DEF_NUM
|
||||
WHERE FQD.FX_QUOTE_DEF_CD = P_CURR_CD + '-USD'
|
||||
AND FQ.QUOTE_DT = (SELECT MAX(XFQ.QUOTE_DT)
|
||||
FROM MKT_FX_QUOTE XFQ
|
||||
INNER JOIN MKT_FX_QUOTE_DEFINITION XFQD ON XFQ.FX_QUOTE_DEF_NUM = XFQD.FX_QUOTE_DEF_NUM
|
||||
WHERE XFQD.FX_QUOTE_DEF_CD = P_CURR_CD+'-USD'
|
||||
AND XFQ.QUOTE_DT BETWEEN TO_DATE(TO_CHAR(P_INVOICE_DT, 'YYYYMM') + '01', 'YYYYMMDD') AND P_INVOICE_DT);
|
||||
ELSE
|
||||
SELECT FX_VALUE INTO RET_VALUE
|
||||
FROM MKT_FX_QUOTE FQ
|
||||
INNER JOIN MKT_FX_QUOTE_DEFINITION FQD ON FQ.FX_QUOTE_DEF_NUM = FQD.FX_QUOTE_DEF_NUM
|
||||
WHERE FQD.FX_QUOTE_DEF_CD = P_CURR_CD + '-USD'
|
||||
AND FQ.QUOTE_DT = (SELECT MAX(XFQ.QUOTE_DT)
|
||||
FROM MKT_FX_QUOTE XFQ
|
||||
INNER JOIN MKT_FX_QUOTE_DEFINITION XFQD ON XFQ.FX_QUOTE_DEF_NUM = XFQD.FX_QUOTE_DEF_NUM
|
||||
WHERE XFQD.FX_QUOTE_DEF_CD = P_CURR_CD+'-USD'
|
||||
AND XFQ.QUOTE_DT BETWEEN TO_DATE(TO_CHAR(SYSDATE, 'YYYYMM') + '01', 'YYYYMMDD') AND SYSDATE);
|
||||
END IF;
|
||||
|
||||
RETURN RET_VALUE;
|
||||
END;
|
||||
|
||||
CREATE OR REPLACE FUNCTION currencyAmount(
|
||||
P_CURR_CD VARCHAR2
|
||||
, P_AMOUNT NUMBER
|
||||
)
|
||||
RETURN NUMBER
|
||||
IS
|
||||
RET_VALUE NUMBER(25,5) := NULL;
|
||||
BEGIN
|
||||
RET_VALUE := (CASE WHEN P_CURR_CD = 'USC' THEN NVL(P_AMOUNT,0) / 100 ELSE NVL(P_AMOUNT,0) END ) ;
|
||||
RETURN RET_VALUE ;
|
||||
END;
|
||||
|
||||
CREATE OR REPLACE FUNCTION currencyExtendedAmount(
|
||||
P_CURR_CD VARCHAR2
|
||||
, P_AMOUNT NUMBER
|
||||
)
|
||||
RETURN NUMBER
|
||||
IS
|
||||
RET_VALUE NUMBER(25,5) := NULL;
|
||||
BEGIN
|
||||
RET_VALUE := (CASE WHEN P_CURR_CD = 'USC' THEN NVL(P_AMOUNT,0) / 100 ELSE NVL(P_AMOUNT,0) END ) ;
|
||||
RETURN RET_VALUE ;
|
||||
END;
|
||||
|
||||
|
||||
CREATE OR REPLACE FUNCTION dateDiff(
|
||||
P_RETURN_TYPE VARCHAR2
|
||||
, P_FROM DATE
|
||||
, P_TO DATE
|
||||
)
|
||||
RETURN NUMBER
|
||||
IS
|
||||
RET_VALUE NUMBER(12) := NULL;
|
||||
BEGIN
|
||||
IF (P_RETURN_TYPE = 'DD') THEN
|
||||
RET_VALUE := TRUNC(P_TO - P_FROM) ;
|
||||
ELSE
|
||||
RET_VALUE := TRUNC(P_TO - P_FROM) ;
|
||||
END IF;
|
||||
RETURN RET_VALUE ;
|
||||
END;
|
||||
|
||||
|
||||
|
||||
CREATE OR REPLACE FUNCTION selectInvoiceNumber(
|
||||
P_TRADE_NUM NUMBER
|
||||
)
|
||||
RETURN VARCHAR2
|
||||
IS
|
||||
RET_VALUE VARCHAR2(3000) := NULL ;
|
||||
BEGIN
|
||||
|
||||
SELECT
|
||||
LISTAGG(X.INVOICE_NUMBER,',') WITHIN GROUP (ORDER BY X.TRADE_NUM ) INVOICE_NUMBER
|
||||
INTO RET_VALUE
|
||||
FROM (
|
||||
SELECT DISTINCT
|
||||
B.TRADE_NUM , B.INVOICE_NUMBER
|
||||
FROM REF_CREDIT_LIMIT_DEFINITION A
|
||||
INNER JOIN STL_ITEM_HDR B ON A.COMPANY_NUM = B.COUNTERPART_COMPANY_NUM
|
||||
LEFT JOIN STL_INVOICE_DETAIL C ON B.ITEM_HDR_NUM = C.ITEM_HDR_NUM AND C.INV_DETAIL_STATUS_IND = 1
|
||||
LEFT JOIN STL_INVOICE_HDR D ON C.INVOICE_HDR_NUM = D.INVOICE_HDR_NUM
|
||||
AND TO_CHAR(D.INVOICE_STATUS_IND) IN (
|
||||
SELECT REGEXP_SUBSTR(NVL('#{V_INVOICE_STATUS_IND}',''), '[^,]+', 1, LEVEL) FROM DUAL
|
||||
CONNECT BY REGEXP_SUBSTR(NVL('#{V_INVOICE_STATUS_IND}',''), '[^,]+', 1, LEVEL) IS NOT NULL )
|
||||
INNER JOIN TRD_TERM F ON B.trade_num = F.trade_num
|
||||
INNER JOIN REF_PAYMENT_TERM E ON B.settle_payment_term_cd = E.payment_term_cd
|
||||
INNER JOIN TRD_HEADER G ON F.trade_num = G.trade_num AND F.internal_side_ind = G.internal_side_ind --2014.02.25 추가
|
||||
WHERE 1=1
|
||||
AND B.TRADE_NUM = P_TRADE_NUM
|
||||
AND B.ITEM_STATUS_IND <> 0
|
||||
AND B.PAYMENT_STATUS_IND <> 2
|
||||
AND (SELECT COUNT(*)
|
||||
FROM STL_ITEM_HDR
|
||||
WHERE PAYMENT_STATUS_IND = 2
|
||||
AND ITEM_STATUS_IND IN (2, 3)
|
||||
AND EXTERNAL_KEY = B.EXTERNAL_KEY) = 0
|
||||
AND B.INTERNAL_COMPANY_NUM NOT IN (1668, 2307, 2142)
|
||||
AND B.COST_TYPE_CD IN
|
||||
( 'FB Chartering_CR'
|
||||
, 'FB Chartering_DR'
|
||||
, 'FB Chartering'
|
||||
, 'Primary Settlement'
|
||||
, 'Provisional Price'
|
||||
, 'Provisional Price Rv'
|
||||
, 'Purchase Adjustment'
|
||||
, 'Sales Adjustment'
|
||||
, 'Barging Fee'
|
||||
, 'Barging Cost'
|
||||
, 'Barging Cost_CR'
|
||||
, 'Barging Cost_DR')
|
||||
AND ( NVL(B.INSTRUMENT_CLASS_CD, '') = 'Physical' OR NVL(G.CLEARED_IND, -1) = -1 )
|
||||
AND ( NVL(B.INSTRUMENT_CLASS_CD, '') <> 'Physical'
|
||||
OR (
|
||||
UPPER(NVL(B.DEAL_ID2, '')) NOT LIKE '%FPP%'
|
||||
AND UPPER(NVL(B.DEAL_ID2, '')) NOT LIKE '%TARS%'
|
||||
AND UPPER(NVL(B.DEAL_ID2, '')) NOT LIKE '%KNOCK OUT%'
|
||||
)
|
||||
OR NVL( TO_CHAR( B.UNDERLYING_START_DT, 'YYYYMMDD'), '19000101') <= TO_CHAR( SYSDATE, 'YYYYMMDD')
|
||||
)
|
||||
AND B.TRADE_STATUS_IND NOT IN (5, 6) /* 5:Void , 6:What If */
|
||||
AND ( NVL(B.INSTRUMENT_CLASS_CD, '') <> 'Physical'
|
||||
OR A.CREDIT_NETTING_IND = 1
|
||||
OR B.DELIVERY_TYPE_IND IN (2, 3)
|
||||
OR ((A.CREDIT_NETTING_IND = 0 OR A.CREDIT_NETTING_IND IS NULL) AND B.STL_BUY_SELL_IND = -1)
|
||||
)
|
||||
AND E.INTERFACE_VALUE_CODE = 'TT'
|
||||
AND B.COUNTERPART_COMPANY_NUM IN (
|
||||
SELECT COMPANY_NUM FROM REF_COMPANY
|
||||
WHERE ( COMPANY_TYPE_IND = '0' AND COMPANY_NUM NOT IN (3739,3743,3745) )
|
||||
OR ( COMPANY_TYPE_IND = '10' AND COMPANY_CD NOT IN ( 'SKEE', 'SKEA','SKEI' ))
|
||||
)
|
||||
AND B.SPLIT_ITEM_IND <> '1' /* 0:N/A, 1:Source, 2:Split. Split 된 경우, Source는 신용 산출 대상에서 제외. split 항목과 중복으로 계산됨 */
|
||||
) X
|
||||
GROUP BY X.TRADE_NUM;
|
||||
|
||||
RETURN RET_VALUE ;
|
||||
|
||||
END;
|
||||
/
|
||||
60
sql/SP_COMMON_SEARCH_CODE2_oracle.sql
Normal file
60
sql/SP_COMMON_SEARCH_CODE2_oracle.sql
Normal file
@@ -0,0 +1,60 @@
|
||||
|
||||
/*
|
||||
exec SP_COMMON_SEARCH_CODE2 'STRATEGY_NUM', '', ''
|
||||
exec SP_COMMON_SEARCH_CODE2 'INDICATOR', 'trade_status_ind', '10'
|
||||
*/
|
||||
/*
|
||||
-- =============================================
|
||||
-- SQLINES LICENSE FOR EVALUATION USE ONLY
|
||||
|
||||
CREATE OR REPLACE PROCEDURE SP_COMMON_SEARCH_CODE2 (
|
||||
-- Add the parameters for the stored procedure here
|
||||
P_CODE_GBN NVARCHAR2(20),
|
||||
P_SQL_CONDITION1 NVARCHAR(MAX),
|
||||
P_SQL_CONDITION2 NVARCHAR(MAX))
|
||||
AS
|
||||
-- SET NOCOUNT ON added to prevent extra result sets from
|
||||
-- interfering with SELECT statements.
|
||||
|
||||
-- Insert statements for procedure here
|
||||
|
||||
V_SQL NVARCHAR(MAX);
|
||||
V_FIRST_SQL NVARCHAR(MAX);
|
||||
V_LAST_SQL NVARCHAR(MAX);
|
||||
V_WHERE_SQL1 NVARCHAR(MAX) := '';
|
||||
V_WHERE_SQL2 NVARCHAR(MAX) := '';
|
||||
V_PARAM_DEFIN NVARCHAR2(1000) := '';BEGIN
|
||||
|
||||
*/
|
||||
|
||||
---------------------------------------------------------------------------------------------------------------
|
||||
|
||||
SELECT
|
||||
'STRATEGY_NUM' AS CODE_GBN
|
||||
, STRATEGY_NUM AS CODE
|
||||
, STRATEGY_NAME AS CODE_NM
|
||||
, STRATEGY_NAME AS ORDER_COL
|
||||
FROM ORG_STRATEGY
|
||||
WHERE 1 = 1
|
||||
/* #{P_SQL_CONDITION1} NOT NULL 인 경우 */
|
||||
AND BOOK_CD IN (
|
||||
SELECT REGEXP_SUBSTR(NVL(#{P_SQL_CONDITION1},''),'[^,]+', 1, LEVEL) FROM DUAL
|
||||
CONNECT BY REGEXP_SUBSTR(NVL(#{P_SQL_CONDITION1},''), '[^,]+', 1, LEVEL) IS NOT NULL )
|
||||
/* #{P_SQL_CONDITION2} NOT NULL 인 경우 */
|
||||
AND PORTFOLIO_CD IN (
|
||||
SELECT REGEXP_SUBSTR(NVL(#{P_SQL_CONDITION2},''),'[^,]+', 1, LEVEL) FROM DUAL
|
||||
CONNECT BY REGEXP_SUBSTR(NVL(#{P_SQL_CONDITION2},''), '[^,]+', 1, LEVEL) IS NOT NULL )
|
||||
---------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
SELECT
|
||||
'INDICATOR' AS CODE_GBN
|
||||
, IND_VALUE_NAME AS VALUE
|
||||
FROM CXL_PROD_DB.DBO.GEN_INDICATOR_VALUE
|
||||
WHERE 1=1
|
||||
/* #{P_SQL_CONDITION1} NOT NULL 인 경우 */
|
||||
AND IND_NAME = #{P_SQL_CONDITION1}
|
||||
/* #{P_SQL_CONDITION2} NOT NULL 인 경우 */
|
||||
AND IND_VALUE = #{P_SQL_CONDITION2}
|
||||
|
||||
---------------------------------------------------------------------------------------------------------------
|
||||
182
sql/SP_COMMON_SEARCH_CODE_oracle.sql
Normal file
182
sql/SP_COMMON_SEARCH_CODE_oracle.sql
Normal file
@@ -0,0 +1,182 @@
|
||||
|
||||
-- =============================================
|
||||
-- Author: <Author,,Name>
|
||||
-- Create date: <Create Date,,>
|
||||
-- Description: <Description,,>
|
||||
/*
|
||||
exec SP_COMMON_SEARCH_CODE 'COST_TYPE', ''
|
||||
exec SP_COMMON_SEARCH_CODE 'INTERFACE_VALUE_CODE', ''
|
||||
exec SP_COMMON_SEARCH_CODE 'COMPANY_NUM', ''
|
||||
exec SP_COMMON_SEARCH_CODE 'QUOTE_CD', 'FWD_FO_180_3.5%_FOB_SINGAPORE_'
|
||||
exec SP_COMMON_SEARCH_CODE 'BOOK_CD', ''
|
||||
exec SP_COMMON_SEARCH_CODE 'BOOK_CD_NM', ''
|
||||
exec SP_COMMON_SEARCH_CODE 'LOCATION_NM', ''
|
||||
exec SP_COMMON_SEARCH_CODE 'INTRA_DATE', ''
|
||||
exec SP_COMMON_SEARCH_CODE 'PORTFOLIO_CD', 'ASIA FO,ASIA LD,ASIA MD'
|
||||
exec SP_COMMON_SEARCH_CODE 'TRADER', 'TRADER'
|
||||
exec SP_COMMON_SEARCH_CODE 'CXL_USER_INC_INACT', ''
|
||||
exec SP_COMMON_SEARCH_CODE 'COMMODITY', ''
|
||||
exec SP_COMMON_SEARCH_CODE 'MKT_SNAPSHOT', ''
|
||||
exec SP_COMMON_SEARCH_CODE '', ''
|
||||
*/
|
||||
-- =============================================
|
||||
-- SQLINES LICENSE FOR EVALUATION USE ONLY
|
||||
/*
|
||||
CREATE OR REPLACE PROCEDURE SP_COMMON_SEARCH_CODE (
|
||||
-- Add the parameters for the stored procedure here
|
||||
P_CODE_GBN NVARCHAR2(20),
|
||||
P_SQL_CONDITION NVARCHAR(MAX))
|
||||
AS
|
||||
-- SET NOCOUNT ON added to prevent extra result sets from
|
||||
-- interfering with SELECT statements.
|
||||
|
||||
V_SQL NVARCHAR(MAX);
|
||||
V_FIRST_SQL NVARCHAR(MAX);
|
||||
V_LAST_SQL NVARCHAR(MAX) := '';
|
||||
V_WHERE_SQL NVARCHAR(MAX) := '';
|
||||
V_PARAM_DEFIN NVARCHAR2(1000);
|
||||
BEGIN
|
||||
*/
|
||||
|
||||
/* -- Insert statements for procedure here
|
||||
IF P_CODE_GBN = 'COST_TYPE'
|
||||
THEN
|
||||
V_FIRST_SQL :=
|
||||
' */
|
||||
SELECT
|
||||
'COST_TYPE' AS CODE_GBN
|
||||
, COST_TYPE_CD AS CODE
|
||||
, COST_TYPE_NAME AS CODE_NM
|
||||
, COST_TYPE_NAME AS ORDER_COL
|
||||
FROM REF_COST_TYPE
|
||||
UNION ALL
|
||||
SELECT
|
||||
'INTERFACE_VALUE_CODE' AS CODE_GBN
|
||||
, INTERFACE_VALUE_CODE AS CODE
|
||||
, INTERFACE_VALUE_CODE AS CODE_NM
|
||||
, INTERFACE_VALUE_CODE AS ORDER_COL
|
||||
FROM REF_PAYMENT_TERM
|
||||
GROUP BY INTERFACE_VALUE_CODE
|
||||
UNION ALL
|
||||
SELECT
|
||||
'COMPANY_NUM' AS CODE_GBN
|
||||
, COMPANY_NUM AS CODE
|
||||
, COMPANY_CD AS CODE_NM
|
||||
, COMPANY_CD AS ORDER_COL
|
||||
FROM REF_COMPANY
|
||||
WHERE COMPANY_TYPE_IND = '0'
|
||||
/* P_SQL_CONDITION 값이 있는 경우 */
|
||||
AND COMPANY_NUM IN (
|
||||
SELECT REGEXP_SUBSTR(NVL(#{P_SQL_CONDITION},''),'[^,]+', 1, LEVEL) FROM DUAL
|
||||
CONNECT BY REGEXP_SUBSTR(NVL(#{P_SQL_CONDITION},''), '[^,]+', 1, LEVEL) IS NOT NULL )
|
||||
UNION ALL
|
||||
SELECT
|
||||
'QUOTE_CD' AS CODE_GBN
|
||||
, QUOTE_DEF_CD AS CODE
|
||||
, QUOTE_DEF_CD AS CODE_NM
|
||||
, QUOTE_DEF_CD AS ORDER_COL
|
||||
FROM MKT_QUOTE_DEFINITION
|
||||
UNION ALL
|
||||
SELECT
|
||||
'BOOK_CD' AS CODE_GBN
|
||||
, BOOK_CD AS CODE
|
||||
, BOOK_CD AS CODE_NM
|
||||
, BOOK_CD AS ORDER_COL
|
||||
FROM ORG_STRATEGY
|
||||
WHERE NVL(BOOK_CD, '') <> ''
|
||||
GROUP BY BOOK_CD
|
||||
UNION ALL
|
||||
SELECT
|
||||
'INTRA_DATE' AS CODE_GBN
|
||||
, MAX(CONVERT(NVARCHAR(10), COB_DT, 23)) AS CODE
|
||||
, MKT_SNAPSHOT_CD AS CODE_NM
|
||||
, MKT_SNAPSHOT_CD AS ORDER_COL
|
||||
FROM EOD_LAST_RUN
|
||||
WHERE 1=1
|
||||
GROUP BY MKT_SNAPSHOT_CD
|
||||
UNION ALL
|
||||
SELECT
|
||||
'PORTFOLIO_CD' AS CODE_GBN
|
||||
, PORTFOLIO_CD AS CODE
|
||||
, PORTFOLIO_CD AS CODE_NM
|
||||
, PORTFOLIO_CD AS ORDER_COL
|
||||
FROM ORG_STRATEGY
|
||||
WHERE NVL(PORTFOLIO_CD, '') <> ''
|
||||
GROUP BY PORTFOLIO_CD
|
||||
UNION ALL
|
||||
SELECT
|
||||
'BOOK_CD_NM' AS CODE_GBN
|
||||
, BOOK_CD AS CODE
|
||||
, BOOK_NAME AS CODE_NM
|
||||
, BOOK_CD AS ORDER_COL
|
||||
FROM ORG_BOOK
|
||||
UNION ALL
|
||||
SELECT
|
||||
'MKT_SNAPSHOT' AS CODE_GBN
|
||||
, MKT_SNAPSHOT_CD AS CODE
|
||||
, MKT_SNAPSHOT_NAME AS CODE_NM
|
||||
, MKT_SNAPSHOT_NAME AS ORDER_COL
|
||||
FROM MKT_SNAPSHOT
|
||||
WHERE 1=1
|
||||
AND STATUS_IND = '1'
|
||||
|
||||
ORDER BY CODE_GBN, ORDER_COL
|
||||
|
||||
---------------------------------------------------------------------------------------------------------------
|
||||
|
||||
SELECT
|
||||
'LOCATION_NM' AS CODE_GBN
|
||||
, LOCATION AS CODE_NM
|
||||
FROM ETRM_MIDDLEWARE.DBO.MD_LOCATION
|
||||
ORDER BY LOCATION
|
||||
|
||||
SELECT DISTINCT
|
||||
'PLANT_NM' AS CODE_GBN
|
||||
, VAL_LEV AS PLANT_NM
|
||||
FROM ETRM_MIDDLEWARE.DBO.STORAGE_VAL
|
||||
ORDER BY PLANT_NM
|
||||
---------------------------------------------------------------------------------------------------------------
|
||||
|
||||
SELECT
|
||||
'CXL_USER_INC_INACT' AS CODE_GBN
|
||||
, (LAST_NAME + SPACE(1) + FIRST_NAME) AS TRADER_NM
|
||||
, PERSON_NUM AS TRADER_NUM
|
||||
, LOGIN_CD AS LOGIN_CD
|
||||
FROM CXL_PROD_DB.DBO.REF_PERSON
|
||||
WHERE 1 = 1
|
||||
AND LEFT(LOGIN_CD, 7) NOT IN ('SUPPORT')
|
||||
AND LEFT(LOGIN_CD, 5) NOT IN ('ADMIN')
|
||||
AND PERSON_NUM <> '4'
|
||||
ORDER BY LAST_NAME
|
||||
|
||||
---------------------------------------------------------------------------------------------------------------
|
||||
|
||||
SELECT
|
||||
'TRADER' AS CODE_GBN
|
||||
, (LAST_NAME + ' ' + FIRST_NAME) AS TRADER_NM
|
||||
, PERSON_NUM AS TRADER_NUM
|
||||
, LOGIN_CD AS LOGIN_CD
|
||||
FROM CXL_PROD_DB.DBO.REF_PERSON
|
||||
WHERE 1 = 1
|
||||
AND STATUS_IND = '1'
|
||||
AND LEFT(LOGIN_CD, 2) IN ('SA', 'AG', 'SI')
|
||||
AND LOGIN_CD != 'SAPINTERFACE'
|
||||
AND JOB_TITLE_IND = CASE WHEN NVL(#{P_SQL_CONDITION},'') = '' THEN '1'
|
||||
WHEN NVL(#{P_SQL_CONDITION},'') = 'TRADER' THEN '1'
|
||||
WHEN NVL(#{P_SQL_CONDITION},'') = 'CXL_USER' THEN JOB_TITLE_IND
|
||||
WHEN NVL(#{P_SQL_CONDITION},'') = 'SCHEDULER' THEN '3'
|
||||
ELSE JOB_TITLE_IND
|
||||
END
|
||||
---------------------------------------------------------------------------------------------------------------
|
||||
|
||||
SELECT
|
||||
'COMMODITY' AS CODE_GBN
|
||||
, CMDTY_CD AS CMDTY_CD
|
||||
, CMDTY_NAME AS CMDTY_NM
|
||||
FROM CXL_PROD_DB.DBO.REF_COMMODITY
|
||||
WHERE 1=1
|
||||
AND STATUS_IND = '1'
|
||||
ORDER BY CMDTY_CD
|
||||
|
||||
/
|
||||
|
||||
403
sql/SP_CREDIT_LIMIT_REPORT_DETAIL_oracle.sql
Normal file
403
sql/SP_CREDIT_LIMIT_REPORT_DETAIL_oracle.sql
Normal file
@@ -0,0 +1,403 @@
|
||||
/*
|
||||
FROM MKT_FX_QUOTE
|
||||
FROM ORG_STRATEGY
|
||||
FROM REF_COMPANY
|
||||
FROM REF_CREDIT_LIMIT_DEFINITION
|
||||
FROM REF_PERSON
|
||||
FROM STL_INVOICE_DETAIL
|
||||
FROM STL_ITEM_HDR
|
||||
FROM TRD_HEADER
|
||||
FROM DBO.FN_SPLIT_TF
|
||||
FROM ETRM_MIDDLEWARE.DBO.CS_CREDIT_EXCESS_TRADE
|
||||
FROM MD_CREDIT_ADVANCE_RECEIVED
|
||||
FROM MD_CREDIT_REPORT_EXCEPT_TRADE
|
||||
JOIN MKT_FX_QUOTE_DEFINITION
|
||||
JOIN REF_COMPANY
|
||||
JOIN REF_PAYMENT_TERM
|
||||
JOIN STL_INVOICE_DETAIL
|
||||
JOIN STL_INVOICE_HDR
|
||||
JOIN STL_ITEM_HDR
|
||||
JOIN TRD_HEADER
|
||||
JOIN TRD_TERM
|
||||
|
||||
*/
|
||||
|
||||
|
||||
/***
|
||||
CREATE PROCEDURE [SP_CREDIT_LIMIT_REPORT_DETAIL]
|
||||
@P_REPORT_GBN NVARCHAR(20), : 조회 구분; 사용않음
|
||||
@P_COUNTPART_COMPANY_NUM NVARCHAR(MAX), : 거래처 회사번호 콤마분리 목록
|
||||
@P_ADVANCE_RECEIVED_ID NVARCHAR(15), : 선수금이 있는 경우 선수금id
|
||||
@P_PAGE INT,
|
||||
@P_RP INT,
|
||||
@P_SORTNAME NVARCHAR(100),
|
||||
@P_SORTORDER NVARCHAR(20)
|
||||
AS
|
||||
P_SORTNAME SORT 항목몀과 P_SORTORDER 정렬방향을 parameter 로 받다 적용
|
||||
***/
|
||||
SELECT ALL_DATA.*
|
||||
FROM (
|
||||
SELECT
|
||||
ROW_NUMBER() OVER(ORDER BY '#(P_SORTNAME} #{P_SORTORDER}', DATA.Sort_Gbn) AS ROWNUM
|
||||
,COUNT(*) OVER() AS TOT_CNT
|
||||
,DATA.*
|
||||
FROM (
|
||||
SELECT
|
||||
2 AS Sort_Gbn
|
||||
, X.Trade
|
||||
, X.Strategy_Num
|
||||
, (SELECT strategy_name FROM ORG_STRATEGY WHERE strategy_num = X.Strategy_Num)
|
||||
AS Strategy
|
||||
, X.Book
|
||||
, X.Trader_Num
|
||||
, (SELECT last_name + ' ' + first_name FROM REF_PERSON WHERE person_num = X.Trader_Num)
|
||||
AS Trader
|
||||
, X.COUNTERPART_NUM
|
||||
, (SELECT COMPANY_CD FROM REF_COMPANY WHERE COMPANY_NUM = X.COUNTERPART_NUM)
|
||||
AS COUNTERPART
|
||||
, X.ACCT_NUM
|
||||
, (SELECT COMPANY_CD FROM REF_COMPANY WHERE COMPANY_NUM = X.ACCT_NUM)
|
||||
AS ACCT
|
||||
, X.DUE
|
||||
, X.INVOICE_OLD
|
||||
, selectInvoiceNumber(X.TRADE)
|
||||
AS Invoice
|
||||
, X.AMOUNT , X.OPENAMT , X.CMDTY_CD , X.COSTTYPE , X.TTM , X.QTY , X.UOM , X.PRICE , X.PREM , X.CUR
|
||||
, X.PUOM , X.INCURRED , X.PTERM , X.PTYPE , X.DELREF , X.DELIVERY , X.BL
|
||||
, X.BS_IND
|
||||
, FN_CXL_GEN_INDICATOR_VALUE('stl_buy_sell_ind', X.BS_Ind)
|
||||
AS BS
|
||||
, X.OpnType_Ind
|
||||
, FN_CXL_GEN_INDICATOR_VALUE('put_call_ind', X.OpnType_Ind)
|
||||
AS OpnType
|
||||
, X.Invoiced_Ind
|
||||
, FN_CXL_GEN_INDICATOR_VALUE('item_invoiced_ind', X.Invoiced_Ind)
|
||||
AS Invoiced
|
||||
, X.Delivered_Ind
|
||||
, FN_CXL_GEN_INDICATOR_VALUE('delivery_type_ind', X.Delivered_Ind)
|
||||
AS Delivered
|
||||
, X.Splitted_Ind
|
||||
, FN_CXL_GEN_INDICATOR_VALUE('split_item_ind', X.Splitted_Ind)
|
||||
AS Splitted
|
||||
, X.PriceStatus_Ind
|
||||
, FN_CXL_GEN_INDICATOR_VALUE('price_status_ind', X.PriceStatus_Ind)
|
||||
AS PriceStatus
|
||||
, X.Payment_Ind
|
||||
, FN_CXL_GEN_INDICATOR_VALUE('payment_status_ind', X.Payment_Ind)
|
||||
AS Payment
|
||||
, X.Description
|
||||
FROM (
|
||||
SELECT
|
||||
AA.Trade AS Trade
|
||||
, AA.Strategy_Num AS Strategy_Num
|
||||
, AA.Book AS Book
|
||||
, MAX(AA.Trader_Num) AS Trader_Num
|
||||
, AA.COUNTERPART_NUM AS COUNTERPART_NUM
|
||||
, MAX(AA.ACCT) AS ACCT_NUM
|
||||
, MIN(AA.DUE_DT) AS DUE
|
||||
, MAX(AA.INVOICE) AS INVOICE_OLD
|
||||
, SUM(CASE
|
||||
WHEN ( ABS(AA.INVOICE_AMT * AA.INVOICE_FX_VALUE) - ABS(AA.PAID_AMT * AA.INVOICE_FX_VALUE)) > 0
|
||||
THEN ((AA.INVOICE_AMT * AA.INVOICE_FX_VALUE) - (AA.PAID_AMT * AA.INVOICE_FX_VALUE))
|
||||
ELSE NULL
|
||||
END) AS AMOUNT
|
||||
, SUM(CASE
|
||||
WHEN ( ABS(AA.EXTENDED_AMT * AA.EXTENDED_FX_VALUE) - ABS(AA.INVOICE_AMT * AA.INVOICE_FX_VALUE)) > 0
|
||||
THEN ((AA.EXTENDED_AMT * AA.EXTENDED_FX_VALUE) - (AA.INVOICE_AMT * AA.INVOICE_FX_VALUE))
|
||||
ELSE NULL
|
||||
END) AS OPENAMT
|
||||
, AA.CMDTY_CD AS CMDTY_CD
|
||||
, MAX(AA.COST_TYPE_CD) AS COSTTYPE
|
||||
, MAX(AA.TTM) AS TTM
|
||||
, SUM(AA.QTY) AS QTY
|
||||
, AA.UOM AS UOM
|
||||
, MAX(AA.PRICE) AS PRICE
|
||||
, MAX(AA.PREM) AS PREM
|
||||
, MAX(AA.CURR_CD) AS CUR
|
||||
, MAX(AA.PUOM) AS PUOM
|
||||
, MAX(AA.INCURRED) AS INCURRED
|
||||
, MAX(AA.PTERM) AS PTERM
|
||||
, MAX(AA.PTYPE) AS PTYPE
|
||||
, MAX(AA.DELREF) AS DELREF
|
||||
, MAX(AA.DELIVERY) AS DELIVERY
|
||||
, MAX(AA.BL) AS BL
|
||||
, MAX(AA.BS_IND) AS BS_IND
|
||||
, MAX(AA.OpnType_Ind) AS OpnType_Ind
|
||||
, MAX(AA.Invoiced_Ind) AS Invoiced_Ind
|
||||
, MAX(AA.Delivered_Ind) AS Delivered_Ind
|
||||
, MAX(AA.Splitted_Ind) AS Splitted_Ind
|
||||
, MAX(AA.PriceStatus_Ind) AS PriceStatus_Ind
|
||||
, MAX(AA.Payment_Ind) AS Payment_Ind
|
||||
, MAX(AA.Description) AS Description
|
||||
FROM (
|
||||
SELECT
|
||||
B.TRADE_NUM AS TRADE
|
||||
, B.STRATEGY_NUM AS STRATEGY_NUM
|
||||
, B.BOOK_CD AS BOOK
|
||||
, B.TRADER_PERSON_NUM AS TRADER_NUM
|
||||
, B.COUNTERPART_COMPANY_NUM AS COUNTERPART_NUM
|
||||
, B.INTERNAL_COMPANY_NUM AS ACCT
|
||||
, NVL( TO_CHAR(D.PAYMENT_DUE_DT, 'YYYYMMDD') , TO_CHAR(B.PAYMENT_DUE_DT, 'YYYYMMDD') )
|
||||
AS DUE_DT
|
||||
, B.INVOICE_NUMBER AS INVOICE
|
||||
, currencyAmount(B.PRICE_CURR_CD, C.ADJ_AMT)
|
||||
AS INVOICE_AMT
|
||||
, currencyAmount(B.PRICE_CURR_CD, D.PAID_AMT)
|
||||
AS PAID_AMT
|
||||
, CASE WHEN B.INVOICE_NUMBER IS NOT NULL THEN
|
||||
CASE WHEN C.INVOICE_DETAIL_OVERRIDE_IND = 1
|
||||
THEN currencyAmount(B.PRICE_CURR_CD, C.OVERRIDE_INVOICE_AMT)
|
||||
ELSE currencyAmount(B.PRICE_CURR_CD, C.INVOICE_AMT) END
|
||||
ELSE currencyAmount(B.PRICE_CURR_CD, B.EXTENDED_AMT) END
|
||||
AS EXTENDED_AMT
|
||||
, NVL(getFX_VALUE(C.AMT_CURR_CD, D.INVOICE_DT),1) AS INVOICE_FX_VALUE
|
||||
, NVL(getFX_VALUE(B.PRICE_CURR_CD, NULL),1) AS EXTENDED_FX_VALUE
|
||||
, B.CMDTY_CD AS CMDTY_CD
|
||||
, B.COST_TYPE_CD AS COST_TYPE_CD
|
||||
, CASE WHEN D.PAYMENT_DUE_DT IS NULL
|
||||
THEN dateDiff('DD', B.PAYMENT_DUE_DT ,SYSDATE)
|
||||
ELSE dateDiff('DD', D.PAYMENT_DUE_DT ,SYSDATE) END
|
||||
AS TTM
|
||||
, (CASE WHEN B.PRICE <0 THEN (-1) * B.QTY ELSE B.QTY END)
|
||||
AS QTY /* 가격이 마이너스일 경우 수량에 마이너스 부호 추가 */
|
||||
, B.QTY_UOM_CD AS UOM
|
||||
, currencyAmount(B.PRICE_CURR_CD, B.PRICE)
|
||||
AS PRICE
|
||||
, B.PREM_DISC AS PREM
|
||||
, CASE WHEN B.PRICE_CURR_CD IS NOT NULL AND B.PRICE_CURR_CD = 'USC'
|
||||
THEN 'USD'
|
||||
ELSE B.PRICE_CURR_CD END
|
||||
AS CURR_CD
|
||||
, B.PRICE_UOM_DESC AS PUOM
|
||||
, TO_CHAR( B.INCURRED_DT, 'YYYY-MM-DD')
|
||||
AS INCURRED
|
||||
, B.SETTLE_PAYMENT_TERM_CD AS PTERM
|
||||
, E.INTERFACE_VALUE_CODE AS PTYPE
|
||||
, B.DELIVERY_REF AS DELREF
|
||||
, B.DELIVERY_NUM AS DELIVERY
|
||||
, TO_CHAR( B.BL_DT, 'YYYY-MM-DD')
|
||||
AS BL
|
||||
, B.STL_BUY_SELL_IND AS BS_IND
|
||||
, B.PUT_CALL_IND AS OPNTYPE_IND
|
||||
, B.ITEM_INVOICED_IND AS INVOICED_IND
|
||||
, B.DELIVERY_TYPE_IND AS DELIVERED_IND
|
||||
, B.SPLIT_ITEM_IND AS SPLITTED_IND
|
||||
, B.PRICE_STATUS_IND AS PRICESTATUS_IND
|
||||
, B.PAYMENT_STATUS_IND AS PAYMENT_IND
|
||||
, B.DESCRIPTION AS DESCRIPTION
|
||||
FROM REF_CREDIT_LIMIT_DEFINITION A
|
||||
INNER JOIN STL_ITEM_HDR B ON A.COMPANY_NUM = B.COUNTERPART_COMPANY_NUM
|
||||
LEFT JOIN (SELECT
|
||||
(CASE WHEN RNK = 1
|
||||
THEN DET.DET_ADJ_AMT + DET_TAX.TAX_ADJ_AMT
|
||||
ELSE DET.DET_ADJ_AMT END )
|
||||
AS ADJ_AMT
|
||||
, DET.*
|
||||
FROM (
|
||||
SELECT
|
||||
X.*
|
||||
, (CASE WHEN OVERRIDE_INVOICE_AMT IS NULL
|
||||
THEN INVOICE_AMT
|
||||
ELSE OVERRIDE_INVOICE_AMT END )
|
||||
DET_ADJ_AMT
|
||||
, RANK() OVER (PARTITION BY INVOICE_HDR_NUM ORDER BY ABS(INVOICE_AMT) DESC ) RNK
|
||||
FROM STL_INVOICE_DETAIL X
|
||||
WHERE SUBSTR(ITEM_DESCRIPTION,1,3) <> 'TAX'
|
||||
) DET
|
||||
, (
|
||||
SELECT
|
||||
X.*
|
||||
, (CASE WHEN OVERRIDE_INVOICE_AMT IS NULL
|
||||
THEN INVOICE_AMT
|
||||
ELSE OVERRIDE_INVOICE_AMT END )
|
||||
AS TAX_ADJ_AMT
|
||||
FROM STL_INVOICE_DETAIL X
|
||||
WHERE SUBSTR(ITEM_DESCRIPTION,1,3) = 'TAX'
|
||||
) DET_TAX
|
||||
WHERE DET.INVOICE_HDR_NUM = DET_TAX.INVOICE_HDR_NUM
|
||||
) C ON B.ITEM_HDR_NUM = C.ITEM_HDR_NUM AND C.INV_DETAIL_STATUS_IND = 1
|
||||
LEFT JOIN STL_INVOICE_HDR D ON C.INVOICE_HDR_NUM = D.INVOICE_HDR_NUM
|
||||
AND D.INVOICE_STATUS_IND IN (
|
||||
SELECT REGEXP_SUBSTR(NVL('#{V_INVOICE_STATUS_IND}',''), '[^,]+', 1, LEVEL) FROM DUAL
|
||||
CONNECT BY REGEXP_SUBSTR(NVL('#{V_INVOICE_STATUS_IND}',''), '[^,]+', 1, LEVEL) IS NOT NULL
|
||||
)
|
||||
INNER JOIN TRD_TERM F ON B.TRADE_NUM = F.TRADE_NUM
|
||||
INNER JOIN REF_PAYMENT_TERM E ON B.SETTLE_PAYMENT_TERM_CD = E.PAYMENT_TERM_CD
|
||||
INNER JOIN TRD_HEADER G ON F.TRADE_NUM = G.TRADE_NUM AND F.INTERNAL_SIDE_IND = G.INTERNAL_SIDE_IND
|
||||
WHERE 1=1
|
||||
AND B.ITEM_STATUS_IND <> 0 /* 0:Defunct,1:Active,2:Reversed,3:Reversal */
|
||||
AND B.PAYMENT_STATUS_IND <> 2
|
||||
AND B.INTERNAL_COMPANY_NUM NOT IN (1668, 2307, 2142)
|
||||
AND B.COST_TYPE_CD IN
|
||||
( 'FB Chartering_CR'
|
||||
, 'FB Chartering_DR'
|
||||
, 'FB Chartering'
|
||||
, 'Primary Settlement'
|
||||
, 'Provisional Price'
|
||||
, 'Provisional Price Rv'
|
||||
, 'Purchase Adjustment'
|
||||
, 'Sales Adjustment'
|
||||
, 'Barging Fee'
|
||||
, 'Barging Cost'
|
||||
, 'Barging Cost_CR'
|
||||
, 'Barging Cost_DR' )
|
||||
AND B.TRADE_NUM NOT IN (SELECT TRADE_NUM
|
||||
FROM MD_CREDIT_REPORT_EXCEPT_TRADE
|
||||
WHERE EXCEPT_YN = 'Y')
|
||||
AND ( NVL(B.INSTRUMENT_CLASS_CD, '') = 'Physical' OR NVL(G.CLEARED_IND, -1) = -1 )
|
||||
AND ( NVL(B.INSTRUMENT_CLASS_CD, '') <> 'Physical'
|
||||
OR (
|
||||
UPPER(NVL(B.DEAL_ID2, '')) NOT LIKE '%FPP%'
|
||||
AND UPPER(NVL(B.DEAL_ID2, '')) NOT LIKE '%TARS%'
|
||||
AND UPPER(NVL(B.DEAL_ID2, '')) NOT LIKE '%KNOCK OUT%'
|
||||
)
|
||||
OR NVL( TO_CHAR( B.UNDERLYING_START_DT, 'YYYYMMDD'), '19000101') <= TO_CHAR( SYSDATE, 'YYYYMMDD')
|
||||
)
|
||||
AND B.TRADE_STATUS_IND NOT IN (5, 6)
|
||||
AND (NVL(B.INSTRUMENT_CLASS_CD, '') <> 'Physical'
|
||||
OR A.CREDIT_NETTING_IND = 1 /* 'Yes' */
|
||||
OR B.DELIVERY_TYPE_IND IN (2, 3) /* 0:Transfer ,1:Match ,2:Netout ,3:Bookout ,4:Stand-Alone Delivery */
|
||||
OR ((A.CREDIT_NETTING_IND = 0 OR A.CREDIT_NETTING_IND IS NULL) AND B.STL_BUY_SELL_IND = -1 ) /* stl_buy_sell_ind: -1:Sell, 1:buy, 0:N/A */
|
||||
OR ((A.CREDIT_NETTING_IND = 0 OR A.CREDIT_NETTING_IND IS NULL) AND F.SETTLE_PAYMENT_TERM_CD IN('SET OFF','BOOK OUT') )
|
||||
) /* SET OFF 거래에 대해 SELL / BUY를 모두 신용에 포함 로직 추가 */
|
||||
AND E.INTERFACE_VALUE_CODE = 'TT'
|
||||
AND B.COUNTERPART_COMPANY_NUM IN (
|
||||
SELECT COMPANY_NUM FROM REF_COMPANY
|
||||
WHERE ( COMPANY_TYPE_IND = '0' AND COMPANY_NUM NOT IN (3739,3743,3745) )
|
||||
OR ( COMPANY_TYPE_IND = '10' AND COMPANY_CD NOT IN ( 'SKEE', 'SKEA','SKEI' ))
|
||||
)
|
||||
AND B.SPLIT_ITEM_IND <> '1' /* 0:N/A, 1:Source, 2:Split. Split 된 경우, Source는 신용 산출 대상에서 제외. split 항목과 중복으로 계산됨 */
|
||||
AND TO_CHAR(B.COUNTERPART_COMPANY_NUM) IN (
|
||||
SELECT REGEXP_SUBSTR(NVL('#{P_COUNTPART_COMPANY_NUM}',''),'[^,]+', 1, LEVEL) FROM DUAL
|
||||
CONNECT BY REGEXP_SUBSTR(NVL('#{P_COUNTPART_COMPANY_NUM}',''), '[^,]+', 1, LEVEL) IS NOT NULL
|
||||
)
|
||||
) AA
|
||||
WHERE 1=1
|
||||
AND AA.PTerm <> 'Prepay before B/L' /* [2019.05.27] @V_SQL9 에 prepay 조건 추가 - Summary Detail 데이터 싱크 맞춤 */
|
||||
GROUP BY AA.TRADE, 2, AA.COUNTERPART_NUM, AA.STRATEGY_NUM, AA.BOOK, AA.CMDTY_CD, AA.UOM
|
||||
) X
|
||||
UNION ALL
|
||||
SELECT
|
||||
1 AS Sort_Gbn
|
||||
, NULL AS Trade
|
||||
, NULL AS Strategy_Num
|
||||
, 'Advance Received' AS Strategy
|
||||
, NULL AS Book
|
||||
, NULL AS Trader_Num
|
||||
, NULL AS Trader
|
||||
, COMPANY.company_num AS Counterpart_Num
|
||||
, (SELECT company_cd FROM REF_COMPANY WHERE company_num = COMPANY.company_num)
|
||||
AS Counterpart
|
||||
, NULL AS Acct_Num
|
||||
, NULL AS Acct
|
||||
, NULL AS Due
|
||||
, NULL AS Invoice_Old
|
||||
, NULL AS Invoice
|
||||
, ADVANCE_RECEIVED.ADVANCE_RECEIVED AS Amount
|
||||
, NULL AS OpenAmt
|
||||
, NULL AS cmdty_cd
|
||||
, NULL AS CostType
|
||||
, NULL AS TTM
|
||||
, NULL AS Qty
|
||||
, NULL AS Uom
|
||||
, NULL AS Price
|
||||
, NULL AS Prem
|
||||
, NULL AS Cur
|
||||
, NULL AS PUoM
|
||||
, NULL AS Incurred
|
||||
, NULL AS PTerm
|
||||
, NULL AS PType
|
||||
, NULL AS DelRef
|
||||
, NULL AS Delivery
|
||||
, NULL AS BL
|
||||
, NULL AS BS_Ind
|
||||
, NULL AS BS
|
||||
, NULL AS OpnType_Ind
|
||||
, NULL AS OpnType
|
||||
, NULL AS Invoiced_Ind
|
||||
, NULL AS Invoiced
|
||||
, NULL AS Delivered_Ind
|
||||
, NULL AS Delivered
|
||||
, NULL AS Splitted_Ind
|
||||
, NULL AS Splitted
|
||||
, NULL AS PriceStatus_Ind
|
||||
, NULL AS PriceStatus
|
||||
, NULL AS Payment_Ind
|
||||
, NULL AS Payment
|
||||
, NULL AS Description
|
||||
FROM (SELECT COMPANY_NUM, SUM( TO_NUMBER(ADVANCE_RECEIVED, '999999999999999.99999999') ) AS ADVANCE_RECEIVED
|
||||
FROM MD_CREDIT_ADVANCE_RECEIVED
|
||||
WHERE ADVANCE_RECEIVED_ID = '#{P_ADVANCE_RECEIVED_ID}'
|
||||
GROUP BY COMPANY_NUM
|
||||
) ADVANCE_RECEIVED
|
||||
INNER JOIN REF_COMPANY COMPANY ON ADVANCE_RECEIVED.COMPANY_NUM = COMPANY.company_num
|
||||
WHERE 1 = 1
|
||||
AND TO_CHAR(COMPANY.COMPANY_NUM) IN (
|
||||
SELECT REGEXP_SUBSTR(NVL('#{P_COUNTPART_COMPANY_NUM}',''),'[^,]+', 1, LEVEL) FROM DUAL
|
||||
CONNECT BY REGEXP_SUBSTR(NVL('#{P_COUNTPART_COMPANY_NUM}',''), '[^,]+', 1, LEVEL) IS NOT NULL
|
||||
)
|
||||
UNION ALL
|
||||
SELECT
|
||||
1 AS Sort_Gbn
|
||||
, trade_num AS Trade
|
||||
, NULL AS Strategy_Num
|
||||
, 'Zero-Out / Credit Over' AS Strategy
|
||||
, NULL AS Book
|
||||
, trader_num AS Trader_Num
|
||||
, NULL AS Trader
|
||||
, CO.company_num AS Counterpart_Num
|
||||
, (SELECT company_cd FROM REF_COMPANY RC WHERE RC.company_num = CO.company_num)
|
||||
AS Counterpart
|
||||
, (select internal_company_num from trd_header where trade_num = co.trade_num)
|
||||
AS Acct_Num /* ACC_NUM 조회가능하도록 조치 */
|
||||
, (select company_cd from ref_company where company_num = (select internal_company_num from trd_header where trade_num = co.trade_num ))
|
||||
AS Acct /* ACCT 조회가능하도록 조치 */
|
||||
, NULL AS Due
|
||||
, NULL AS Invoice_Old
|
||||
, NULL AS Invoice
|
||||
, NULL AS Amount
|
||||
, extended_amt AS OpenAmt
|
||||
, NULL AS cmdty_cd
|
||||
, NULL AS CostType
|
||||
, NULL AS TTM
|
||||
, NULL AS Qty
|
||||
, NULL AS Uom
|
||||
, NULL AS Price
|
||||
, NULL AS Prem
|
||||
, NULL AS Cur
|
||||
, NULL AS PUoM
|
||||
, NULL AS Incurred
|
||||
, NULL AS PTerm
|
||||
, NULL AS PType
|
||||
, NULL AS DelRef
|
||||
, NULL AS Delivery
|
||||
, NULL AS BL
|
||||
, NULL AS BS_Ind
|
||||
, NULL AS BS
|
||||
, NULL AS OpnType_Ind
|
||||
, NULL AS OpnType
|
||||
, NULL AS Invoiced_Ind
|
||||
, NULL AS Invoiced
|
||||
, NULL AS Delivered_Ind
|
||||
, NULL AS Delivered
|
||||
, NULL AS Splitted_Ind
|
||||
, NULL AS Splitted
|
||||
, NULL AS PriceStatus_Ind
|
||||
, NULL AS PriceStatus
|
||||
, NULL AS Payment_Ind
|
||||
, NULL AS Payment
|
||||
, NULL AS Description
|
||||
FROM CS_CREDIT_EXCESS_TRADE CO
|
||||
WHERE 1 = 1
|
||||
AND CO.TRADE_STATUS_IND = 10 /* 10 Discrepancy */
|
||||
AND CO.ZERO_OUT_IND = 1 /* 1:'YES' */
|
||||
AND TO_CHAR(CO.COMPANY_NUM) IN (
|
||||
SELECT REGEXP_SUBSTR(NVL('#{P_COUNTPART_COMPANY_NUM}',''),'[^,]+', 1, LEVEL) FROM DUAL
|
||||
CONNECT BY REGEXP_SUBSTR(NVL('#{P_COUNTPART_COMPANY_NUM}',''),'[^,]+', 1, LEVEL) IS NOT NULL
|
||||
)
|
||||
)DATA
|
||||
) ALL_DATA
|
||||
WHERE 1=1
|
||||
AND ALL_DATA.ROWNUM BETWEEN ((' + CONVERT(NVARCHAR, @P_PAGE) + ' - 1) * ' + CONVERT(NVARCHAR, @P_RP) + ') + 1
|
||||
AND (' + CONVERT(NVARCHAR, @P_PAGE) + ' * ' + CONVERT(NVARCHAR, @P_RP) + ')
|
||||
ORDER BY ALL_DATA.ROWNUM
|
||||
662
sql/SP_CREDIT_LIMIT_REPORT_SUMMARY_#credit_solution_oracle.sql
Normal file
662
sql/SP_CREDIT_LIMIT_REPORT_SUMMARY_#credit_solution_oracle.sql
Normal file
@@ -0,0 +1,662 @@
|
||||
|
||||
/****
|
||||
SP_CREDIT_LIMIT_REPORT_SUMMARY
|
||||
> 구분 'CREDIT_SOLUTION' 인 경우
|
||||
EXEC(@V_SORT_SQL1 + @V_SQL1 + @V_SQL2 + @V_SQL3 + @V_SQL4 + @V_SQL5 + @V_SQL6 + @V_SQL7 + @V_SQL8 + @V_WHERE_SQL1 + @V_SQL9 + @V_SQL13 + @V_WHERE_SQL4 + @V_SQL10 + @V_WHERE_SQL2 + @V_SQL11 + @V_SORT_SQL2 + @V_SORT_SQL3 + @V_ORDER_SQL)
|
||||
|
||||
****/
|
||||
|
||||
SELECT ALL_DATA.*
|
||||
FROM (
|
||||
SELECT ROW_NUMBER() OVER(ORDER BY DATA.Counterparty) AS ROWNUM
|
||||
,DATA.*
|
||||
FROM (
|
||||
|
||||
---------------------------------------------------------------------------------------------------------------
|
||||
/*== @V_SQL1 == */
|
||||
SELECT
|
||||
PRT_WEB.COUNTERPARTY_NUM
|
||||
, PRT_WEB.COUNTERPARTY
|
||||
, PRT_WEB.COUNTERPARTY_EXCEL
|
||||
, PRT_WEB.COUNTERPARTY_NAME
|
||||
, PRT_WEB.CREDIT_ACC
|
||||
, (CASE WHEN TO_NUMBER(PRT_WEB.CREDITLIMIT) = 1
|
||||
THEN 0
|
||||
ELSE TO_NUMBER(PRT_WEB.CREDITLIMIT)
|
||||
END) AS CREDITLIMIT
|
||||
, TO_NUMBER(PRT_WEB.CREDITLIMIT * 0.9) AS TOLERANCE
|
||||
, PRT_WEB.CP_GUARANTEE
|
||||
, CASE WHEN PRT_WEB.ETRM_NET_EXPOSURE <0
|
||||
THEN (CASE WHEN TO_NUMBER(PRT_WEB.CREDITLIMIT) = 1
|
||||
THEN 0
|
||||
ELSE TO_NUMBER(PRT_WEB.CREDITLIMIT)
|
||||
END)
|
||||
ELSE (CASE WHEN TO_NUMBER(PRT_WEB.AVAILABILITY) = 1
|
||||
THEN 0
|
||||
ELSE TO_NUMBER(PRT_WEB.AVAILABILITY)
|
||||
END) END AS AVAILABILITY /* PRT_WEB.AVAILABILITY 출력에서 PRT_WEB.ETRM_NET_EXPOSURE 에 따른 AVAILABILITY 계산으로 변경 */
|
||||
, PRT_WEB.AMOUNT_UNINVOICED
|
||||
, PRT_WEB.AMOUNT_INVOICED
|
||||
, PRT_WEB.ETRM_NET_EXPOSURE
|
||||
, PRT_WEB.ETRM_NET_EXP_1
|
||||
, PRT_WEB.CHANGE
|
||||
, (CASE WHEN TO_NUMBER(PRT_WEB.ETRM_BALANCE) = 1
|
||||
THEN 0
|
||||
ELSE TO_NUMBER(PRT_WEB.ETRM_BALANCE)
|
||||
END) AS ETRM_BALANCE
|
||||
, CASE WHEN PRT_WEB.CREDITLIMIT = 1
|
||||
AND PRT_WEB.AVAILABILITY <= 0
|
||||
AND PRT_WEB.ETRM_NET_EXPOSURE <= 0
|
||||
THEN 0
|
||||
ELSE
|
||||
/* (PRT_WEB.ETRM_Net_Exposure / PRT_WEB.CreditLimit) * 100 */
|
||||
(CASE WHEN PRT_WEB.CreditLimit= 0
|
||||
THEN (PRT_WEB.ETRM_Net_Exposure - PRT_WEB.Advance_Received) * 100
|
||||
ELSE ((PRT_WEB.ETRM_Net_Exposure - PRT_WEB.Advance_Received) / PRT_WEB.CreditLimit) * 100 END)
|
||||
END AS ETRM_USAGE
|
||||
, PRT_WEB.USAGE_1
|
||||
, PRT_WEB.TI_LIMIT
|
||||
, PRT_WEB.ADVANCE_RECEIVED
|
||||
, PRT_WEB.TI_NET_EXPOSURE
|
||||
, PRT_WEB.TI_NET_EXPOSURE_1
|
||||
, PRT_WEB.TI_CHANGE
|
||||
, PRT_WEB.TI_USAGE
|
||||
, PRT_WEB.TI_USAGE_1
|
||||
, (CASE WHEN TO_NUMBER(PRT_WEB.CONSOLIDATED_LIMIT) = 1
|
||||
THEN 0
|
||||
ELSE TO_NUMBER(PRT_WEB.CONSOLIDATED_LIMIT) END) AS CONSOLIDATED_LIMIT
|
||||
, PRT_WEB.CREDIT_RATING
|
||||
, PRT_WEB.BIZ_TYPE
|
||||
, PRT_WEB.CONSOLIDATED_NET_EXPOSURE
|
||||
, CASE
|
||||
WHEN PRT_WEB.CREDITLIMIT = 1
|
||||
AND PRT_WEB.AVAILABILITY = 0
|
||||
AND PRT_WEB.ETRM_NET_EXPOSURE <= 0
|
||||
THEN
|
||||
CASE WHEN PRT_WEB.TI_LIMIT = 0 THEN 0
|
||||
ELSE PRT_WEB.TI_USAGE END
|
||||
WHEN PRT_WEB.CREDITLIMIT = 1
|
||||
AND PRT_WEB.AVAILABILITY = 0
|
||||
AND PRT_WEB.ETRM_NET_EXPOSURE > 0
|
||||
THEN
|
||||
CASE WHEN PRT_WEB.TI_LIMIT = 0
|
||||
THEN 100
|
||||
ELSE (PRT_WEB.ETRM_NET_EXPOSURE + PRT_WEB.TI_NET_EXPOSURE) / (PRT_WEB.CREDITLIMIT + PRT_WEB.TI_LIMIT) * 100 END
|
||||
ELSE
|
||||
(CASE WHEN PRT_WEB.CREDITLIMIT= 0
|
||||
THEN (PRT_WEB.ETRM_NET_EXPOSURE + PRT_WEB.TI_NET_EXPOSURE) / PRT_WEB.TI_LIMIT * 100
|
||||
ELSE (PRT_WEB.ETRM_NET_EXPOSURE + PRT_WEB.TI_NET_EXPOSURE) / (PRT_WEB.CREDITLIMIT + PRT_WEB.TI_LIMIT) * 100
|
||||
END)
|
||||
END AS TOTAL_USAGE
|
||||
, PRT_WEB.STATUS
|
||||
, PRT_WEB.STATUS_IND
|
||||
, PRT_WEB.CREDIT_STATUS
|
||||
, PRT_WEB.NEXT_REVIEW_DATE
|
||||
, PRT_WEB.TOT_CNT
|
||||
FROM ( /* begin of PRT_WEB view */
|
||||
SELECT
|
||||
RCLD.COMPANY_NUM AS COUNTERPARTY_NUM
|
||||
, '<A ONCLICK="LOADPAGE(''' || REF_COMPY.COMPANY_CD ||''', '''||TO_CHAR(RCLD.COMPANY_NUM)
|
||||
||''');" <FONT STYLE="COLOR:#3399FF; CURSOR:POINTER;" ONMOUSEOVER="THIS.STYLE.COLOR=''#FF9900''" ONMOUSEOUT="THIS.STYLE.COLOR=''#3399FF''"><U>'
|
||||
|| REF_COMPY.COMPANY_CD ||'</U></FONT>'
|
||||
AS COUNTERPARTY
|
||||
, REF_COMPY.COMPANY_CD
|
||||
AS COUNTERPARTY_EXCEL
|
||||
, REF_COMPY.COMPANY_NAME
|
||||
AS COUNTERPARTY_NAME
|
||||
,NVL((SELECT LPAD(CREDIT_ACC , 10, '0') FROM ETRM_REF_COUNTERPARTY WHERE USE_YN = 'Y' AND COMPANY_NUM = RCLD.COMPANY_NUM), '')
|
||||
AS CREDIT_ACC
|
||||
,MAX(NVL(RCLD.CREDIT_LIMIT, 0)) AS CREDITLIMIT
|
||||
,0.000 AS CP_GUARANTEE
|
||||
, CASE WHEN ( TO_NUMBER(MAX(NVL(RCLD.CREDIT_LIMIT, 0)))
|
||||
- TO_NUMBER(SUM(NVL(BB.AMOUNT_OPENAMT,0)))
|
||||
+ NVL(MAX(ADVANCE_RECEIVED.ADVANCE_RECEIVED), 0) ) < 0
|
||||
THEN 0
|
||||
ELSE ( TO_NUMBER(MAX(NVL(RCLD.CREDIT_LIMIT, 0)))
|
||||
- TO_NUMBER(SUM(NVL(BB.AMOUNT_OPENAMT,0)))
|
||||
+ NVL(MAX(ADVANCE_RECEIVED.ADVANCE_RECEIVED), 0) )
|
||||
END
|
||||
AS AVAILABILITY /* CREDIT = 1 인경우 AVAILABILITY 를 0 으로 세팅 */
|
||||
, TO_NUMBER(SUM(NVL(BB.OPENAMT, 0)))
|
||||
AS AMOUNT_UNINVOICED
|
||||
, TO_NUMBER(SUM(NVL(BB.AMOUNT,0)))
|
||||
AS AMOUNT_INVOICED
|
||||
, TO_NUMBER(SUM(NVL(BB.AMOUNT_OPENAMT,0))) - 0.000
|
||||
AS ETRM_NET_EXPOSURE
|
||||
, MAX(MCRS.ETRM_NET_EXPOSURE)
|
||||
AS ETRM_NET_EXP_1
|
||||
, ( TO_NUMBER(SUM(NVL(BB.AMOUNT_OPENAMT,0))) - 0.000 )
|
||||
- TO_NUMBER(MAX(MCRS.ETRM_NET_EXPOSURE))
|
||||
AS CHANGE
|
||||
, TO_NUMBER(MAX(NVL(RCLD.CREDIT_LIMIT, 0))) - TO_NUMBER(SUM(NVL(BB.AMOUNT_OPENAMT,0))) - 0.000
|
||||
AS ETRM_BALANCE
|
||||
, 0 AS ETRM_USAGE
|
||||
, MAX(MCRS.ETRM_USAGE) AS USAGE_1
|
||||
, NVL(MAX(SAP_CONNTERPARTY.CREDIT_LIMIT), 0) AS TI_LIMIT
|
||||
, NVL(MAX(ADVANCE_RECEIVED.ADVANCE_RECEIVED), 0) AS ADVANCE_RECEIVED
|
||||
, NVL(MAX(SAP_CONNTERPARTY.CREDIT_EXPOSURE), 0) AS TI_NET_EXPOSURE
|
||||
, MAX(MCRS.TI_NET_EXPOSURE) AS TI_NET_EXPOSURE_1
|
||||
, 0.000 AS TI_CHANGE
|
||||
/* */
|
||||
,CASE WHEN NVL(MAX(SAP_CONNTERPARTY.CREDIT_EXPOSURE), 0) = 0
|
||||
THEN 0
|
||||
ELSE
|
||||
CASE WHEN NVL(MAX(SAP_CONNTERPARTY.CREDIT_LIMIT), 0) = 0
|
||||
THEN ROUND(NVL(MAX(SAP_CONNTERPARTY.CREDIT_EXPOSURE), 0)/1, 2) * 100
|
||||
ELSE ROUND(NVL(MAX(SAP_CONNTERPARTY.CREDIT_EXPOSURE), 0)/NVL(MAX(SAP_CONNTERPARTY.CREDIT_LIMIT), 0), 2) * 100
|
||||
END
|
||||
END AS TI_USAGE
|
||||
,MAX(MCRS.TI_USAGE) AS TI_USAGE_1
|
||||
,TO_NUMBER( MAX(CASE WHEN NVL(RCLD.CREDIT_LIMIT, 0) = 1 THEN 0 ELSE NVL(RCLD.CREDIT_LIMIT, 0) END) )
|
||||
+ NVL(MAX(SAP_CONNTERPARTY.CREDIT_LIMIT), 0)
|
||||
AS Consolidated_Limit
|
||||
, MAX(RCLD.INTERNAL_CREDIT_RATING) AS CREDIT_RATING
|
||||
, MAX(RCLD.EXTERNAL_CREDIT_RATING) AS BIZ_TYPE
|
||||
, ((TO_NUMBER((21, 8), (SUM(NVL(BB.Amount, 0))) + TO_NUMBER((21, 8), SUM(NVL(BB.OpenAmt,0))))) - 0.000)
|
||||
+ NVL(MAX(SAP_CONNTERPARTY.CREDIT_EXPOSURE), 0)
|
||||
AS Consolidated_NET_EXPOSURE
|
||||
, CASE
|
||||
WHEN TO_NUMBER((21, 8), MAX(NVL(RCLD.credit_limit, 0))) in (1, 0) AND NVL(MAX(SAP_CONNTERPARTY.CREDIT_LIMIT), 0) = 0 THEN 100
|
||||
ELSE
|
||||
CASE WHEN TO_NUMBER(MAX(NVL(RCLD.CREDIT_LIMIT, 0))) in (1, 0) AND NVL(MAX(SAP_CONNTERPARTY.CREDIT_LIMIT), 0) <> 0
|
||||
THEN ROUND(NVL(MAX(SAP_CONNTERPARTY.CREDIT_EXPOSURE), 0) / NVL(MAX(SAP_CONNTERPARTY.CREDIT_LIMIT), 0), 2) * 100
|
||||
ELSE ROUND((((SUM(NVL(BB.AMOUNT_OPENAMT,0)))) - 0.000) + NVL(MAX(SAP_CONNTERPARTY.CREDIT_EXPOSURE), 0)
|
||||
/ ( TO_NUMBER(MAX(NVL(RCLD.credit_limit, 0))) + NVL(MAX(SAP_CONNTERPARTY.CREDIT_LIMIT), 0)), 2)* 100
|
||||
END
|
||||
END AS TOTAL_USAGE /* Credit = 1 인경우 availability 를 0, USAGE 100 세팅하기 때문에 Total_USAGE도 그에 맞춰 수정 */
|
||||
, FN_CXL_GEN_INDICATOR_VALUE('restricted_ind',REF_COMPY.RESTRICTED_IND)
|
||||
AS Status
|
||||
,REF_COMPY.RESTRICTED_IND
|
||||
AS Status_Ind
|
||||
,MAX(RCLD.Credit_Status) AS Credit_Status
|
||||
,MAX(NVL(RCLD.Next_Review_Date, '')) AS Next_Review_Date
|
||||
,COUNT(*) OVER() AS TOT_CNT
|
||||
|
||||
/* @V_SQL3 = ' */
|
||||
FROM (
|
||||
SELECT
|
||||
COMPANY_NUM AS COMPANY_NUM
|
||||
, (CASE WHEN CREDIT_LIMIT = 0 THEN 1 ELSE CREDIT_LIMIT END) AS CREDIT_LIMIT
|
||||
, NVL(INTERNAL_CREDIT_RATING, '') AS INTERNAL_CREDIT_RATING
|
||||
, NVL(EXTERNAL_CREDIT_RATING, '') AS EXTERNAL_CREDIT_RATING
|
||||
, NVL(CREDIT_STATUS, '') AS CREDIT_STATUS
|
||||
, TO_CHAR(NEXT_REVIEW_DATE, 'YYYY-MM-DD') AS NEXT_REVIEW_DATE
|
||||
FROM REF_CREDIT_LIMIT_DEFINITION
|
||||
WHERE COMPANY_NUM IN (
|
||||
SELECT COMPANY_NUM
|
||||
FROM REF_COMPANY
|
||||
WHERE ( COMPANY_TYPE_IND = '0' AND COMPANY_NUM NOT IN ( 3739,3743,3745 ))
|
||||
OR ( COMPANY_TYPE_IND = '10' AND COMPANY_CD NOT IN ( 'SKEE', 'SKEA','SKEI' ))
|
||||
)
|
||||
) RCLD
|
||||
LEFT JOIN REF_COMPANY REF_COMPY ON REF_COMPY.COMPANY_NUM = RCLD.COMPANY_NUM
|
||||
LEFT JOIN MD_CREDIT_REPORT_SUMMARY MCRS ON RCLD.company_num = MCRS.COUNTERPARTY AND INPUT_DATE = TO_CHAR( SYSDATE-1, 'YYYYMMDD')
|
||||
LEFT JOIN (
|
||||
SELECT COMPANY_NUM, LPAD( credit_acc, 10, '0') AS CREDIT_ACC
|
||||
FROM ETRM_REF_COUNTERPARTY
|
||||
WHERE USE_YN = 'Y' )
|
||||
ETRM_COUNTERPARTY ON RCLD.company_num = ETRM_COUNTERPARTY.COMPANY_NUM
|
||||
LEFT JOIN (
|
||||
SELECT
|
||||
COUNTERPARTY_CD
|
||||
,SUM(TO_NUMBER(CREDIT_LIMIT , '999999999999.999999' )) AS CREDIT_LIMIT
|
||||
,SUM(TO_NUMBER(CREDIT_EXPOSURE, '999999999999.999999' )) AS CREDIT_EXPOSURE
|
||||
FROM MD_CREDIT_SAP_IF_COUNTERPARTY
|
||||
WHERE CREDIT_SAP_ID = '#{P_CREDIT_SAP_ID}'
|
||||
GROUP BY COUNTERPARTY_CD )
|
||||
SAP_CONNTERPARTY ON ETRM_COUNTERPARTY.CREDIT_ACC = SAP_CONNTERPARTY.COUNTERPARTY_CD
|
||||
LEFT JOIN (
|
||||
SELECT
|
||||
COMPANY_NUM
|
||||
, SUM(TO_NUMBER( ADVANCE_RECEIVED, '999999999999.999999' )) AS ADVANCE_RECEIVED
|
||||
FROM MD_CREDIT_ADVANCE_RECEIVED
|
||||
WHERE ADVANCE_RECEIVED_ID = '#{P_ADVANCE_RECEIVED_ID}'
|
||||
GROUP BY COMPANY_NUM )
|
||||
ADVANCE_RECEIVED ON RCLD.company_num = ADVANCE_RECEIVED.COMPANY_NUM
|
||||
LEFT JOIN
|
||||
( /** begin of BB view */
|
||||
SELECT
|
||||
RCLD.COMPANY_NUM AS COUNTERPARTY_NUM
|
||||
, '<A ONCLICK="LOADPAGE(''' || REF_COMPY.COMPANY_CD ||''', '''||TO_CHAR(RCLD.COMPANY_NUM)
|
||||
||''');" <FONT STYLE="COLOR:#3399FF; CURSOR:POINTER;" ONMOUSEOVER="THIS.STYLE.COLOR=''#FF9900''" ONMOUSEOUT="THIS.STYLE.COLOR=''#3399FF''"><U>'
|
||||
|| REF_COMPY.COMPANY_CD ||'</U></FONT>'
|
||||
AS COUNTERPARTY
|
||||
, REF_COMPY.COMPANY_CD
|
||||
AS COUNTERPARTY_EXCEL
|
||||
, REF_COMPY.COMPANY_NAME
|
||||
AS COUNTERPARTY_NAME
|
||||
,NVL((SELECT LPAD(CREDIT_ACC , 10, '0') FROM ETRM_REF_COUNTERPARTY WHERE USE_YN = 'Y' AND COMPANY_NUM = RCLD.COMPANY_NUM), '')
|
||||
AS CREDIT_ACC
|
||||
,MAX(NVL(RCLD.CREDIT_LIMIT, 0)) AS CREDITLIMIT
|
||||
,0.000 AS CP_GUARANTEE
|
||||
, CASE WHEN ( TO_NUMBER(MAX(NVL(RCLD.CREDIT_LIMIT, 0)))
|
||||
- TO_NUMBER(SUM(NVL(BB.AMOUNT_OPENAMT,0)))
|
||||
+ NVL(MAX(ADVANCE_RECEIVED.ADVANCE_RECEIVED), 0) ) < 0
|
||||
THEN 0
|
||||
ELSE ( TO_NUMBER(MAX(NVL(RCLD.CREDIT_LIMIT, 0)))
|
||||
- TO_NUMBER(SUM(NVL(BB.AMOUNT_OPENAMT,0)))
|
||||
+ NVL(MAX(ADVANCE_RECEIVED.ADVANCE_RECEIVED), 0) )
|
||||
END
|
||||
AS AVAILABILITY /* CREDIT = 1 인경우 AVAILABILITY 를 0 으로 세팅 */
|
||||
, TO_NUMBER(SUM(NVL(BB.OPENAMT, 0)))
|
||||
AS AMOUNT_UNINVOICED
|
||||
, TO_NUMBER(SUM(NVL(BB.AMOUNT,0)))
|
||||
AS AMOUNT_INVOICED
|
||||
, TO_NUMBER(SUM(NVL(BB.AMOUNT_OPENAMT,0))) - 0.000
|
||||
AS ETRM_NET_EXPOSURE
|
||||
, MAX(MCRS.ETRM_NET_EXPOSURE)
|
||||
AS ETRM_NET_EXP_1
|
||||
, ( TO_NUMBER(SUM(NVL(BB.AMOUNT_OPENAMT,0))) - 0.000 )
|
||||
- TO_NUMBER(MAX(MCRS.ETRM_NET_EXPOSURE))
|
||||
AS CHANGE
|
||||
, TO_NUMBER(MAX(NVL(RCLD.CREDIT_LIMIT, 0))) - TO_NUMBER(SUM(NVL(BB.AMOUNT_OPENAMT,0))) - 0.000
|
||||
AS ETRM_BALANCE
|
||||
, 0 AS ETRM_USAGE
|
||||
, MAX(MCRS.ETRM_USAGE) AS USAGE_1
|
||||
, NVL(MAX(SAP_CONNTERPARTY.CREDIT_LIMIT), 0) AS TI_LIMIT
|
||||
, NVL(MAX(ADVANCE_RECEIVED.ADVANCE_RECEIVED), 0) AS ADVANCE_RECEIVED
|
||||
, NVL(MAX(SAP_CONNTERPARTY.CREDIT_EXPOSURE), 0) AS TI_NET_EXPOSURE
|
||||
, MAX(MCRS.TI_NET_EXPOSURE) AS TI_NET_EXPOSURE_1
|
||||
, 0.000 AS TI_CHANGE
|
||||
/* */
|
||||
,CASE WHEN NVL(MAX(SAP_CONNTERPARTY.CREDIT_EXPOSURE), 0) = 0
|
||||
THEN 0
|
||||
ELSE
|
||||
CASE WHEN NVL(MAX(SAP_CONNTERPARTY.CREDIT_LIMIT), 0) = 0
|
||||
THEN ROUND(NVL(MAX(SAP_CONNTERPARTY.CREDIT_EXPOSURE), 0)/1, 2) * 100
|
||||
ELSE ROUND(NVL(MAX(SAP_CONNTERPARTY.CREDIT_EXPOSURE), 0)/NVL(MAX(SAP_CONNTERPARTY.CREDIT_LIMIT), 0), 2) * 100
|
||||
END
|
||||
END AS TI_USAGE
|
||||
,MAX(MCRS.TI_USAGE) AS TI_USAGE_1
|
||||
,TO_NUMBER( MAX(CASE WHEN NVL(RCLD.CREDIT_LIMIT, 0) = 1 THEN 0 ELSE NVL(RCLD.CREDIT_LIMIT, 0) END) )
|
||||
+ NVL(MAX(SAP_CONNTERPARTY.CREDIT_LIMIT), 0)
|
||||
AS Consolidated_Limit
|
||||
, MAX(RCLD.INTERNAL_CREDIT_RATING) AS CREDIT_RATING
|
||||
, MAX(RCLD.EXTERNAL_CREDIT_RATING) AS BIZ_TYPE
|
||||
, ((TO_NUMBER((21, 8), (SUM(NVL(BB.Amount, 0))) + TO_NUMBER((21, 8), SUM(NVL(BB.OpenAmt,0))))) - 0.000)
|
||||
+ NVL(MAX(SAP_CONNTERPARTY.CREDIT_EXPOSURE), 0)
|
||||
AS Consolidated_NET_EXPOSURE
|
||||
, CASE
|
||||
WHEN TO_NUMBER((21, 8), MAX(NVL(RCLD.credit_limit, 0))) in (1, 0) AND NVL(MAX(SAP_CONNTERPARTY.CREDIT_LIMIT), 0) = 0
|
||||
THEN 100
|
||||
ELSE CASE WHEN TO_NUMBER(MAX(NVL(RCLD.CREDIT_LIMIT, 0))) in (1, 0) AND NVL(MAX(SAP_CONNTERPARTY.CREDIT_LIMIT), 0) <> 0
|
||||
THEN ROUND(NVL(MAX(SAP_CONNTERPARTY.CREDIT_EXPOSURE), 0) / NVL(MAX(SAP_CONNTERPARTY.CREDIT_LIMIT), 0), 2) * 100
|
||||
ELSE ROUND((((SUM(NVL(BB.AMOUNT_OPENAMT,0)))) - 0.000) + NVL(MAX(SAP_CONNTERPARTY.CREDIT_EXPOSURE), 0)
|
||||
/ ( TO_NUMBER(MAX(NVL(RCLD.credit_limit, 0))) + NVL(MAX(SAP_CONNTERPARTY.CREDIT_LIMIT), 0)), 2)* 100
|
||||
END
|
||||
END AS Total_USAGE /* Credit = 1 인경우 availability 를 0, USAGE 100 세팅하기 때문에 Total_USAGE도 그에 맞춰 수정 */
|
||||
, FN_CXL_GEN_INDICATOR_VALUE('restricted_ind',REF_COMPY.RESTRICTED_IND)
|
||||
AS Status
|
||||
,REF_COMPY.RESTRICTED_IND
|
||||
AS Status_Ind
|
||||
,MAX(RCLD.Credit_Status) AS Credit_Status
|
||||
,MAX(NVL(RCLD.Next_Review_Date, '')) AS Next_Review_Date
|
||||
,COUNT(*) OVER() AS TOT_CNT
|
||||
|
||||
/* @V_SQL3 = ' */
|
||||
FROM (
|
||||
SELECT
|
||||
COMPANY_NUM AS COMPANY_NUM
|
||||
, (CASE WHEN CREDIT_LIMIT = 0 THEN 1 ELSE CREDIT_LIMIT END) AS CREDIT_LIMIT
|
||||
, NVL(INTERNAL_CREDIT_RATING, '') AS INTERNAL_CREDIT_RATING
|
||||
, NVL(EXTERNAL_CREDIT_RATING, '') AS EXTERNAL_CREDIT_RATING
|
||||
, NVL(CREDIT_STATUS, '') AS CREDIT_STATUS
|
||||
, TO_CHAR(NEXT_REVIEW_DATE, 'YYYY-MM-DD') AS NEXT_REVIEW_DATE
|
||||
FROM REF_CREDIT_LIMIT_DEFINITION
|
||||
WHERE COMPANY_NUM IN (
|
||||
SELECT COMPANY_NUM
|
||||
FROM REF_COMPANY
|
||||
WHERE ( COMPANY_TYPE_IND = '0' AND COMPANY_NUM NOT IN ( 3739,3743,3745 ))
|
||||
OR ( COMPANY_TYPE_IND = '10' AND COMPANY_CD NOT IN ( 'SKEE', 'SKEA','SKEI' ))
|
||||
)
|
||||
) RCLD
|
||||
LEFT JOIN REF_COMPANY REF_COMPY ON REF_COMPY.COMPANY_NUM = RCLD.COMPANY_NUM
|
||||
LEFT JOIN MD_CREDIT_REPORT_SUMMARY MCRS ON RCLD.company_num = MCRS.COUNTERPARTY AND INPUT_DATE = TO_CHAR( SYSDATE-1, 'YYYYMMDD')
|
||||
LEFT JOIN (
|
||||
SELECT COMPANY_NUM, LPAD( credit_acc, 10, '0') AS CREDIT_ACC
|
||||
FROM ETRM_REF_COUNTERPARTY
|
||||
WHERE USE_YN = 'Y' )
|
||||
ETRM_COUNTERPARTY ON RCLD.company_num = ETRM_COUNTERPARTY.COMPANY_NUM
|
||||
LEFT JOIN (
|
||||
SELECT
|
||||
COUNTERPARTY_CD
|
||||
,SUM(TO_NUMBER(CREDIT_LIMIT , '999999999999.999999' )) AS CREDIT_LIMIT
|
||||
,SUM(TO_NUMBER(CREDIT_EXPOSURE, '999999999999.999999' )) AS CREDIT_EXPOSURE
|
||||
FROM MD_CREDIT_SAP_IF_COUNTERPARTY
|
||||
WHERE CREDIT_SAP_ID = '#{P_CREDIT_SAP_ID}'
|
||||
GROUP BY COUNTERPARTY_CD )
|
||||
SAP_CONNTERPARTY ON ETRM_COUNTERPARTY.CREDIT_ACC = SAP_CONNTERPARTY.COUNTERPARTY_CD
|
||||
LEFT JOIN (
|
||||
SELECT
|
||||
COMPANY_NUM
|
||||
, SUM(TO_NUMBER( ADVANCE_RECEIVED, '999999999999.999999' )) AS ADVANCE_RECEIVED
|
||||
FROM MD_CREDIT_ADVANCE_RECEIVED
|
||||
WHERE ADVANCE_RECEIVED_ID = '#{P_ADVANCE_RECEIVED_ID}'
|
||||
GROUP BY COMPANY_NUM )
|
||||
ADVANCE_RECEIVED ON RCLD.company_num = ADVANCE_RECEIVED.COMPANY_NUM
|
||||
LEFT JOIN
|
||||
( SELECT
|
||||
2 AS Sort_Gbn
|
||||
, X.Trade
|
||||
, X.Strategy_Num
|
||||
, (SELECT strategy_name FROM ORG_STRATEGY WHERE strategy_num = X.Strategy_Num)
|
||||
AS Strategy
|
||||
, X.Book
|
||||
, X.Trader_Num
|
||||
, (SELECT last_name + ' ' + first_name FROM REF_PERSON WHERE person_num = X.Trader_Num)
|
||||
AS Trader
|
||||
, X.COUNTERPARTY_NUM
|
||||
, (SELECT COMPANY_CD FROM REF_COMPANY WHERE COMPANY_NUM = X.COUNTERPARTY_NUM)
|
||||
AS COUNTERPART
|
||||
, X.ACCT_NUM
|
||||
, (SELECT COMPANY_CD FROM REF_COMPANY WHERE COMPANY_NUM = X.ACCT_NUM)
|
||||
AS ACCT
|
||||
, X.DUE
|
||||
, X.INVOICE_OLD
|
||||
, selectInvoiceNumber(X.TRADE)
|
||||
AS Invoice
|
||||
, X.AMOUNT , X.OPENAMT
|
||||
, NVL(X.AMOUNT,0)+NVL(X.OPENAMT,0) AS AMOUNT_OPENAMT
|
||||
, X.CMDTY_CD , X.COSTTYPE , X.TTM , X.QTY , X.UOM , X.PRICE , X.PREM , X.CUR
|
||||
, X.PUOM , X.INCURRED , X.PTERM , X.PTYPE , X.DELREF , X.DELIVERY , X.BL
|
||||
, X.BS_IND
|
||||
, FN_CXL_GEN_INDICATOR_VALUE('stl_buy_sell_ind', X.BS_Ind)
|
||||
AS BS
|
||||
, X.OpnType_Ind
|
||||
, FN_CXL_GEN_INDICATOR_VALUE('put_call_ind', X.OpnType_Ind)
|
||||
AS OpnType
|
||||
, X.Invoiced_Ind
|
||||
, FN_CXL_GEN_INDICATOR_VALUE('item_invoiced_ind', X.Invoiced_Ind)
|
||||
AS Invoiced
|
||||
, X.Delivered_Ind
|
||||
, FN_CXL_GEN_INDICATOR_VALUE('delivery_type_ind', X.Delivered_Ind)
|
||||
AS Delivered
|
||||
, X.Splitted_Ind
|
||||
, FN_CXL_GEN_INDICATOR_VALUE('split_item_ind', X.Splitted_Ind)
|
||||
AS Splitted
|
||||
, X.PriceStatus_Ind
|
||||
, FN_CXL_GEN_INDICATOR_VALUE('price_status_ind', X.PriceStatus_Ind)
|
||||
AS PriceStatus
|
||||
, X.Payment_Ind
|
||||
, FN_CXL_GEN_INDICATOR_VALUE('payment_status_ind', X.Payment_Ind)
|
||||
AS Payment
|
||||
, X.Description
|
||||
FROM ( /* begin of X view */
|
||||
SELECT
|
||||
AA.Trade AS Trade
|
||||
, AA.Strategy_Num AS Strategy_Num
|
||||
, AA.Book AS Book
|
||||
, MAX(AA.Trader_Num) AS Trader_Num
|
||||
, AA.COUNTERPART_NUM AS COUNTERPARTY_NUM
|
||||
/* , AA.COUNTERPART_NUM AS COUNTERPART_NUM */
|
||||
, MAX(AA.ACCT) AS ACCT_NUM
|
||||
, MIN(AA.DUE_DT) AS DUE
|
||||
, MAX(AA.INVOICE) AS INVOICE_OLD
|
||||
, SUM(CASE
|
||||
WHEN ( ABS(AA.INVOICE_AMT * AA.INVOICE_FX_VALUE) - ABS(AA.PAID_AMT * AA.INVOICE_FX_VALUE)) > 0
|
||||
THEN ((AA.INVOICE_AMT * AA.INVOICE_FX_VALUE) - (AA.PAID_AMT * AA.INVOICE_FX_VALUE))
|
||||
ELSE NULL
|
||||
END) AS AMOUNT
|
||||
, SUM(CASE
|
||||
WHEN ( ABS(AA.EXTENDED_AMT * AA.EXTENDED_FX_VALUE) - ABS(AA.INVOICE_AMT * AA.INVOICE_FX_VALUE)) > 0
|
||||
THEN ((AA.EXTENDED_AMT * AA.EXTENDED_FX_VALUE) - (AA.INVOICE_AMT * AA.INVOICE_FX_VALUE))
|
||||
ELSE NULL
|
||||
END) AS OPENAMT
|
||||
, AA.CMDTY_CD AS CMDTY_CD
|
||||
, MAX(AA.COST_TYPE_CD) AS COSTTYPE
|
||||
, MAX(AA.TTM) AS TTM
|
||||
, SUM(AA.QTY) AS QTY
|
||||
, AA.UOM AS UOM
|
||||
, MAX(AA.PRICE) AS PRICE
|
||||
, MAX(AA.PREM) AS PREM
|
||||
, MAX(AA.CURR_CD) AS CUR
|
||||
, MAX(AA.PUOM) AS PUOM
|
||||
, MAX(AA.INCURRED) AS INCURRED
|
||||
, MAX(AA.PTERM) AS PTERM
|
||||
, MAX(AA.PTYPE) AS PTYPE
|
||||
, MAX(AA.DELREF) AS DELREF
|
||||
, MAX(AA.DELIVERY) AS DELIVERY
|
||||
, MAX(AA.BL) AS BL
|
||||
, MAX(AA.BS_IND) AS BS_IND
|
||||
, MAX(AA.OpnType_Ind) AS OpnType_Ind
|
||||
, MAX(AA.Invoiced_Ind) AS Invoiced_Ind
|
||||
, MAX(AA.Delivered_Ind) AS Delivered_Ind
|
||||
, MAX(AA.Splitted_Ind) AS Splitted_Ind
|
||||
, MAX(AA.PriceStatus_Ind) AS PriceStatus_Ind
|
||||
, MAX(AA.Payment_Ind) AS Payment_Ind
|
||||
, MAX(AA.Description) AS Description
|
||||
FROM ( /* begin of AA view */
|
||||
SELECT
|
||||
B.TRADE_NUM AS TRADE
|
||||
, B.STRATEGY_NUM AS STRATEGY_NUM
|
||||
, B.BOOK_CD AS BOOK
|
||||
, B.TRADER_PERSON_NUM AS TRADER_NUM
|
||||
, B.COUNTERPART_COMPANY_NUM AS COUNTERPART_NUM
|
||||
, B.INTERNAL_COMPANY_NUM AS ACCT
|
||||
, NVL( TO_CHAR(D.PAYMENT_DUE_DT, 'YYYYMMDD') , TO_CHAR(B.PAYMENT_DUE_DT, 'YYYYMMDD') )
|
||||
AS DUE_DT
|
||||
, B.INVOICE_NUMBER AS INVOICE
|
||||
, currencyAmount(B.PRICE_CURR_CD, C.ADJ_AMT)
|
||||
AS INVOICE_AMT
|
||||
, currencyAmount(B.PRICE_CURR_CD, D.PAID_AMT)
|
||||
AS PAID_AMT
|
||||
, CASE WHEN B.INVOICE_NUMBER IS NOT NULL THEN
|
||||
CASE WHEN C.INVOICE_DETAIL_OVERRIDE_IND = 1
|
||||
THEN currencyAmount(B.PRICE_CURR_CD, C.OVERRIDE_INVOICE_AMT)
|
||||
ELSE currencyAmount(B.PRICE_CURR_CD, C.INVOICE_AMT) END
|
||||
ELSE currencyAmount(B.PRICE_CURR_CD, B.EXTENDED_AMT) END
|
||||
AS EXTENDED_AMT
|
||||
, NVL(getFX_VALUE(C.AMT_CURR_CD, D.INVOICE_DT),1) AS INVOICE_FX_VALUE
|
||||
, NVL(getFX_VALUE(B.PRICE_CURR_CD, NULL),1) AS EXTENDED_FX_VALUE
|
||||
, B.CMDTY_CD AS CMDTY_CD
|
||||
, B.COST_TYPE_CD AS COST_TYPE_CD
|
||||
, CASE WHEN D.PAYMENT_DUE_DT IS NULL
|
||||
THEN dateDiff('DD', B.PAYMENT_DUE_DT ,SYSDATE)
|
||||
ELSE dateDiff('DD', D.PAYMENT_DUE_DT ,SYSDATE) END
|
||||
AS TTM
|
||||
, (CASE WHEN B.PRICE <0 THEN (-1) * B.QTY ELSE B.QTY END)
|
||||
AS QTY /* 가격이 마이너스일 경우 수량에 마이너스 부호 추가 */
|
||||
, B.QTY_UOM_CD AS UOM
|
||||
, currencyAmount(B.PRICE_CURR_CD, B.PRICE)
|
||||
AS PRICE
|
||||
, B.PREM_DISC AS PREM
|
||||
, CASE WHEN B.PRICE_CURR_CD IS NOT NULL AND B.PRICE_CURR_CD = 'USC'
|
||||
THEN 'USD'
|
||||
ELSE B.PRICE_CURR_CD END
|
||||
AS CURR_CD
|
||||
, B.PRICE_UOM_DESC AS PUOM
|
||||
, TO_CHAR( B.INCURRED_DT, 'YYYY-MM-DD')
|
||||
AS INCURRED
|
||||
, B.SETTLE_PAYMENT_TERM_CD AS PTERM
|
||||
, E.INTERFACE_VALUE_CODE AS PTYPE
|
||||
, B.DELIVERY_REF AS DELREF
|
||||
, B.DELIVERY_NUM AS DELIVERY
|
||||
, TO_CHAR( B.BL_DT, 'YYYY-MM-DD')
|
||||
AS BL
|
||||
, B.STL_BUY_SELL_IND AS BS_IND
|
||||
, B.PUT_CALL_IND AS OPNTYPE_IND
|
||||
, B.ITEM_INVOICED_IND AS INVOICED_IND
|
||||
, B.DELIVERY_TYPE_IND AS DELIVERED_IND
|
||||
, B.SPLIT_ITEM_IND AS SPLITTED_IND
|
||||
, B.PRICE_STATUS_IND AS PRICESTATUS_IND
|
||||
, B.PAYMENT_STATUS_IND AS PAYMENT_IND
|
||||
, B.DESCRIPTION AS DESCRIPTION
|
||||
FROM REF_CREDIT_LIMIT_DEFINITION A
|
||||
INNER JOIN STL_ITEM_HDR B ON A.COMPANY_NUM = B.COUNTERPART_COMPANY_NUM
|
||||
LEFT JOIN (SELECT
|
||||
(CASE WHEN RNK = 1
|
||||
THEN DET.DET_ADJ_AMT + DET_TAX.TAX_ADJ_AMT
|
||||
ELSE DET.DET_ADJ_AMT END )
|
||||
AS ADJ_AMT
|
||||
, DET.*
|
||||
FROM (
|
||||
SELECT
|
||||
X.*
|
||||
, (CASE WHEN OVERRIDE_INVOICE_AMT IS NULL
|
||||
THEN INVOICE_AMT
|
||||
ELSE OVERRIDE_INVOICE_AMT END )
|
||||
DET_ADJ_AMT
|
||||
, RANK() OVER (PARTITION BY INVOICE_HDR_NUM ORDER BY ABS(INVOICE_AMT) DESC ) RNK
|
||||
FROM STL_INVOICE_DETAIL X
|
||||
WHERE SUBSTR(ITEM_DESCRIPTION,1,3) <> 'TAX'
|
||||
) DET
|
||||
, (
|
||||
SELECT
|
||||
X.*
|
||||
, (CASE WHEN OVERRIDE_INVOICE_AMT IS NULL
|
||||
THEN INVOICE_AMT
|
||||
ELSE OVERRIDE_INVOICE_AMT END )
|
||||
AS TAX_ADJ_AMT
|
||||
FROM STL_INVOICE_DETAIL X
|
||||
WHERE SUBSTR(ITEM_DESCRIPTION,1,3) = 'TAX'
|
||||
) DET_TAX
|
||||
WHERE DET.INVOICE_HDR_NUM = DET_TAX.INVOICE_HDR_NUM
|
||||
) C ON B.ITEM_HDR_NUM = C.ITEM_HDR_NUM AND C.INV_DETAIL_STATUS_IND = 1
|
||||
LEFT JOIN STL_INVOICE_HDR D ON C.INVOICE_HDR_NUM = D.INVOICE_HDR_NUM
|
||||
AND D.INVOICE_STATUS_IND IN (
|
||||
SELECT REGEXP_SUBSTR(NVL('#{V_INVOICE_STATUS_IND}',''), '[^,]+', 1, LEVEL) FROM DUAL
|
||||
CONNECT BY REGEXP_SUBSTR(NVL('#{V_INVOICE_STATUS_IND}',''), '[^,]+', 1, LEVEL) IS NOT NULL
|
||||
)
|
||||
INNER JOIN TRD_TERM F ON B.TRADE_NUM = F.TRADE_NUM
|
||||
INNER JOIN REF_PAYMENT_TERM E ON B.SETTLE_PAYMENT_TERM_CD = E.PAYMENT_TERM_CD
|
||||
INNER JOIN TRD_HEADER G ON F.TRADE_NUM = G.TRADE_NUM AND F.INTERNAL_SIDE_IND = G.INTERNAL_SIDE_IND
|
||||
WHERE 1=1
|
||||
AND B.ITEM_STATUS_IND <> 0 /* 0:Defunct,1:Active,2:Reversed,3:Reversal */
|
||||
AND B.PAYMENT_STATUS_IND <> 2
|
||||
AND B.INTERNAL_COMPANY_NUM NOT IN (1668, 2307, 2142)
|
||||
AND B.COST_TYPE_CD IN
|
||||
( 'FB Chartering_CR'
|
||||
, 'FB Chartering_DR'
|
||||
, 'FB Chartering'
|
||||
, 'Primary Settlement'
|
||||
, 'Provisional Price'
|
||||
, 'Provisional Price Rv'
|
||||
, 'Purchase Adjustment'
|
||||
, 'Sales Adjustment'
|
||||
, 'Barging Fee'
|
||||
, 'Barging Cost'
|
||||
, 'Barging Cost_CR'
|
||||
, 'Barging Cost_DR' )
|
||||
AND B.TRADE_NUM NOT IN (SELECT TRADE_NUM
|
||||
FROM MD_CREDIT_REPORT_EXCEPT_TRADE
|
||||
WHERE EXCEPT_YN = 'Y')
|
||||
AND ( NVL(B.INSTRUMENT_CLASS_CD, '') = 'Physical' OR NVL(G.CLEARED_IND, -1) = -1 )
|
||||
AND ( NVL(B.INSTRUMENT_CLASS_CD, '') <> 'Physical'
|
||||
OR (
|
||||
UPPER(NVL(B.DEAL_ID2, '')) NOT LIKE '%FPP%'
|
||||
AND UPPER(NVL(B.DEAL_ID2, '')) NOT LIKE '%TARS%'
|
||||
AND UPPER(NVL(B.DEAL_ID2, '')) NOT LIKE '%KNOCK OUT%'
|
||||
)
|
||||
OR NVL( TO_CHAR( B.UNDERLYING_START_DT, 'YYYYMMDD'), '19000101') <= TO_CHAR( SYSDATE, 'YYYYMMDD')
|
||||
)
|
||||
AND B.TRADE_STATUS_IND NOT IN (5, 6)
|
||||
AND (NVL(B.INSTRUMENT_CLASS_CD, '') <> 'Physical'
|
||||
OR A.CREDIT_NETTING_IND = 1 /* 'Yes' */
|
||||
OR B.DELIVERY_TYPE_IND IN (2, 3) /* 0:Transfer ,1:Match ,2:Netout ,3:Bookout ,4:Stand-Alone Delivery */
|
||||
OR ((A.CREDIT_NETTING_IND = 0 OR A.CREDIT_NETTING_IND IS NULL) AND B.STL_BUY_SELL_IND = -1 ) /* stl_buy_sell_ind: -1:Sell, 1:buy, 0:N/A */
|
||||
OR ((A.CREDIT_NETTING_IND = 0 OR A.CREDIT_NETTING_IND IS NULL) AND F.SETTLE_PAYMENT_TERM_CD IN('SET OFF','BOOK OUT') )
|
||||
) /* SET OFF 거래에 대해 SELL / BUY를 모두 신용에 포함 로직 추가 */
|
||||
AND E.INTERFACE_VALUE_CODE = 'TT'
|
||||
AND B.COUNTERPART_COMPANY_NUM IN (
|
||||
SELECT COMPANY_NUM FROM REF_COMPANY
|
||||
WHERE ( COMPANY_TYPE_IND = '0' AND COMPANY_NUM NOT IN (3739,3743,3745) )
|
||||
OR ( COMPANY_TYPE_IND = '10' AND COMPANY_CD NOT IN ( 'SKEE', 'SKEA','SKEI' ))
|
||||
)
|
||||
AND B.SPLIT_ITEM_IND <> '1' /* 0:N/A, 1:Source, 2:Split. Split 된 경우, Source는 신용 산출 대상에서 제외. split 항목과 중복으로 계산됨 */
|
||||
AND TO_CHAR(B.COUNTERPART_COMPANY_NUM) IN (
|
||||
SELECT REGEXP_SUBSTR(NVL('#{P_COUNTPART_COMPANY_NUM}',''),'[^,]+', 1, LEVEL) FROM DUAL
|
||||
CONNECT BY REGEXP_SUBSTR(NVL('#{P_COUNTPART_COMPANY_NUM}',''), '[^,]+', 1, LEVEL) IS NOT NULL
|
||||
)
|
||||
) AA
|
||||
WHERE 1=1
|
||||
AND AA.PTerm <> 'Prepay before B/L' /* [2019.05.27] @V_SQL9 에 prepay 조건 추가 - Summary Detail 데이터 싱크 맞춤 */
|
||||
GROUP BY AA.TRADE, AA.COUNTERPART_NUM, AA.STRATEGY_NUM, AA.BOOK, AA.CMDTY_CD, AA.UOM
|
||||
) X
|
||||
UNION ALL
|
||||
SELECT
|
||||
1 AS Sort_Gbn
|
||||
, trade_num AS Trade
|
||||
, NULL AS Strategy_Num
|
||||
, 'Zero-Out / Credit Over' AS Strategy
|
||||
, NULL AS Book
|
||||
, trader_num AS Trader_Num
|
||||
, NULL AS Trader
|
||||
, CO.company_num AS Counterpart_Num
|
||||
, (SELECT company_cd FROM REF_COMPANY RC WHERE RC.company_num = CO.company_num)
|
||||
AS Counterpart
|
||||
, (select internal_company_num from trd_header where trade_num = co.trade_num)
|
||||
AS Acct_Num /* ACC_NUM 조회가능하도록 조치 */
|
||||
, (select company_cd from ref_company where company_num = (select internal_company_num from trd_header where trade_num = co.trade_num ))
|
||||
AS Acct /* ACCT 조회가능하도록 조치 */
|
||||
, NULL AS Due
|
||||
, NULL AS Invoice_Old
|
||||
, NULL AS Invoice
|
||||
, NULL AS Amount
|
||||
, extended_amt AS OpenAmt
|
||||
, extended_amt AS AMOUNT_OPENAMT
|
||||
, NULL AS cmdty_cd
|
||||
, NULL AS CostType
|
||||
, NULL AS TTM
|
||||
, NULL AS Qty
|
||||
, NULL AS Uom
|
||||
, NULL AS Price
|
||||
, NULL AS Prem
|
||||
, NULL AS Cur
|
||||
, NULL AS PUoM
|
||||
, NULL AS Incurred
|
||||
, NULL AS PTerm
|
||||
, NULL AS PType
|
||||
, NULL AS DelRef
|
||||
, NULL AS Delivery
|
||||
, NULL AS BL
|
||||
, NULL AS BS_Ind
|
||||
, NULL AS BS
|
||||
, NULL AS OpnType_Ind
|
||||
, NULL AS OpnType
|
||||
, NULL AS Invoiced_Ind
|
||||
, NULL AS Invoiced
|
||||
, NULL AS Delivered_Ind
|
||||
, NULL AS Delivered
|
||||
, NULL AS Splitted_Ind
|
||||
, NULL AS Splitted
|
||||
, NULL AS PriceStatus_Ind
|
||||
, NULL AS PriceStatus
|
||||
, NULL AS Payment_Ind
|
||||
, NULL AS Payment
|
||||
, NULL AS Description
|
||||
FROM CS_CREDIT_EXCESS_TRADE CO
|
||||
WHERE 1 = 1
|
||||
AND CO.TRADE_STATUS_IND = 10 /* 10 Discrepancy */
|
||||
AND CO.ZERO_OUT_IND = 1
|
||||
AND TO_CHAR(CO.COMPANY_NUM) IN (
|
||||
SELECT REGEXP_SUBSTR(NVL('#{P_COUNTPART_COMPANY_NUM}',''),'[^,]+', 1, LEVEL) FROM DUAL
|
||||
CONNECT BY REGEXP_SUBSTR(NVL('#{P_COUNTPART_COMPANY_NUM}',''),'[^,]+', 1, LEVEL) IS NOT NULL
|
||||
)
|
||||
/* @V_SQL10 */
|
||||
) BB ON RCLD.COMPANY_NUM = BB.COUNTERPARTY_NUM /* BB.counterpart_Num 에서 BB.counterparty_Num 으로 변경 */
|
||||
WHERE 1 = 1
|
||||
/* @V_WHERE_SQL2 */
|
||||
AND TO_CHAR(RCLD.COMPANY_NUM) IN (
|
||||
SELECT REGEXP_SUBSTR(NVL('#{P_COUNTPART_COMPANY_NUM}',''),'[^,]+', 1, LEVEL) FROM DUAL
|
||||
CONNECT BY REGEXP_SUBSTR(NVL('#{P_COUNTPART_COMPANY_NUM}',''),'[^,]+', 1, LEVEL) IS NOT NULL
|
||||
)
|
||||
/* @V_SQL11 */
|
||||
GROUP BY RCLD.COMPANY_NUM
|
||||
|
||||
) PRT_WEB /* USAGE 계산 등 REPORT 출력을 위해 전체 테이블 한번 더 묶음 (PRT_WEB) */
|
||||
/* @V_SORT_SQL2= ' */
|
||||
) DATA
|
||||
) ALL_DATA
|
||||
WHERE 1=1
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
---------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
AND ALL_DATA.ROWNUM BETWEEN ((' + TO_CHAR(, #{P_PAGE)} + ' - 1) * ' + TO_CHAR(, #{P_RP)} + ') + 1 AND (' + TO_CHAR(, #{P_PAGE)} + ' * ' + TO_CHAR(, #{P_RP)} + ')'
|
||||
ORDER BY ALL_DATA.ROWNUM
|
||||
|
||||
|
||||
@@ -0,0 +1,549 @@
|
||||
|
||||
/****
|
||||
SP_CREDIT_LIMIT_REPORT_SUMMARY
|
||||
> 구분 'CREDIT_SOLUTION' 인 경우
|
||||
EXEC(@V_SORT_SQL1 + @V_SQL1 + @V_SQL2 + @V_SQL3 + @V_SQL4 + @V_SQL5 + @V_SQL6 + @V_SQL7 + @V_SQL8 + @V_WHERE_SQL1 + @V_SQL9 + @V_SQL13 + @V_WHERE_SQL4 + @V_SQL10 + @V_WHERE_SQL2 + @V_SQL11 + @V_SORT_SQL2 + @V_SORT_SQL3 + @V_ORDER_SQL)
|
||||
|
||||
****/
|
||||
|
||||
SELECT ALL_DATA.*
|
||||
FROM (
|
||||
SELECT ROW_NUMBER() OVER(ORDER BY DATA.Counterparty) AS ROWNUM
|
||||
,DATA.*
|
||||
FROM (
|
||||
|
||||
---------------------------------------------------------------------------------------------------------------
|
||||
/*== @V_SQL1 == */
|
||||
SELECT
|
||||
PRT_WEB.COUNTERPARTY_NUM
|
||||
, '<A ONCLICK="LOADPAGE(''' || REF_COMPY.COMPANY_CD ||''', '''||TO_CHAR(RCLD.COMPANY_NUM)
|
||||
||''');" <FONT STYLE="COLOR:#3399FF; CURSOR:POINTER;" ONMOUSEOVER="THIS.STYLE.COLOR=''#FF9900''" ONMOUSEOUT="THIS.STYLE.COLOR=''#3399FF''"><U>'
|
||||
|| REF_COMPY.COMPANY_CD ||'</U></FONT>'
|
||||
AS COUNTERPARTY
|
||||
, REF_COMPY.COMPANY_CD
|
||||
AS COUNTERPARTY_EXCEL
|
||||
, REF_COMPY.COMPANY_NAME
|
||||
AS COUNTERPARTY_NAME
|
||||
,NVL((SELECT LPAD(CREDIT_ACC , 10, '0') FROM ETRM_REF_COUNTERPARTY WHERE USE_YN = 'Y' AND COMPANY_NUM = RCLD.COMPANY_NUM), '')
|
||||
AS CREDIT_ACC
|
||||
, (CASE WHEN TO_NUMBER(PRT_WEB.CREDITLIMIT) = 1
|
||||
THEN 0
|
||||
ELSE TO_NUMBER(PRT_WEB.CREDITLIMIT)
|
||||
END) AS CREDITLIMIT
|
||||
, TO_NUMBER(PRT_WEB.CREDITLIMIT * 0.9) AS TOLERANCE
|
||||
, PRT_WEB.CP_GUARANTEE
|
||||
, CASE WHEN PRT_WEB.ETRM_NET_EXPOSURE <0
|
||||
THEN (CASE WHEN TO_NUMBER(PRT_WEB.CREDITLIMIT) = 1
|
||||
THEN 0
|
||||
ELSE TO_NUMBER(PRT_WEB.CREDITLIMIT)
|
||||
END)
|
||||
ELSE (CASE WHEN TO_NUMBER(PRT_WEB.AVAILABILITY) = 1
|
||||
THEN 0
|
||||
ELSE TO_NUMBER(PRT_WEB.AVAILABILITY)
|
||||
END) END AS AVAILABILITY /* PRT_WEB.AVAILABILITY 출력에서 PRT_WEB.ETRM_NET_EXPOSURE 에 따른 AVAILABILITY 계산으로 변경 */
|
||||
, PRT_WEB.AMOUNT_UNINVOICED
|
||||
, PRT_WEB.AMOUNT_INVOICED
|
||||
, PRT_WEB.ETRM_NET_EXPOSURE
|
||||
, PRT_WEB.ETRM_NET_EXP_1
|
||||
, PRT_WEB.CHANGE
|
||||
, (CASE WHEN TO_NUMBER(PRT_WEB.ETRM_BALANCE) = 1
|
||||
THEN 0
|
||||
ELSE TO_NUMBER(PRT_WEB.ETRM_BALANCE)
|
||||
END) AS ETRM_BALANCE
|
||||
, CASE WHEN PRT_WEB.CREDITLIMIT = 1
|
||||
AND PRT_WEB.AVAILABILITY <= 0
|
||||
AND PRT_WEB.ETRM_NET_EXPOSURE <= 0
|
||||
THEN 0
|
||||
ELSE
|
||||
/* (PRT_WEB.ETRM_Net_Exposure / PRT_WEB.CreditLimit) * 100 */
|
||||
(CASE WHEN PRT_WEB.CreditLimit= 0
|
||||
THEN (PRT_WEB.ETRM_Net_Exposure - PRT_WEB.Advance_Received) * 100
|
||||
ELSE ((PRT_WEB.ETRM_Net_Exposure - PRT_WEB.Advance_Received) / PRT_WEB.CreditLimit) * 100 END)
|
||||
END AS ETRM_USAGE
|
||||
, PRT_WEB.USAGE_1
|
||||
, PRT_WEB.TI_LIMIT
|
||||
, PRT_WEB.ADVANCE_RECEIVED
|
||||
, PRT_WEB.TI_NET_EXPOSURE
|
||||
, PRT_WEB.TI_NET_EXPOSURE_1
|
||||
, PRT_WEB.TI_CHANGE
|
||||
, PRT_WEB.TI_USAGE
|
||||
, PRT_WEB.TI_USAGE_1
|
||||
, (CASE WHEN TO_NUMBER(PRT_WEB.CONSOLIDATED_LIMIT) = 1
|
||||
THEN 0
|
||||
ELSE TO_NUMBER(PRT_WEB.CONSOLIDATED_LIMIT) END) AS CONSOLIDATED_LIMIT
|
||||
, PRT_WEB.CREDIT_RATING
|
||||
, PRT_WEB.BIZ_TYPE
|
||||
, PRT_WEB.CONSOLIDATED_NET_EXPOSURE
|
||||
, CASE
|
||||
WHEN PRT_WEB.CREDITLIMIT = 1
|
||||
AND PRT_WEB.AVAILABILITY = 0
|
||||
AND PRT_WEB.ETRM_NET_EXPOSURE <= 0
|
||||
THEN
|
||||
CASE WHEN PRT_WEB.TI_LIMIT = 0 THEN 0
|
||||
ELSE PRT_WEB.TI_USAGE END
|
||||
WHEN PRT_WEB.CREDITLIMIT = 1
|
||||
AND PRT_WEB.AVAILABILITY = 0
|
||||
AND PRT_WEB.ETRM_NET_EXPOSURE > 0
|
||||
THEN
|
||||
CASE WHEN PRT_WEB.TI_LIMIT = 0
|
||||
THEN 100
|
||||
ELSE (PRT_WEB.ETRM_NET_EXPOSURE + PRT_WEB.TI_NET_EXPOSURE) / (PRT_WEB.CREDITLIMIT + PRT_WEB.TI_LIMIT) * 100 END
|
||||
ELSE
|
||||
(CASE WHEN PRT_WEB.CREDITLIMIT= 0
|
||||
THEN (PRT_WEB.ETRM_NET_EXPOSURE + PRT_WEB.TI_NET_EXPOSURE) / PRT_WEB.TI_LIMIT * 100
|
||||
ELSE (PRT_WEB.ETRM_NET_EXPOSURE + PRT_WEB.TI_NET_EXPOSURE) / (PRT_WEB.CREDITLIMIT + PRT_WEB.TI_LIMIT) * 100
|
||||
END)
|
||||
END AS TOTAL_USAGE
|
||||
, FN_CXL_GEN_INDICATOR_VALUE('restricted_ind',REF_COMPY.RESTRICTED_IND)
|
||||
AS STATUS
|
||||
,REF_COMPY.RESTRICTED_IND
|
||||
AS STATUS_IND
|
||||
, PRT_WEB.CREDIT_STATUS
|
||||
, PRT_WEB.NEXT_REVIEW_DATE
|
||||
, PRT_WEB.TOT_CNT
|
||||
FROM ( /* begin of PRT_WEB view */
|
||||
SELECT
|
||||
RCLD.COMPANY_NUM AS COUNTERPARTY_NUM
|
||||
/* scalar subquery 제거로 group by가 맞지 않아 PRT_WEB 으로 이동 */
|
||||
-- , '<A ONCLICK="LOADPAGE(''' || REF_COMPY.COMPANY_CD ||''', '''||TO_CHAR(RCLD.COMPANY_NUM)
|
||||
-- ||''');" <FONT STYLE="COLOR:#3399FF; CURSOR:POINTER;" ONMOUSEOVER="THIS.STYLE.COLOR=''#FF9900''" ONMOUSEOUT="THIS.STYLE.COLOR=''#3399FF''"><U>'
|
||||
-- || REF_COMPY.COMPANY_CD ||'</U></FONT>'
|
||||
-- AS COUNTERPARTY
|
||||
-- , REF_COMPY.COMPANY_CD
|
||||
-- AS COUNTERPARTY_EXCEL
|
||||
-- , REF_COMPY.COMPANY_NAME
|
||||
-- AS COUNTERPARTY_NAME
|
||||
-- ,NVL((SELECT LPAD(CREDIT_ACC , 10, '0') FROM ETRM_REF_COUNTERPARTY WHERE USE_YN = 'Y' AND COMPANY_NUM = RCLD.COMPANY_NUM), '')
|
||||
-- AS CREDIT_ACC
|
||||
,MAX(NVL(RCLD.CREDIT_LIMIT, 0)) AS CREDITLIMIT
|
||||
,0.000 AS CP_GUARANTEE
|
||||
, CASE WHEN ( TO_NUMBER(MAX(NVL(RCLD.CREDIT_LIMIT, 0)))
|
||||
- TO_NUMBER(SUM(NVL(BB.AMOUNT_OPENAMT,0)))
|
||||
+ NVL(MAX(ADVANCE_RECEIVED.ADVANCE_RECEIVED), 0) ) < 0
|
||||
THEN 0
|
||||
ELSE ( TO_NUMBER(MAX(NVL(RCLD.CREDIT_LIMIT, 0)))
|
||||
- TO_NUMBER(SUM(NVL(BB.AMOUNT_OPENAMT,0)))
|
||||
+ NVL(MAX(ADVANCE_RECEIVED.ADVANCE_RECEIVED), 0) )
|
||||
END
|
||||
AS AVAILABILITY /* CREDIT = 1 인경우 AVAILABILITY 를 0 으로 세팅 */
|
||||
, TO_NUMBER(SUM(NVL(BB.OPENAMT, 0)))
|
||||
AS AMOUNT_UNINVOICED
|
||||
, TO_NUMBER(SUM(NVL(BB.AMOUNT,0)))
|
||||
AS AMOUNT_INVOICED
|
||||
, TO_NUMBER(SUM(NVL(BB.AMOUNT_OPENAMT,0))) - 0.000
|
||||
AS ETRM_NET_EXPOSURE
|
||||
, MAX(MCRS.ETRM_NET_EXPOSURE)
|
||||
AS ETRM_NET_EXP_1
|
||||
, ( TO_NUMBER(SUM(NVL(BB.AMOUNT_OPENAMT,0))) - 0.000 )
|
||||
- TO_NUMBER(MAX(MCRS.ETRM_NET_EXPOSURE))
|
||||
AS CHANGE
|
||||
, TO_NUMBER(MAX(NVL(RCLD.CREDIT_LIMIT, 0))) - TO_NUMBER(SUM(NVL(BB.AMOUNT_OPENAMT,0))) - 0.000
|
||||
AS ETRM_BALANCE
|
||||
, 0 AS ETRM_USAGE
|
||||
, MAX(MCRS.ETRM_USAGE) AS USAGE_1
|
||||
, NVL(MAX(SAP_CONNTERPARTY.CREDIT_LIMIT), 0) AS TI_LIMIT
|
||||
, NVL(MAX(ADVANCE_RECEIVED.ADVANCE_RECEIVED), 0) AS ADVANCE_RECEIVED
|
||||
, NVL(MAX(SAP_CONNTERPARTY.CREDIT_EXPOSURE), 0) AS TI_NET_EXPOSURE
|
||||
, MAX(MCRS.TI_NET_EXPOSURE) AS TI_NET_EXPOSURE_1
|
||||
, 0.000 AS TI_CHANGE
|
||||
/* */
|
||||
,CASE WHEN NVL(MAX(SAP_CONNTERPARTY.CREDIT_EXPOSURE), 0) = 0
|
||||
THEN 0
|
||||
ELSE
|
||||
CASE WHEN NVL(MAX(SAP_CONNTERPARTY.CREDIT_LIMIT), 0) = 0
|
||||
THEN ROUND(NVL(MAX(SAP_CONNTERPARTY.CREDIT_EXPOSURE), 0)/1, 2) * 100
|
||||
ELSE ROUND(NVL(MAX(SAP_CONNTERPARTY.CREDIT_EXPOSURE), 0)/NVL(MAX(SAP_CONNTERPARTY.CREDIT_LIMIT), 0), 2) * 100
|
||||
END
|
||||
END AS TI_USAGE
|
||||
,MAX(MCRS.TI_USAGE) AS TI_USAGE_1
|
||||
,TO_NUMBER( MAX(CASE WHEN NVL(RCLD.CREDIT_LIMIT, 0) = 1 THEN 0 ELSE NVL(RCLD.CREDIT_LIMIT, 0) END) )
|
||||
+ NVL(MAX(SAP_CONNTERPARTY.CREDIT_LIMIT), 0)
|
||||
AS Consolidated_Limit
|
||||
, MAX(RCLD.INTERNAL_CREDIT_RATING) AS CREDIT_RATING
|
||||
, MAX(RCLD.EXTERNAL_CREDIT_RATING) AS BIZ_TYPE
|
||||
, ( TO_NUMBER(SUM(NVL(BB.AMOUNT_OPENAMT,0))) - 0.000) + NVL(MAX(SAP_CONNTERPARTY.CREDIT_EXPOSURE), 0)
|
||||
AS Consolidated_NET_EXPOSURE
|
||||
, CASE WHEN TO_NUMBER( MAX(NVL(RCLD.CREDIT_LIMIT, 0))) in (1, 0) AND NVL(MAX(SAP_CONNTERPARTY.CREDIT_LIMIT), 0) = 0
|
||||
THEN 100
|
||||
ELSE CASE WHEN TO_NUMBER(MAX(NVL(RCLD.CREDIT_LIMIT, 0))) in (1, 0) AND NVL(MAX(SAP_CONNTERPARTY.CREDIT_LIMIT), 0) <> 0
|
||||
THEN ROUND(NVL(MAX(SAP_CONNTERPARTY.CREDIT_EXPOSURE), 0) / NVL(MAX(SAP_CONNTERPARTY.CREDIT_LIMIT), 0), 2) * 100
|
||||
ELSE ROUND((((SUM(NVL(BB.AMOUNT_OPENAMT,0)))) - 0.000) + NVL(MAX(SAP_CONNTERPARTY.CREDIT_EXPOSURE), 0)
|
||||
/ ( TO_NUMBER(MAX(NVL(RCLD.credit_limit, 0))) + NVL(MAX(SAP_CONNTERPARTY.CREDIT_LIMIT), 0)), 2)* 100
|
||||
END
|
||||
END AS Total_USAGE /* Credit = 1 인경우 availability 를 0, USAGE 100 세팅하기 때문에 Total_USAGE도 그에 맞춰 수정 */
|
||||
/* scalar subquery 제거로 group by가 맞지 않아 PRT_WEB 으로 이동 */
|
||||
-- , FN_CXL_GEN_INDICATOR_VALUE('restricted_ind',REF_COMPY.RESTRICTED_IND)
|
||||
-- AS Status
|
||||
-- ,REF_COMPY.RESTRICTED_IND
|
||||
-- AS Status_Ind
|
||||
,MAX(RCLD.Credit_Status) AS Credit_Status
|
||||
,MAX(NVL(RCLD.Next_Review_Date, '')) AS Next_Review_Date
|
||||
,COUNT(*) OVER() AS TOT_CNT
|
||||
|
||||
/* @V_SQL3 = ' */
|
||||
FROM (
|
||||
SELECT
|
||||
COMPANY_NUM AS COMPANY_NUM /* pk */
|
||||
, (CASE WHEN CREDIT_LIMIT = 0 THEN 1 ELSE CREDIT_LIMIT END) AS CREDIT_LIMIT
|
||||
, NVL(INTERNAL_CREDIT_RATING, '') AS INTERNAL_CREDIT_RATING
|
||||
, NVL(EXTERNAL_CREDIT_RATING, '') AS EXTERNAL_CREDIT_RATING
|
||||
, NVL(CREDIT_STATUS, '') AS CREDIT_STATUS
|
||||
, TO_CHAR(NEXT_REVIEW_DATE, 'YYYY-MM-DD') AS NEXT_REVIEW_DATE
|
||||
FROM REF_CREDIT_LIMIT_DEFINITION
|
||||
WHERE COMPANY_NUM IN (
|
||||
SELECT COMPANY_NUM
|
||||
FROM REF_COMPANY
|
||||
WHERE ( COMPANY_TYPE_IND = '0' AND COMPANY_NUM NOT IN ( 3739,3743,3745 ))
|
||||
OR ( COMPANY_TYPE_IND = '10' AND COMPANY_CD NOT IN ( 'SKEE', 'SKEA','SKEI' ))
|
||||
)
|
||||
) RCLD
|
||||
LEFT JOIN MD_CREDIT_REPORT_SUMMARY MCRS ON RCLD.company_num = MCRS.COUNTERPARTY AND INPUT_DATE = TO_CHAR( SYSDATE-1, 'YYYYMMDD') /* PK join */
|
||||
LEFT JOIN (
|
||||
SELECT COMPANY_NUM, LPAD( credit_acc, 10, '0') AS CREDIT_ACC
|
||||
FROM ETRM_REF_COUNTERPARTY
|
||||
WHERE USE_YN = 'Y' )
|
||||
ETRM_COUNTERPARTY ON RCLD.company_num = ETRM_COUNTERPARTY.COMPANY_NUM /* PK join */
|
||||
LEFT JOIN (
|
||||
SELECT
|
||||
COUNTERPARTY_CD
|
||||
,SUM(TO_NUMBER(CREDIT_LIMIT , '999999999999.999999' )) AS CREDIT_LIMIT
|
||||
,SUM(TO_NUMBER(CREDIT_EXPOSURE, '999999999999.999999' )) AS CREDIT_EXPOSURE
|
||||
FROM MD_CREDIT_SAP_IF_COUNTERPARTY
|
||||
WHERE CREDIT_SAP_ID = '#{P_CREDIT_SAP_ID}'
|
||||
GROUP BY COUNTERPARTY_CD )
|
||||
SAP_CONNTERPARTY ON ETRM_COUNTERPARTY.CREDIT_ACC = SAP_CONNTERPARTY.COUNTERPARTY_CD /* Uinque join */
|
||||
LEFT JOIN (
|
||||
SELECT
|
||||
COMPANY_NUM
|
||||
, SUM(TO_NUMBER( ADVANCE_RECEIVED, '999999999999.999999' )) AS ADVANCE_RECEIVED
|
||||
FROM MD_CREDIT_ADVANCE_RECEIVED
|
||||
WHERE ADVANCE_RECEIVED_ID = '#{P_ADVANCE_RECEIVED_ID}'
|
||||
GROUP BY COMPANY_NUM )
|
||||
ADVANCE_RECEIVED ON RCLD.company_num = ADVANCE_RECEIVED.COMPANY_NUM /* Uinque join */
|
||||
LEFT JOIN
|
||||
( SELECT
|
||||
2 AS Sort_Gbn
|
||||
, X.Trade
|
||||
, X.Strategy_Num
|
||||
, (SELECT strategy_name FROM ORG_STRATEGY WHERE strategy_num = X.Strategy_Num)
|
||||
AS Strategy
|
||||
, X.Book
|
||||
, X.Trader_Num
|
||||
, (SELECT last_name + ' ' + first_name FROM REF_PERSON WHERE person_num = X.Trader_Num)
|
||||
AS Trader
|
||||
, X.COUNTERPARTY_NUM
|
||||
, (SELECT COMPANY_CD FROM REF_COMPANY WHERE COMPANY_NUM = X.COUNTERPARTY_NUM)
|
||||
AS COUNTERPART
|
||||
, X.ACCT_NUM
|
||||
, (SELECT COMPANY_CD FROM REF_COMPANY WHERE COMPANY_NUM = X.ACCT_NUM)
|
||||
AS ACCT
|
||||
, X.DUE
|
||||
, X.INVOICE_OLD
|
||||
, selectInvoiceNumber(X.TRADE)
|
||||
AS Invoice
|
||||
, X.AMOUNT , X.OPENAMT
|
||||
, NVL(X.AMOUNT,0)+NVL(X.OPENAMT,0) AS AMOUNT_OPENAMT
|
||||
, X.CMDTY_CD , X.COSTTYPE , X.TTM , X.QTY , X.UOM , X.PRICE , X.PREM , X.CUR
|
||||
, X.PUOM , X.INCURRED , X.PTERM , X.PTYPE , X.DELREF , X.DELIVERY , X.BL
|
||||
, X.BS_IND
|
||||
, FN_CXL_GEN_INDICATOR_VALUE('stl_buy_sell_ind', X.BS_Ind)
|
||||
AS BS
|
||||
, X.OpnType_Ind
|
||||
, FN_CXL_GEN_INDICATOR_VALUE('put_call_ind', X.OpnType_Ind)
|
||||
AS OpnType
|
||||
, X.Invoiced_Ind
|
||||
, FN_CXL_GEN_INDICATOR_VALUE('item_invoiced_ind', X.Invoiced_Ind)
|
||||
AS Invoiced
|
||||
, X.Delivered_Ind
|
||||
, FN_CXL_GEN_INDICATOR_VALUE('delivery_type_ind', X.Delivered_Ind)
|
||||
AS Delivered
|
||||
, X.Splitted_Ind
|
||||
, FN_CXL_GEN_INDICATOR_VALUE('split_item_ind', X.Splitted_Ind)
|
||||
AS Splitted
|
||||
, X.PriceStatus_Ind
|
||||
, FN_CXL_GEN_INDICATOR_VALUE('price_status_ind', X.PriceStatus_Ind)
|
||||
AS PriceStatus
|
||||
, X.Payment_Ind
|
||||
, FN_CXL_GEN_INDICATOR_VALUE('payment_status_ind', X.Payment_Ind)
|
||||
AS Payment
|
||||
, X.Description
|
||||
FROM ( /* begin of X view */
|
||||
SELECT
|
||||
AA.Trade AS Trade
|
||||
, AA.Strategy_Num AS Strategy_Num
|
||||
, AA.Book AS Book
|
||||
, MAX(AA.Trader_Num) AS Trader_Num
|
||||
, AA.COUNTERPART_NUM AS COUNTERPARTY_NUM
|
||||
/* , AA.COUNTERPART_NUM AS COUNTERPART_NUM */
|
||||
, MAX(AA.ACCT) AS ACCT_NUM
|
||||
, MIN(AA.DUE_DT) AS DUE
|
||||
, MAX(AA.INVOICE) AS INVOICE_OLD
|
||||
, SUM(CASE
|
||||
WHEN ( ABS(AA.INVOICE_AMT * AA.INVOICE_FX_VALUE) - ABS(AA.PAID_AMT * AA.INVOICE_FX_VALUE)) > 0
|
||||
THEN ((AA.INVOICE_AMT * AA.INVOICE_FX_VALUE) - (AA.PAID_AMT * AA.INVOICE_FX_VALUE))
|
||||
ELSE NULL
|
||||
END) AS AMOUNT
|
||||
, SUM(CASE
|
||||
WHEN ( ABS(AA.EXTENDED_AMT * AA.EXTENDED_FX_VALUE) - ABS(AA.INVOICE_AMT * AA.INVOICE_FX_VALUE)) > 0
|
||||
THEN ((AA.EXTENDED_AMT * AA.EXTENDED_FX_VALUE) - (AA.INVOICE_AMT * AA.INVOICE_FX_VALUE))
|
||||
ELSE NULL
|
||||
END) AS OPENAMT
|
||||
, AA.CMDTY_CD AS CMDTY_CD
|
||||
, MAX(AA.COST_TYPE_CD) AS COSTTYPE
|
||||
, MAX(AA.TTM) AS TTM
|
||||
, SUM(AA.QTY) AS QTY
|
||||
, AA.UOM AS UOM
|
||||
, MAX(AA.PRICE) AS PRICE
|
||||
, MAX(AA.PREM) AS PREM
|
||||
, MAX(AA.CURR_CD) AS CUR
|
||||
, MAX(AA.PUOM) AS PUOM
|
||||
, MAX(AA.INCURRED) AS INCURRED
|
||||
, MAX(AA.PTERM) AS PTERM
|
||||
, MAX(AA.PTYPE) AS PTYPE
|
||||
, MAX(AA.DELREF) AS DELREF
|
||||
, MAX(AA.DELIVERY) AS DELIVERY
|
||||
, MAX(AA.BL) AS BL
|
||||
, MAX(AA.BS_IND) AS BS_IND
|
||||
, MAX(AA.OpnType_Ind) AS OpnType_Ind
|
||||
, MAX(AA.Invoiced_Ind) AS Invoiced_Ind
|
||||
, MAX(AA.Delivered_Ind) AS Delivered_Ind
|
||||
, MAX(AA.Splitted_Ind) AS Splitted_Ind
|
||||
, MAX(AA.PriceStatus_Ind) AS PriceStatus_Ind
|
||||
, MAX(AA.Payment_Ind) AS Payment_Ind
|
||||
, MAX(AA.Description) AS Description
|
||||
FROM ( /* begin of AA view */
|
||||
SELECT
|
||||
B.TRADE_NUM AS TRADE
|
||||
, B.STRATEGY_NUM AS STRATEGY_NUM
|
||||
, B.BOOK_CD AS BOOK
|
||||
, B.TRADER_PERSON_NUM AS TRADER_NUM
|
||||
, B.COUNTERPART_COMPANY_NUM AS COUNTERPART_NUM
|
||||
, B.INTERNAL_COMPANY_NUM AS ACCT
|
||||
, NVL( TO_CHAR(D.PAYMENT_DUE_DT, 'YYYYMMDD') , TO_CHAR(B.PAYMENT_DUE_DT, 'YYYYMMDD') )
|
||||
AS DUE_DT
|
||||
, B.INVOICE_NUMBER AS INVOICE
|
||||
, currencyAmount(B.PRICE_CURR_CD, C.ADJ_AMT)
|
||||
AS INVOICE_AMT
|
||||
, currencyAmount(B.PRICE_CURR_CD, D.PAID_AMT)
|
||||
AS PAID_AMT
|
||||
, CASE WHEN B.INVOICE_NUMBER IS NOT NULL THEN
|
||||
CASE WHEN C.INVOICE_DETAIL_OVERRIDE_IND = 1
|
||||
THEN currencyAmount(B.PRICE_CURR_CD, C.OVERRIDE_INVOICE_AMT)
|
||||
ELSE currencyAmount(B.PRICE_CURR_CD, C.INVOICE_AMT) END
|
||||
ELSE currencyAmount(B.PRICE_CURR_CD, B.EXTENDED_AMT) END
|
||||
AS EXTENDED_AMT
|
||||
, NVL(getFX_VALUE(C.AMT_CURR_CD, D.INVOICE_DT),1) AS INVOICE_FX_VALUE
|
||||
, NVL(getFX_VALUE(B.PRICE_CURR_CD, NULL),1) AS EXTENDED_FX_VALUE
|
||||
, B.CMDTY_CD AS CMDTY_CD
|
||||
, B.COST_TYPE_CD AS COST_TYPE_CD
|
||||
, CASE WHEN D.PAYMENT_DUE_DT IS NULL
|
||||
THEN dateDiff('DD', B.PAYMENT_DUE_DT ,SYSDATE)
|
||||
ELSE dateDiff('DD', D.PAYMENT_DUE_DT ,SYSDATE) END
|
||||
AS TTM
|
||||
, (CASE WHEN B.PRICE <0 THEN (-1) * B.QTY ELSE B.QTY END)
|
||||
AS QTY /* 가격이 마이너스일 경우 수량에 마이너스 부호 추가 */
|
||||
, B.QTY_UOM_CD AS UOM
|
||||
, currencyAmount(B.PRICE_CURR_CD, B.PRICE)
|
||||
AS PRICE
|
||||
, B.PREM_DISC AS PREM
|
||||
, CASE WHEN B.PRICE_CURR_CD IS NOT NULL AND B.PRICE_CURR_CD = 'USC'
|
||||
THEN 'USD'
|
||||
ELSE B.PRICE_CURR_CD END
|
||||
AS CURR_CD
|
||||
, B.PRICE_UOM_DESC AS PUOM
|
||||
, TO_CHAR( B.INCURRED_DT, 'YYYY-MM-DD')
|
||||
AS INCURRED
|
||||
, B.SETTLE_PAYMENT_TERM_CD AS PTERM
|
||||
, E.INTERFACE_VALUE_CODE AS PTYPE
|
||||
, B.DELIVERY_REF AS DELREF
|
||||
, B.DELIVERY_NUM AS DELIVERY
|
||||
, TO_CHAR( B.BL_DT, 'YYYY-MM-DD')
|
||||
AS BL
|
||||
, B.STL_BUY_SELL_IND AS BS_IND
|
||||
, B.PUT_CALL_IND AS OPNTYPE_IND
|
||||
, B.ITEM_INVOICED_IND AS INVOICED_IND
|
||||
, B.DELIVERY_TYPE_IND AS DELIVERED_IND
|
||||
, B.SPLIT_ITEM_IND AS SPLITTED_IND
|
||||
, B.PRICE_STATUS_IND AS PRICESTATUS_IND
|
||||
, B.PAYMENT_STATUS_IND AS PAYMENT_IND
|
||||
, B.DESCRIPTION AS DESCRIPTION
|
||||
FROM REF_CREDIT_LIMIT_DEFINITION A
|
||||
INNER JOIN STL_ITEM_HDR B ON A.COMPANY_NUM = B.COUNTERPART_COMPANY_NUM
|
||||
LEFT JOIN (SELECT
|
||||
(CASE WHEN RNK = 1
|
||||
THEN DET.DET_ADJ_AMT + DET_TAX.TAX_ADJ_AMT
|
||||
ELSE DET.DET_ADJ_AMT END )
|
||||
AS ADJ_AMT
|
||||
, DET.*
|
||||
FROM (
|
||||
SELECT
|
||||
X.*
|
||||
, (CASE WHEN OVERRIDE_INVOICE_AMT IS NULL
|
||||
THEN INVOICE_AMT
|
||||
ELSE OVERRIDE_INVOICE_AMT END )
|
||||
DET_ADJ_AMT
|
||||
, RANK() OVER (PARTITION BY INVOICE_HDR_NUM ORDER BY ABS(INVOICE_AMT) DESC ) RNK
|
||||
FROM STL_INVOICE_DETAIL X
|
||||
WHERE SUBSTR(ITEM_DESCRIPTION,1,3) <> 'TAX'
|
||||
) DET
|
||||
, (
|
||||
SELECT
|
||||
X.*
|
||||
, (CASE WHEN OVERRIDE_INVOICE_AMT IS NULL
|
||||
THEN INVOICE_AMT
|
||||
ELSE OVERRIDE_INVOICE_AMT END )
|
||||
AS TAX_ADJ_AMT
|
||||
FROM STL_INVOICE_DETAIL X
|
||||
WHERE SUBSTR(ITEM_DESCRIPTION,1,3) = 'TAX'
|
||||
) DET_TAX
|
||||
WHERE DET.INVOICE_HDR_NUM = DET_TAX.INVOICE_HDR_NUM
|
||||
) C ON B.ITEM_HDR_NUM = C.ITEM_HDR_NUM AND C.INV_DETAIL_STATUS_IND = 1
|
||||
LEFT JOIN STL_INVOICE_HDR D ON C.INVOICE_HDR_NUM = D.INVOICE_HDR_NUM
|
||||
AND D.INVOICE_STATUS_IND IN (
|
||||
SELECT REGEXP_SUBSTR(NVL('#{V_INVOICE_STATUS_IND}',''), '[^,]+', 1, LEVEL) FROM DUAL
|
||||
CONNECT BY REGEXP_SUBSTR(NVL('#{V_INVOICE_STATUS_IND}',''), '[^,]+', 1, LEVEL) IS NOT NULL
|
||||
)
|
||||
INNER JOIN TRD_TERM F ON B.TRADE_NUM = F.TRADE_NUM
|
||||
INNER JOIN REF_PAYMENT_TERM E ON B.SETTLE_PAYMENT_TERM_CD = E.PAYMENT_TERM_CD
|
||||
INNER JOIN TRD_HEADER G ON F.TRADE_NUM = G.TRADE_NUM AND F.INTERNAL_SIDE_IND = G.INTERNAL_SIDE_IND
|
||||
WHERE 1=1
|
||||
AND B.ITEM_STATUS_IND <> 0 /* 0:Defunct,1:Active,2:Reversed,3:Reversal */
|
||||
AND B.PAYMENT_STATUS_IND <> 2
|
||||
AND B.INTERNAL_COMPANY_NUM NOT IN (1668, 2307, 2142)
|
||||
AND B.COST_TYPE_CD IN
|
||||
( 'FB Chartering_CR'
|
||||
, 'FB Chartering_DR'
|
||||
, 'FB Chartering'
|
||||
, 'Primary Settlement'
|
||||
, 'Provisional Price'
|
||||
, 'Provisional Price Rv'
|
||||
, 'Purchase Adjustment'
|
||||
, 'Sales Adjustment'
|
||||
, 'Barging Fee'
|
||||
, 'Barging Cost'
|
||||
, 'Barging Cost_CR'
|
||||
, 'Barging Cost_DR' )
|
||||
AND B.TRADE_NUM NOT IN (SELECT TRADE_NUM
|
||||
FROM MD_CREDIT_REPORT_EXCEPT_TRADE
|
||||
WHERE EXCEPT_YN = 'Y')
|
||||
AND ( NVL(B.INSTRUMENT_CLASS_CD, '') = 'Physical' OR NVL(G.CLEARED_IND, -1) = -1 )
|
||||
AND ( NVL(B.INSTRUMENT_CLASS_CD, '') <> 'Physical'
|
||||
OR (
|
||||
UPPER(NVL(B.DEAL_ID2, '')) NOT LIKE '%FPP%'
|
||||
AND UPPER(NVL(B.DEAL_ID2, '')) NOT LIKE '%TARS%'
|
||||
AND UPPER(NVL(B.DEAL_ID2, '')) NOT LIKE '%KNOCK OUT%'
|
||||
)
|
||||
OR NVL( TO_CHAR( B.UNDERLYING_START_DT, 'YYYYMMDD'), '19000101') <= TO_CHAR( SYSDATE, 'YYYYMMDD')
|
||||
)
|
||||
AND B.TRADE_STATUS_IND NOT IN (5, 6)
|
||||
AND (NVL(B.INSTRUMENT_CLASS_CD, '') <> 'Physical'
|
||||
OR A.CREDIT_NETTING_IND = 1 /* 'Yes' */
|
||||
OR B.DELIVERY_TYPE_IND IN (2, 3) /* 0:Transfer ,1:Match ,2:Netout ,3:Bookout ,4:Stand-Alone Delivery */
|
||||
OR ((A.CREDIT_NETTING_IND = 0 OR A.CREDIT_NETTING_IND IS NULL) AND B.STL_BUY_SELL_IND = -1 ) /* stl_buy_sell_ind: -1:Sell, 1:buy, 0:N/A */
|
||||
OR ((A.CREDIT_NETTING_IND = 0 OR A.CREDIT_NETTING_IND IS NULL) AND F.SETTLE_PAYMENT_TERM_CD IN('SET OFF','BOOK OUT') )
|
||||
) /* SET OFF 거래에 대해 SELL / BUY를 모두 신용에 포함 로직 추가 */
|
||||
AND E.INTERFACE_VALUE_CODE = 'TT'
|
||||
AND B.COUNTERPART_COMPANY_NUM IN (
|
||||
SELECT COMPANY_NUM FROM REF_COMPANY
|
||||
WHERE ( COMPANY_TYPE_IND = '0' AND COMPANY_NUM NOT IN (3739,3743,3745) )
|
||||
OR ( COMPANY_TYPE_IND = '10' AND COMPANY_CD NOT IN ( 'SKEE', 'SKEA','SKEI' ))
|
||||
)
|
||||
AND B.SPLIT_ITEM_IND <> '1' /* 0:N/A, 1:Source, 2:Split. Split 된 경우, Source는 신용 산출 대상에서 제외. split 항목과 중복으로 계산됨 */
|
||||
AND TO_CHAR(B.COUNTERPART_COMPANY_NUM) IN (
|
||||
SELECT REGEXP_SUBSTR(NVL('#{P_COUNTPART_COMPANY_NUM}',''),'[^,]+', 1, LEVEL) FROM DUAL
|
||||
CONNECT BY REGEXP_SUBSTR(NVL('#{P_COUNTPART_COMPANY_NUM}',''), '[^,]+', 1, LEVEL) IS NOT NULL
|
||||
)
|
||||
) AA
|
||||
WHERE 1=1
|
||||
AND AA.PTerm <> 'Prepay before B/L' /* [2019.05.27] @V_SQL9 에 prepay 조건 추가 - Summary Detail 데이터 싱크 맞춤 */
|
||||
GROUP BY AA.TRADE, AA.COUNTERPART_NUM, AA.STRATEGY_NUM, AA.BOOK, AA.CMDTY_CD, AA.UOM
|
||||
) X
|
||||
UNION ALL
|
||||
SELECT
|
||||
1 AS Sort_Gbn
|
||||
, trade_num AS Trade
|
||||
, NULL AS Strategy_Num
|
||||
, 'Zero-Out / Credit Over' AS Strategy
|
||||
, NULL AS Book
|
||||
, trader_num AS Trader_Num
|
||||
, NULL AS Trader
|
||||
, CO.COMPANY_NUM AS COUNTERPARTY_NUM
|
||||
, (SELECT company_cd FROM REF_COMPANY RC WHERE RC.company_num = CO.company_num)
|
||||
AS Counterpart
|
||||
, (select internal_company_num from trd_header where trade_num = co.trade_num)
|
||||
AS Acct_Num /* ACC_NUM 조회가능하도록 조치 */
|
||||
, (select company_cd from ref_company where company_num = (select internal_company_num from trd_header where trade_num = co.trade_num ))
|
||||
AS Acct /* ACCT 조회가능하도록 조치 */
|
||||
, NULL AS Due
|
||||
, NULL AS Invoice_Old
|
||||
, NULL AS Invoice
|
||||
, NULL AS Amount
|
||||
, extended_amt AS OpenAmt
|
||||
, extended_amt AS AMOUNT_OPENAMT
|
||||
, NULL AS cmdty_cd
|
||||
, NULL AS CostType
|
||||
, NULL AS TTM
|
||||
, NULL AS Qty
|
||||
, NULL AS Uom
|
||||
, NULL AS Price
|
||||
, NULL AS Prem
|
||||
, NULL AS Cur
|
||||
, NULL AS PUoM
|
||||
, NULL AS Incurred
|
||||
, NULL AS PTerm
|
||||
, NULL AS PType
|
||||
, NULL AS DelRef
|
||||
, NULL AS Delivery
|
||||
, NULL AS BL
|
||||
, NULL AS BS_Ind
|
||||
, NULL AS BS
|
||||
, NULL AS OpnType_Ind
|
||||
, NULL AS OpnType
|
||||
, NULL AS Invoiced_Ind
|
||||
, NULL AS Invoiced
|
||||
, NULL AS Delivered_Ind
|
||||
, NULL AS Delivered
|
||||
, NULL AS Splitted_Ind
|
||||
, NULL AS Splitted
|
||||
, NULL AS PriceStatus_Ind
|
||||
, NULL AS PriceStatus
|
||||
, NULL AS Payment_Ind
|
||||
, NULL AS Payment
|
||||
, NULL AS Description
|
||||
FROM CS_CREDIT_EXCESS_TRADE CO
|
||||
WHERE 1 = 1
|
||||
AND CO.TRADE_STATUS_IND = 10 /* 10 Discrepancy */
|
||||
AND CO.ZERO_OUT_IND = 1
|
||||
AND TO_CHAR(CO.COMPANY_NUM) IN (
|
||||
SELECT REGEXP_SUBSTR(NVL('#{P_COUNTPART_COMPANY_NUM}',''),'[^,]+', 1, LEVEL) FROM DUAL
|
||||
CONNECT BY REGEXP_SUBSTR(NVL('#{P_COUNTPART_COMPANY_NUM}',''),'[^,]+', 1, LEVEL) IS NOT NULL
|
||||
)
|
||||
/* @V_SQL10 */
|
||||
) BB ON RCLD.COMPANY_NUM = BB.COUNTERPARTY_NUM /* BB.counterpart_Num 에서 BB.counterparty_Num 으로 변경 */
|
||||
WHERE 1 = 1
|
||||
/* @V_WHERE_SQL2 */
|
||||
AND TO_CHAR(RCLD.COMPANY_NUM) IN (
|
||||
SELECT REGEXP_SUBSTR(NVL('#{P_COUNTPART_COMPANY_NUM}',''),'[^,]+', 1, LEVEL) FROM DUAL
|
||||
CONNECT BY REGEXP_SUBSTR(NVL('#{P_COUNTPART_COMPANY_NUM}',''),'[^,]+', 1, LEVEL) IS NOT NULL
|
||||
)
|
||||
/* @V_SQL11 */
|
||||
GROUP BY RCLD.COMPANY_NUM
|
||||
) PRT_WEB /* USAGE 계산 등 REPORT 출력을 위해 전체 테이블 한번 더 묶음 (PRT_WEB) */
|
||||
LEFT JOIN REF_COMPANY REF_COMPY ON REF_COMPY.COMPANY_NUM = PRT_WEB.COUNTERPARTY_NUM
|
||||
|
||||
/* @V_SORT_SQL2= ' */
|
||||
) DATA
|
||||
) ALL_DATA
|
||||
WHERE 1=1
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
---------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
AND ALL_DATA.ROWNUM BETWEEN ((' + TO_CHAR(, #{P_PAGE)} + ' - 1) * ' + TO_CHAR(, #{P_RP)} + ') + 1 AND (' + TO_CHAR(, #{P_PAGE)} + ' * ' + TO_CHAR(, #{P_RP)} + ')'
|
||||
ORDER BY ALL_DATA.ROWNUM
|
||||
|
||||
|
||||
14
src/main/java/com/Application.java
Normal file
14
src/main/java/com/Application.java
Normal file
@@ -0,0 +1,14 @@
|
||||
package com;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.web.support.SpringBootServletInitializer;
|
||||
|
||||
@SpringBootApplication
|
||||
public class Application extends SpringBootServletInitializer {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(Application.class, args);
|
||||
}
|
||||
|
||||
}
|
||||
122
src/main/java/com/skti/bcm/board/domain/model/Article.java
Normal file
122
src/main/java/com/skti/bcm/board/domain/model/Article.java
Normal file
@@ -0,0 +1,122 @@
|
||||
/**
|
||||
* Copyright (c) 2018 SK INNOVATION Co., Ltd. All rights reserved.
|
||||
*
|
||||
* This software is the confidential and proprietary information of SK INNOVATION.
|
||||
* You shall not disclose such confidential information and shall use it only in accordance
|
||||
* with the terms of the license agreement you entered into with SK INNOVATION.
|
||||
*/
|
||||
package com.skti.bcm.board.domain.model;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.FetchType;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.Lob;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.OneToMany;
|
||||
import javax.persistence.Transient;
|
||||
|
||||
import org.hibernate.annotations.Type;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonBackReference;
|
||||
import com.fasterxml.jackson.annotation.JsonManagedReference;
|
||||
import com.skti.bcm.common.domain.model.BaseModelUseYnSupport;
|
||||
import com.skti.bcm.file.domain.model.AttachFile;
|
||||
import com.skti.bcm.file.domain.service.dto.AttachFileUpdateDTO;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
*
|
||||
* History
|
||||
* - 2018. 07. 17. | in01871 | 최초작성.
|
||||
* - 2018. 07. 17. | in01943 | 2차 수정.
|
||||
* </pre>
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Entity(name = "TB_BCM_ARTICLE")
|
||||
public class Article extends BaseModelUseYnSupport {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 게시글 아이디 */
|
||||
@ApiModelProperty(hidden = true)
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.AUTO)
|
||||
@Column(name="ARTICLE_ID", nullable = false)
|
||||
private Long articleId;
|
||||
|
||||
/** 게시판 아이디 */
|
||||
@ApiModelProperty(required = false, example = "게시판 아이디")
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
@JoinColumn(name = "BOARD_ID", nullable = false)
|
||||
@JsonBackReference
|
||||
private Board board;
|
||||
|
||||
/** 게시글 제목 */
|
||||
@ApiModelProperty(required = true, example = "공지사항 입니다.")
|
||||
@Column(name = "ARTICLE_TITLE", length = 128, nullable = false)
|
||||
private String articleTitle;
|
||||
|
||||
/** 게시글 내용 */
|
||||
@ApiModelProperty(required = true, example = "내용 입니다.")
|
||||
@Column(name = "ARTICLE_CTNT", nullable = false)
|
||||
@Lob
|
||||
private String articleContent;
|
||||
|
||||
/** 게시글 타입 */
|
||||
@Column(name = "ARTICLE_TYP", length = 50, nullable = false)
|
||||
private String articleType;
|
||||
|
||||
/** 게시글 시작일자 */
|
||||
@ApiModelProperty(required = false, example = "20180719")
|
||||
@Column(name = "ARTICLE_BEGIN_DT", length = 8, nullable = true)
|
||||
private String articleBeginDtm;
|
||||
|
||||
/** 게시글 종료일자 */
|
||||
@ApiModelProperty(required = false, example = "99991231")
|
||||
@Column(name = "ARTICLE_END_DT", length = 8, nullable = true)
|
||||
private String articleEndDtm;
|
||||
|
||||
/** 긴급 */
|
||||
@ApiModelProperty(required = true, example = "true")
|
||||
@Type(type = "yes_no")
|
||||
@Column(name = "EMGC_YN", length = 1, nullable = false)
|
||||
private boolean emgcYn = true;
|
||||
|
||||
/** 조회수 */
|
||||
@ApiModelProperty(required = true, example = "0")
|
||||
@Column(name = "HIT_CNT", nullable = false)
|
||||
private int hitCnt;
|
||||
|
||||
@ApiModelProperty(hidden = true)
|
||||
@OneToMany(mappedBy = "article", fetch = FetchType.LAZY)
|
||||
@JsonManagedReference
|
||||
private List<Comment> comment;
|
||||
|
||||
/** 첨부 수 */
|
||||
@Transient
|
||||
private int attachCount;
|
||||
|
||||
/** 첨부 수 */
|
||||
@Transient
|
||||
private List<AttachFile> attachFile;
|
||||
|
||||
/** 답글 수*/
|
||||
@Transient
|
||||
private int commentCount;
|
||||
|
||||
/** 저장/삭제 할 첨부 파일 list*/
|
||||
@Transient
|
||||
private AttachFileUpdateDTO attachFileUpdateDTO;
|
||||
|
||||
}
|
||||
111
src/main/java/com/skti/bcm/board/domain/model/Board.java
Normal file
111
src/main/java/com/skti/bcm/board/domain/model/Board.java
Normal file
@@ -0,0 +1,111 @@
|
||||
/**
|
||||
* Copyright (c) 2018 SK INNOVATION Co., Ltd. All rights reserved.
|
||||
*
|
||||
* This software is the confidential and proprietary information of SK INNOVATION.
|
||||
* You shall not disclose such confidential information and shall use it only in accordance
|
||||
* with the terms of the license agreement you entered into with SK INNOVATION.
|
||||
*/
|
||||
package com.skti.bcm.board.domain.model;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.FetchType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.OneToMany;
|
||||
|
||||
import org.hibernate.annotations.Type;
|
||||
import org.hibernate.validator.constraints.Length;
|
||||
import org.hibernate.validator.constraints.NotBlank;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonManagedReference;
|
||||
import com.skti.bcm.common.domain.model.BaseModelUseYnSupport;
|
||||
import com.skti.core.constant.BoardAttachFileType;
|
||||
import com.skti.core.constant.BoardType;
|
||||
import com.skti.core.validation.annotation.Enum;
|
||||
import com.skti.core.validation.annotation.Ids;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 게시판
|
||||
*
|
||||
* History
|
||||
* - 2018. 7. 17. | in01871 | 최초작성.
|
||||
* </pre>
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Entity(name = "TB_BCM_BOARD")
|
||||
public class Board extends BaseModelUseYnSupport {
|
||||
|
||||
private static final long serialVersionUID = 4273773746993665959L;
|
||||
|
||||
/** 게시판 아이디 */
|
||||
@ApiModelProperty(required = true, example = "notice")
|
||||
@Id
|
||||
@NotBlank
|
||||
@Ids
|
||||
@Column(name = "BOARD_ID", nullable = false, unique = true)
|
||||
private String boardId;
|
||||
|
||||
/** 게시판 명 */
|
||||
@ApiModelProperty(required = true, example = "게시판 명")
|
||||
@NotBlank
|
||||
@Length(max = 128)
|
||||
@Column(name = "BOARD_NM", length = 128, nullable = false)
|
||||
private String boardName;
|
||||
|
||||
/** 게시판 설명 */
|
||||
@ApiModelProperty(required = false, example = "게시판 설명입니다.")
|
||||
@Length(max = 2000)
|
||||
@Column(name = "BOARD_DESC", length = 2000, nullable = true)
|
||||
private String boardDesc;
|
||||
|
||||
/** 게시판 유형 */
|
||||
@ApiModelProperty(required = true, example = "메인 Type = MAIN, 팝업 Type = POPUP")
|
||||
@Enum(enumClass = BoardType.class, ignoreCase = true)
|
||||
@Column(name = "BOARD_TYP", length = 50, nullable = false)
|
||||
private String boardType;
|
||||
|
||||
/** 첨부파일 유형 */
|
||||
@ApiModelProperty(required = true, example = "사용안함 = NO, 1개 = SINGLE, 복수 = MULTI")
|
||||
@Enum(enumClass = BoardAttachFileType.class, ignoreCase = true)
|
||||
@Column(name = "ATTACH_FILE_TYP", length = 50, nullable = false)
|
||||
private String attachFileType;
|
||||
|
||||
/** 댓글 사용 여부 */
|
||||
@ApiModelProperty(required = true, example = "true")
|
||||
@Type(type = "yes_no")
|
||||
@Column(name = "COMMENT_USE_YN", length = 1, nullable = false)
|
||||
private boolean commentUseYn = true;
|
||||
|
||||
/** 긴급 사용 여부 */
|
||||
@ApiModelProperty(required = true, example = "true")
|
||||
@Type(type = "yes_no")
|
||||
@Column(name = "EMGC_USE_YN", length = 1, nullable = false)
|
||||
private boolean emergencyUseYn = true;
|
||||
|
||||
/** 기간 사용 여부 */
|
||||
@ApiModelProperty(required = true, example = "true")
|
||||
@Type(type = "yes_no")
|
||||
@Column(name = "TERM_USE_YN", length = 1, nullable = false)
|
||||
private boolean termUseYn = true;
|
||||
|
||||
/** 기준 경로 */
|
||||
@ApiModelProperty(hidden = true)
|
||||
@NotBlank
|
||||
@Length(max = 1000)
|
||||
@Column(name = "BASE_PATH", length = 1000, nullable = false)
|
||||
private String basePath;
|
||||
|
||||
@ApiModelProperty(hidden = true)
|
||||
@OneToMany(mappedBy = "board", fetch = FetchType.LAZY)
|
||||
@JsonManagedReference
|
||||
private List<Article> article;
|
||||
|
||||
}
|
||||
57
src/main/java/com/skti/bcm/board/domain/model/Comment.java
Normal file
57
src/main/java/com/skti/bcm/board/domain/model/Comment.java
Normal file
@@ -0,0 +1,57 @@
|
||||
/**
|
||||
* Copyright (c) 2018 SK INNOVATION Co., Ltd. All rights reserved.
|
||||
*
|
||||
* This software is the confidential and proprietary information of SK INNOVATION.
|
||||
* You shall not disclose such confidential information and shall use it only in accordance
|
||||
* with the terms of the license agreement you entered into with SK INNOVATION.
|
||||
*/
|
||||
package com.skti.bcm.board.domain.model;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.ManyToOne;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonBackReference;
|
||||
import com.skti.bcm.common.domain.model.BaseModelUseYnSupport;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 댓글
|
||||
*
|
||||
* History
|
||||
* - 2018. 7. 17. | in01871 | 최초작성.
|
||||
* </pre>
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Entity(name = "TB_BCM_COMMENT")
|
||||
public class Comment extends BaseModelUseYnSupport {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 댓글 아이디 */
|
||||
@ApiModelProperty(hidden = true)
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.AUTO)
|
||||
@Column(name = "COMMENT_ID", nullable = false)
|
||||
private Long commentId;
|
||||
|
||||
/** 게시글 아이디 */
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "ARTICLE_ID", nullable = false)
|
||||
@JsonBackReference
|
||||
private Article article;
|
||||
|
||||
/** 댓글 내용 */
|
||||
@Column(name = "COMMENT_CTNT", length = 1000, nullable = false)
|
||||
private String commentCtnt;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
/**
|
||||
* Copyright (c) 2018 SK INNOVATION Co., Ltd. All rights reserved.
|
||||
*
|
||||
* This software is the confidential and proprietary information of SK INNOVATION.
|
||||
* You shall not disclose such confidential information and shall use it only in accordance
|
||||
* with the terms of the license agreement you entered into with SK INNOVATION.
|
||||
*/
|
||||
package com.skti.bcm.board.domain.repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.data.domain.Pageable;
|
||||
|
||||
import com.skti.bcm.board.domain.model.Article;
|
||||
import com.skti.bcm.board.domain.service.dto.ArticleSearchDTO;
|
||||
import com.skti.core.vo.PageDTO;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
*
|
||||
* History
|
||||
* - 2018. 7. 19. | in01871 | 최초작성.
|
||||
* - 2018. 9. 11. | in01943 | 2차수정.
|
||||
* </pre>
|
||||
*/
|
||||
public interface ArticleRepository {
|
||||
|
||||
public List<Article> findAllByBoardBoardId(String boardId);
|
||||
|
||||
public Article save(Article article);
|
||||
|
||||
public Article findOne(Long articleId);
|
||||
|
||||
/*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
|
||||
| custom method
|
||||
|-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 게시글 페이징, 검색 목록조회
|
||||
* </pre>
|
||||
*/
|
||||
public PageDTO<Article> findQueryBySearch(ArticleSearchDTO search, Pageable pageable);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
/**
|
||||
* Copyright (c) 2018 SK INNOVATION Co., Ltd. All rights reserved.
|
||||
*
|
||||
* This software is the confidential and proprietary information of SK INNOVATION.
|
||||
* You shall not disclose such confidential information and shall use it only in accordance
|
||||
* with the terms of the license agreement you entered into with SK INNOVATION.
|
||||
*/
|
||||
package com.skti.bcm.board.domain.repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.data.domain.Pageable;
|
||||
|
||||
import com.skti.bcm.board.domain.model.Board;
|
||||
import com.skti.bcm.board.domain.service.dto.BoardSearchDTO;
|
||||
import com.skti.core.vo.PageDTO;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
*
|
||||
* History
|
||||
* - 2018. 7. 18. | in01871 | 최초작성.
|
||||
* </pre>
|
||||
*/
|
||||
public interface BoardRepository {
|
||||
|
||||
/*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
|
||||
| jpaRepository 기본기능
|
||||
|-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 게시판 전체 조회
|
||||
* </pre>
|
||||
*/
|
||||
public List<Board> findAll();
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 게시판 단일 조회
|
||||
* </pre>
|
||||
*/
|
||||
public Board findOne(String boardId);
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 게시판 생성 / 수정
|
||||
* </pre>
|
||||
*/
|
||||
public Board save(Board board);
|
||||
|
||||
/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
|
||||
| custom method
|
||||
|=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
|
||||
|
||||
public PageDTO<Board> findQueryBySearch(BoardSearchDTO Search, Pageable pageable);
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
/**
|
||||
* Copyright (c) 2018 SK INNOVATION Co., Ltd. All rights reserved.
|
||||
*
|
||||
* This software is the confidential and proprietary information of SK INNOVATION.
|
||||
* You shall not disclose such confidential information and shall use it only in accordance
|
||||
* with the terms of the license agreement you entered into with SK INNOVATION.
|
||||
*/
|
||||
package com.skti.bcm.board.domain.repository;
|
||||
|
||||
import com.skti.bcm.board.domain.model.Comment;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
*
|
||||
* History
|
||||
* - 2018. 7. 19. | in01871 | 최초작성.
|
||||
* </pre>
|
||||
*/
|
||||
public interface CommentRepository {
|
||||
|
||||
public Comment save(Comment comment);
|
||||
|
||||
public Comment findOne(Long commentId);
|
||||
|
||||
public void delete(Long commentId);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
/**
|
||||
* Copyright (c) 2018 SK INNOVATION Co., Ltd. All rights reserved.
|
||||
*
|
||||
* This software is the confidential and proprietary information of SK INNOVATION.
|
||||
* You shall not disclose such confidential information and shall use it only in accordance
|
||||
* with the terms of the license agreement you entered into with SK INNOVATION.
|
||||
*/
|
||||
package com.skti.bcm.board.domain.repository.jpa;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import com.skti.bcm.board.domain.model.Article;
|
||||
import com.skti.bcm.board.domain.repository.ArticleRepository;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
*
|
||||
* History
|
||||
* - 2018. 7. 19. | in01871 | 최초작성.
|
||||
* - 2018. 7. 19. | in01943 | 2차수정.
|
||||
* </pre>
|
||||
*/
|
||||
@Repository
|
||||
public interface ArticleRepositoryJpa extends ArticleRepository, JpaRepository<Article, Long>, ArticleRepositoryJpaExtend {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
/**
|
||||
* Copyright (c) 2018 SK INNOVATION Co., Ltd. All rights reserved.
|
||||
*
|
||||
* This software is the confidential and proprietary information of SK INNOVATION.
|
||||
* You shall not disclose such confidential information and shall use it only in accordance
|
||||
* with the terms of the license agreement you entered into with SK INNOVATION.
|
||||
*/
|
||||
package com.skti.bcm.board.domain.repository.jpa;
|
||||
|
||||
import org.springframework.data.domain.Pageable;
|
||||
|
||||
import com.skti.bcm.board.domain.model.Article;
|
||||
import com.skti.bcm.board.domain.service.dto.ArticleSearchDTO;
|
||||
import com.skti.core.vo.PageDTO;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* BCM 권한 JPA Repository Extend
|
||||
*
|
||||
* History
|
||||
* - 2018. 8. 10. | in01876 | 최초작성.
|
||||
* - 2018. 8. 22. | in01876 | 2차 수정.
|
||||
*
|
||||
* </pre>
|
||||
*/
|
||||
public interface ArticleRepositoryJpaExtend {
|
||||
|
||||
public PageDTO<Article> findQueryBySearch(ArticleSearchDTO search, Pageable pageable);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,115 @@
|
||||
/**
|
||||
* Copyright (c) 2018 SK INNOVATION Co., Ltd. All rights reserved.
|
||||
*
|
||||
* This software is the confidential and proprietary information of SK INNOVATION.
|
||||
* You shall not disclose such confidential information and shall use it only in accordance
|
||||
* with the terms of the license agreement you entered into with SK INNOVATION.
|
||||
*/
|
||||
package com.skti.bcm.board.domain.repository.jpa;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.PersistenceContext;
|
||||
import javax.persistence.TypedQuery;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.data.domain.Sort.Order;
|
||||
|
||||
import com.skti.bcm.board.domain.model.Article;
|
||||
import com.skti.bcm.board.domain.service.dto.ArticleSearchDTO;
|
||||
import com.skti.core.vo.PageDTO;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* BCM 게시글 JPA Repository ExtendImpl
|
||||
*
|
||||
* History
|
||||
* - 2018. 9. 11. | in01943 | 최초작성.
|
||||
* </pre>
|
||||
*/
|
||||
public class ArticleRepositoryJpaImpl implements ArticleRepositoryJpaExtend {
|
||||
|
||||
@PersistenceContext
|
||||
EntityManager em;
|
||||
|
||||
@Override
|
||||
public PageDTO<Article> findQueryBySearch(ArticleSearchDTO search, Pageable pageable) {
|
||||
|
||||
Long articleId;
|
||||
|
||||
StringBuilder query = new StringBuilder("");
|
||||
Map<String, Object> paramMap = new HashMap<>();
|
||||
|
||||
// 기본 검색
|
||||
//query.append("SELECT r FROM TB_BCM_ARTICLE r WHERE UPPER(r.useYn) = 'Y' ");
|
||||
|
||||
query.append("SELECT r FROM TB_BCM_ARTICLE r ");
|
||||
query.append("INNER JOIN r.board ");
|
||||
query.append("WHERE (r.board.boardId = :boardId) AND UPPER(r.useYn) = 'Y' ");
|
||||
paramMap.put("boardId", search.getBoardId());
|
||||
|
||||
|
||||
// 검색어
|
||||
if (search.getKeyword() != null) {
|
||||
// 검색어가 게기글 번호인지 check
|
||||
try {
|
||||
articleId = Long.parseLong(search.getKeyword());
|
||||
} catch (Exception e) {
|
||||
articleId = null;
|
||||
}
|
||||
|
||||
if (articleId == null) {
|
||||
query.append("AND UPPER(r.articleTitle) LIKE :keyword ");
|
||||
paramMap.put("keyword", "%" + search.getKeyword().toUpperCase() + "%");
|
||||
} else {
|
||||
query.append("AND (r.articleId = :articleId OR UPPER(r.articleTitle) LIKE :keyword) AND UPPER(r.useYn) = 'Y' ");
|
||||
paramMap.put("articleId", Long.parseLong(search.getKeyword()));
|
||||
paramMap.put("keyword", "%" + search.getKeyword().toUpperCase() + "%");
|
||||
}
|
||||
}
|
||||
|
||||
if (search.isTermUseYn()) {
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
|
||||
Calendar c1 = Calendar.getInstance();
|
||||
|
||||
String today = sdf.format(c1.getTime());
|
||||
|
||||
query.append("AND r.articleBeginDtm <= :today AND r.articleEndDtm >= :today ");
|
||||
paramMap.put("today", today);
|
||||
}
|
||||
|
||||
Sort sort = pageable.getSort();
|
||||
String sortStr = sort.toString();
|
||||
|
||||
if (StringUtils.isNotBlank(sortStr)) {
|
||||
query.append(" ORDER BY ");
|
||||
/** table join이 없을 경우 사용 : query.append(Util.removeChar(sortStr, ":")); */
|
||||
int queryLength = query.toString().length();
|
||||
sort.forEach((Order arg) -> query.append(((queryLength == query.toString().length()) ? "r." : ", r.") + arg.getProperty() + " " + arg.getDirection() + " "));
|
||||
}
|
||||
|
||||
// Query 생성
|
||||
TypedQuery<Article> typedQuery = em.createQuery(query.toString(), Article.class);
|
||||
|
||||
// 조건 파라메터 추가
|
||||
paramMap.forEach(typedQuery::setParameter);
|
||||
|
||||
PageDTO<Article> result = new PageDTO<>();
|
||||
result.setTotalCount(typedQuery.getResultList().size());
|
||||
|
||||
// 조건 페이징 추가
|
||||
typedQuery.setFirstResult(pageable.getOffset());
|
||||
typedQuery.setMaxResults(pageable.getPageSize());
|
||||
|
||||
result.setPage(pageable);
|
||||
result.setList(typedQuery.getResultList());
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
/**
|
||||
* Copyright (c) 2018 SK INNOVATION Co., Ltd. All rights reserved.
|
||||
*
|
||||
* This software is the confidential and proprietary information of SK INNOVATION.
|
||||
* You shall not disclose such confidential information and shall use it only in accordance
|
||||
* with the terms of the license agreement you entered into with SK INNOVATION.
|
||||
*/
|
||||
package com.skti.bcm.board.domain.repository.jpa;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
import com.skti.bcm.board.domain.model.Board;
|
||||
import com.skti.bcm.board.domain.repository.BoardRepository;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
*
|
||||
* BCM 게시판 JPA Repository
|
||||
*
|
||||
* History
|
||||
* - 2018. 7. 19. | in01871 | 최초작성.
|
||||
* </pre>
|
||||
*/
|
||||
|
||||
public interface BoardRepositoryJpa extends BoardRepository, JpaRepository<Board, String>, BoardRepositoryJpaExtend {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
/**
|
||||
* Copyright (c) 2018 SK INNOVATION Co., Ltd. All rights reserved.
|
||||
*
|
||||
* This software is the confidential and proprietary information of SK INNOVATION.
|
||||
* You shall not disclose such confidential information and shall use it only in accordance
|
||||
* with the terms of the license agreement you entered into with SK INNOVATION.
|
||||
*/
|
||||
package com.skti.bcm.board.domain.repository.jpa;
|
||||
|
||||
import org.springframework.data.domain.Pageable;
|
||||
|
||||
import com.skti.bcm.board.domain.model.Board;
|
||||
import com.skti.bcm.board.domain.service.dto.BoardSearchDTO;
|
||||
import com.skti.core.vo.PageDTO;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
*
|
||||
* BCM 게시판 JPA Custom Repository
|
||||
*
|
||||
* History
|
||||
* - 2018. 9. 18. | in01871 | 최초작성.
|
||||
* </pre>
|
||||
*/
|
||||
public interface BoardRepositoryJpaExtend {
|
||||
|
||||
public PageDTO<Board> findQueryBySearch(BoardSearchDTO search, Pageable pageable);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
/**
|
||||
* Copyright (c) 2018 SK INNOVATION Co., Ltd. All rights reserved.
|
||||
*
|
||||
* This software is the confidential and proprietary information of SK INNOVATION.
|
||||
* You shall not disclose such confidential information and shall use it only in accordance
|
||||
* with the terms of the license agreement you entered into with SK INNOVATION.
|
||||
*/
|
||||
package com.skti.bcm.board.domain.repository.jpa;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.PersistenceContext;
|
||||
import javax.persistence.TypedQuery;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import com.skti.bcm.board.domain.model.Board;
|
||||
import com.skti.bcm.board.domain.service.dto.BoardSearchDTO;
|
||||
import com.skti.core.util.Util;
|
||||
import com.skti.core.vo.PageDTO;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
*
|
||||
* BCM 게시판 JPA Repository Impl
|
||||
*
|
||||
* History
|
||||
* - 2018. 9. 18. | in01871 | 최초작성.
|
||||
* </pre>
|
||||
*/
|
||||
@Repository
|
||||
public class BoardRepositoryJpaImpl implements BoardRepositoryJpaExtend {
|
||||
|
||||
private static final String KEYWORD = "keyword";
|
||||
|
||||
@PersistenceContext
|
||||
EntityManager em;
|
||||
|
||||
@Override
|
||||
public PageDTO<Board> findQueryBySearch(BoardSearchDTO search, Pageable pageable) {
|
||||
|
||||
String where = "";
|
||||
Map<String, String> paramMap = new HashMap<>();
|
||||
|
||||
// 기본 검색
|
||||
if (search.getKeyword() != null) {
|
||||
where += "(UPPER(b.boardId) LIKE :keyword or UPPER(b.boardName) LIKE :keyword) ";
|
||||
paramMap.put(KEYWORD, "%" + search.getKeyword().toUpperCase() + "%");
|
||||
|
||||
}
|
||||
|
||||
if (where != "") {
|
||||
where = "WHERE" + where;
|
||||
|
||||
}
|
||||
|
||||
Sort sort = pageable.getSort();
|
||||
String sortStr = sort.toString();
|
||||
String orderBy = "";
|
||||
|
||||
if (StringUtils.isNotBlank(sortStr)) {
|
||||
orderBy += "ORDER BY ";
|
||||
orderBy += Util.removeChar(sortStr, ":");
|
||||
|
||||
}
|
||||
|
||||
String query = "" + "SELECT b " + "FROM TB_BCM_BOARD b " + where + orderBy;
|
||||
|
||||
TypedQuery<Board> typedQuery = em.createQuery(query, Board.class);
|
||||
|
||||
paramMap.forEach((String key, String value) -> typedQuery.setParameter(key, value));
|
||||
|
||||
PageDTO<Board> result = new PageDTO<>();
|
||||
result.setTotalCount(typedQuery.getResultList().size());
|
||||
|
||||
typedQuery.setFirstResult(pageable.getOffset());
|
||||
typedQuery.setMaxResults(pageable.getPageSize());
|
||||
|
||||
result.setList(typedQuery.getResultList());
|
||||
result.setPage(pageable);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
/**
|
||||
* Copyright (c) 2018 SK INNOVATION Co., Ltd. All rights reserved.
|
||||
*
|
||||
* This software is the confidential and proprietary information of SK INNOVATION.
|
||||
* You shall not disclose such confidential information and shall use it only in accordance
|
||||
* with the terms of the license agreement you entered into with SK INNOVATION.
|
||||
*/
|
||||
package com.skti.bcm.board.domain.repository.jpa;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import com.skti.bcm.board.domain.model.Comment;
|
||||
import com.skti.bcm.board.domain.repository.CommentRepository;
|
||||
|
||||
/**
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* History
|
||||
* - 2018. 7. 19. | in01871 | 최초작성.
|
||||
* </pre>
|
||||
*/
|
||||
@Repository
|
||||
public interface CommentRepositoryJpa extends CommentRepository, JpaRepository<Comment, Long>{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
/**
|
||||
* Copyright (c) 2018 SK INNOVATION Co., Ltd. All rights reserved.
|
||||
*
|
||||
* This software is the confidential and proprietary information of SK INNOVATION.
|
||||
* You shall not disclose such confidential information and shall use it only in accordance
|
||||
* with the terms of the license agreement you entered into with SK INNOVATION.
|
||||
*/
|
||||
package com.skti.bcm.board.domain.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.data.domain.Pageable;
|
||||
|
||||
import com.skti.bcm.board.domain.model.Article;
|
||||
import com.skti.bcm.board.domain.model.Comment;
|
||||
import com.skti.bcm.board.domain.service.dto.ArticleSearchDTO;
|
||||
import com.skti.core.vo.PageDTO;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
*
|
||||
* History
|
||||
* - 2018. 9. 11. | in01943 | 최초작성.
|
||||
* </pre>
|
||||
*/
|
||||
public interface ArticleService {
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 조건에 따라 필터가 되는 게시글 목록
|
||||
* </pre>
|
||||
*/
|
||||
public PageDTO<Article> findQueryByKeyword(ArticleSearchDTO search, Pageable pageable);
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 게시판별 게시글 조회
|
||||
* </pre>
|
||||
*/
|
||||
public List<Article> getArticleList(String boardId);
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 게시글 상세 조회
|
||||
* </pre>
|
||||
*/
|
||||
public Article getArticle(Long articleId);
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 게시글 생성
|
||||
* </pre>
|
||||
*/
|
||||
public Article createArticle(Article article, String boardId);
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 게시글 수정
|
||||
* </pre>
|
||||
*/
|
||||
public Article updateArticle(Article article, Long articleId);
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 게시글 삭제
|
||||
* </pre>
|
||||
*/
|
||||
public Article deleteArticle(Long articleId);
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 게시글 생성
|
||||
* </pre>
|
||||
*/
|
||||
public Comment createComment(Comment comment, Long articleId);
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 게시글 수정
|
||||
* </pre>
|
||||
*/
|
||||
public Comment updateComment(Comment comment, Long commentId);
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 게시글 삭제
|
||||
* </pre>
|
||||
*/
|
||||
public Comment deleteComment(Long commentId);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,271 @@
|
||||
/**
|
||||
* Copyright (c) 2018 SK INNOVATION Co., Ltd. All rights reserved.
|
||||
*
|
||||
* This software is the confidential and proprietary information of SK INNOVATION.
|
||||
* You shall not disclose such confidential information and shall use it only in accordance
|
||||
* with the terms of the license agreement you entered into with SK INNOVATION.
|
||||
*/
|
||||
package com.skti.bcm.board.domain.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.nhncorp.lucy.security.xss.LucyXssFilter;
|
||||
import com.skti.bcm.board.domain.model.Article;
|
||||
import com.skti.bcm.board.domain.model.Board;
|
||||
import com.skti.bcm.board.domain.model.Comment;
|
||||
import com.skti.bcm.board.domain.repository.ArticleRepository;
|
||||
import com.skti.bcm.board.domain.repository.BoardRepository;
|
||||
import com.skti.bcm.board.domain.repository.CommentRepository;
|
||||
import com.skti.bcm.board.domain.service.dto.ArticleSearchDTO;
|
||||
import com.skti.bcm.file.domain.model.AttachFile;
|
||||
import com.skti.bcm.file.domain.repository.AttachFileRepository;
|
||||
import com.skti.bcm.file.domain.service.AttachFileService;
|
||||
import com.skti.bcm.user.domain.service.dto.UserInfoDTO;
|
||||
import com.skti.core.constant.ArticleType;
|
||||
import com.skti.core.constant.CommonConstant;
|
||||
import com.skti.core.constant.FileType;
|
||||
import com.skti.core.exception.BizException;
|
||||
import com.skti.core.exception.NotFoundException;
|
||||
import com.skti.core.util.SessionUtil;
|
||||
import com.skti.core.vo.PageDTO;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
*
|
||||
* History
|
||||
* - 2018. 7. 19. | in01871 | 최초작성.
|
||||
* - 2018. 9. 11. | in01943 | 2수정.
|
||||
* </pre>
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
public class ArticleServiceImpl implements ArticleService {
|
||||
|
||||
private static final String USER_MESSAGE_KEY_NOT_FOUND = "bcm.common.NOT_FOUND";
|
||||
private static final String BCM_COMMON_EXCEPTION_BIZ_CREATOR = "bcm.common.exception.biz-creator";
|
||||
|
||||
@Autowired
|
||||
ArticleRepository articleRepository;
|
||||
|
||||
@Autowired
|
||||
BoardRepository boardRepository;
|
||||
|
||||
@Autowired
|
||||
CommentRepository commentRepository;
|
||||
|
||||
@Autowired
|
||||
private AttachFileRepository attachFileRepository;
|
||||
|
||||
@Autowired
|
||||
private AttachFileService attachFileService;
|
||||
|
||||
@Autowired
|
||||
private LucyXssFilter lucyXssFilter;
|
||||
|
||||
@Override
|
||||
public PageDTO<Article> findQueryByKeyword(ArticleSearchDTO search, Pageable pageable) {
|
||||
List<AttachFile> attachfiles;
|
||||
PageDTO<Article> result = articleRepository.findQueryBySearch(search, pageable);
|
||||
|
||||
for (int i = 0; i < result.getList().size(); i++) {
|
||||
attachfiles = attachFileRepository.findByTargetIdAndTargetTypeAndUseYnTrue(
|
||||
result.getList().get(i).getArticleId().toString(), FileType.ARTICLE.toString());
|
||||
result.getList().get(i).setCommentCount(result.getList().get(i).getComment().size());
|
||||
result.getList().get(i).setAttachCount(attachfiles.size());
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Article> getArticleList(String boardId) {
|
||||
|
||||
return articleRepository.findAllByBoardBoardId(boardId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Article getArticle(Long articleId) {
|
||||
|
||||
Article article = articleRepository.findOne(articleId);
|
||||
List<AttachFile> attachfiles = attachFileRepository
|
||||
.findByTargetIdAndTargetTypeAndUseYnTrue(articleId.toString(), FileType.ARTICLE.toString());
|
||||
|
||||
if (article == null) {
|
||||
throw NotFoundException.withUserMessageKey(USER_MESSAGE_KEY_NOT_FOUND).withSystemMessage("article == null")
|
||||
.build();
|
||||
}
|
||||
|
||||
article.setHitCnt(article.getHitCnt() + 1);
|
||||
articleRepository.save(article);
|
||||
|
||||
article.setCommentCount(article.getComment().size());
|
||||
article.setAttachCount(attachfiles.size());
|
||||
article.setAttachFile(attachfiles);
|
||||
|
||||
return article;
|
||||
}
|
||||
|
||||
private void checkMyCreateOrAdminRole(String createId) {
|
||||
// 로그인 사용자 정보 추가
|
||||
UserInfoDTO userInfoDTO = SessionUtil.getLoginUserInfo();
|
||||
|
||||
// 본인/admin 인지 check
|
||||
if (!createId.equals(userInfoDTO.getUser().getLoginId()) && !userInfoDTO.isRole(CommonConstant.BOARD_ADMIN_ROLE)) {
|
||||
throw BizException.withUserMessageKey(BCM_COMMON_EXCEPTION_BIZ_CREATOR).build();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Article createArticle(Article article, String boardId) {
|
||||
|
||||
Board board = boardRepository.findOne(boardId);
|
||||
|
||||
if (board == null) {
|
||||
throw NotFoundException.withUserMessageKey(USER_MESSAGE_KEY_NOT_FOUND).withSystemMessage("board == null")
|
||||
.build();
|
||||
}
|
||||
|
||||
// HTML타입의 본문인 경우, 문제되는 마크업들을 필터링함.
|
||||
if (ArticleType.HTML.toString().equals(article.getArticleType())) {
|
||||
String content = article.getArticleContent();
|
||||
log.info("content={}", content);
|
||||
String cleanedContent = lucyXssFilter.doFilter(content);
|
||||
log.info("cleanedContent={}", cleanedContent);
|
||||
article.setArticleContent(cleanedContent);
|
||||
}
|
||||
|
||||
article.setBoard(board);
|
||||
|
||||
Article retArticle = articleRepository.save(article);
|
||||
|
||||
attachFileService.updateList(Long.toString(retArticle.getArticleId()), FileType.ARTICLE.toString(),
|
||||
article.getAttachFileUpdateDTO());
|
||||
|
||||
return retArticle;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Article updateArticle(Article article, Long articleId) {
|
||||
|
||||
// 1. articleEntity select
|
||||
Article updateArticle = articleRepository.findOne(articleId);
|
||||
|
||||
if (updateArticle == null) {
|
||||
throw NotFoundException.withUserMessageKey(USER_MESSAGE_KEY_NOT_FOUND)
|
||||
.withSystemMessage("updateArticle == null").build();
|
||||
}
|
||||
|
||||
// 게시글 권한자 및 본인
|
||||
checkMyCreateOrAdminRole(updateArticle.getCreateBy());
|
||||
|
||||
// HTML타입의 본문인 경우, 문제되는 마크업들을 필터링함.
|
||||
if (ArticleType.HTML.toString().equals(article.getArticleType())) {
|
||||
String content = article.getArticleContent();
|
||||
log.info("content={}", content);
|
||||
String cleanedContent = lucyXssFilter.doFilter(content);
|
||||
log.info("cleanedContent={}", cleanedContent);
|
||||
article.setArticleContent(cleanedContent);
|
||||
}
|
||||
|
||||
// 2. update data
|
||||
updateArticle.setArticleTitle(article.getArticleTitle());
|
||||
updateArticle.setArticleContent((article.getArticleContent() == null ? updateArticle.getArticleContent()
|
||||
: article.getArticleContent()));
|
||||
updateArticle.setArticleType(article.getArticleType());
|
||||
updateArticle.setHitCnt(updateArticle.getHitCnt());
|
||||
updateArticle.setArticleBeginDtm(article.getArticleBeginDtm());
|
||||
updateArticle.setArticleEndDtm(article.getArticleEndDtm());
|
||||
updateArticle.setEmgcYn(article.isEmgcYn());
|
||||
|
||||
// 3. save
|
||||
articleRepository.save(updateArticle);
|
||||
|
||||
attachFileService.updateList(Long.toString(articleId), FileType.ARTICLE.toString(),
|
||||
article.getAttachFileUpdateDTO());
|
||||
|
||||
return updateArticle;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Article deleteArticle(Long articleId) {
|
||||
|
||||
Article article = articleRepository.findOne(articleId);
|
||||
|
||||
// 게시글 권한자 및 본인
|
||||
checkMyCreateOrAdminRole(article.getCreateBy());
|
||||
|
||||
article.setUseYn(false);
|
||||
|
||||
articleRepository.save(article);
|
||||
|
||||
attachFileService.deleteList(Long.toString(articleId), FileType.ARTICLE.toString());
|
||||
|
||||
return article;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Comment createComment(Comment comment, Long articleId) {
|
||||
|
||||
Article article = articleRepository.findOne(articleId);
|
||||
|
||||
if (article == null) {
|
||||
throw NotFoundException.withUserMessageKey(USER_MESSAGE_KEY_NOT_FOUND).withSystemMessage("article == null")
|
||||
.build();
|
||||
}
|
||||
|
||||
comment.setArticle(article);
|
||||
|
||||
return commentRepository.save(comment);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Comment updateComment(Comment comment, Long commentId) {
|
||||
|
||||
// 1. commentEntity select
|
||||
Comment updateComment = commentRepository.findOne(commentId);
|
||||
|
||||
if (updateComment == null) {
|
||||
throw NotFoundException.withUserMessageKey(USER_MESSAGE_KEY_NOT_FOUND)
|
||||
.withSystemMessage("updateComment == null").build();
|
||||
}
|
||||
|
||||
// 권한 check
|
||||
checkMyCreateOrAdminRole(updateComment.getCreateBy());
|
||||
|
||||
// 2. update data
|
||||
updateComment.setCommentCtnt(comment.getCommentCtnt());
|
||||
updateComment.setUseYn(comment.isUseYn());
|
||||
|
||||
// 3. save
|
||||
commentRepository.save(updateComment);
|
||||
|
||||
return updateComment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Comment deleteComment(Long commentId) {
|
||||
|
||||
Comment comment = commentRepository.findOne(commentId);
|
||||
|
||||
if (comment == null) {
|
||||
throw NotFoundException.withUserMessageKey(USER_MESSAGE_KEY_NOT_FOUND)
|
||||
.withSystemMessage("deleteComment == null").build();
|
||||
}
|
||||
|
||||
// 권한 check
|
||||
checkMyCreateOrAdminRole(comment.getCreateBy());
|
||||
|
||||
comment.setUseYn(false);
|
||||
|
||||
commentRepository.delete(commentId);
|
||||
|
||||
return comment;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
/**
|
||||
* Copyright (c) 2018 SK INNOVATION Co., Ltd. All rights reserved.
|
||||
*
|
||||
* This software is the confidential and proprietary information of SK INNOVATION.
|
||||
* You shall not disclose such confidential information and shall use it only in accordance
|
||||
* with the terms of the license agreement you entered into with SK INNOVATION.
|
||||
*/
|
||||
package com.skti.bcm.board.domain.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.data.domain.Pageable;
|
||||
|
||||
import com.skti.bcm.board.domain.model.Board;
|
||||
import com.skti.bcm.board.domain.service.dto.BoardSearchDTO;
|
||||
import com.skti.core.vo.PageDTO;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
*
|
||||
* BCM 게시판 관리 Service
|
||||
*
|
||||
* History
|
||||
* - 2018. 7. 23. | in01871 | 최초작성.
|
||||
* </pre>
|
||||
*/
|
||||
public interface BoardService {
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 게시판 목록 조회
|
||||
* </pre>
|
||||
*/
|
||||
public List<Board> findAll();
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 게시판 단일 조회
|
||||
* </pre>
|
||||
*/
|
||||
public Board findOne(String boardId);
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 게시판 등록
|
||||
* </pre>
|
||||
*/
|
||||
public Board create(Board board);
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 게시판 수정
|
||||
* </pre>
|
||||
*/
|
||||
public Board update(String boardId, Board board);
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 검색 조건에 따른 게시판 목록 조회
|
||||
* </pre>
|
||||
*/
|
||||
public PageDTO<Board> findQueryBySearch(BoardSearchDTO search, Pageable pageable);
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 게시판 ID 중복 체크
|
||||
* </pre>
|
||||
*/
|
||||
public Boolean duplicateBoardId(String boardId);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,160 @@
|
||||
/**
|
||||
* Copyright (c) 2018 SK INNOVATION Co., Ltd. All rights reserved.
|
||||
*
|
||||
* This software is the confidential and proprietary information of SK INNOVATION.
|
||||
* You shall not disclose such confidential information and shall use it only in accordance
|
||||
* with the terms of the license agreement you entered into with SK INNOVATION.
|
||||
*/
|
||||
package com.skti.bcm.board.domain.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.modelmapper.ModelMapper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.skti.bcm.board.domain.model.Board;
|
||||
import com.skti.bcm.board.domain.repository.BoardRepository;
|
||||
import com.skti.bcm.board.domain.service.dto.BoardSearchDTO;
|
||||
import com.skti.core.exception.NotFoundException;
|
||||
import com.skti.core.vo.PageDTO;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
*
|
||||
* BCM 게시판 관리 ServiceImpl
|
||||
*
|
||||
* History
|
||||
* - 2018. 8. 7. | in01868 | 최초작성.
|
||||
* - 2018. 9. 18. | in01871 | 2차 수정.
|
||||
* </pre>
|
||||
*/
|
||||
@Service
|
||||
public class BoardServiceImpl implements BoardService {
|
||||
|
||||
@Autowired
|
||||
BoardRepository boardRepository;
|
||||
|
||||
@Autowired
|
||||
ModelMapper modelMapper;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 게시판 목록 조회
|
||||
* </pre>
|
||||
* @see com.skti.bcm.board.domain.service.BoardService#findAll()
|
||||
*/
|
||||
@Override
|
||||
public List<Board> findAll() {
|
||||
|
||||
return boardRepository.findAll();
|
||||
}
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 게시판 상세 조회
|
||||
* </pre>
|
||||
* @see com.skti.bcm.board.domain.service.BoardService#findOne(java.lang.Long)
|
||||
*/
|
||||
@Override
|
||||
public Board findOne(String boardId) {
|
||||
|
||||
Board board = boardRepository.findOne(boardId);
|
||||
|
||||
if (board == null) {
|
||||
throw NotFoundException.withUserMessageKey("bcm.common.NOT_FOUND")
|
||||
.withSystemMessage("board == null")
|
||||
.build();
|
||||
}
|
||||
|
||||
return board;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* <pre>
|
||||
* 게시판 등록
|
||||
* </pre>
|
||||
* @see com.skti.bcm.board.domain.service.BoardService#create(com.skti.bcm.board.domain.service.dto.BoardSaveDTO)
|
||||
*/
|
||||
@Override
|
||||
public Board create(Board board) {
|
||||
|
||||
board.setBasePath("/boards/");
|
||||
|
||||
Board firstSave = boardRepository.save(board);
|
||||
|
||||
firstSave.setBasePath("/boards/" + firstSave.getBoardId());
|
||||
|
||||
Board secondSave = boardRepository.save(firstSave);
|
||||
|
||||
return secondSave;
|
||||
}
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 게시판 수정
|
||||
* </pre>
|
||||
* @see com.skti.bcm.board.domain.service.BoardService#update(com.skti.bcm.board.domain.model.Board, java.lang.Long)
|
||||
*/
|
||||
@Override
|
||||
public Board update(String boardId, Board board) {
|
||||
|
||||
// 1. boardEntity select
|
||||
Board updateBoard = boardRepository.findOne(boardId);
|
||||
|
||||
if (updateBoard == null) {
|
||||
throw NotFoundException.withUserMessageKey("bcm.common.NOT_FOUND")
|
||||
.withSystemMessage("updateBoard == null")
|
||||
.build();
|
||||
}
|
||||
|
||||
// 2. update data put
|
||||
updateBoard.setBoardName(board.getBoardName());
|
||||
updateBoard.setBoardDesc(board.getBoardDesc());
|
||||
updateBoard.setBoardType(board.getBoardType());
|
||||
updateBoard.setAttachFileType(board.getAttachFileType());
|
||||
updateBoard.setEmergencyUseYn(board.isEmergencyUseYn());
|
||||
updateBoard.setTermUseYn(board.isTermUseYn());
|
||||
updateBoard.setCommentUseYn(board.isCommentUseYn());
|
||||
updateBoard.setUseYn(board.isUseYn());
|
||||
|
||||
// 3. save
|
||||
boardRepository.save(updateBoard);
|
||||
|
||||
return updateBoard;
|
||||
}
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 검색 조건에 따른 게시판 목록 조회
|
||||
* </pre>
|
||||
* @see com.skti.bcm.board.domain.service.BoardService#findQueryBySearch(com.skti.bcm.board.domain.service.dto.BoardSearchDTO, org.springframework.data.domain.Pageable)
|
||||
*/
|
||||
@Override
|
||||
public PageDTO<Board> findQueryBySearch(BoardSearchDTO search, Pageable pageable) {
|
||||
|
||||
return boardRepository.findQueryBySearch(search, pageable);
|
||||
}
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 게시판 ID 중복체크
|
||||
* </pre>
|
||||
* @see com.skti.bcm.board.domain.service.BoardService#duplicateBoardId(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public Boolean duplicateBoardId(String boardId) {
|
||||
|
||||
Boolean isDuplicate = false;
|
||||
|
||||
Board board = boardRepository.findOne(boardId);
|
||||
if (board != null) {
|
||||
isDuplicate = true;
|
||||
}
|
||||
|
||||
return isDuplicate;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
/**
|
||||
* Copyright (c) 2018 SK INNOVATION Co., Ltd. All rights reserved.
|
||||
*
|
||||
* This software is the confidential and proprietary information of SK INNOVATION.
|
||||
* You shall not disclose such confidential information and shall use it only in accordance
|
||||
* with the terms of the license agreement you entered into with SK INNOVATION.
|
||||
*/
|
||||
package com.skti.bcm.board.domain.service.dto;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public class ArticleSaveDTO implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -3427902307396202162L;
|
||||
|
||||
private String articleId;
|
||||
|
||||
private String articleTitle;
|
||||
|
||||
private String articleCtnt;
|
||||
|
||||
private String articleBeginDtm;
|
||||
|
||||
private String articleEndDtm;
|
||||
|
||||
private boolean emgcYn;
|
||||
|
||||
private int hitCnt;
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
/**
|
||||
* Copyright (c) 2018 SK INNOVATION Co., Ltd. All rights reserved.
|
||||
*
|
||||
* This software is the confidential and proprietary information of SK INNOVATION.
|
||||
* You shall not disclose such confidential information and shall use it only in accordance
|
||||
* with the terms of the license agreement you entered into with SK INNOVATION.
|
||||
*/
|
||||
package com.skti.bcm.board.domain.service.dto;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.hibernate.validator.constraints.Length;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* BCM 게시글 검색 DTO
|
||||
*
|
||||
* History
|
||||
* - 2018. 9. 11. | in01943 | 최초작성.
|
||||
* </pre>
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
public class ArticleSearchDTO implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 6673191829153649949L;
|
||||
|
||||
/** 게시판 아이디 */
|
||||
private String boardId;
|
||||
|
||||
/** 기본검색 */
|
||||
@Length(max = 20)
|
||||
private String keyword;
|
||||
|
||||
/** 미사용 포함여부 */
|
||||
private boolean isUnusedInclude = false;
|
||||
|
||||
/** 리스트 타입 결과 사용 */
|
||||
private boolean isList = false;
|
||||
|
||||
/** 게시판 기간 사용 여부 */
|
||||
private boolean termUseYn = true;
|
||||
|
||||
public boolean isUnusedInclude() {
|
||||
return isUnusedInclude;
|
||||
}
|
||||
|
||||
public void setIsUnusedInclude(boolean isUnusedInclude) {
|
||||
this.isUnusedInclude = isUnusedInclude;
|
||||
}
|
||||
|
||||
public boolean isList() {
|
||||
return isList;
|
||||
}
|
||||
|
||||
public void setIsList(boolean isList) {
|
||||
this.isList = isList;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
/**
|
||||
* Copyright (c) 2018 SK INNOVATION Co., Ltd. All rights reserved.
|
||||
*
|
||||
* This software is the confidential and proprietary information of SK INNOVATION.
|
||||
* You shall not disclose such confidential information and shall use it only in accordance
|
||||
* with the terms of the license agreement you entered into with SK INNOVATION.
|
||||
*/
|
||||
package com.skti.bcm.board.domain.service.dto;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public class BoardSaveDTO implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 201878214821081498L;
|
||||
|
||||
/** 게시판 아이디 */
|
||||
private String boardId;
|
||||
|
||||
/** 게시판 명 */
|
||||
private String boardName;
|
||||
|
||||
/** 게시판 설명 */
|
||||
private String boardDesc;
|
||||
|
||||
/** 게시판 유형 */
|
||||
private String boardType;
|
||||
|
||||
/** 첨부파일 유형 */
|
||||
private String attachFileType;
|
||||
|
||||
/** 댓글 사용 여부 */
|
||||
private boolean commentUseYn = true;
|
||||
|
||||
/** 긴급 사용 여부 */
|
||||
private boolean emergencyUseYn = true;
|
||||
|
||||
/** 기간 사용 여부 */
|
||||
private boolean termUseYn = true;
|
||||
|
||||
/** 기준 경로 */
|
||||
private String basePath;
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
/**
|
||||
* Copyright (c) 2018 SK INNOVATION Co., Ltd. All rights reserved.
|
||||
*
|
||||
* This software is the confidential and proprietary information of SK INNOVATION.
|
||||
* You shall not disclose such confidential information and shall use it only in accordance
|
||||
* with the terms of the license agreement you entered into with SK INNOVATION.
|
||||
*/
|
||||
package com.skti.bcm.board.domain.service.dto;
|
||||
|
||||
import org.hibernate.validator.constraints.Length;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
*
|
||||
* BoardSearchDTO
|
||||
*
|
||||
* History
|
||||
* - 2018. 9. 18. | in01871 | 최초작성.
|
||||
* </pre>
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
public class BoardSearchDTO {
|
||||
|
||||
@Length(max = 20)
|
||||
private String keyword;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
/**
|
||||
* Copyright (c) 2018 SK INNOVATION Co., Ltd. All rights reserved.
|
||||
*
|
||||
* This software is the confidential and proprietary information of SK INNOVATION.
|
||||
* You shall not disclose such confidential information and shall use it only in accordance
|
||||
* with the terms of the license agreement you entered into with SK INNOVATION.
|
||||
*/
|
||||
package com.skti.bcm.board.domain.service.dto;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public class CommentDTO implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -2889471655165282421L;
|
||||
|
||||
private String commentId;
|
||||
|
||||
private String articleId;
|
||||
|
||||
private String commentCtnt;
|
||||
|
||||
}
|
||||
184
src/main/java/com/skti/bcm/board/web/ArticleController.java
Normal file
184
src/main/java/com/skti/bcm/board/web/ArticleController.java
Normal file
@@ -0,0 +1,184 @@
|
||||
/**
|
||||
* Copyright (c) 2018 SK INNOVATION Co., Ltd. All rights reserved.
|
||||
*
|
||||
* This software is the confidential and proprietary information of SK INNOVATION.
|
||||
* You shall not disclose such confidential information and shall use it only in accordance
|
||||
* with the terms of the license agreement you entered into with SK INNOVATION.
|
||||
*/
|
||||
package com.skti.bcm.board.web;
|
||||
|
||||
import javax.validation.Valid;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.data.web.PageableDefault;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import com.skti.bcm.board.domain.model.Article;
|
||||
import com.skti.bcm.board.domain.model.Board;
|
||||
import com.skti.bcm.board.domain.model.Comment;
|
||||
import com.skti.bcm.board.domain.service.ArticleService;
|
||||
import com.skti.bcm.board.domain.service.BoardService;
|
||||
import com.skti.bcm.board.domain.service.dto.ArticleSearchDTO;
|
||||
import com.skti.core.component.MessageComponent;
|
||||
import com.skti.core.constant.Path;
|
||||
import com.skti.core.vo.RestResponse;
|
||||
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
*
|
||||
* History
|
||||
* - 2018. 07. 20. | in01871 | 최초작성.
|
||||
* - 2018. 09. 11. | in01943 | 2차수정
|
||||
* </pre>
|
||||
*/
|
||||
@Api(tags = "게시글 관리")
|
||||
@RestController
|
||||
public class ArticleController {
|
||||
|
||||
private static final String BCM_BOARD_ASTERISK = "bcm.board.*";
|
||||
private static final String BCM_CODE_ASTERISK = "bcm.code.*";
|
||||
|
||||
@Autowired
|
||||
private BoardService boardService;
|
||||
|
||||
@Autowired
|
||||
private ArticleService articleService;
|
||||
|
||||
/*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
|
||||
| VIEW
|
||||
|-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
|
||||
|
||||
@ApiOperation(value = "게시글 목록")
|
||||
@GetMapping(value = Path.VIEW_BOARD_ARTICLES)
|
||||
public ModelAndView viewArticleList(
|
||||
@ApiParam(name = "boardId", required = true, value = "게시판ID") @PathVariable String boardId) {
|
||||
|
||||
Board board = boardService.findOne(boardId);
|
||||
|
||||
ModelAndView modelAndView = new ModelAndView();
|
||||
modelAndView.addObject("board", board);
|
||||
modelAndView.setViewName("skiaf/view/board/article-list");
|
||||
modelAndView.addObject(MessageComponent.JS_MESSAGES_KEY_PATTERN, BCM_BOARD_ASTERISK);
|
||||
return modelAndView;
|
||||
}
|
||||
|
||||
@ApiOperation(value = "게시글 상세(main type)")
|
||||
@GetMapping(value = Path.VIEW_BOARD_ARTICLES_DETAIL)
|
||||
public ModelAndView viewArticleDetail(
|
||||
@ApiParam(name = "boardId", required = true, value = "게시판ID") @PathVariable String boardId) {
|
||||
|
||||
Board board = boardService.findOne(boardId);
|
||||
|
||||
ModelAndView modelAndView = new ModelAndView();
|
||||
modelAndView.addObject("board", board);
|
||||
modelAndView.setViewName("skiaf/view/board/article-detail");
|
||||
modelAndView.addObject(MessageComponent.JS_MESSAGES_KEY_PATTERN, BCM_BOARD_ASTERISK);
|
||||
return modelAndView;
|
||||
}
|
||||
|
||||
@ApiOperation(value = "게시글 수정 popup(main type)")
|
||||
@GetMapping(value = Path.VIEW_ARTICLES_SAVE_POPUP_DETAIL)
|
||||
public ModelAndView viewArticleDeteilSavePopup(@PathVariable String boardId) {
|
||||
|
||||
Board board = boardService.findOne(boardId);
|
||||
|
||||
ModelAndView modelAndView = new ModelAndView();
|
||||
modelAndView.addObject("board", board);
|
||||
modelAndView.setViewName("skiaf/view/board/article-detail-save-popup");
|
||||
modelAndView.addObject(MessageComponent.JS_MESSAGES_KEY_PATTERN, BCM_CODE_ASTERISK);
|
||||
return modelAndView;
|
||||
}
|
||||
|
||||
@ApiOperation(value = "게시글 조회-수정 popup(popup type)")
|
||||
@GetMapping(value = Path.VIEW_ARTICLES_UPDATE_POPUP_DETAIL)
|
||||
public ModelAndView viewArticleDeteilViewSavePopup(@PathVariable String boardId) {
|
||||
|
||||
Board board = boardService.findOne(boardId);
|
||||
|
||||
ModelAndView modelAndView = new ModelAndView();
|
||||
modelAndView.addObject("board", board);
|
||||
modelAndView.setViewName("skiaf/view/board/article-detail-update-popup");
|
||||
modelAndView.addObject(MessageComponent.JS_MESSAGES_KEY_PATTERN, BCM_CODE_ASTERISK);
|
||||
return modelAndView;
|
||||
}
|
||||
|
||||
@ApiOperation(value = "게시글 등록 popup")
|
||||
@GetMapping(value = Path.VIEW_ARTICLES_CREATE_POPUP)
|
||||
public ModelAndView viewArticleCreatePopup(@PathVariable String boardId) {
|
||||
|
||||
Board board = boardService.findOne(boardId);
|
||||
|
||||
ModelAndView modelAndView = new ModelAndView();
|
||||
modelAndView.addObject("board", board);
|
||||
modelAndView.setViewName("skiaf/view/board/article-create-popup");
|
||||
modelAndView.addObject(MessageComponent.JS_MESSAGES_KEY_PATTERN, BCM_CODE_ASTERISK);
|
||||
return modelAndView;
|
||||
}
|
||||
|
||||
/*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
|
||||
| REST API
|
||||
|-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
|
||||
|
||||
@ApiOperation(value = "게시글 검색 페이징 목록 조회")
|
||||
@GetMapping(value = Path.ARTICLES)
|
||||
public RestResponse findQueryBySearch(@Valid ArticleSearchDTO search,
|
||||
@PageableDefault(sort = { "emgcYn", "articleId" }, direction = Sort.Direction.DESC) Pageable pageable) {
|
||||
return new RestResponse(articleService.findQueryByKeyword(search, pageable));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "게시글 상세조회")
|
||||
@GetMapping(value = Path.ARTICLES_DETAIL)
|
||||
public RestResponse getArticle(@PathVariable Long articleId) {
|
||||
return new RestResponse(articleService.getArticle(articleId));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "게시글 수정")
|
||||
@PutMapping(value = Path.ARTICLES_DETAIL)
|
||||
public RestResponse updateComment(@PathVariable(required = true) Long articleId, @RequestBody Article article) {
|
||||
return new RestResponse(articleService.updateArticle(article, articleId));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "게시글 삭제")
|
||||
@DeleteMapping(value = Path.ARTICLES_DETAIL)
|
||||
public RestResponse deleteArticle(@PathVariable(required = true) Long articleId) {
|
||||
return new RestResponse(articleService.deleteArticle(articleId));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "게시글 등록")
|
||||
@PostMapping(value = Path.ARTICLES_CREATE)
|
||||
public RestResponse createArticle(@PathVariable(required = true) String boardId, @RequestBody Article article) {
|
||||
return new RestResponse(articleService.createArticle(article, boardId));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "댓글 등록")
|
||||
@PostMapping(value = Path.ARTICLES_MAP_COMMENTS)
|
||||
public RestResponse createComment(@PathVariable(required = true) Long articleId, @RequestBody Comment comment) {
|
||||
return new RestResponse(articleService.createComment(comment, articleId));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "댓글 수정")
|
||||
@PutMapping(value = Path.COMMENTS_DETAIL)
|
||||
public RestResponse updateComment(@PathVariable(required = true) Long commentsId, @RequestBody Comment comment) {
|
||||
return new RestResponse(articleService.updateComment(comment, commentsId));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "댓글 삭제")
|
||||
@DeleteMapping(value = Path.COMMENTS_DETAIL)
|
||||
public RestResponse deleteComment(@PathVariable(required = true) Long commentsId) {
|
||||
return new RestResponse(articleService.deleteComment(commentsId));
|
||||
}
|
||||
|
||||
}
|
||||
141
src/main/java/com/skti/bcm/board/web/BoardController.java
Normal file
141
src/main/java/com/skti/bcm/board/web/BoardController.java
Normal file
@@ -0,0 +1,141 @@
|
||||
/**
|
||||
* Copyright (c) 2018 SK INNOVATION Co., Ltd. All rights reserved.
|
||||
*
|
||||
* This software is the confidential and proprietary information of SK INNOVATION.
|
||||
* You shall not disclose such confidential information and shall use it only in accordance
|
||||
* with the terms of the license agreement you entered into with SK INNOVATION.
|
||||
*/
|
||||
package com.skti.bcm.board.web;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.data.web.PageableDefault;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import com.skti.bcm.board.domain.model.Board;
|
||||
import com.skti.bcm.board.domain.service.BoardService;
|
||||
import com.skti.bcm.board.domain.service.dto.BoardSearchDTO;
|
||||
import com.skti.core.component.MessageComponent;
|
||||
import com.skti.core.constant.Path;
|
||||
import com.skti.core.vo.RestResponse;
|
||||
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
|
||||
/**
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* History
|
||||
* - 2018. 7. 20. | in01871 | 최초작성.
|
||||
* </pre>
|
||||
*/
|
||||
@Api(tags = "게시판 관리")
|
||||
@RestController
|
||||
public class BoardController {
|
||||
|
||||
private static final String BCM_BOARD_ASTERISK = "bcm.board.*";
|
||||
|
||||
@Autowired
|
||||
private BoardService boardService;
|
||||
|
||||
@Autowired
|
||||
private MessageComponent messageComponent;
|
||||
|
||||
/*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
|
||||
| VIEW
|
||||
|-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
|
||||
|
||||
@GetMapping(value = Path.VIEW_BOARDS)
|
||||
public ModelAndView boardList() {
|
||||
|
||||
ModelAndView modelAndView = new ModelAndView();
|
||||
modelAndView.addObject(MessageComponent.JS_MESSAGES_KEY_PATTERN, BCM_BOARD_ASTERISK);
|
||||
modelAndView.setViewName("skiaf/view/board/board-list");
|
||||
|
||||
return modelAndView;
|
||||
}
|
||||
|
||||
@GetMapping(value = Path.VIEW_BOARDS_CREATE)
|
||||
public ModelAndView boardCreate() {
|
||||
|
||||
ModelAndView modelAndView = new ModelAndView();
|
||||
modelAndView.addObject(MessageComponent.JS_MESSAGES_KEY_PATTERN, BCM_BOARD_ASTERISK);
|
||||
modelAndView.setViewName("skiaf/view/board/board-create-popup");
|
||||
|
||||
return modelAndView;
|
||||
}
|
||||
|
||||
@GetMapping(value = Path.VIEW_BOARDS_UPDATE)
|
||||
public ModelAndView boardUpdate() {
|
||||
ModelAndView modelAndView = new ModelAndView();
|
||||
modelAndView.addObject(MessageComponent.JS_MESSAGES_KEY_PATTERN, BCM_BOARD_ASTERISK);
|
||||
modelAndView.setViewName("skiaf/view/board/board-update-popup");
|
||||
|
||||
return modelAndView;
|
||||
}
|
||||
|
||||
|
||||
/*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
|
||||
| REST API
|
||||
|-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
|
||||
|
||||
@ApiOperation(value = "게시판 조회")
|
||||
@GetMapping(value = Path.BOARDS)
|
||||
public RestResponse findQueryByKeyword(BoardSearchDTO search,
|
||||
@PageableDefault(sort = { "updateDate" }, direction = Sort.Direction.DESC) Pageable pageable) {
|
||||
|
||||
return new RestResponse(boardService.findQueryBySearch(search, pageable));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "게시판 상세조회")
|
||||
@GetMapping(value = Path.BOARDS_DETAIL)
|
||||
public RestResponse findOne(@ApiParam(name = "boardId", required = true, value = "게시판 아이디") @PathVariable String boardId) {
|
||||
|
||||
return new RestResponse(boardService.findOne(boardId));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "게시판 등록")
|
||||
@PostMapping(value = Path.BOARDS)
|
||||
public RestResponse create(@RequestBody Board board) {
|
||||
|
||||
return new RestResponse(boardService.create(board));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "게시판 수정")
|
||||
@PutMapping(value = Path.BOARDS_DETAIL)
|
||||
public RestResponse update(HttpServletRequest request, HttpServletResponse response,
|
||||
@ApiParam(name = "boardId", required = true, value = "게시판 아이디") @PathVariable String boardId,
|
||||
@ApiParam(name = "update board object", required = true, value = "게시판 정보") @RequestBody Board board) {
|
||||
|
||||
return new RestResponse(boardService.update(boardId, board));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "게시판 ID 중복체크")
|
||||
@GetMapping(value = Path.BOARDS_DUPLICATE)
|
||||
public RestResponse duplicateBoardId(
|
||||
@ApiParam(name = "boardId", required = true, value = "게시판 ID") @PathVariable String boardId) {
|
||||
|
||||
RestResponse restResponse = new RestResponse();
|
||||
Boolean isDuplicate = boardService.duplicateBoardId(boardId);
|
||||
restResponse.setData(isDuplicate);
|
||||
|
||||
if (isDuplicate) {
|
||||
restResponse.setUserMessage(messageComponent.getMessage("bcm.common.DUPLICATE"));
|
||||
}
|
||||
|
||||
return restResponse;
|
||||
|
||||
}
|
||||
}
|
||||
93
src/main/java/com/skti/bcm/code/domain/model/Code.java
Normal file
93
src/main/java/com/skti/bcm/code/domain/model/Code.java
Normal file
@@ -0,0 +1,93 @@
|
||||
/**
|
||||
* Copyright (c) 2018 SK INNOVATION Co., Ltd. All rights reserved.
|
||||
*
|
||||
* This software is the confidential and proprietary information of SK INNOVATION.
|
||||
* You shall not disclose such confidential information and shall use it only in accordance
|
||||
* with the terms of the license agreement you entered into with SK INNOVATION.
|
||||
*/
|
||||
package com.skti.bcm.code.domain.model;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.FetchType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.IdClass;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.Transient;
|
||||
|
||||
import org.hibernate.validator.constraints.Length;
|
||||
import org.hibernate.validator.constraints.NotBlank;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonBackReference;
|
||||
import com.skti.bcm.common.domain.model.BaseModelUseYnSupport;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* BCM 코드 Entity
|
||||
*
|
||||
* History
|
||||
* - 2018. 8. 10. | in01866 | 최초작성.
|
||||
* - 2018. 8. 22. | in01866 | 2차 수정.
|
||||
* </pre>
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@Entity(name = "TB_BCM_CDDTL")
|
||||
@IdClass(CodeId.class)
|
||||
public class Code extends BaseModelUseYnSupport {
|
||||
|
||||
private static final long serialVersionUID = -1517443110525152693L;
|
||||
|
||||
/** 코드 그룹 아이디 */
|
||||
@Id
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
@JoinColumn(name = "CD_ID", nullable = false)
|
||||
@JsonBackReference
|
||||
private CodeGroup codeGroup;
|
||||
|
||||
/** 코드 상세 ID */
|
||||
@Id
|
||||
@NotBlank
|
||||
@Column(name = "CD_DTL_ID", nullable = false)
|
||||
private String codeId;
|
||||
|
||||
/** 코드 상세명 1 */
|
||||
@Length(max = 128)
|
||||
@Column(name = "CD_DTL_NM1", length = 128)
|
||||
private String codeName1;
|
||||
|
||||
/** 코드 상세명 2 */
|
||||
@Length(max = 128)
|
||||
@Column(name = "CD_DTL_NM2", length = 128)
|
||||
private String codeName2;
|
||||
|
||||
/** 코드 상세명 3 */
|
||||
@Length(max = 128)
|
||||
@Column(name = "CD_DTL_NM3", length = 128)
|
||||
private String codeName3;
|
||||
|
||||
/** 코드 상세명 4 */
|
||||
/* 4번째 언어 추가시, 주석 해제
|
||||
@Length(max = 128)
|
||||
@Column(name = "CD_DTL_NM4", length = 128)
|
||||
private String codeName4;
|
||||
*/
|
||||
|
||||
/**코드 상세 설명 */
|
||||
@Length(max = 2000)
|
||||
@Column(name = "CD_DTL_DESC", length = 2000)
|
||||
private String codeDesc;
|
||||
|
||||
/** 코드 정렬 순번 */
|
||||
@Column(name = "CD_SORT_SEQ")
|
||||
private int codeSortSeq;
|
||||
|
||||
/** 현재 언어 기준 코드 상세명 */
|
||||
@Transient
|
||||
private String codeName;
|
||||
|
||||
}
|
||||
85
src/main/java/com/skti/bcm/code/domain/model/CodeGroup.java
Normal file
85
src/main/java/com/skti/bcm/code/domain/model/CodeGroup.java
Normal file
@@ -0,0 +1,85 @@
|
||||
/**
|
||||
* Copyright (c) 2018 SK INNOVATION Co., Ltd. All rights reserved.
|
||||
*
|
||||
* This software is the confidential and proprietary information of SK INNOVATION.
|
||||
* You shall not disclose such confidential information and shall use it only in accordance
|
||||
* with the terms of the license agreement you entered into with SK INNOVATION.
|
||||
*/
|
||||
package com.skti.bcm.code.domain.model;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.FetchType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.OneToMany;
|
||||
import javax.persistence.Transient;
|
||||
|
||||
import org.hibernate.validator.constraints.Length;
|
||||
import org.hibernate.validator.constraints.NotBlank;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonManagedReference;
|
||||
import com.skti.bcm.common.domain.model.BaseModelUseYnSupport;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* BCM 코드 그룹 Entity
|
||||
*
|
||||
* History
|
||||
* - 2018. 8. 10. | in01866 | 최초작성.
|
||||
* - 2018. 8. 22. | in01866 | 2차 수정.
|
||||
* </pre>
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@Entity(name = "TB_BCM_CDMST")
|
||||
public class CodeGroup extends BaseModelUseYnSupport {
|
||||
|
||||
private static final long serialVersionUID = 1773423046943949463L;
|
||||
|
||||
/** 코드 그룹 아이디 */
|
||||
@Id
|
||||
@NotBlank
|
||||
@Column(name = "CD_ID", nullable = false)
|
||||
private String codeGroupId;
|
||||
|
||||
/** 코드 그룹명 1 */
|
||||
@Length(max = 128)
|
||||
@Column(name = "CD_NM1", length = 128)
|
||||
private String codeGroupName1;
|
||||
|
||||
/** 코드 그룹명 2 */
|
||||
@Length(max = 128)
|
||||
@Column(name = "CD_NM2", length = 128)
|
||||
private String codeGroupName2;
|
||||
|
||||
/** 코드 그룹명 3 */
|
||||
@Length(max = 128)
|
||||
@Column(name = "CD_NM3", length = 128)
|
||||
private String codeGroupName3;
|
||||
|
||||
/** 코드 그룹명 4 */
|
||||
/* 4번째 언어 추가시, 주석 해제
|
||||
@Length(max = 128)
|
||||
@Column(name = "CD_NM4", length = 128)
|
||||
private String codeGroupName4;
|
||||
*/
|
||||
|
||||
/** 코드 그룹 설명 */
|
||||
@Length(max = 2000)
|
||||
@Column(name = "CD_DESC", length = 2000)
|
||||
private String codeGroupDesc;
|
||||
|
||||
@OneToMany(mappedBy = "codeGroup", fetch = FetchType.LAZY)
|
||||
@JsonManagedReference
|
||||
private List<Code> codeList;
|
||||
|
||||
/** 현재 언어 기준 코드 그룹명 */
|
||||
@Transient
|
||||
private String codeGroupName;
|
||||
|
||||
}
|
||||
45
src/main/java/com/skti/bcm/code/domain/model/CodeId.java
Normal file
45
src/main/java/com/skti/bcm/code/domain/model/CodeId.java
Normal file
@@ -0,0 +1,45 @@
|
||||
/**
|
||||
* Copyright (c) 2018 SK INNOVATION Co., Ltd. All rights reserved.
|
||||
*
|
||||
* This software is the confidential and proprietary information of SK INNOVATION.
|
||||
* You shall not disclose such confidential information and shall use it only in accordance
|
||||
* with the terms of the license agreement you entered into with SK INNOVATION.
|
||||
*/
|
||||
package com.skti.bcm.code.domain.model;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* BCM 코드 ID
|
||||
*
|
||||
* History
|
||||
* - 2018. 8. 10. | in01866 | 최초작성.
|
||||
* - 2018. 8. 22. | in01866 | 2차 수정.
|
||||
* </pre>
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@EqualsAndHashCode
|
||||
public class CodeId implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -3008752536791896023L;
|
||||
|
||||
/** 코드 그룹 아이디 */
|
||||
private String codeGroup;
|
||||
|
||||
/** 코드 상세 아이디 */
|
||||
private String codeId;
|
||||
|
||||
public CodeId(String codeGroup, String cdDtlId) {
|
||||
super();
|
||||
this.codeGroup = codeGroup;
|
||||
this.codeId = cdDtlId;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
/**
|
||||
* Copyright (c) 2018 SK INNOVATION Co., Ltd. All rights reserved.
|
||||
*
|
||||
* This software is the confidential and proprietary information of SK INNOVATION.
|
||||
* You shall not disclose such confidential information and shall use it only in accordance
|
||||
* with the terms of the license agreement you entered into with SK INNOVATION.
|
||||
*/
|
||||
package com.skti.bcm.code.domain.repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.data.domain.Pageable;
|
||||
|
||||
import com.skti.bcm.code.domain.model.CodeGroup;
|
||||
import com.skti.bcm.code.domain.service.dto.CodeSearchDTO;
|
||||
import com.skti.core.vo.PageDTO;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* BCM 코드 그룹 Repository
|
||||
*
|
||||
* History
|
||||
* - 2018. 8. 10. | in01866 | 최초작성.
|
||||
* - 2018. 8. 22. | in01866 | 2차 수정.
|
||||
* </pre>
|
||||
*/
|
||||
public interface CodeGroupRepository {
|
||||
|
||||
/*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
|
||||
| jpaRepository 기본기능
|
||||
|-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 코드 그룹 목록 조회
|
||||
* </pre>
|
||||
*/
|
||||
public List<CodeGroup> findAll();
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 코드 그룹 조회
|
||||
* </pre>
|
||||
*/
|
||||
public CodeGroup findOne(String codeGroupId);
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 코드 그룹 ID 및 사용여부 조건을 만족하는 코드 그룹 조회
|
||||
* </pre>
|
||||
*/
|
||||
public CodeGroup findByCodeGroupIdAndUseYn(String codeGroupId, boolean useYn);
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 코드 그룹 저장/수정
|
||||
* </pre>
|
||||
*/
|
||||
public CodeGroup save(CodeGroup codeGroup);
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 코드 그룹 목록 저장
|
||||
* </pre>
|
||||
*/
|
||||
public List<CodeGroup> save(List<CodeGroup> codeGroupList);
|
||||
|
||||
/*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
|
||||
| custom method
|
||||
|-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 코드 그룹 페이징, 검색 목록 조회
|
||||
* </pre>
|
||||
*/
|
||||
public PageDTO<CodeGroup> findQueryBySearch(CodeSearchDTO search, Pageable pageable);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
/**
|
||||
* Copyright (c) 2018 SK INNOVATION Co., Ltd. All rights reserved.
|
||||
*
|
||||
* This software is the confidential and proprietary information of SK INNOVATION.
|
||||
* You shall not disclose such confidential information and shall use it only in accordance
|
||||
* with the terms of the license agreement you entered into with SK INNOVATION.
|
||||
*/
|
||||
package com.skti.bcm.code.domain.repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.data.domain.Sort;
|
||||
|
||||
import com.skti.bcm.code.domain.model.Code;
|
||||
import com.skti.bcm.code.domain.model.CodeId;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* BCM 코드 Repository
|
||||
*
|
||||
* History
|
||||
* - 2018. 8. 10. | in01866 | 최초작성.
|
||||
* - 2018. 8. 22. | in01866 | 2차 수정.
|
||||
* </pre>
|
||||
*/
|
||||
public interface CodeRepository {
|
||||
|
||||
/*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
|
||||
| jpaRepository 기본기능
|
||||
|-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 코드 목록 조회
|
||||
* </pre>
|
||||
*/
|
||||
public List<Code> findAll();
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 코드 아이디 목록에 있는 코드 조회
|
||||
* </pre>
|
||||
*/
|
||||
public List<Code> findByCodeIdIn(List<String> codeId);
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 코드 조회
|
||||
* </pre>
|
||||
*/
|
||||
public Code findOne(CodeId codeId);
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 코드 저장/수정
|
||||
* </pre>
|
||||
*/
|
||||
public Code save(Code code);
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 코드 목록 저장/수정
|
||||
* </pre>
|
||||
*/
|
||||
public <S extends Code> List<S> save(Iterable<S> codeList);
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 코드 삭제
|
||||
* </pre>
|
||||
*/
|
||||
public void delete(Code code);
|
||||
|
||||
/*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
|
||||
| custom method
|
||||
|-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 코드 페이징, 검색 목록 조회
|
||||
* </pre>
|
||||
*/
|
||||
public List<Code> findQueryByCodeGroupId(String codeGroupId, Sort sort);
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
/**
|
||||
* Copyright (c) 2018 SK INNOVATION Co., Ltd. All rights reserved.
|
||||
*
|
||||
* This software is the confidential and proprietary information of SK INNOVATION.
|
||||
* You shall not disclose such confidential information and shall use it only in accordance
|
||||
* with the terms of the license agreement you entered into with SK INNOVATION.
|
||||
*/
|
||||
package com.skti.bcm.code.domain.repository.jpa;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
import com.skti.bcm.code.domain.model.CodeGroup;
|
||||
import com.skti.bcm.code.domain.repository.CodeGroupRepository;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* BCM 코드 그룹 JPA Repository
|
||||
*
|
||||
* History
|
||||
* - 2018. 8. 10. | in01866 | 최초작성.
|
||||
* - 2018. 8. 22. | in01866 | 2차 수정.
|
||||
* </pre>
|
||||
*/
|
||||
public interface CodeGroupRepositoryJpa extends CodeGroupRepository, JpaRepository<CodeGroup, String>, CodeGroupRepositoryJpaExtend {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
/**
|
||||
* Copyright (c) 2018 SK INNOVATION Co., Ltd. All rights reserved.
|
||||
*
|
||||
* This software is the confidential and proprietary information of SK INNOVATION.
|
||||
* You shall not disclose such confidential information and shall use it only in accordance
|
||||
* with the terms of the license agreement you entered into with SK INNOVATION.
|
||||
*/
|
||||
package com.skti.bcm.code.domain.repository.jpa;
|
||||
|
||||
import org.springframework.data.domain.Pageable;
|
||||
|
||||
import com.skti.bcm.code.domain.model.CodeGroup;
|
||||
import com.skti.bcm.code.domain.service.dto.CodeSearchDTO;
|
||||
import com.skti.core.vo.PageDTO;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* BCM 코드 그룹 JPA Repository Extend
|
||||
*
|
||||
* History
|
||||
* - 2018. 8. 10. | in01866 | 최초작성.
|
||||
* - 2018. 8. 22. | in01866 | 2차 수정.
|
||||
* </pre>
|
||||
*/
|
||||
public interface CodeGroupRepositoryJpaExtend {
|
||||
|
||||
public PageDTO<CodeGroup> findQueryBySearch(CodeSearchDTO search, Pageable pageable);
|
||||
}
|
||||
@@ -0,0 +1,153 @@
|
||||
/**
|
||||
* Copyright (c) 2018 SK INNOVATION Co., Ltd. All rights reserved.
|
||||
*
|
||||
* This software is the confidential and proprietary information of SK INNOVATION.
|
||||
* You shall not disclose such confidential information and shall use it only in accordance
|
||||
* with the terms of the license agreement you entered into with SK INNOVATION.
|
||||
*/
|
||||
package com.skti.bcm.code.domain.repository.jpa;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.PersistenceContext;
|
||||
import javax.persistence.TypedQuery;
|
||||
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.data.domain.Sort.Order;
|
||||
|
||||
import com.skti.bcm.code.domain.model.CodeGroup;
|
||||
import com.skti.bcm.code.domain.service.dto.CodeSearchDTO;
|
||||
import com.skti.core.vo.PageDTO;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* BCM 코드 그룹 JPA Repository Extend Implements
|
||||
*
|
||||
* History
|
||||
* - 2018. 8. 10. | in01866 | 최초작성.
|
||||
* - 2018. 8. 24. | in01866 | 2차 수정.
|
||||
* </pre>
|
||||
*/
|
||||
public class CodeGroupRepositoryJpaImpl implements CodeGroupRepositoryJpaExtend {
|
||||
|
||||
@PersistenceContext
|
||||
EntityManager em;
|
||||
|
||||
@Override
|
||||
public PageDTO<CodeGroup> findQueryBySearch(CodeSearchDTO search, Pageable pageable) {
|
||||
|
||||
/*
|
||||
* where 처리
|
||||
*/
|
||||
// 기본 검색
|
||||
String where = "";
|
||||
Map<String, Object> paramMap = new HashMap<>();
|
||||
|
||||
// 검색어
|
||||
if (search.getKeyword() != null) {
|
||||
where += "(UPPER(a.codeGroupId) LIKE :keyword ";
|
||||
where += "OR UPPER(a.codeGroupName1) LIKE :keyword ";
|
||||
where += "OR UPPER(a.codeGroupName2) LIKE :keyword ";
|
||||
where += "OR UPPER(a.codeGroupName3) LIKE :keyword ";
|
||||
/* 4번째 언어 추가시, 주석 해제
|
||||
where += "OR UPPER(a.codeGroupName4) LIKE :keyword ";
|
||||
*/
|
||||
|
||||
// 코드까지 검색 포함
|
||||
if (!search.isCodeInclude()) {
|
||||
where += "OR UPPER(b.codeId) LIKE :keyword ";
|
||||
where += "OR UPPER(b.codeName1) LIKE :keyword ";
|
||||
where += "OR UPPER(b.codeName2) LIKE :keyword ";
|
||||
where += "OR UPPER(b.codeName3) LIKE :keyword ";
|
||||
/* 4번째 언어 추가시, 주석 해제
|
||||
where += "OR UPPER(b.codeName4) LIKE :keyword ";
|
||||
*/
|
||||
}
|
||||
|
||||
// 검색어 조건 닫기
|
||||
where += ") ";
|
||||
|
||||
paramMap.put("keyword", "%" + search.getKeyword().toUpperCase() + "%");
|
||||
}
|
||||
|
||||
// 사용만 조회하는지 확인
|
||||
if (!search.isUnusedInclude()) {
|
||||
if (where != "") {
|
||||
where += "AND ";
|
||||
}
|
||||
// 사용만 조회
|
||||
where += "UPPER(a.useYn) = 'Y' ";
|
||||
}
|
||||
|
||||
// 조건이 하나라도 있는지 검사
|
||||
if (where != "") {
|
||||
where = "WHERE " + where;
|
||||
}
|
||||
|
||||
/*
|
||||
* group by 처리
|
||||
*/
|
||||
String groupBy = "GROUP BY a.codeGroupId "
|
||||
+ ", a.codeGroupName1 "
|
||||
+ ", a.codeGroupName2 "
|
||||
+ ", a.codeGroupName3 "
|
||||
/* 4번째 언어 추가시, 주석 해제
|
||||
+ ", a.codeGroupName4 "
|
||||
*/
|
||||
+ ", a.codeGroupDesc "
|
||||
+ ", a.createBy "
|
||||
+ ", a.updateBy "
|
||||
+ ", a.createDate "
|
||||
+ ", a.updateDate "
|
||||
+ ", a.useYn ";
|
||||
|
||||
/*
|
||||
* order by 처리
|
||||
*/
|
||||
Sort sort = pageable.getSort();
|
||||
String orderBy = "";
|
||||
|
||||
String[] orderByText = {""};
|
||||
sort.forEach((Order arg) -> orderByText[0] = "a." + arg.getProperty() + " " + arg.getDirection() + " ");
|
||||
|
||||
if (orderByText[0] != "") {
|
||||
orderBy += "ORDER BY ";
|
||||
orderBy += orderByText[0];
|
||||
}
|
||||
|
||||
/*
|
||||
* Query 처리
|
||||
*/
|
||||
// Query 생성
|
||||
String query = ""
|
||||
+ "SELECT a "
|
||||
+ "FROM TB_BCM_CDMST a "
|
||||
+ "LEFT JOIN a.codeList b "
|
||||
+ where
|
||||
+ groupBy
|
||||
+ orderBy;
|
||||
|
||||
TypedQuery<CodeGroup> typedQuery = em.createQuery(query, CodeGroup.class);
|
||||
|
||||
// 조건 파라메터 추가
|
||||
paramMap.forEach((String key, Object value) -> typedQuery.setParameter(key, value));
|
||||
|
||||
PageDTO<CodeGroup> result = new PageDTO<>();
|
||||
result.setTotalCount(typedQuery.getResultList().size());
|
||||
|
||||
// 페이징 추가
|
||||
if(search.isPaging()) {
|
||||
typedQuery.setFirstResult(pageable.getOffset());
|
||||
typedQuery.setMaxResults(pageable.getPageSize());
|
||||
|
||||
result.setPage(pageable);
|
||||
}
|
||||
|
||||
result.setList(typedQuery.getResultList());
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
/**
|
||||
* Copyright (c) 2018 SK INNOVATION Co., Ltd. All rights reserved.
|
||||
*
|
||||
* This software is the confidential and proprietary information of SK INNOVATION.
|
||||
* You shall not disclose such confidential information and shall use it only in accordance
|
||||
* with the terms of the license agreement you entered into with SK INNOVATION.
|
||||
*/
|
||||
package com.skti.bcm.code.domain.repository.jpa;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
import com.skti.bcm.code.domain.model.Code;
|
||||
import com.skti.bcm.code.domain.model.CodeId;
|
||||
import com.skti.bcm.code.domain.repository.CodeRepository;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* BCM 코드 JPA Repository
|
||||
*
|
||||
* History
|
||||
* - 2018. 8. 10. | in01866 | 최초작성.
|
||||
* - 2018. 8. 22. | in01866 | 2차 수정.
|
||||
* </pre>
|
||||
*/
|
||||
public interface CodeRepositoryJpa extends CodeRepository, JpaRepository<Code, CodeId>, CodeRepositoryJpaExtend {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
/**
|
||||
* Copyright (c) 2018 SK INNOVATION Co., Ltd. All rights reserved.
|
||||
*
|
||||
* This software is the confidential and proprietary information of SK INNOVATION.
|
||||
* You shall not disclose such confidential information and shall use it only in accordance
|
||||
* with the terms of the license agreement you entered into with SK INNOVATION.
|
||||
*/
|
||||
package com.skti.bcm.code.domain.repository.jpa;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.data.domain.Sort;
|
||||
|
||||
import com.skti.bcm.code.domain.model.Code;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* BCM 코드 JPA Repository Extend
|
||||
*
|
||||
* History
|
||||
* - 2018. 8. 10. | in01866 | 최초작성.
|
||||
* - 2018. 8. 22. | in01866 | 2차 수정.
|
||||
* </pre>
|
||||
*/
|
||||
public interface CodeRepositoryJpaExtend {
|
||||
|
||||
public List<Code> findQueryByCodeGroupId(String codeGroupId, Sort sort);
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
/**
|
||||
* Copyright (c) 2018 SK INNOVATION Co., Ltd. All rights reserved.
|
||||
*
|
||||
* This software is the confidential and proprietary information of SK INNOVATION.
|
||||
* You shall not disclose such confidential information and shall use it only in accordance
|
||||
* with the terms of the license agreement you entered into with SK INNOVATION.
|
||||
*/
|
||||
package com.skti.bcm.code.domain.repository.jpa;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.PersistenceContext;
|
||||
import javax.persistence.TypedQuery;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.data.domain.Sort.Order;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import com.skti.bcm.code.domain.model.Code;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* BCM 코드 JPA Repository Extend Implements
|
||||
*
|
||||
* History
|
||||
* - 2018. 8. 10. | in01866 | 최초작성.
|
||||
* - 2018. 8. 24. | in01866 | 2차 수정.
|
||||
* </pre>
|
||||
*/
|
||||
@Repository
|
||||
public class CodeRepositoryJpaImpl implements CodeRepositoryJpaExtend {
|
||||
|
||||
@PersistenceContext
|
||||
EntityManager em;
|
||||
|
||||
@Override
|
||||
public List<Code> findQueryByCodeGroupId(String codeGroupId, Sort sort) {
|
||||
|
||||
/*
|
||||
* 조건 처리
|
||||
*/
|
||||
// 기본 검색
|
||||
String where = "";
|
||||
Map<String, Object> paramMap = new HashMap<>();
|
||||
|
||||
// 검색어
|
||||
if (!StringUtils.isBlank(codeGroupId)) {
|
||||
where += "(a.codeGroup.codeGroupId = :codeGroupId) ";
|
||||
paramMap.put("codeGroupId", codeGroupId);
|
||||
}
|
||||
|
||||
// 조건이 하나라도 있는지 검사
|
||||
if (!StringUtils.isBlank(where)) {
|
||||
where = "WHERE " + where;
|
||||
}
|
||||
|
||||
/*
|
||||
* 정렬 처리
|
||||
*/
|
||||
|
||||
String orderBy = "";
|
||||
|
||||
String[] orderByText = {""};
|
||||
sort.forEach((Order arg) -> orderByText[0] = "a." + arg.getProperty() + " " + arg.getDirection() + " ");
|
||||
|
||||
if (!StringUtils.isBlank(orderByText[0])) {
|
||||
orderBy += "ORDER BY ";
|
||||
orderBy += orderByText[0];
|
||||
}
|
||||
|
||||
/*
|
||||
* Query 처리
|
||||
*/
|
||||
|
||||
// Query 생성
|
||||
String query = ""
|
||||
+ "SELECT a "
|
||||
+ "FROM TB_BCM_CDDTL a "
|
||||
+ "INNER JOIN a.codeGroup "
|
||||
+ where
|
||||
+ orderBy;
|
||||
|
||||
TypedQuery<Code> typedQuery = em.createQuery(query, Code.class);
|
||||
|
||||
// 조건 파라메터 추가
|
||||
paramMap.forEach((String key, Object value) -> typedQuery.setParameter(key, value));
|
||||
|
||||
return typedQuery.getResultList();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
/**
|
||||
* Copyright (c) 2018 SK INNOVATION Co., Ltd. All rights reserved.
|
||||
*
|
||||
* This software is the confidential and proprietary information of SK INNOVATION.
|
||||
* You shall not disclose such confidential information and shall use it only in accordance
|
||||
* with the terms of the license agreement you entered into with SK INNOVATION.
|
||||
*/
|
||||
package com.skti.bcm.code.domain.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.data.domain.Pageable;
|
||||
|
||||
import com.skti.bcm.code.domain.model.CodeGroup;
|
||||
import com.skti.bcm.code.domain.service.dto.CodeSearchDTO;
|
||||
import com.skti.core.vo.PageDTO;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* BCM 코드 그룹 Service
|
||||
*
|
||||
* History
|
||||
* - 2018. 8. 10. | in01866 | 최초작성.
|
||||
* - 2018. 8. 22. | in01866 | 2차 수정.
|
||||
* </pre>
|
||||
*/
|
||||
public interface CodeGroupService {
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 코드 그룹 조회
|
||||
* </pre>
|
||||
*/
|
||||
public CodeGroup findOne(String codeGroupId);
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 코드 그룹 ID 및 사용여부 조건을 만족하는 코드 그룹 조회
|
||||
* </pre>
|
||||
*/
|
||||
public CodeGroup findByCodeGroupIdAndUseYn(String codeGroupId, boolean useYn);
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 코드 그룹 저장
|
||||
* </pre>
|
||||
*/
|
||||
public CodeGroup create(CodeGroup codeGroup);
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 코드 그룹 수정
|
||||
* </pre>
|
||||
*/
|
||||
public CodeGroup update(String codeGroupId, CodeGroup codeGroup);
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 코드 그룹 전체 목록 조회
|
||||
* </pre>
|
||||
*/
|
||||
public List<CodeGroup> findAll();
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 현재 언어의 코드 그룹명 조회
|
||||
* </pre>
|
||||
*/
|
||||
public String findCodeGroupNameByCurrentLanguage(CodeGroup codeGroup);
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 코드 그룹 페이징, 검색 목록 조회
|
||||
* </pre>
|
||||
*/
|
||||
public PageDTO<CodeGroup> findQueryBySearch(CodeSearchDTO search, Pageable pageable);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,145 @@
|
||||
/**
|
||||
* Copyright (c) 2018 SK INNOVATION Co., Ltd. All rights reserved.
|
||||
*
|
||||
* This software is the confidential and proprietary information of SK INNOVATION.
|
||||
* You shall not disclose such confidential information and shall use it only in accordance
|
||||
* with the terms of the license agreement you entered into with SK INNOVATION.
|
||||
*/
|
||||
package com.skti.bcm.code.domain.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.modelmapper.ModelMapper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import com.skti.bcm.code.domain.model.CodeGroup;
|
||||
import com.skti.bcm.code.domain.repository.CodeGroupRepository;
|
||||
import com.skti.bcm.code.domain.service.dto.CodeSearchDTO;
|
||||
import com.skti.core.component.MessageComponent;
|
||||
import com.skti.core.exception.ValidationException;
|
||||
import com.skti.core.vo.PageDTO;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* BCM 코드 그룹 Service Implements
|
||||
*
|
||||
* History
|
||||
* - 2018. 8. 10. | in01866 | 최초작성.
|
||||
* - 2018. 8. 22. | in01866 | 2차 수정.
|
||||
* </pre>
|
||||
*/
|
||||
@Service
|
||||
@Transactional
|
||||
public class CodeGroupServiceImpl implements CodeGroupService {
|
||||
|
||||
private static final int LANGUAGE_INDEX_ZERO = 0;
|
||||
private static final int LANGUAGE_INDEX_ONE = 1;
|
||||
private static final int LANGUAGE_INDEX_TWO = 2;
|
||||
/* 4번째 언어 추가시, 주석 해제
|
||||
private static final int LANGUAGE_INDEX_THREE = 3;
|
||||
*/
|
||||
|
||||
private static final String USER_MESSAGE_KEY_EMPTY = "bcm.common.EMPTY";
|
||||
private static final String USER_MESSAGE_KEY_DUPLICATE = "bcm.common.DUPLICATE";
|
||||
|
||||
@Autowired
|
||||
CodeGroupRepository codeGroupRepository;
|
||||
|
||||
@Autowired
|
||||
CodeService codeService;
|
||||
|
||||
@Autowired
|
||||
ModelMapper modelMapper;
|
||||
|
||||
@Autowired
|
||||
MessageComponent messageComponent;
|
||||
|
||||
@Override
|
||||
public CodeGroup findOne(String codeGroupId) {
|
||||
|
||||
CodeGroup codeGroup = codeGroupRepository.findOne(codeGroupId);
|
||||
if (codeGroup == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
codeGroup.setCodeGroupName(this.findCodeGroupNameByCurrentLanguage(codeGroup));
|
||||
return codeGroup;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CodeGroup findByCodeGroupIdAndUseYn(String codeGroupId, boolean useYn) {
|
||||
CodeGroup codeGroup = codeGroupRepository.findByCodeGroupIdAndUseYn(codeGroupId, useYn);
|
||||
if (codeGroup == null) {
|
||||
return null;
|
||||
}
|
||||
codeGroup.setCodeGroupName(this.findCodeGroupNameByCurrentLanguage(codeGroup));
|
||||
return codeGroup;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CodeGroup update(String codeGroupId, CodeGroup codeGroup) {
|
||||
|
||||
// 저장된 데이터 있는지 조회
|
||||
CodeGroup selectCodeGroup = this.findOne(codeGroupId);
|
||||
if (selectCodeGroup == null) {
|
||||
throw ValidationException.withUserMessageKey(USER_MESSAGE_KEY_EMPTY)
|
||||
.withSystemMessage("selectCodeGroup == null").build();
|
||||
}
|
||||
|
||||
// 저장
|
||||
codeGroup.setCodeGroupId(codeGroupId);
|
||||
return codeGroupRepository.save(codeGroup);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CodeGroup> findAll() {
|
||||
return codeGroupRepository.findAll();
|
||||
}
|
||||
|
||||
@Override
|
||||
public CodeGroup create(CodeGroup codeGroup) {
|
||||
if (codeGroup == null) {
|
||||
throw ValidationException.withUserMessageKey(USER_MESSAGE_KEY_EMPTY)
|
||||
.withSystemMessage("codeGroup == null").build();
|
||||
}
|
||||
String codeGroupId = codeGroup.getCodeGroupId();
|
||||
if (StringUtils.isEmpty(codeGroupId)) {
|
||||
throw ValidationException.withUserMessageKey(USER_MESSAGE_KEY_EMPTY)
|
||||
.withSystemMessage("codeGroupId == null").build();
|
||||
}
|
||||
|
||||
CodeGroup selectCodeGroup = this.findOne(codeGroupId);
|
||||
if (selectCodeGroup != null) {
|
||||
throw ValidationException.withUserMessageKey(USER_MESSAGE_KEY_DUPLICATE)
|
||||
.withSystemMessage("selectCodeGroup != null").build();
|
||||
}
|
||||
return codeGroupRepository.save(codeGroup);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageDTO<CodeGroup> findQueryBySearch(CodeSearchDTO search, Pageable pageable) {
|
||||
return codeGroupRepository.findQueryBySearch(search, pageable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String findCodeGroupNameByCurrentLanguage(CodeGroup codeGroup) {
|
||||
int index = messageComponent.getLanguageIndex();
|
||||
String codeGroupName = "";
|
||||
|
||||
switch (index) {
|
||||
case LANGUAGE_INDEX_ZERO: codeGroupName = codeGroup.getCodeGroupName1(); break;
|
||||
case LANGUAGE_INDEX_ONE: codeGroupName = codeGroup.getCodeGroupName2(); break;
|
||||
case LANGUAGE_INDEX_TWO: codeGroupName = codeGroup.getCodeGroupName3(); break;
|
||||
/* 4번째 언어 추가시, 주석 해제
|
||||
case LANGUAGE_INDEX_THREE: codeGroupName = codeGroup.getCodeGroupName4(); break;
|
||||
*/
|
||||
default: codeGroupName = "";
|
||||
}
|
||||
|
||||
return codeGroupName;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
/**
|
||||
* Copyright (c) 2018 SK INNOVATION Co., Ltd. All rights reserved.
|
||||
*
|
||||
* This software is the confidential and proprietary information of SK INNOVATION.
|
||||
* You shall not disclose such confidential information and shall use it only in accordance
|
||||
* with the terms of the license agreement you entered into with SK INNOVATION.
|
||||
*/
|
||||
package com.skti.bcm.code.domain.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.data.domain.Sort;
|
||||
|
||||
import com.skti.bcm.code.domain.model.Code;
|
||||
import com.skti.bcm.code.domain.service.dto.CodeDetailDTO;
|
||||
import com.skti.bcm.code.domain.service.dto.CodeUpdateDTO;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* BCM 코드 그룹 Service
|
||||
*
|
||||
* History
|
||||
* - 2018. 8. 10. | in01866 | 최초작성.
|
||||
* - 2018. 8. 22. | in01866 | 2차 수정.
|
||||
* </pre>
|
||||
*/
|
||||
public interface CodeService {
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 코드 조회
|
||||
* </pre>
|
||||
*/
|
||||
public Code findOne(String codeGroupId, String codeId);
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 코드 목록 저장
|
||||
* </pre>
|
||||
*/
|
||||
public List<Code> createList(List<CodeDetailDTO> codeDetailDTOList, String codeGroupId);
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 코드 목록 수정
|
||||
* </pre>
|
||||
*/
|
||||
public List<Code> updateList(CodeUpdateDTO codeUpdateDTO);
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 코드 전체 목록 조회
|
||||
* </pre>
|
||||
*/
|
||||
public List<Code> findAll();
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 코드 삭제
|
||||
* </pre>
|
||||
*/
|
||||
public void delete(Code code);
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 코드 페이징, 검색 목록 조회
|
||||
* </pre>
|
||||
*/
|
||||
public List<CodeDetailDTO> findQueryByCodeGroupId(String codeGroupId, Sort sort);
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 현재 언어 기준 코드 목록 조회
|
||||
* </pre>
|
||||
*/
|
||||
public List<Code> findByCodeGroupDetail(String codeGroupId);
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 현재 언어의 코드명 조회
|
||||
* </pre>
|
||||
*/
|
||||
public String findCodeNameByCurrentLanguage(Code code);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,282 @@
|
||||
/**
|
||||
* Copyright (c) 2018 SK INNOVATION Co., Ltd. All rights reserved.
|
||||
*
|
||||
* This software is the confidential and proprietary information of SK INNOVATION.
|
||||
* You shall not disclose such confidential information and shall use it only in accordance
|
||||
* with the terms of the license agreement you entered into with SK INNOVATION.
|
||||
*/
|
||||
package com.skti.bcm.code.domain.service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.modelmapper.ModelMapper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import com.skti.bcm.code.domain.model.Code;
|
||||
import com.skti.bcm.code.domain.model.CodeGroup;
|
||||
import com.skti.bcm.code.domain.model.CodeId;
|
||||
import com.skti.bcm.code.domain.repository.CodeRepository;
|
||||
import com.skti.bcm.code.domain.service.dto.CodeDetailDTO;
|
||||
import com.skti.bcm.code.domain.service.dto.CodeUpdateDTO;
|
||||
import com.skti.core.component.MessageComponent;
|
||||
import com.skti.core.constant.MessageDisplayType;
|
||||
import com.skti.core.exception.NotFoundException;
|
||||
import com.skti.core.exception.ValidationException;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* BCM 코드 Service Implements
|
||||
*
|
||||
* History
|
||||
* - 2018. 8. 10. | in01866 | 최초작성.
|
||||
* - 2018. 8. 22. | in01866 | 2차 수정.
|
||||
* </pre>
|
||||
*/
|
||||
@Service
|
||||
@Transactional
|
||||
public class CodeServiceImpl implements CodeService {
|
||||
|
||||
private static final int LANGUAGE_INDEX_ZERO = 0;
|
||||
private static final int LANGUAGE_INDEX_ONE = 1;
|
||||
private static final int LANGUAGE_INDEX_TWO = 2;
|
||||
/* 4번째 언어 추가시, 주석 해제
|
||||
private static final int LANGUAGE_INDEX_THREE = 3;
|
||||
*/
|
||||
|
||||
private static final String USER_MESSAGE_KEY_DUPLICATE = "bcm.common.DUPLICATE";
|
||||
private static final String USER_MESSAGE_KEY_EMPTY = "bcm.common.EMPTY";
|
||||
|
||||
@Autowired
|
||||
CodeRepository codeRepository;
|
||||
|
||||
@Autowired
|
||||
CodeGroupService codeGroupService;
|
||||
|
||||
@Autowired
|
||||
private ModelMapper modelMapper;
|
||||
|
||||
@Autowired
|
||||
MessageComponent messageComponent;
|
||||
|
||||
@Override
|
||||
public Code findOne(String codeGroupId, String codeId) {
|
||||
Code code = codeRepository.findOne(new CodeId(codeGroupId, codeId));
|
||||
if(code != null) {
|
||||
code.setCodeName(this.findCodeNameByCurrentLanguage(code));
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Code> createList(List<CodeDetailDTO> codeDetailDTOList, String codeGroupId) {
|
||||
|
||||
// 저장할 아이디 목록
|
||||
List<String> codeIdList = new ArrayList<>();
|
||||
codeDetailDTOList.forEach((CodeDetailDTO codeDetailDTO) -> {
|
||||
|
||||
// 아이디 있는지 체크
|
||||
if (StringUtils.isEmpty(codeDetailDTO.getCodeId())) {
|
||||
throw ValidationException.withUserMessageKey(USER_MESSAGE_KEY_EMPTY)
|
||||
.withSystemMessage("codeId isEmpty")
|
||||
.withDisplayType(MessageDisplayType.LAYER_POPUP)
|
||||
.build();
|
||||
}
|
||||
|
||||
// 아이디 중복 체크
|
||||
if (codeIdList.contains(codeDetailDTO.getCodeId())) {
|
||||
throw ValidationException.withUserMessageKey(USER_MESSAGE_KEY_DUPLICATE)
|
||||
.withSystemMessage("this.isDuplicate(codeDetailDTOList)")
|
||||
.withDisplayType(MessageDisplayType.LAYER_POPUP)
|
||||
.build();
|
||||
}
|
||||
codeIdList.add(codeDetailDTO.getCodeId());
|
||||
});
|
||||
|
||||
// 존재하는 아이디가 있는지 확인
|
||||
List<Code> existCodeList = codeRepository.findByCodeIdIn(codeIdList);
|
||||
if (existCodeList != null && !existCodeList.isEmpty()) {
|
||||
// 이미 존재하는 아이디 있음
|
||||
throw ValidationException.withUserMessageKey(USER_MESSAGE_KEY_DUPLICATE)
|
||||
.withSystemMessage("existCodeList.size() > 0")
|
||||
.withDisplayType(MessageDisplayType.LAYER_POPUP)
|
||||
.build();
|
||||
}
|
||||
|
||||
// 코드 그룹 조회
|
||||
CodeGroup codeGroup = codeGroupService.findOne(codeGroupId);
|
||||
|
||||
// 저장
|
||||
List<Code> codeList = new ArrayList<>();
|
||||
codeDetailDTOList.forEach((CodeDetailDTO codeDetailDTO) -> {
|
||||
Code code = modelMapper.map(codeDetailDTO, Code.class);
|
||||
code.setCodeGroup(codeGroup);
|
||||
codeList.add(code);
|
||||
});
|
||||
return codeRepository.save(codeList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Code> updateList(CodeUpdateDTO codeUpdateDTO) {
|
||||
|
||||
// 리턴 객체
|
||||
List<Code> result = new ArrayList<>();
|
||||
|
||||
// 업데이트 목록
|
||||
List<CodeDetailDTO> updateList = codeUpdateDTO.getUpdateList();
|
||||
|
||||
// 저장할 아이디 목록
|
||||
List<String> codeIdList = new ArrayList<>();
|
||||
updateList.forEach((CodeDetailDTO codeDetailDTO) -> {
|
||||
|
||||
// 아이디 있는지 체크
|
||||
if (StringUtils.isEmpty(codeDetailDTO.getCodeId())) {
|
||||
throw ValidationException.withUserMessageKey(USER_MESSAGE_KEY_EMPTY)
|
||||
.withSystemMessage("codeId isEmpty")
|
||||
.withDisplayType(MessageDisplayType.LAYER_POPUP)
|
||||
.build();
|
||||
}
|
||||
|
||||
// 아이디 중복 체크
|
||||
if (codeIdList.contains(codeDetailDTO.getCodeId())) {
|
||||
throw ValidationException.withUserMessageKey(USER_MESSAGE_KEY_DUPLICATE)
|
||||
.withSystemMessage("this.isDuplicate(codeDetailDTO)")
|
||||
.withDisplayType(MessageDisplayType.LAYER_POPUP)
|
||||
.build();
|
||||
}
|
||||
codeIdList.add(codeDetailDTO.getCodeId());
|
||||
});
|
||||
|
||||
String codeGroupId = codeUpdateDTO.getCodeGroupId();
|
||||
CodeGroup codeGroup = codeGroupService.findOne(codeGroupId);
|
||||
|
||||
// 업데이트 할 코드가 모두 존재하는지 확인
|
||||
List<Code> existCodeList = codeRepository.findByCodeIdIn(codeIdList);
|
||||
if (existCodeList.size() != updateList.size()) {
|
||||
throw NotFoundException
|
||||
.withSystemMessage("existCodeList.size() != updateList.size()")
|
||||
.withDisplayType(MessageDisplayType.LAYER_POPUP)
|
||||
.build();
|
||||
}
|
||||
|
||||
// 수정
|
||||
List<Code> codeList = new ArrayList<>();
|
||||
|
||||
updateList.forEach((CodeDetailDTO codeDetailDTO) -> {
|
||||
Code code = modelMapper.map(codeDetailDTO, Code.class);
|
||||
code.setCodeGroup(codeGroup);
|
||||
codeList.add(code);
|
||||
});
|
||||
result.addAll(codeRepository.save(codeList));
|
||||
|
||||
// 저장 처리
|
||||
result.addAll(this.createList(codeUpdateDTO.getSaveList(), codeUpdateDTO.getCodeGroupId()));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Code> findAll() {
|
||||
return codeRepository.findAll();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(Code code) {
|
||||
codeRepository.delete(code);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Code> findByCodeGroupDetail(String codeGroupId) {
|
||||
List<Code> resultCodeList = new ArrayList<>();
|
||||
|
||||
// 사용중인 코드 그룹에서 코드 그룹 조회
|
||||
CodeGroup codeGroup = codeGroupService.findByCodeGroupIdAndUseYn(codeGroupId, true);
|
||||
if (codeGroup == null) {
|
||||
return resultCodeList;
|
||||
}
|
||||
|
||||
// 코드 그룹의 하위 코드 목록 조회
|
||||
List<Code> codeList = codeGroup.getCodeList();
|
||||
if (codeList == null) {
|
||||
return resultCodeList;
|
||||
}
|
||||
|
||||
// 현재 언어 기준 코드값 조회
|
||||
codeList.forEach((Code code) -> {
|
||||
// 사용여부 체크
|
||||
if (!code.isUseYn()) {
|
||||
return;
|
||||
}
|
||||
code.setCodeName(this.findCodeNameByCurrentLanguage(code));
|
||||
resultCodeList.add(code);
|
||||
});
|
||||
|
||||
// 정렬 순번에 따라 오름차순 정렬
|
||||
resultCodeList.sort((code1, code2) -> code1.getCodeSortSeq() - code2.getCodeSortSeq());
|
||||
|
||||
return resultCodeList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CodeDetailDTO> findQueryByCodeGroupId(String codeGroupId, Sort sort) {
|
||||
// 코드 페이지 조회
|
||||
List<Code> codeList = codeRepository.findQueryByCodeGroupId(codeGroupId, sort);
|
||||
|
||||
List<CodeDetailDTO> codeDetailDTOList = new ArrayList<>();
|
||||
|
||||
// 코드 그룹 아이디 입력
|
||||
codeList.forEach((Code code) -> {
|
||||
if (code.getCodeGroup() == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
CodeDetailDTO codeDetailDTO = modelMapper.map(code, CodeDetailDTO.class);
|
||||
codeDetailDTO.setCodeGroupId(code.getCodeGroup().getCodeGroupId());
|
||||
codeDetailDTOList.add(codeDetailDTO);
|
||||
});
|
||||
|
||||
return codeDetailDTOList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String findCodeNameByCurrentLanguage(Code code) {
|
||||
int index = messageComponent.getLanguageIndex();
|
||||
String codeName = "";
|
||||
|
||||
switch (index) {
|
||||
case LANGUAGE_INDEX_ZERO: codeName = code.getCodeName1(); break;
|
||||
case LANGUAGE_INDEX_ONE: codeName = code.getCodeName2(); break;
|
||||
case LANGUAGE_INDEX_TWO: codeName = code.getCodeName3(); break;
|
||||
/* 4번째 언어 추가시, 주석 해제
|
||||
case LANGUAGE_INDEX_THREE: codeName = code.getCodeName4(); break;
|
||||
*/
|
||||
default: codeName = "";
|
||||
}
|
||||
|
||||
return codeName;
|
||||
}
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 코드 중복 확인
|
||||
* </pre>
|
||||
*/
|
||||
public boolean isDuplicate(List<CodeDetailDTO> codeDetailDTOList) {
|
||||
List<String> id = new ArrayList<>();
|
||||
boolean isDuplicate = false;
|
||||
String codeId = "";
|
||||
for (CodeDetailDTO codeDetailDTO : codeDetailDTOList) {
|
||||
codeId = codeDetailDTO.getCodeId();
|
||||
if (id.contains(codeId)) {
|
||||
isDuplicate = true;
|
||||
break;
|
||||
}
|
||||
id.add(codeId);
|
||||
}
|
||||
return isDuplicate;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
/**
|
||||
* Copyright (c) 2018 SK INNOVATION Co., Ltd. All rights reserved.
|
||||
*
|
||||
* This software is the confidential and proprietary information of SK INNOVATION.
|
||||
* You shall not disclose such confidential information and shall use it only in accordance
|
||||
* with the terms of the license agreement you entered into with SK INNOVATION.
|
||||
*/
|
||||
package com.skti.bcm.code.domain.service.dto;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
import org.hibernate.annotations.Type;
|
||||
import org.hibernate.validator.constraints.Length;
|
||||
import org.hibernate.validator.constraints.NotBlank;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* BCM 코드 상세 DTO
|
||||
*
|
||||
* History
|
||||
* - 2018. 8. 10. | in01866 | 최초작성.
|
||||
* - 2018. 8. 22. | in01866 | 2차 수정.
|
||||
* </pre>
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
public class CodeDetailDTO implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1008365157420151778L;
|
||||
|
||||
/** 코드 그룹 아이디 */
|
||||
@NotBlank
|
||||
private String codeGroupId;
|
||||
|
||||
/** 코드 상세 아이디 */
|
||||
@NotBlank
|
||||
private String codeId;
|
||||
|
||||
/** 현재 언어 기준 코드 상세명 */
|
||||
private String codeName;
|
||||
|
||||
/** 코드 상세명 1 */
|
||||
@Length(max = 128)
|
||||
private String codeName1;
|
||||
|
||||
/** 코드 상세명 2 */
|
||||
@Length(max = 128)
|
||||
private String codeName2;
|
||||
|
||||
/** 코드 상세명 3 */
|
||||
@Length(max = 128)
|
||||
private String codeName3;
|
||||
|
||||
/** 코드 상세명 4 */
|
||||
/* 4번째 언어 추가시, 주석 해제
|
||||
@Length(max = 128)
|
||||
private String codeName4;
|
||||
*/
|
||||
|
||||
/** 코드 상세 설명 */
|
||||
@Length(max = 2000)
|
||||
private String codeDesc;
|
||||
|
||||
/** 코드 상세 정렬 순번 */
|
||||
private int codeSortSeq;
|
||||
|
||||
/** 등록 ID */
|
||||
protected String createBy;
|
||||
|
||||
/** 수정 ID */
|
||||
protected String updateBy;
|
||||
|
||||
/** 생성일자 */
|
||||
protected Date createDate;
|
||||
|
||||
/** 수정일자 */
|
||||
protected Date updateDate;
|
||||
|
||||
/** 사용 여부 */
|
||||
@Type(type = "yes_no")
|
||||
private boolean useYn = true;
|
||||
|
||||
public void setUseYn(boolean useYn) {
|
||||
this.useYn = useYn;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
/**
|
||||
* Copyright (c) 2018 SK INNOVATION Co., Ltd. All rights reserved.
|
||||
*
|
||||
* This software is the confidential and proprietary information of SK INNOVATION.
|
||||
* You shall not disclose such confidential information and shall use it only in accordance
|
||||
* with the terms of the license agreement you entered into with SK INNOVATION.
|
||||
*/
|
||||
package com.skti.bcm.code.domain.service.dto;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.hibernate.validator.constraints.Length;
|
||||
import org.hibernate.validator.constraints.NotBlank;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* BCM 코드 그룹 상세 DTO
|
||||
*
|
||||
* History
|
||||
* - 2018. 8. 10. | in01866 | 최초작성.
|
||||
* - 2018. 8. 22. | in01866 | 2차 수정.
|
||||
* </pre>
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
public class CodeGroupDetailDTO implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -2826454127855595948L;
|
||||
|
||||
/** 코드 그룹 아이디 */
|
||||
@NotBlank
|
||||
private String codeGroupId;
|
||||
|
||||
/** 코드 그룹명 1 */
|
||||
@Length(max = 128)
|
||||
private String codeGroupName1;
|
||||
|
||||
/** 코드 그룹명 2 */
|
||||
@Length(max = 128)
|
||||
private String codeGroupName2;
|
||||
|
||||
/** 코드 그룹명 3 */
|
||||
@Length(max = 128)
|
||||
private String codeGroupName3;
|
||||
|
||||
/** 코드 그룹명 4 */
|
||||
/* 4번째 언어 추가시, 주석 해제
|
||||
@Length(max = 128)
|
||||
private String codeGroupName4;
|
||||
*/
|
||||
|
||||
/** 코드 그룹 상세 설명 */
|
||||
@Length(max = 2000)
|
||||
private String codeGroupDesc;
|
||||
|
||||
/** 코드 상세 정렬 순번 */
|
||||
private int codeSortSeq;
|
||||
|
||||
/** 코드 상세 사용여부 */
|
||||
private boolean useYn = true;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
/**
|
||||
* Copyright (c) 2018 SK INNOVATION Co., Ltd. All rights reserved.
|
||||
*
|
||||
* This software is the confidential and proprietary information of SK INNOVATION.
|
||||
* You shall not disclose such confidential information and shall use it only in accordance
|
||||
* with the terms of the license agreement you entered into with SK INNOVATION.
|
||||
*/
|
||||
package com.skti.bcm.code.domain.service.dto;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.hibernate.validator.constraints.Length;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* BCM 코드 검색 DTO
|
||||
*
|
||||
* History
|
||||
* - 2018. 8. 10. | in01866 | 최초작성.
|
||||
* - 2018. 8. 22. | in01866 | 2차 수정.
|
||||
* </pre>
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
public class CodeSearchDTO implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -8663212786455753116L;
|
||||
|
||||
/** 기본검색 */
|
||||
@Length(max = 20)
|
||||
private String keyword;
|
||||
|
||||
/** 코드명, 코드ID 포함 검색 */
|
||||
private boolean isCodeInclude = false;
|
||||
|
||||
/** 미사용 포함여부 */
|
||||
private boolean isUnusedInclude = false;
|
||||
|
||||
/** 페이징 사용여부 */
|
||||
private boolean isPaging = false;
|
||||
|
||||
public boolean isCodeInclude() {
|
||||
return isCodeInclude;
|
||||
}
|
||||
|
||||
public void setCodeInclude(boolean isCodeInclude) {
|
||||
this.isCodeInclude = isCodeInclude;
|
||||
}
|
||||
|
||||
public boolean isUnusedInclude() {
|
||||
return isUnusedInclude;
|
||||
}
|
||||
|
||||
public void setIsUnusedInclude(boolean isUnusedInclude) {
|
||||
this.isUnusedInclude = isUnusedInclude;
|
||||
}
|
||||
|
||||
public boolean isPaging() {
|
||||
return isPaging;
|
||||
}
|
||||
|
||||
public void setIsPaging(boolean isPaging) {
|
||||
this.isPaging = isPaging;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
/**
|
||||
* Copyright (c) 2018 SK INNOVATION Co., Ltd. All rights reserved.
|
||||
*
|
||||
* This software is the confidential and proprietary information of SK INNOVATION.
|
||||
* You shall not disclose such confidential information and shall use it only in accordance
|
||||
* with the terms of the license agreement you entered into with SK INNOVATION.
|
||||
*/
|
||||
package com.skti.bcm.code.domain.service.dto;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
import org.hibernate.validator.constraints.Length;
|
||||
import org.hibernate.validator.constraints.NotBlank;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* BCM 코드 수정 DTO
|
||||
*
|
||||
* History
|
||||
* - 2018. 8. 10. | in01866 | 최초작성.
|
||||
* - 2018. 8. 22. | in01866 | 2차 수정.
|
||||
* </pre>
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
public class CodeUpdateDTO implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -7923743155214405561L;
|
||||
|
||||
/** 코드 그룹 아이디 */
|
||||
@NotBlank
|
||||
@Length(max = 10)
|
||||
private String codeGroupId;
|
||||
|
||||
/** 코드 저장 목록 */
|
||||
private List<CodeDetailDTO> saveList;
|
||||
|
||||
/** 코드 수정 목록 */
|
||||
private List<CodeDetailDTO> updateList;
|
||||
|
||||
}
|
||||
109
src/main/java/com/skti/bcm/code/web/CodeController.java
Normal file
109
src/main/java/com/skti/bcm/code/web/CodeController.java
Normal file
@@ -0,0 +1,109 @@
|
||||
/**
|
||||
* Copyright (c) 2018 SK INNOVATION Co., Ltd. All rights reserved.
|
||||
*
|
||||
* This software is the confidential and proprietary information of SK INNOVATION.
|
||||
* You shall not disclose such confidential information and shall use it only in accordance
|
||||
* with the terms of the license agreement you entered into with SK INNOVATION.
|
||||
*/
|
||||
package com.skti.bcm.code.web;
|
||||
|
||||
import javax.validation.Valid;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.data.web.SortDefault;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import com.skti.bcm.code.domain.service.CodeService;
|
||||
import com.skti.bcm.code.domain.service.dto.CodeUpdateDTO;
|
||||
import com.skti.core.component.MessageComponent;
|
||||
import com.skti.core.constant.Path;
|
||||
import com.skti.core.controller.AbstractBCMController;
|
||||
import com.skti.core.vo.RestResponse;
|
||||
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* BCM 코드 관리 Controller
|
||||
*
|
||||
* History
|
||||
* - 2018. 8. 10. | in01866 | 최초작성.
|
||||
* - 2018. 8. 22. | in01866 | 2차 수정.
|
||||
* </pre>
|
||||
*/
|
||||
@Api(tags = "코드 관리 - 코드")
|
||||
@RestController
|
||||
public class CodeController extends AbstractBCMController {
|
||||
|
||||
@Autowired
|
||||
private CodeService codeService;
|
||||
|
||||
/*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
|
||||
| VIEW
|
||||
|-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
|
||||
|
||||
@GetMapping(value = Path.VIEW_CODES)
|
||||
public ModelAndView codeList() {
|
||||
ModelAndView modelAndView = new ModelAndView();
|
||||
modelAndView.addObject(MessageComponent.JS_MESSAGES_KEY_PATTERN, "bcm.code.*");
|
||||
modelAndView.setViewName("skiaf/view/code/code-list");
|
||||
return modelAndView;
|
||||
}
|
||||
|
||||
// @GetMapping(value = Path.VIEW_CODES_CREATE)
|
||||
// public ModelAndView codeCreate() {
|
||||
// ModelAndView modelAndView = new ModelAndView();
|
||||
// modelAndView.addObject(MessageComponent.JS_MESSAGES_KEY_PATTERN, "bcm.code.*");
|
||||
// modelAndView.setViewName("skiaf/view/code/code-create");
|
||||
// return modelAndView;
|
||||
// }
|
||||
|
||||
@GetMapping(value = Path.VIEW_CODESLOV_POPUP_SELECT)
|
||||
public ModelAndView viewCodeLovSelectPopup() {
|
||||
ModelAndView modelAndView = new ModelAndView();
|
||||
modelAndView.addObject(MessageComponent.JS_MESSAGES_KEY_PATTERN, "bcm.code.");
|
||||
modelAndView.setViewName("skiaf/view/code/codelov-select-popup");
|
||||
return modelAndView;
|
||||
}
|
||||
|
||||
/*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
|
||||
| REST API
|
||||
|-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
|
||||
|
||||
@ApiOperation(value = "현재 언어에 따른 코드값 목록 조회")
|
||||
@GetMapping(value = Path.CODES_DETAIL_LANG)
|
||||
public RestResponse findByCodeGroupAndCurrentLang(@PathVariable String codeGroupId) {
|
||||
|
||||
return new RestResponse(codeService.findByCodeGroupDetail(codeGroupId));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "코드 저장")
|
||||
@PostMapping(value = Path.CODES)
|
||||
public RestResponse create(@Valid @RequestBody CodeUpdateDTO codeUpdateDTO) {
|
||||
|
||||
return new RestResponse(codeService.createList(codeUpdateDTO.getSaveList(), codeUpdateDTO.getCodeGroupId()));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "코드 수정")
|
||||
@PutMapping(value = Path.CODES)
|
||||
public RestResponse update(@Valid @RequestBody CodeUpdateDTO codeUpdateDTO) {
|
||||
|
||||
return new RestResponse(codeService.updateList(codeUpdateDTO));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "코드 목록 조회")
|
||||
@GetMapping(value = Path.CODES)
|
||||
public RestResponse findQueryBySearch(String codeGroupId,
|
||||
@SortDefault.SortDefaults({@SortDefault(sort = "codeSortSeq", direction = Sort.Direction.ASC)}) Sort sort) {
|
||||
|
||||
return new RestResponse(codeService.findQueryByCodeGroupId(codeGroupId, sort));
|
||||
}
|
||||
}
|
||||
108
src/main/java/com/skti/bcm/code/web/CodeGroupController.java
Normal file
108
src/main/java/com/skti/bcm/code/web/CodeGroupController.java
Normal file
@@ -0,0 +1,108 @@
|
||||
/**
|
||||
* Copyright (c) 2018 SK INNOVATION Co., Ltd. All rights reserved.
|
||||
*
|
||||
* This software is the confidential and proprietary information of SK INNOVATION.
|
||||
* You shall not disclose such confidential information and shall use it only in accordance
|
||||
* with the terms of the license agreement you entered into with SK INNOVATION.
|
||||
*/
|
||||
package com.skti.bcm.code.web;
|
||||
|
||||
import javax.validation.Valid;
|
||||
|
||||
import org.hibernate.validator.constraints.NotBlank;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.data.web.PageableDefault;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import com.skti.bcm.code.domain.model.CodeGroup;
|
||||
import com.skti.bcm.code.domain.service.CodeGroupService;
|
||||
import com.skti.bcm.code.domain.service.dto.CodeSearchDTO;
|
||||
import com.skti.core.component.MessageComponent;
|
||||
import com.skti.core.constant.Path;
|
||||
import com.skti.core.controller.AbstractBCMController;
|
||||
import com.skti.core.util.Util;
|
||||
import com.skti.core.vo.RestResponse;
|
||||
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* BCM 코드 그룹 관리 Controller
|
||||
*
|
||||
* History
|
||||
* - 2018. 8. 10. | in01866 | 최초작성.
|
||||
* - 2018. 8. 22. | in01866 | 2차 수정.
|
||||
* </pre>
|
||||
*/
|
||||
@Api(tags = "코드 관리 - 코드 그룹")
|
||||
@RestController
|
||||
public class CodeGroupController extends AbstractBCMController {
|
||||
|
||||
@Autowired
|
||||
private CodeGroupService codeGroupService;
|
||||
|
||||
/*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
|
||||
| VIEW
|
||||
|-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
|
||||
|
||||
@GetMapping(value = Path.VIEW_CODE_GROUPS_CREATE)
|
||||
public ModelAndView codeGroupCreate() {
|
||||
ModelAndView modelAndView = new ModelAndView();
|
||||
modelAndView.addObject(MessageComponent.JS_MESSAGES_KEY_PATTERN, "bcm.code.*");
|
||||
modelAndView.setViewName("skiaf/view/code/codegroup-save-popup");
|
||||
return modelAndView;
|
||||
}
|
||||
|
||||
@GetMapping(value = Path.VIEW_CODE_GROUPS_SELECT)
|
||||
public ModelAndView codeGroupPopup() {
|
||||
ModelAndView modelAndView = new ModelAndView();
|
||||
modelAndView.addObject(MessageComponent.JS_MESSAGES_KEY_PATTERN, "bcm.code.*");
|
||||
modelAndView.setViewName("skiaf/view/code/codegroup-select-popup");
|
||||
return modelAndView;
|
||||
}
|
||||
|
||||
/*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
|
||||
| REST API
|
||||
|-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
|
||||
|
||||
@ApiOperation(value = "코드 그룹 조회")
|
||||
@GetMapping(value = Path.CODE_GROUPS_DETAIL)
|
||||
public RestResponse findOne(@PathVariable String codeGroupIdBase64) {
|
||||
|
||||
String codeGroupId = Util.decodeUrlAndBase64(codeGroupIdBase64);
|
||||
return new RestResponse(codeGroupService.findOne(codeGroupId));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "코드 그룹 저장")
|
||||
@PostMapping(value = Path.CODE_GROUPS)
|
||||
public RestResponse create(@Valid @RequestBody CodeGroup codeGroup) {
|
||||
|
||||
return new RestResponse(codeGroupService.create(codeGroup));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "코드 그룹 수정")
|
||||
@PutMapping(value = Path.CODE_GROUPS_DETAIL)
|
||||
public RestResponse update(@Valid @PathVariable @NotBlank(message = "bcm.code.codegroup.valid.id") String codeGroupIdBase64,
|
||||
@Valid @RequestBody CodeGroup codeGroup) {
|
||||
|
||||
String codeGroupId = Util.decodeUrlAndBase64(codeGroupIdBase64);
|
||||
return new RestResponse(codeGroupService.update(codeGroupId, codeGroup));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "코드 목록 조회")
|
||||
@GetMapping(value = Path.CODE_GROUPS)
|
||||
public RestResponse findQueryBySearch(@Valid CodeSearchDTO search,
|
||||
@PageableDefault(sort = { "updateDate" }, direction = Sort.Direction.DESC) Pageable pageable) {
|
||||
|
||||
return new RestResponse(codeGroupService.findQueryBySearch(search, pageable));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
/**
|
||||
* Copyright (c) 2018 SK INNOVATION Co., Ltd. All rights reserved.
|
||||
*
|
||||
* This software is the confidential and proprietary information of SK INNOVATION.
|
||||
* You shall not disclose such confidential information and shall use it only in accordance
|
||||
* with the terms of the license agreement you entered into with SK INNOVATION.
|
||||
*/
|
||||
package com.skti.bcm.common.domain.model;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.MappedSuperclass;
|
||||
import javax.persistence.PrePersist;
|
||||
import javax.persistence.PreUpdate;
|
||||
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.skti.bcm.user.domain.model.User;
|
||||
import com.skti.core.util.SessionUtil;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 모든 모델(엔티티)의 공통
|
||||
*
|
||||
* History
|
||||
* - 2018. 8. 23. | in01868 | 최초작성.
|
||||
* </pre>
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@MappedSuperclass
|
||||
public abstract class BaseModel implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 9176671936939908250L;
|
||||
|
||||
/** 등록 ID */
|
||||
@ApiModelProperty(hidden = true)
|
||||
@Column(name = "REG_USER_ID", length = 36, updatable = false)
|
||||
protected String createBy;
|
||||
|
||||
/** 수정 ID */
|
||||
@ApiModelProperty(hidden = true)
|
||||
@Column(name = "UPD_USER_ID", length = 36)
|
||||
protected String updateBy;
|
||||
|
||||
/** 생성일자 */
|
||||
@ApiModelProperty(hidden = true)
|
||||
@Column(name = "REG_DTM", updatable = false)
|
||||
@JsonFormat(pattern="yyyy-MM-dd HH:mm:ss")
|
||||
protected Date createDate;
|
||||
|
||||
/** 수정일자 */
|
||||
@ApiModelProperty(hidden = true)
|
||||
@Column(name = "UPD_DTM")
|
||||
@JsonFormat(pattern="yyyy-MM-dd HH:mm:ss")
|
||||
protected Date updateDate;
|
||||
|
||||
@PrePersist
|
||||
public void prePersist() {
|
||||
this.createDate = new Date();
|
||||
this.updateDate = this.createDate;
|
||||
|
||||
User user = SessionUtil.getLoginUser();
|
||||
if (user != null) {
|
||||
this.createBy = user.getLoginId();
|
||||
this.updateBy = this.createBy;
|
||||
}
|
||||
}
|
||||
|
||||
@PreUpdate
|
||||
public void preUpdate() {
|
||||
this.updateDate = new Date();
|
||||
|
||||
User user = SessionUtil.getLoginUser();
|
||||
if (user != null) {
|
||||
this.updateBy = user.getLoginId();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return ToStringBuilder.reflectionToString(this, ToStringStyle.DEFAULT_STYLE);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
/**
|
||||
* Copyright (c) 2018 SK INNOVATION Co., Ltd. All rights reserved.
|
||||
*
|
||||
* This software is the confidential and proprietary information of SK INNOVATION.
|
||||
* You shall not disclose such confidential information and shall use it only in accordance
|
||||
* with the terms of the license agreement you entered into with SK INNOVATION.
|
||||
*/
|
||||
package com.skti.bcm.common.domain.model;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.MappedSuperclass;
|
||||
|
||||
import org.hibernate.annotations.Type;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@MappedSuperclass
|
||||
public abstract class BaseModelUseYnSupport extends BaseModel {
|
||||
|
||||
private static final long serialVersionUID = 5702235059802869980L;
|
||||
|
||||
/** 사용 여부 */
|
||||
@Type(type = "yes_no")
|
||||
@Column(name = "USE_YN", length = 1, nullable = false)
|
||||
private boolean useYn = true;
|
||||
|
||||
}
|
||||
83
src/main/java/com/skti/bcm/element/domain/model/Element.java
Normal file
83
src/main/java/com/skti/bcm/element/domain/model/Element.java
Normal file
@@ -0,0 +1,83 @@
|
||||
/**
|
||||
* Copyright (c) 2018 SK INNOVATION Co., Ltd. All rights reserved.
|
||||
*
|
||||
* This software is the confidential and proprietary information of SK INNOVATION.
|
||||
* You shall not disclose such confidential information and shall use it only in accordance
|
||||
* with the terms of the license agreement you entered into with SK INNOVATION.
|
||||
*/
|
||||
package com.skti.bcm.element.domain.model;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.FetchType;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.OneToMany;
|
||||
|
||||
import org.hibernate.validator.constraints.Length;
|
||||
import org.hibernate.validator.constraints.NotBlank;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonBackReference;
|
||||
import com.fasterxml.jackson.annotation.JsonManagedReference;
|
||||
import com.skti.bcm.common.domain.model.BaseModelUseYnSupport;
|
||||
import com.skti.bcm.program.domain.model.Program;
|
||||
import com.skti.bcm.role.domain.model.ElementRoleMap;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
*
|
||||
* BCM 프로그램요소 Entity
|
||||
*
|
||||
* History
|
||||
* - 2018. 7. 25. | in01871 | 최초작성.
|
||||
* - 2018. 8. 27. | in01871 | 2차 수정.
|
||||
* </pre>
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Entity(name = "TB_BCM_VIEW_ELEMENT")
|
||||
public class Element extends BaseModelUseYnSupport {
|
||||
|
||||
private static final long serialVersionUID = -1090106417814961305L;
|
||||
|
||||
/** 요소 순번 */
|
||||
@ApiModelProperty(hidden = true)
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.AUTO)
|
||||
private Long elementSeq;
|
||||
|
||||
/** 프로그램 아이디 */
|
||||
@ApiModelProperty(required = true, example = "PSNEW-01")
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "PRGM_ID")
|
||||
@JsonBackReference
|
||||
private Program program;
|
||||
|
||||
/** 요소 키 */
|
||||
@ApiModelProperty(required = true, example = "#btn001")
|
||||
@NotBlank
|
||||
@Length(max = 128)
|
||||
@Column(length = 128, nullable = false)
|
||||
private String elementKey;
|
||||
|
||||
/** 요소 설명 */
|
||||
@ApiModelProperty(required = false, example = "버튼1 입니다.")
|
||||
@Length(max = 2000)
|
||||
@Column(length = 2000, nullable = true)
|
||||
private String elementDesc;
|
||||
|
||||
@ApiModelProperty(hidden = true)
|
||||
@OneToMany(mappedBy = "element", fetch = FetchType.LAZY)
|
||||
@JsonManagedReference
|
||||
private List<ElementRoleMap> elementRoleMap;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
/**
|
||||
* Copyright (c) 2018 SK INNOVATION Co., Ltd. All rights reserved.
|
||||
*
|
||||
* This software is the confidential and proprietary information of SK INNOVATION.
|
||||
* You shall not disclose such confidential information and shall use it only in accordance
|
||||
* with the terms of the license agreement you entered into with SK INNOVATION.
|
||||
*/
|
||||
package com.skti.bcm.element.domain.repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.skti.bcm.element.domain.model.Element;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
*
|
||||
* BCM 프로그램요소 Repository
|
||||
*
|
||||
* History
|
||||
* - 2018. 7. 25. | in01871 | 최초작성.
|
||||
* - 2018. 8. 27. | in01871 | 2차 수정.
|
||||
* </pre>
|
||||
*/
|
||||
public interface ElementRepository {
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 프로그램요소 전체 조회
|
||||
* </pre>
|
||||
*/
|
||||
public List<Element> findAll();
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 프로그램요소 순번으로 프로그램요소 정보 조회
|
||||
* </pre>
|
||||
*/
|
||||
public Element findByElementSeq(Long elementSeq);
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 프로그램아이디 프로그램요소순번으로 프로그램요소 조회
|
||||
* </pre>
|
||||
*/
|
||||
public Element findByProgramProgramIdAndElementSeqOrderByUpdateDateDesc(String programId, Long elementSeq);
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 프로그램 아이디로 프로그램 요소 목록 조회
|
||||
* </pre>
|
||||
*/
|
||||
public List<Element> findByProgramProgramIdOrderByUpdateDateDesc(String programId);
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 프로그램 요소 저장
|
||||
* </pre>
|
||||
*/
|
||||
public Element save(Element element);
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 프로그램요소 프로그램요소키로 프로그램요소 조회
|
||||
* </pre>
|
||||
*/
|
||||
public Element findByProgramProgramIdAndElementKey(String programId, String elementKey);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
/**
|
||||
* Copyright (c) 2018 SK INNOVATION Co., Ltd. All rights reserved.
|
||||
*
|
||||
* This software is the confidential and proprietary information of SK INNOVATION.
|
||||
* You shall not disclose such confidential information and shall use it only in accordance
|
||||
* with the terms of the license agreement you entered into with SK INNOVATION.
|
||||
*/
|
||||
package com.skti.bcm.element.domain.repository.jpa;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
import com.skti.bcm.element.domain.model.Element;
|
||||
import com.skti.bcm.element.domain.repository.ElementRepository;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
*
|
||||
* BCM 프로그램요소 JPA Repository
|
||||
*
|
||||
* History
|
||||
* - 2018. 7. 25. | in01871 | 최초작성.
|
||||
* - 2018. 8. 27. | in01871 | 2차 수정.
|
||||
* </pre>
|
||||
*/
|
||||
public interface ElementRepositoryJpa extends ElementRepository, JpaRepository<Element, Long> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
/**
|
||||
* Copyright (c) 2018 SK INNOVATION Co., Ltd. All rights reserved.
|
||||
*
|
||||
* This software is the confidential and proprietary information of SK INNOVATION.
|
||||
* You shall not disclose such confidential information and shall use it only in accordance
|
||||
* with the terms of the license agreement you entered into with SK INNOVATION.
|
||||
*/
|
||||
package com.skti.bcm.element.domain.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.skti.bcm.element.domain.model.Element;
|
||||
import com.skti.bcm.element.domain.service.dto.ElementDetailDTO;
|
||||
import com.skti.bcm.element.domain.service.dto.ElementRoleListDTO;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
*
|
||||
* BCM 프로그램요소 관리 Service
|
||||
*
|
||||
* History
|
||||
* - 2018. 8. 13. | in01871 | 최초작성.
|
||||
* - 2018. 8. 27. | in01871 | 2차 수정.
|
||||
* </pre>
|
||||
*/
|
||||
public interface ElementService {
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 프로그램요소 목록 전체 조회
|
||||
* </pre>
|
||||
*/
|
||||
public List<Element> findAll();
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 프로그램요소 등록
|
||||
* </pre>
|
||||
*/
|
||||
public Element create(String programId, ElementDetailDTO elementDetailDTO);
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 프로그램요소 상세조회
|
||||
* </pre>
|
||||
*/
|
||||
public Element findOne(Long elementSeq);
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 프로그램요소 수정
|
||||
* </pre>
|
||||
*/
|
||||
public Element update(String programId, Long elementSeq, ElementDetailDTO elementDetailDTO);
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 프로그램아이디로 목록 조회
|
||||
* </pre>
|
||||
*/
|
||||
public ElementRoleListDTO findByProgramProgramId(String programId);
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 프로그램요소 중복 체크
|
||||
* </pre>
|
||||
*/
|
||||
public Boolean duplicateElement(String programId, String elementKey);
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 프로그램요소캐시를 모두 제거함.
|
||||
* </pre>
|
||||
*/
|
||||
public void clearElementCache();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,163 @@
|
||||
/**
|
||||
* Copyright (c) 2018 SK INNOVATION Co., Ltd. All rights reserved.
|
||||
*
|
||||
* This software is the confidential and proprietary information of SK INNOVATION.
|
||||
* You shall not disclose such confidential information and shall use it only in accordance
|
||||
* with the terms of the license agreement you entered into with SK INNOVATION.
|
||||
*/
|
||||
package com.skti.bcm.element.domain.service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.modelmapper.ModelMapper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cache.annotation.CacheEvict;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.skti.bcm.element.domain.model.Element;
|
||||
import com.skti.bcm.element.domain.repository.ElementRepository;
|
||||
import com.skti.bcm.element.domain.service.dto.ElementDetailDTO;
|
||||
import com.skti.bcm.element.domain.service.dto.ElementRoleListDTO;
|
||||
import com.skti.bcm.program.domain.model.Program;
|
||||
import com.skti.bcm.program.domain.service.ProgramService;
|
||||
import com.skti.bcm.role.domain.model.ElementRoleMap;
|
||||
import com.skti.bcm.role.domain.service.dto.ElementRoleMapDTO;
|
||||
import com.skti.core.exception.NotFoundException;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
*
|
||||
* BCM 프로그램요소 관리 ServiceImpl
|
||||
*
|
||||
* History
|
||||
* - 2018. 8. 09. | in01871 | 최초작성.
|
||||
* - 2018. 8. 27. | in01871 | 2차 수정.
|
||||
* </pre>
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class ElementServiceImpl implements ElementService {
|
||||
|
||||
private static final String ELEMENT_CACHE_NAME = "ELEMENT_CACHE_NAME";
|
||||
|
||||
@Autowired
|
||||
private ElementRepository elementRepository;
|
||||
|
||||
@Autowired
|
||||
private ProgramService programService;
|
||||
|
||||
@Autowired
|
||||
private ModelMapper modelMapper;
|
||||
|
||||
@Override
|
||||
public List<Element> findAll() {
|
||||
|
||||
return elementRepository.findAll();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Element create(String programId, ElementDetailDTO elementDetailDTO) {
|
||||
|
||||
Element element = modelMapper.map(elementDetailDTO, Element.class);
|
||||
Program program = new Program();
|
||||
program.setProgramId(programId);
|
||||
element.setProgram(program);
|
||||
|
||||
return elementRepository.save(element);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Element findOne(Long elementSeq) {
|
||||
|
||||
Element element = elementRepository.findByElementSeq(elementSeq);
|
||||
|
||||
if (element == null) {
|
||||
throw NotFoundException.withSystemMessage("element == null").build();
|
||||
}
|
||||
|
||||
return element;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Element update(String programId, Long elementSeq, ElementDetailDTO elementDetailDTO) {
|
||||
|
||||
Element elementEntity = elementRepository.findByProgramProgramIdAndElementSeqOrderByUpdateDateDesc(programId, elementSeq);
|
||||
|
||||
if (elementEntity == null) {
|
||||
throw NotFoundException.withSystemMessage("element == null").build();
|
||||
}
|
||||
|
||||
elementEntity.setElementDesc(elementDetailDTO.getElementDesc());
|
||||
elementEntity.setUseYn(elementDetailDTO.isUseYn());
|
||||
|
||||
elementRepository.save(elementEntity);
|
||||
|
||||
return elementEntity;
|
||||
}
|
||||
|
||||
//@Cacheable(cacheNames = ELEMENT_CACHE_NAME, key = "#programId")
|
||||
@Override
|
||||
public ElementRoleListDTO findByProgramProgramId(String programId) {
|
||||
log.info("findByProgramProgramId, programId={}", programId);
|
||||
|
||||
ElementRoleListDTO elementRoleListDTO = new ElementRoleListDTO();
|
||||
|
||||
List<Element> elementList = elementRepository.findByProgramProgramIdOrderByUpdateDateDesc(programId);
|
||||
elementRoleListDTO.setElementList(elementList);
|
||||
|
||||
List<ElementRoleMapDTO> elementRoleMapDTOList = new ArrayList<>();
|
||||
elementList.forEach((Element element) -> {
|
||||
|
||||
if (element == null || element.getElementRoleMap() == null || element.getElementRoleMap().isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
element.getElementRoleMap().forEach((ElementRoleMap elementRoleMap) -> {
|
||||
ElementRoleMapDTO elementRoleMapDTO = modelMapper.map(elementRoleMap, ElementRoleMapDTO.class);
|
||||
elementRoleMapDTO.setElementSeq(elementRoleMap.getElement().getElementSeq());
|
||||
elementRoleMapDTO.setElementKey(elementRoleMap.getElement().getElementKey());
|
||||
elementRoleMapDTO.setElementDesc(elementRoleMap.getElement().getElementDesc());
|
||||
elementRoleMapDTO.setRoleId(elementRoleMap.getRole().getRoleId());
|
||||
elementRoleMapDTO.setRoleName(elementRoleMap.getRole().getRoleName());
|
||||
elementRoleMapDTO.setRoleDesc(elementRoleMap.getRole().getRoleDesc());
|
||||
elementRoleMapDTO.setVisibleYn(elementRoleMap.isVisibleYn());
|
||||
elementRoleMapDTO.setEnableYn(elementRoleMap.isEnableYn());
|
||||
|
||||
elementRoleMapDTOList.add(elementRoleMapDTO);
|
||||
});
|
||||
});
|
||||
|
||||
elementRoleListDTO.setElementRoleMapList(elementRoleMapDTOList);
|
||||
elementRoleListDTO.setProgram(programService.findOne(programId));
|
||||
|
||||
return elementRoleListDTO;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean duplicateElement(String programId, String elementKey) {
|
||||
|
||||
Boolean isDuplicate = false;
|
||||
|
||||
List<Element> element = elementRepository.findByProgramProgramIdOrderByUpdateDateDesc(programId);
|
||||
|
||||
for (int i = 0, iLen = element.size(); i < iLen; i++) {
|
||||
if (StringUtils.equals(element.get(i).getElementKey(), elementKey)) {
|
||||
isDuplicate = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return isDuplicate;
|
||||
}
|
||||
|
||||
@CacheEvict(cacheNames = {ELEMENT_CACHE_NAME}, allEntries = true)
|
||||
@Override
|
||||
public void clearElementCache() {
|
||||
log.info("clearElementCache");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
/**
|
||||
* Copyright (c) 2018 SK INNOVATION Co., Ltd. All rights reserved.
|
||||
*
|
||||
* This software is the confidential and proprietary information of SK INNOVATION.
|
||||
* You shall not disclose such confidential information and shall use it only in accordance
|
||||
* with the terms of the license agreement you entered into with SK INNOVATION.
|
||||
*/
|
||||
package com.skti.bcm.element.domain.service.dto;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.hibernate.validator.constraints.Length;
|
||||
import org.hibernate.validator.constraints.NotBlank;
|
||||
|
||||
import com.skti.core.validation.annotation.Ids;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
*
|
||||
* BCM 프로그램요소 상세보기 DTO
|
||||
*
|
||||
* History
|
||||
* - 2018. 8. 13. | in01871 | 최초작성.
|
||||
* - 2018. 8. 27. | in01871 | 2차 수정.
|
||||
* </pre>
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
public class ElementDetailDTO implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -6539890710997315319L;
|
||||
|
||||
@NotBlank
|
||||
@Ids
|
||||
private String programId;
|
||||
|
||||
@NotBlank
|
||||
@Length(max = 128)
|
||||
private String elementKey;
|
||||
|
||||
@Length(max = 2000)
|
||||
private String elementDesc;
|
||||
|
||||
private boolean useYn = true;
|
||||
|
||||
public void setUseYn(boolean useYn) {
|
||||
this.useYn = useYn;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
/**
|
||||
* Copyright (c) 2018 SK INNOVATION Co., Ltd. All rights reserved.
|
||||
*
|
||||
* This software is the confidential and proprietary information of SK INNOVATION.
|
||||
* You shall not disclose such confidential information and shall use it only in accordance
|
||||
* with the terms of the license agreement you entered into with SK INNOVATION.
|
||||
*/
|
||||
package com.skti.bcm.element.domain.service.dto;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
import com.skti.bcm.element.domain.model.Element;
|
||||
import com.skti.bcm.program.domain.model.Program;
|
||||
import com.skti.bcm.role.domain.service.dto.ElementRoleMapDTO;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
*
|
||||
* BCM 프로그램요소 권한 매핑 목록 DTO
|
||||
*
|
||||
* History
|
||||
* - 2018. 8. 13. | in01871 | 최초작성.
|
||||
* - 2018. 8. 27. | in01871 | 2차 수정.
|
||||
* </pre>
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
public class ElementRoleListDTO implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 6133548581427121884L;
|
||||
|
||||
private Program program;
|
||||
|
||||
/** 프로그램 요소 목록 */
|
||||
private List<Element> elementList;
|
||||
|
||||
/** 프로그램 요소 권한 맵 목록 */
|
||||
private List<ElementRoleMapDTO> elementRoleMapList;
|
||||
|
||||
}
|
||||
232
src/main/java/com/skti/bcm/element/web/ElementController.java
Normal file
232
src/main/java/com/skti/bcm/element/web/ElementController.java
Normal file
@@ -0,0 +1,232 @@
|
||||
/**
|
||||
* Copyright (c) 2018 SK INNOVATION Co., Ltd. All rights reserved.
|
||||
*
|
||||
* This software is the confidential and proprietary information of SK INNOVATION.
|
||||
* You shall not disclose such confidential information and shall use it only in accordance
|
||||
* with the terms of the license agreement you entered into with SK INNOVATION.
|
||||
*/
|
||||
package com.skti.bcm.element.web;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import com.skti.bcm.element.domain.service.ElementService;
|
||||
import com.skti.bcm.element.domain.service.dto.ElementDetailDTO;
|
||||
import com.skti.bcm.role.domain.service.RoleMapService;
|
||||
import com.skti.bcm.role.domain.service.dto.ElementRoleMapDTO;
|
||||
import com.skti.core.component.MessageComponent;
|
||||
import com.skti.core.constant.Path;
|
||||
import com.skti.core.vo.RestResponse;
|
||||
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
*
|
||||
* BCM 프로그램요소 관리 Controller
|
||||
*
|
||||
* History
|
||||
* - 2018. 8. 09. | in01871 | 최초작성.
|
||||
* - 2018. 8. 27. | in01871 | 2차 수정.
|
||||
* </pre>
|
||||
*/
|
||||
@Api(tags = "프로그램요소 관리")
|
||||
@RestController
|
||||
public class ElementController {
|
||||
|
||||
private static final String BCM_ELEMENT_ASTERISK = "bcm.element.*";
|
||||
|
||||
@Autowired
|
||||
private ElementService elementService;
|
||||
|
||||
@Autowired
|
||||
private RoleMapService roleMapService;
|
||||
|
||||
@Autowired
|
||||
private MessageComponent messageComponent;
|
||||
|
||||
/*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
|
||||
| VIEW
|
||||
|-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
|
||||
|
||||
@GetMapping(value = Path.VIEW_ELEMENT)
|
||||
public ModelAndView elementDetail() {
|
||||
|
||||
ModelAndView modelAndView = new ModelAndView();
|
||||
modelAndView.addObject(MessageComponent.JS_MESSAGES_KEY_PATTERN, BCM_ELEMENT_ASTERISK);
|
||||
modelAndView.setViewName("skiaf/view/element/element-detail");
|
||||
|
||||
return modelAndView;
|
||||
}
|
||||
|
||||
@GetMapping(value = Path.VIEW_ELEMENT_ROLE)
|
||||
public ModelAndView elementRole(@PathVariable String programId) {
|
||||
|
||||
ModelAndView modelAndView = new ModelAndView();
|
||||
modelAndView.addObject(MessageComponent.JS_MESSAGES_KEY_PATTERN, BCM_ELEMENT_ASTERISK);
|
||||
modelAndView.setViewName("skiaf/view/element/element-role-detail");
|
||||
|
||||
return modelAndView;
|
||||
}
|
||||
|
||||
@GetMapping(value = Path.VIEW_ELEMENT_CREATE)
|
||||
public ModelAndView elementCreate() {
|
||||
|
||||
ModelAndView modelAndView = new ModelAndView();
|
||||
modelAndView.addObject(MessageComponent.JS_MESSAGES_KEY_PATTERN, BCM_ELEMENT_ASTERISK);
|
||||
modelAndView.setViewName("skiaf/view/element/element-create-popup");
|
||||
|
||||
return modelAndView;
|
||||
}
|
||||
|
||||
@GetMapping(value = Path.VIEW_ELEMENT_UPDATE)
|
||||
public ModelAndView elementUpdate() {
|
||||
|
||||
ModelAndView modelAndView = new ModelAndView();
|
||||
modelAndView.addObject(MessageComponent.JS_MESSAGES_KEY_PATTERN, BCM_ELEMENT_ASTERISK);
|
||||
modelAndView.setViewName("skiaf/view/element/element-update-popup");
|
||||
|
||||
return modelAndView;
|
||||
}
|
||||
|
||||
@GetMapping(value = Path.VIEW_ELEMENT_ROLE_POPUP)
|
||||
public ModelAndView elementRolePopup() {
|
||||
|
||||
ModelAndView modelAndView = new ModelAndView();
|
||||
modelAndView.addObject(MessageComponent.JS_MESSAGES_KEY_PATTERN, BCM_ELEMENT_ASTERISK);
|
||||
modelAndView.setViewName("skiaf/view/element/element-role-popup");
|
||||
|
||||
return modelAndView;
|
||||
}
|
||||
|
||||
/*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
|
||||
| REST API
|
||||
|-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 프로그램요소 등록
|
||||
* </pre>
|
||||
*/
|
||||
@ApiOperation(value = "프로그램요소 등록")
|
||||
@PostMapping(value = Path.ELEMENT)
|
||||
public RestResponse create(
|
||||
@ApiParam(name = "element", required = true, value = "프로그램 요소 정보")
|
||||
@PathVariable(required = true) String programId,
|
||||
@RequestBody ElementDetailDTO elementDetailDTO) {
|
||||
|
||||
RestResponse result = new RestResponse(elementService.create(programId, elementDetailDTO));
|
||||
|
||||
elementService.clearElementCache();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 프로그램 아이디로 목록 조회
|
||||
* </pre>
|
||||
*/
|
||||
@ApiOperation(value = "프로그램 아이디로 목록 조회")
|
||||
@GetMapping(value = Path.ELEMENT)
|
||||
public RestResponse findByProgramProgramId(
|
||||
@ApiParam(name = "programId", required = true, value = "프로그램 아이디") @PathVariable(required = true) String programId) {
|
||||
|
||||
return new RestResponse(elementService.findByProgramProgramId(programId));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "프로그램요소 순번 조회")
|
||||
@GetMapping(value = Path.ELEMENT_DETAIL)
|
||||
public RestResponse findOne(
|
||||
@ApiParam(name = "elementSeq", required = true, value = "프로그램 요소 순번") @PathVariable(required = true) Long elementSeq) {
|
||||
|
||||
return new RestResponse(elementService.findOne(elementSeq));
|
||||
}
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 프로그램요소 수정
|
||||
* </pre>
|
||||
*/
|
||||
@ApiOperation(value = "프로그램요소 수정")
|
||||
@PutMapping(value = Path.ELEMENT_DETAIL)
|
||||
public RestResponse update(
|
||||
@ApiParam(name = "programId", required = true, value = "프로그램 아이디") @PathVariable(required = true) String programId,
|
||||
@ApiParam(name = "elementSeq", required = true, value = "프로그램 요소 순번") @PathVariable(required = true) Long elementSeq,
|
||||
@ApiParam(name = "elementDetailDTO", required = true, value = "프로그램 요소") @RequestBody ElementDetailDTO elementDetailDTO) {
|
||||
|
||||
RestResponse result = new RestResponse(elementService.update(programId, elementSeq, elementDetailDTO));
|
||||
|
||||
elementService.clearElementCache();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 프로그램요소 중복체크
|
||||
* </pre>
|
||||
*/
|
||||
@ApiOperation(value = "프로그램요소 중복체크")
|
||||
@GetMapping(value = Path.ELEMENT_DUPLICATE)
|
||||
public RestResponse duplicateElement(
|
||||
@ApiParam(name = "programId", required = true, value = "프로그램 아이디") @PathVariable(required = true) String programId,
|
||||
@ApiParam(name = "elementKey", required = true, value = "프로그램 요소") @PathVariable(required = true) String elementKey) {
|
||||
|
||||
RestResponse restResponse = new RestResponse();
|
||||
|
||||
Boolean isDuplicate = elementService.duplicateElement(programId, elementKey);
|
||||
restResponse.setData(isDuplicate);
|
||||
|
||||
if (isDuplicate) {
|
||||
restResponse.setUserMessage(messageComponent.getMessage("bcm.common.DUPLICATE"));
|
||||
}
|
||||
|
||||
return restResponse;
|
||||
}
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 프로그램요소 권한 매핑 저장
|
||||
* </pre>
|
||||
*/
|
||||
@ApiOperation(value = "프로그램요소 권한 매핑 저장")
|
||||
@PostMapping(value = Path.ELEMENT_ROLE_MAPS)
|
||||
public RestResponse saveElementByRoleId(@PathVariable String programId,
|
||||
@RequestBody List<ElementRoleMapDTO> elementRoleMapDTO) {
|
||||
|
||||
return new RestResponse(roleMapService.saveElementsByMapIdRoleId(elementRoleMapDTO));
|
||||
}
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 프로그램요소 권한 매핑 삭제
|
||||
* </pre>
|
||||
*/
|
||||
@ApiOperation(value = "프로그램요소 권한 매핑 삭제")
|
||||
@DeleteMapping(value = Path.ELEMENT_ROLE_MAPS)
|
||||
public RestResponse deleteElementByRoleId(@PathVariable String programId,
|
||||
@RequestBody List<ElementRoleMapDTO> elementRoleMapDTO) {
|
||||
|
||||
return new RestResponse(roleMapService.deleteElementsByMapIdRoleId(elementRoleMapDTO));
|
||||
}
|
||||
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
elementService.clearElementCache();
|
||||
}
|
||||
|
||||
}
|
||||
69
src/main/java/com/skti/bcm/file/domain/model/AttachFile.java
Normal file
69
src/main/java/com/skti/bcm/file/domain/model/AttachFile.java
Normal file
@@ -0,0 +1,69 @@
|
||||
/**
|
||||
* Copyright (c) 2018 SK INNOVATION Co., Ltd. All rights reserved.
|
||||
*
|
||||
* This software is the confidential and proprietary information of SK INNOVATION.
|
||||
* You shall not disclose such confidential information and shall use it only in accordance
|
||||
* with the terms of the license agreement you entered into with SK INNOVATION.
|
||||
*/
|
||||
package com.skti.bcm.file.domain.model;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
|
||||
import com.skti.bcm.common.domain.model.BaseModelUseYnSupport;
|
||||
import com.skti.core.validation.annotation.Ids;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 첨부파일
|
||||
*
|
||||
* History
|
||||
* - 2018. 7. 17. | in01871 | 최초작성.
|
||||
* </pre>
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Entity(name = "TB_BCM_ATTACH_FILE")
|
||||
public class AttachFile extends BaseModelUseYnSupport {
|
||||
|
||||
private static final long serialVersionUID = 4134687661750263540L;
|
||||
|
||||
/** 파일 아이디 */
|
||||
@Id
|
||||
@Ids
|
||||
@Column(name = "FILE_ID", nullable = false)
|
||||
private String fileId;
|
||||
|
||||
/** 사용처 ID */
|
||||
@Column(name = "TARGET_ID", length = 50, nullable = false)
|
||||
private String targetId;
|
||||
|
||||
/** 사용처 유형 */
|
||||
@Column(name = "TARGET_TYP", length = 50, nullable = false)
|
||||
private String targetType;
|
||||
|
||||
/** 원본 파일 이름 */
|
||||
@Column(name = "ORI_FILE_NM", length = 200, nullable = false)
|
||||
private String originalFileName;
|
||||
|
||||
/** 서버 파일 이름 */
|
||||
@Column(name = "SVR_FILE_NM", length = 200, nullable = false)
|
||||
private String severFileName;
|
||||
|
||||
/** 파일 경로 */
|
||||
@Column(name = "FILE_PATH", length = 200, nullable = false)
|
||||
private String filePath;
|
||||
|
||||
/** 확장자 */
|
||||
@Column(name = "FILE_EXT", length = 10, nullable = false)
|
||||
private String fileExtension;
|
||||
|
||||
/** 파일 사이즈 */
|
||||
@Column(name = "FILE_SIZE", nullable = false)
|
||||
private Long fileSize;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
/**
|
||||
* Copyright (c) 2018 SK INNOVATION Co., Ltd. All rights reserved.
|
||||
*
|
||||
* This software is the confidential and proprietary information of SK INNOVATION.
|
||||
* You shall not disclose such confidential information and shall use it only in accordance
|
||||
* with the terms of the license agreement you entered into with SK INNOVATION.
|
||||
*/
|
||||
package com.skti.bcm.file.domain.repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.skti.bcm.file.domain.model.AttachFile;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
*
|
||||
* History
|
||||
* - 2018. 7. 20. | in01871 | 최초작성.
|
||||
* </pre>
|
||||
*/
|
||||
public interface AttachFileRepository {
|
||||
|
||||
public List<AttachFile> findAll();
|
||||
|
||||
public List<AttachFile> findByTargetIdAndTargetTypeAndUseYnTrue(String targetId, String targetType);
|
||||
|
||||
public AttachFile save(AttachFile attachFile);
|
||||
|
||||
public AttachFile findOne(String fileId);
|
||||
|
||||
public AttachFile findTopByTargetIdAndTargetTypeAndUseYnTrue(String targetId, String targetType);
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
/**
|
||||
* Copyright (c) 2018 SK INNOVATION Co., Ltd. All rights reserved.
|
||||
*
|
||||
* This software is the confidential and proprietary information of SK INNOVATION.
|
||||
* You shall not disclose such confidential information and shall use it only in accordance
|
||||
* with the terms of the license agreement you entered into with SK INNOVATION.
|
||||
*/
|
||||
package com.skti.bcm.file.domain.repository.jpa;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
import com.skti.bcm.file.domain.model.AttachFile;
|
||||
import com.skti.bcm.file.domain.repository.AttachFileRepository;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
*
|
||||
* History
|
||||
* - 2018. 09. 11. | in01866 | 최초작성.
|
||||
* </pre>
|
||||
*/
|
||||
public interface AttachFileRepositoryJpa extends AttachFileRepository, JpaRepository<AttachFile, String>{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
/**
|
||||
* Copyright (c) 2018 SK INNOVATION Co., Ltd. All rights reserved.
|
||||
*
|
||||
* This software is the confidential and proprietary information of SK INNOVATION.
|
||||
* You shall not disclose such confidential information and shall use it only in accordance
|
||||
* with the terms of the license agreement you entered into with SK INNOVATION.
|
||||
*/
|
||||
package com.skti.bcm.file.domain.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.skti.bcm.file.domain.model.AttachFile;
|
||||
import com.skti.bcm.file.domain.service.dto.AttachFileCreateDTO;
|
||||
import com.skti.bcm.file.domain.service.dto.AttachFileUpdateDTO;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
*
|
||||
* History
|
||||
* - 2018. 09. 11. | in01866 | 최초작성.
|
||||
* </pre>
|
||||
*/
|
||||
public interface AttachFileService {
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 파일 ID로 첨부파일 조회
|
||||
* </pre>
|
||||
*/
|
||||
public AttachFile findOne(String fileId);
|
||||
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 사용되는 Target 정보로 첨부파일 조회
|
||||
* </pre>
|
||||
*/
|
||||
public AttachFile findTopByTargetIdAndTargetType(String targetId, String targetType);
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 첨부파일 등록
|
||||
* </pre>
|
||||
*/
|
||||
public AttachFile create(AttachFileCreateDTO attachFileSaveDTO);
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 첨부파일 삭제 - 미사용으로 전환
|
||||
* </pre>
|
||||
*/
|
||||
public AttachFile delete(String fileId);
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 첨부파일 목록 조회
|
||||
* </pre>
|
||||
*/
|
||||
public List<AttachFile> findAll();
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 사용되는 Target 정보로 첨부파일 목록 조회
|
||||
* </pre>
|
||||
*/
|
||||
public List<AttachFile> findByTargetIdAndTargetType(String targetId, String targetType);
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 첨부파일 목록 등록
|
||||
* </pre>
|
||||
*/
|
||||
public List<AttachFile> createList(List<AttachFileCreateDTO> attachFileSaveDTOList);
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 사용되는 Target 정보로 첨부파일 목록 수정
|
||||
* </pre>
|
||||
*/
|
||||
public List<AttachFile> updateList(String targetId, String targetType, AttachFileUpdateDTO attachFileUpdateDTO);
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 첨부파일 목록 삭제 - 미사용으로 전환
|
||||
* </pre>
|
||||
*/
|
||||
public List<AttachFile> deleteList(List<String> fileIdList);
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 같은 타입정보로 연결된 파일 목록 삭제 - 미사용으로 전환
|
||||
* </pre>
|
||||
*/
|
||||
public List<AttachFile> deleteList(String targetId, String targetType);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,153 @@
|
||||
/**
|
||||
* Copyright (c) 2018 SK INNOVATION Co., Ltd. All rights reserved.
|
||||
*
|
||||
* This software is the confidential and proprietary information of SK INNOVATION.
|
||||
* You shall not disclose such confidential information and shall use it only in accordance
|
||||
* with the terms of the license agreement you entered into with SK INNOVATION.
|
||||
*/
|
||||
package com.skti.bcm.file.domain.service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import com.skti.bcm.file.domain.model.AttachFile;
|
||||
import com.skti.bcm.file.domain.repository.AttachFileRepository;
|
||||
import com.skti.bcm.file.domain.service.dto.AttachFileCreateDTO;
|
||||
import com.skti.bcm.file.domain.service.dto.AttachFileUpdateDTO;
|
||||
import com.skti.core.exception.ValidationException;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
*
|
||||
* History
|
||||
* - 2018. 7. 23. | in01871 | 최초작성.
|
||||
* </pre>
|
||||
*/
|
||||
@Service
|
||||
public class AttachFileServiceImpl implements AttachFileService {
|
||||
|
||||
private static final String USER_MESSAGE_KEY_EMPTY = "bcm.common.EMPTY";
|
||||
private static final String SYSTEM_MESSAGE_EMPTY_ATTACH_FILE = "attachFile == null";
|
||||
|
||||
@Autowired
|
||||
private AttachFileRepository attachFileRepository;
|
||||
|
||||
@Autowired
|
||||
private FileService fileService;
|
||||
|
||||
@Override
|
||||
public List<AttachFile> findAll() {
|
||||
|
||||
return attachFileRepository.findAll();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public AttachFile findOne(String fileId) {
|
||||
|
||||
return attachFileRepository.findOne(fileId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AttachFile create(AttachFileCreateDTO attachFileSaveDTO) {
|
||||
|
||||
AttachFile attachFile = fileService.moveSaveLocation(attachFileSaveDTO);
|
||||
if (attachFile == null) {
|
||||
throw ValidationException.withUserMessageKey(USER_MESSAGE_KEY_EMPTY)
|
||||
.withSystemMessage(SYSTEM_MESSAGE_EMPTY_ATTACH_FILE).build();
|
||||
}
|
||||
attachFileRepository.save(attachFile);
|
||||
|
||||
return attachFile;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AttachFile> createList(List<AttachFileCreateDTO> attachFileSaveDTOList) {
|
||||
|
||||
List<AttachFile> attachFileList = new ArrayList<>();
|
||||
attachFileSaveDTOList.forEach((AttachFileCreateDTO attachFileSaveDTO) -> attachFileList.add(this.create(attachFileSaveDTO)));
|
||||
return attachFileList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AttachFile delete(String fileId) {
|
||||
|
||||
AttachFile attachFile = this.findOne(fileId);
|
||||
if (attachFile == null) {
|
||||
throw ValidationException.withUserMessageKey(USER_MESSAGE_KEY_EMPTY)
|
||||
.withSystemMessage(SYSTEM_MESSAGE_EMPTY_ATTACH_FILE).build();
|
||||
}
|
||||
fileService.moveDeleteLocation(attachFile);
|
||||
attachFile.setUseYn(false);
|
||||
|
||||
attachFileRepository.save(attachFile);
|
||||
return attachFile;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AttachFile> updateList(String targetId, String targetType, AttachFileUpdateDTO attachFileUpdateDTO) {
|
||||
|
||||
if (attachFileUpdateDTO == null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
List<String> deleteFileIdList = attachFileUpdateDTO.getDeleteFileIdList();
|
||||
|
||||
// 파일 삭제 처리
|
||||
if (deleteFileIdList != null) {
|
||||
this.deleteList(deleteFileIdList);
|
||||
|
||||
}
|
||||
|
||||
// 파일 저장 처리
|
||||
List<String> saveFileIdList = attachFileUpdateDTO.getSaveFileIdList();
|
||||
if (saveFileIdList != null) {
|
||||
List<AttachFileCreateDTO> attachFileSaveDTOList = new ArrayList<>();
|
||||
saveFileIdList.forEach((String fileId) -> {
|
||||
AttachFileCreateDTO attachFileSaveDTO = new AttachFileCreateDTO();
|
||||
attachFileSaveDTO.setFileId(fileId);
|
||||
attachFileSaveDTO.setTargetId(targetId);
|
||||
attachFileSaveDTO.setTargetType(targetType);
|
||||
attachFileSaveDTOList.add(attachFileSaveDTO);
|
||||
});
|
||||
|
||||
this.createList(attachFileSaveDTOList);
|
||||
}
|
||||
|
||||
return this.findByTargetIdAndTargetType(targetId, targetType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AttachFile> deleteList(List<String> fileIdList) {
|
||||
|
||||
List<AttachFile> attachFileList = new ArrayList<>();
|
||||
fileIdList.forEach((String fileId) -> attachFileList.add(this.delete(fileId)));
|
||||
return attachFileList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AttachFile> deleteList(String targetId, String targetType) {
|
||||
|
||||
List<AttachFile> deleteFileList = new ArrayList<>();
|
||||
|
||||
List<AttachFile> attachFileList = this.findByTargetIdAndTargetType(targetId, targetType);
|
||||
attachFileList.forEach((AttachFile attachFile) -> deleteFileList.add(this.delete(attachFile.getFileId())));
|
||||
return deleteFileList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AttachFile findTopByTargetIdAndTargetType(String targetId, String targetType) {
|
||||
|
||||
return attachFileRepository.findTopByTargetIdAndTargetTypeAndUseYnTrue(targetId, targetType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AttachFile> findByTargetIdAndTargetType(String targetId, String targetType) {
|
||||
|
||||
return attachFileRepository.findByTargetIdAndTargetTypeAndUseYnTrue(targetId, targetType);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
/**
|
||||
* Copyright (c) 2018 SK INNOVATION Co., Ltd. All rights reserved.
|
||||
*
|
||||
* This software is the confidential and proprietary information of SK INNOVATION.
|
||||
* You shall not disclose such confidential information and shall use it only in accordance
|
||||
* with the terms of the license agreement you entered into with SK INNOVATION.
|
||||
*/
|
||||
package com.skti.bcm.file.domain.service;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import com.skti.bcm.file.domain.model.AttachFile;
|
||||
import com.skti.bcm.file.domain.service.dto.AttachFileCreateDTO;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
*
|
||||
* History
|
||||
* - 2018. 09. 11. | in01866 | 최초작성.
|
||||
* </pre>
|
||||
*/
|
||||
public interface FileService {
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 첨부파일 업로드
|
||||
* </pre>
|
||||
*/
|
||||
public String uploadFile(MultipartFile file);
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 임시 저장된 파일을 저장 디렉토리로 이동
|
||||
* </pre>
|
||||
*/
|
||||
public AttachFile moveSaveLocation(AttachFileCreateDTO attachFileSaveDTO);
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 저장된 파일을 삭제 디렉토리로 이동
|
||||
* </pre>
|
||||
*/
|
||||
public AttachFile moveDeleteLocation(AttachFile attachFile);
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 등록된 첨부파일 가져오기
|
||||
* </pre>
|
||||
*/
|
||||
public File downloadFile(String filePathWithName);
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 지난 임시 파일제거
|
||||
* </pre>
|
||||
*/
|
||||
public void cleanTempFile(int daysAgo);
|
||||
}
|
||||
@@ -0,0 +1,371 @@
|
||||
/**
|
||||
* Copyright (c) 2018 SK INNOVATION Co., Ltd. All rights reserved.
|
||||
*
|
||||
* This software is the confidential and proprietary information of SK INNOVATION.
|
||||
* You shall not disclose such confidential information and shall use it only in accordance
|
||||
* with the terms of the license agreement you entered into with SK INNOVATION.
|
||||
*/
|
||||
package com.skti.bcm.file.domain.service;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.apache.tomcat.util.http.fileupload.FileUtils;
|
||||
import org.modelmapper.ModelMapper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import com.skti.bcm.file.domain.model.AttachFile;
|
||||
import com.skti.bcm.file.domain.service.dto.AttachFileCreateDTO;
|
||||
import com.skti.core.exception.BizException;
|
||||
import com.skti.core.exception.ValidationException;
|
||||
import com.skti.core.util.Util;
|
||||
|
||||
import cool.graph.cuid.Cuid;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
*
|
||||
* History
|
||||
* - 2018. 7. 23. | in01871 | 최초작성.
|
||||
* </pre>
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class FileServiceImpl implements FileService {
|
||||
|
||||
private static final String SKIAF = "skiaf";
|
||||
private static final String USER_MESSAGE_KEY_FIKE_SEND = "bcm.common.FILE_SEND";
|
||||
private static final String USER_MESSAGE_KEY_FILE_EXT = "bcm.common.FILE_EXT";
|
||||
private static final String USER_MESSAGE_KEY_EMPTY = "bcm.common.EMPTY";
|
||||
private static final String SYSTEM_MESSAGE_FILE_EXT = "allowExtension.indexOf(fileExtension) < 0";
|
||||
private static final String SYSTEM_MESSAGE_EMPTY_ATTACH_FILE_SAVE_DTO = "attachFileSaveDTO == null";
|
||||
private static final String SYSTEM_MESSAGE_FOLDER_NOT_FOUND = "folder == null";
|
||||
private static final String SYSTEM_MESSAGE_FILE_NOT_FOUND = "folder == null";
|
||||
|
||||
private static final String JAVA_IO_TMPDIR = "java.io.tmpdir";
|
||||
|
||||
@Value("${bcm.attach-file.dir.temp}")
|
||||
private String tempRootPath;
|
||||
|
||||
@Value("${bcm.attach-file.dir.save}")
|
||||
private String saveRootPath;
|
||||
|
||||
@Value("${bcm.attach-file.dir.delete}")
|
||||
private String deleteRootPath;
|
||||
|
||||
@Value("${bcm.attach-file.temp.clear-ago}")
|
||||
private int tempClearDayAgo;
|
||||
|
||||
@Value("#{'${bcm.attach-file.allowed-extensions}'.split(',')}")
|
||||
private List<String> allowExtensions;
|
||||
|
||||
@Autowired
|
||||
private ModelMapper modelMapper;
|
||||
|
||||
@Override
|
||||
public String uploadFile(MultipartFile file) {
|
||||
|
||||
// 파일이 있는지 확인
|
||||
if (file == null) {
|
||||
throw ValidationException.withUserMessageKey(USER_MESSAGE_KEY_EMPTY)
|
||||
.withSystemMessage(SYSTEM_MESSAGE_FILE_NOT_FOUND).build();
|
||||
}
|
||||
|
||||
// 파일명 생성
|
||||
String filename = StringUtils.getFilename((StringUtils.cleanPath(file.getOriginalFilename())));
|
||||
|
||||
// 파일 확장자 검사
|
||||
String fileExtension = this.getExtension(filename);
|
||||
if (allowExtensions.indexOf(fileExtension.toLowerCase()) < 0) {
|
||||
throw ValidationException.withUserMessageKey(USER_MESSAGE_KEY_FILE_EXT)
|
||||
.withSystemMessage(SYSTEM_MESSAGE_FILE_EXT).build();
|
||||
}
|
||||
|
||||
// 파일 아이디 생성
|
||||
String cuid = Cuid.createCuid();
|
||||
|
||||
try {
|
||||
|
||||
// 불필요 기존 임시 파일 제거
|
||||
this.cleanTempFile(tempClearDayAgo);
|
||||
|
||||
// 임시 저장위치 생성
|
||||
File tempDir = new File(getTempFilePath() + File.separator + cuid);
|
||||
if (!tempDir.isDirectory()) {
|
||||
tempDir.mkdirs();
|
||||
}
|
||||
|
||||
// 임시 저장 위치에 파일 저장
|
||||
String savePath = tempDir.getAbsolutePath() + File.separator + filename;
|
||||
file.transferTo(new File(savePath));
|
||||
|
||||
log.info("temporary file uploaded [file id : " + cuid + "] : " + savePath);
|
||||
|
||||
} catch (IllegalStateException e) {
|
||||
log.error("temporary file upload failed", e);
|
||||
throw BizException
|
||||
.withUserMessage(USER_MESSAGE_KEY_FIKE_SEND)
|
||||
.withSystemMessage("file upload fail : IllegalStateException").build();
|
||||
|
||||
} catch (IOException e) {
|
||||
log.error("temporary file upload failed", e);
|
||||
throw BizException
|
||||
.withUserMessage(USER_MESSAGE_KEY_FIKE_SEND)
|
||||
.withSystemMessage("file upload fail : IOException").build();
|
||||
}
|
||||
|
||||
return cuid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AttachFile moveSaveLocation(AttachFileCreateDTO attachFileSaveDTO) {
|
||||
|
||||
// 파일정보 검사
|
||||
if (attachFileSaveDTO == null) {
|
||||
throw ValidationException.withUserMessageKey(USER_MESSAGE_KEY_EMPTY)
|
||||
.withSystemMessage(SYSTEM_MESSAGE_EMPTY_ATTACH_FILE_SAVE_DTO).build();
|
||||
}
|
||||
|
||||
// 임시 저장된 파일 경로
|
||||
File tempDir = new File(getTempFilePath() + File.separator + attachFileSaveDTO.getFileId());
|
||||
|
||||
// 임시 저장된 경로에서 하위 첫번째 파일 가져오기
|
||||
File[] listOfFiles = tempDir.listFiles();
|
||||
if (listOfFiles[0] == null || !listOfFiles[0].exists() || listOfFiles[0].isDirectory()) {
|
||||
throw BizException.withSystemMessage(SYSTEM_MESSAGE_FOLDER_NOT_FOUND).build();
|
||||
}
|
||||
File tempFile = listOfFiles[0];
|
||||
|
||||
// 저장할 위치
|
||||
Date now = new Date();
|
||||
SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd");
|
||||
String saveDir = File.separator + format.format(now);
|
||||
File dir = new File(getSaveFilePath() + saveDir);
|
||||
|
||||
// 존재 하지 않으면 생성
|
||||
if (!dir.isDirectory()) {
|
||||
dir.mkdirs();
|
||||
}
|
||||
|
||||
// 파일 정보 조사
|
||||
String originalFileName = tempFile.getName();
|
||||
String fileExtension = this.getExtension(tempFile);
|
||||
Long fileSize = tempFile.length();
|
||||
|
||||
// 임시 파일을 지정된 위치로 이동
|
||||
String savePath = dir.getAbsolutePath() + File.separator + attachFileSaveDTO.getFileId();
|
||||
|
||||
// 파일 이동
|
||||
if (!tempFile.renameTo(new File(savePath))) {
|
||||
|
||||
log.error("failed to move temporary file to save path [file id : " + attachFileSaveDTO.getFileId() + "] : " + savePath);
|
||||
|
||||
// 실패시 처리
|
||||
throw BizException
|
||||
.withUserMessage(USER_MESSAGE_KEY_FIKE_SEND)
|
||||
.withSystemMessage("tempFile.renameTo(new File(savePath)").build();
|
||||
}
|
||||
|
||||
|
||||
log.info("moved temporary file to save path [file id : " + attachFileSaveDTO.getFileId() + "] : " + savePath);
|
||||
|
||||
AttachFile attachFile = modelMapper.map(attachFileSaveDTO, AttachFile.class);
|
||||
attachFile.setOriginalFileName(originalFileName);
|
||||
attachFile.setFileExtension(fileExtension);
|
||||
attachFile.setFileSize(fileSize);
|
||||
attachFile.setFilePath(saveDir + File.separator);
|
||||
attachFile.setSeverFileName(attachFileSaveDTO.getFileId());
|
||||
|
||||
return attachFile;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AttachFile moveDeleteLocation(AttachFile attachFile) {
|
||||
|
||||
// 파일정보 검사
|
||||
if (attachFile == null) {
|
||||
throw ValidationException.withUserMessageKey(USER_MESSAGE_KEY_EMPTY)
|
||||
.withSystemMessage(SYSTEM_MESSAGE_EMPTY_ATTACH_FILE_SAVE_DTO).build();
|
||||
}
|
||||
|
||||
// 저장된 파일 경로
|
||||
File saveFile = new File(getSaveFilePath() + attachFile.getFilePath() + attachFile.getFileId());
|
||||
|
||||
// 저장된 경로에서 파일 가져오기
|
||||
if (saveFile == null || !saveFile.exists() || saveFile.isDirectory()) {
|
||||
throw BizException.withSystemMessage(SYSTEM_MESSAGE_FOLDER_NOT_FOUND).build();
|
||||
}
|
||||
|
||||
// 삭제 디렉토리 위치
|
||||
Date now = new Date();
|
||||
SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd");
|
||||
String deleteDir = File.separator + format.format(now);
|
||||
File dir = new File(getDeleteFilePath() + deleteDir);
|
||||
|
||||
// 존재 하지 않으면 생성
|
||||
if (!dir.isDirectory()) {
|
||||
dir.mkdirs();
|
||||
}
|
||||
|
||||
// 저장된 파일을 지정된 위치로 이동
|
||||
String deletePath = dir.getAbsolutePath() + File.separator + attachFile.getFileId();
|
||||
if (!saveFile.renameTo(new File(deletePath))) {
|
||||
|
||||
log.error("failed to move saved file to delete path [file id : " + attachFile.getFileId() + "] : " + deletePath);
|
||||
|
||||
// 실패시 처리
|
||||
throw BizException
|
||||
.withUserMessage(USER_MESSAGE_KEY_FIKE_SEND)
|
||||
.withSystemMessage("saveFile.renameTo(new File(deletePath))").build();
|
||||
}
|
||||
|
||||
log.info("moved save file to delete path [file id : " + attachFile.getFileId() + "] : " + deletePath);
|
||||
|
||||
// 삭제 정보 입력
|
||||
attachFile.setFilePath(deleteDir + File.separator);
|
||||
attachFile.setSeverFileName(attachFile.getFileId());
|
||||
|
||||
return attachFile;
|
||||
}
|
||||
|
||||
@Override
|
||||
public File downloadFile(String filePathWithName) {
|
||||
|
||||
// 전달할 파일 위치 조회
|
||||
File file = new File(getSaveFilePath() + filePathWithName);
|
||||
if(!file.exists()) {
|
||||
return null;
|
||||
}
|
||||
if (file.isDirectory()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return file;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void cleanTempFile(int clearDayAgo) {
|
||||
// Calendar 생성
|
||||
Calendar calandar = Calendar.getInstance();
|
||||
long todayMillis = calandar.getTimeInMillis();
|
||||
// long oneDayMillis = (long) 24 * 60 * 60 * 1000;
|
||||
long oneDayMillis = TimeUnit.MILLISECONDS.convert(1, TimeUnit.DAYS);
|
||||
|
||||
Calendar fileCalandar = Calendar.getInstance();
|
||||
Date fileDate = null;
|
||||
|
||||
// Temp 파일 경로
|
||||
File path = new File(this.getTempFilePath());
|
||||
File[] listOfFiles = path.listFiles();
|
||||
if (listOfFiles == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < listOfFiles.length; i++) {
|
||||
|
||||
if (!listOfFiles[i].exists()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// 파일의 마지막 수정시간 가져오기
|
||||
fileDate = new Date(listOfFiles[i].lastModified());
|
||||
|
||||
// 현재시간과 파일 수정시간 시간차 계산(단위 : 밀리 세컨드)
|
||||
fileCalandar.setTime(fileDate);
|
||||
long diffMillis = todayMillis - fileCalandar.getTimeInMillis();
|
||||
|
||||
// 날짜로 계산
|
||||
int diffDay = (int) (diffMillis / oneDayMillis);
|
||||
|
||||
// 지난 파일 삭제
|
||||
if (diffDay >= clearDayAgo) {
|
||||
try {
|
||||
FileUtils.forceDelete(listOfFiles[i]);
|
||||
log.info("temporary file removed : " + listOfFiles[i].getAbsolutePath());
|
||||
} catch (IOException e) {
|
||||
log.info("failed to remove temporary file : " + listOfFiles[i].getAbsolutePath());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 확장자를 구한다.
|
||||
* </pre>
|
||||
*/
|
||||
private String getExtension(File file) {
|
||||
String name = file.getName();
|
||||
int lastIndexOf = name.lastIndexOf('.');
|
||||
if (lastIndexOf < 0) {
|
||||
return "";
|
||||
}
|
||||
return name.substring(lastIndexOf + 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 확장자를 구한다.
|
||||
* </pre>
|
||||
*/
|
||||
private String getExtension(String fileName) {
|
||||
|
||||
int lastIndexOf = fileName.lastIndexOf('.');
|
||||
if (lastIndexOf < 0) {
|
||||
return "";
|
||||
}
|
||||
return fileName.substring(lastIndexOf + 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 임시 경로
|
||||
* </pre>
|
||||
*/
|
||||
private String getTempFilePath() {
|
||||
|
||||
if (StringUtils.isEmpty(tempRootPath)) {
|
||||
return System.getProperty(JAVA_IO_TMPDIR) + File.separator + SKIAF;
|
||||
}
|
||||
return Util.removeLastSeperator(tempRootPath);
|
||||
}
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 저장 경로
|
||||
* </pre>
|
||||
*/
|
||||
private String getSaveFilePath() {
|
||||
|
||||
if (StringUtils.isEmpty(saveRootPath)) {
|
||||
return System.getProperty(JAVA_IO_TMPDIR);
|
||||
}
|
||||
return Util.removeLastSeperator(saveRootPath);
|
||||
}
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 삭제 경로
|
||||
* </pre>
|
||||
*/
|
||||
private String getDeleteFilePath() {
|
||||
|
||||
if (StringUtils.isEmpty(deleteRootPath)) {
|
||||
return System.getProperty(JAVA_IO_TMPDIR);
|
||||
}
|
||||
return Util.removeLastSeperator(deleteRootPath);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
/**
|
||||
* Copyright (c) 2018 SK INNOVATION Co., Ltd. All rights reserved.
|
||||
*
|
||||
* This software is the confidential and proprietary information of SK INNOVATION.
|
||||
* You shall not disclose such confidential information and shall use it only in accordance
|
||||
* with the terms of the license agreement you entered into with SK INNOVATION.
|
||||
*/
|
||||
package com.skti.bcm.file.domain.service.dto;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public class AttachFileCreateDTO implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -54725768852398151L;
|
||||
|
||||
/** 파일 아이디 */
|
||||
private String fileId;
|
||||
|
||||
/** 사용처 ID */
|
||||
private String targetId;
|
||||
|
||||
/** 사용처 유형 */
|
||||
private String targetType;
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
/**
|
||||
* Copyright (c) 2018 SK INNOVATION Co., Ltd. All rights reserved.
|
||||
*
|
||||
* This software is the confidential and proprietary information of SK INNOVATION.
|
||||
* You shall not disclose such confidential information and shall use it only in accordance
|
||||
* with the terms of the license agreement you entered into with SK INNOVATION.
|
||||
*/
|
||||
package com.skti.bcm.file.domain.service.dto;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public class AttachFileDetailDTO implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -8786343657599059869L;
|
||||
|
||||
/** 파일 아이디 */
|
||||
private Long fileId;
|
||||
|
||||
/** 사용처 ID */
|
||||
private String targetId;
|
||||
|
||||
/** 사용처 유형 */
|
||||
private String targetType;
|
||||
|
||||
/** 원본 파일 이름 */
|
||||
private String originalFileName;
|
||||
|
||||
/** 서버 파일 이름 */
|
||||
private String severFileName;
|
||||
|
||||
/** 파일 경로 */
|
||||
private String filePath;
|
||||
|
||||
/** 확장자 */
|
||||
private String fileExtension;
|
||||
|
||||
/** 파일 사이즈 */
|
||||
private int fileSize;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
/**
|
||||
* Copyright (c) 2018 SK INNOVATION Co., Ltd. All rights reserved.
|
||||
*
|
||||
* This software is the confidential and proprietary information of SK INNOVATION.
|
||||
* You shall not disclose such confidential information and shall use it only in accordance
|
||||
* with the terms of the license agreement you entered into with SK INNOVATION.
|
||||
*/
|
||||
package com.skti.bcm.file.domain.service.dto;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public class AttachFileUpdateDTO {
|
||||
|
||||
private List<String> deleteFileIdList;
|
||||
|
||||
private List<String> saveFileIdList;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
/**
|
||||
* Copyright (c) 2018 SK INNOVATION Co., Ltd. All rights reserved.
|
||||
*
|
||||
* This software is the confidential and proprietary information of SK INNOVATION.
|
||||
* You shall not disclose such confidential information and shall use it only in accordance
|
||||
* with the terms of the license agreement you entered into with SK INNOVATION.
|
||||
*/
|
||||
package com.skti.bcm.file.web;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import com.skti.bcm.file.domain.service.AttachFileService;
|
||||
import com.skti.bcm.file.domain.service.dto.AttachFileCreateDTO;
|
||||
import com.skti.bcm.file.domain.service.dto.AttachFileUpdateDTO;
|
||||
import com.skti.core.constant.Path;
|
||||
import com.skti.core.vo.RestResponse;
|
||||
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
*
|
||||
* History
|
||||
* - 2018. 9. 11. | in01866 | 최초작성.
|
||||
* </pre>
|
||||
*/
|
||||
@Api(tags = "첨부 파일 관리")
|
||||
@RestController
|
||||
public class AttachFileController {
|
||||
|
||||
@Autowired
|
||||
private AttachFileService attachFileService;
|
||||
|
||||
/*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
|
||||
| REST API
|
||||
|-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
|
||||
|
||||
@ApiOperation(value = "파일 등록")
|
||||
@PostMapping(value = Path.ATTACHFILES_DETAIL)
|
||||
public RestResponse create(@PathVariable String fileId, @RequestBody AttachFileCreateDTO attachFileSaveDTO) {
|
||||
|
||||
attachFileSaveDTO.setFileId(fileId);
|
||||
return new RestResponse(attachFileService.create(attachFileSaveDTO));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "파일 삭제 - 미사용으로 전환")
|
||||
@DeleteMapping(value = Path.ATTACHFILES_DETAIL)
|
||||
public RestResponse delete(@PathVariable String fileId) {
|
||||
|
||||
return new RestResponse(attachFileService.delete(fileId));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "파일 목록 조회")
|
||||
@GetMapping(value = Path.ATTACHFILES_TARGET)
|
||||
public RestResponse findByTargetIdAndTargetType(@PathVariable String targetId, @PathVariable String targetType) {
|
||||
|
||||
return new RestResponse(attachFileService.findByTargetIdAndTargetType(targetId, targetType));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "파일 목록 등록")
|
||||
@PostMapping(value = Path.ATTACHFILES)
|
||||
public RestResponse createList(@RequestBody List<AttachFileCreateDTO> attachFileSaveDTOList) {
|
||||
|
||||
return new RestResponse(attachFileService.createList(attachFileSaveDTOList));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "파일 목록 수정")
|
||||
@PostMapping(value = Path.ATTACHFILES_TARGET)
|
||||
public RestResponse updateList(@PathVariable String targetId, @PathVariable String targetType,
|
||||
@RequestBody AttachFileUpdateDTO attachFileUpdateDTO) {
|
||||
|
||||
return new RestResponse(attachFileService.updateList(targetId, targetType, attachFileUpdateDTO));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "파일 목록 삭제 - 미사용으로 전환")
|
||||
@DeleteMapping(value = Path.ATTACHFILES)
|
||||
public RestResponse deleteList(@RequestBody List<String> fileIdList) {
|
||||
|
||||
return new RestResponse(attachFileService.deleteList(fileIdList));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "같은 타입정보로 연결된 파일 목록 삭제 - 미사용으로 전환")
|
||||
@DeleteMapping(value = Path.ATTACHFILES_TARGET)
|
||||
public RestResponse deleteList(@PathVariable String targetId, @PathVariable String targetType) {
|
||||
|
||||
return new RestResponse(attachFileService.deleteList(targetId, targetType));
|
||||
}
|
||||
}
|
||||
151
src/main/java/com/skti/bcm/file/web/FileController.java
Normal file
151
src/main/java/com/skti/bcm/file/web/FileController.java
Normal file
@@ -0,0 +1,151 @@
|
||||
/**
|
||||
* Copyright (c) 2018 SK INNOVATION Co., Ltd. All rights reserved.
|
||||
*
|
||||
* This software is the confidential and proprietary information of SK INNOVATION.
|
||||
* You shall not disclose such confidential information and shall use it only in accordance
|
||||
* with the terms of the license agreement you entered into with SK INNOVATION.
|
||||
*/
|
||||
package com.skti.bcm.file.web;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.util.FileCopyUtils;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestHeader;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import org.springframework.web.util.UriUtils;
|
||||
|
||||
import com.skti.bcm.file.domain.model.AttachFile;
|
||||
import com.skti.bcm.file.domain.service.AttachFileService;
|
||||
import com.skti.bcm.file.domain.service.FileService;
|
||||
import com.skti.core.constant.Path;
|
||||
import com.skti.core.exception.BizException;
|
||||
import com.skti.core.exception.ValidationException;
|
||||
import com.skti.core.util.Util;
|
||||
import com.skti.core.vo.RestResponse;
|
||||
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
*
|
||||
* History
|
||||
* - 2018. 9. 11. | in01866 | 최초작성.
|
||||
* </pre>
|
||||
*/
|
||||
@Api(tags = "파일")
|
||||
@Slf4j
|
||||
@RestController
|
||||
public class FileController {
|
||||
|
||||
private static final String PDF_EXTENSION = "pdf";
|
||||
private static final String USER_MESSAGE_KEY_FILE_DOWNLOAD = "bcm.common.EMPTY";
|
||||
private static final String USER_MESSAGE_KEY_EMPTY = "bcm.common.EMPTY";
|
||||
private static final String SYSTEM_MESSAGE_EMPTY_ATTACH_FILE = "attachFile == null";
|
||||
private static final String SYSTEM_MESSAGE_EMPTY_FILE = "file == null";
|
||||
private static final String SYSTEM_MESSAGE_NOT_USED_FILE = "!attachFile.isUseYn()";
|
||||
private static final String SYSTEM_MESSAGE_FILE_DOWNLOAD = "file download error";
|
||||
|
||||
@Autowired
|
||||
private FileService fileService;
|
||||
|
||||
@Autowired
|
||||
private AttachFileService attachFileService;
|
||||
|
||||
/*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
|
||||
| REST API
|
||||
|-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
|
||||
|
||||
@ApiOperation(value = "파일 업로드")
|
||||
@PostMapping(value = Path.FILES)
|
||||
public RestResponse upload(@RequestParam("file") MultipartFile file) {
|
||||
|
||||
String uploadFileName = fileService.uploadFile(file);
|
||||
|
||||
// 업로드 된 파일아이디 전달
|
||||
Map<String, String> result = new HashMap<>();
|
||||
result.put("fileId", uploadFileName);
|
||||
return new RestResponse(result);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "파일 다운로드")
|
||||
@GetMapping(value = Path.FILES_DETAIL)
|
||||
public void download(@RequestHeader(value="User-Agent", required=false) String userAgent,
|
||||
@PathVariable String fileId,
|
||||
HttpServletRequest request, HttpServletResponse response) {
|
||||
|
||||
// 첨부 파일 조회
|
||||
AttachFile attachFile = attachFileService.findOne(fileId);
|
||||
if (attachFile == null) {
|
||||
throw ValidationException.withUserMessageKey(USER_MESSAGE_KEY_EMPTY)
|
||||
.withSystemMessage(SYSTEM_MESSAGE_EMPTY_ATTACH_FILE).build();
|
||||
}
|
||||
if (!attachFile.isUseYn()) {
|
||||
throw ValidationException.withUserMessageKey(USER_MESSAGE_KEY_EMPTY)
|
||||
.withSystemMessage(SYSTEM_MESSAGE_NOT_USED_FILE).build();
|
||||
}
|
||||
|
||||
// 첨부파일 정보로 파일 조회
|
||||
File file = fileService.downloadFile(attachFile.getFilePath() + attachFile.getFileId());
|
||||
|
||||
// 파일이 있는지 확인
|
||||
if (file == null || !file.exists() || file.isDirectory()) {
|
||||
throw ValidationException.withUserMessageKey(USER_MESSAGE_KEY_EMPTY)
|
||||
.withSystemMessage(SYSTEM_MESSAGE_EMPTY_FILE).build();
|
||||
}
|
||||
|
||||
// 원본 파일명
|
||||
String originalFile = attachFile.getOriginalFileName();
|
||||
|
||||
try (
|
||||
FileInputStream fileInputStream = new FileInputStream(file);
|
||||
OutputStream outputStream = response.getOutputStream()
|
||||
) {
|
||||
// 브라우저에 따라 파일명 인코딩 변경
|
||||
boolean ie = Util.isIEBrowser(userAgent);
|
||||
if (ie) {
|
||||
originalFile = UriUtils.encode(originalFile, StandardCharsets.UTF_8.name());
|
||||
} else {
|
||||
originalFile = new String(originalFile.getBytes("UTF-8"), StandardCharsets.ISO_8859_1.name());
|
||||
}
|
||||
|
||||
// 첨부파일 응답헤더 설정
|
||||
if (attachFile.getFileExtension() != null && attachFile.getFileExtension().equalsIgnoreCase(PDF_EXTENSION)) {
|
||||
|
||||
// pdf 파일이면 바로 보기 설정
|
||||
response.setContentType(MediaType.APPLICATION_PDF.toString());
|
||||
response.setHeader("Content-Disposition", "inline; filename=" + originalFile);
|
||||
|
||||
} else {
|
||||
response.setHeader("Content-Disposition", "attachment; filename=" + originalFile);
|
||||
|
||||
}
|
||||
response.setHeader("Content-Length", String.valueOf(file.length()));
|
||||
FileCopyUtils.copy(fileInputStream, outputStream);
|
||||
|
||||
} catch (Exception e) {
|
||||
|
||||
log.error(SYSTEM_MESSAGE_FILE_DOWNLOAD, e);
|
||||
throw BizException
|
||||
.withUserMessage(USER_MESSAGE_KEY_FILE_DOWNLOAD)
|
||||
.withSystemMessage(SYSTEM_MESSAGE_FILE_DOWNLOAD).build();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
79
src/main/java/com/skti/bcm/i18n/domain/model/Message.java
Normal file
79
src/main/java/com/skti/bcm/i18n/domain/model/Message.java
Normal file
@@ -0,0 +1,79 @@
|
||||
/**
|
||||
* Copyright (c) 2018 SK INNOVATION Co., Ltd. All rights reserved.
|
||||
*
|
||||
* This software is the confidential and proprietary information of SK INNOVATION.
|
||||
* You shall not disclose such confidential information and shall use it only in accordance
|
||||
* with the terms of the license agreement you entered into with SK INNOVATION.
|
||||
*/
|
||||
package com.skti.bcm.i18n.domain.model;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
|
||||
import org.hibernate.validator.constraints.Length;
|
||||
import org.hibernate.validator.constraints.NotBlank;
|
||||
|
||||
import com.skti.bcm.common.domain.model.BaseModelUseYnSupport;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* BCM 메시지 Entity
|
||||
*
|
||||
* History
|
||||
* - 2018. 8. 10. | in01866 | 최초작성.
|
||||
* - 2018. 8. 22. | in01866 | 2차 수정.
|
||||
* </pre>
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@Entity(name = "TB_BCM_MSG")
|
||||
public class Message extends BaseModelUseYnSupport {
|
||||
|
||||
private static final long serialVersionUID = -809692337424007898L;
|
||||
|
||||
/** 메시지 키 */
|
||||
@Id
|
||||
@NotBlank
|
||||
@Column(name="MSG_KEY", nullable = false)
|
||||
private String messageKey;
|
||||
|
||||
/** 메시지 명1 */
|
||||
@Length(max = 2000)
|
||||
@Column(name="MSG_NM1", length = 2000)
|
||||
private String messageName1;
|
||||
|
||||
/** 메시지 명2 */
|
||||
@Length(max = 2000)
|
||||
@Column(name="MSG_NM2", length = 2000)
|
||||
private String messageName2;
|
||||
|
||||
/** 메시지 명3 */
|
||||
@Length(max = 2000)
|
||||
@Column(name="MSG_NM3", length = 2000)
|
||||
private String messageName3;
|
||||
|
||||
/** 메시지 명4 */
|
||||
/* 4번째 언어 추가시, 주석 해제
|
||||
@Length(max = 2000)
|
||||
@Column(name="MSG_NM4", length = 2000)
|
||||
private String messageName4;
|
||||
*/
|
||||
|
||||
/** 메시지 설명 */
|
||||
@Length(max = 2000)
|
||||
@Column(name="MSG_DESC", length = 2000)
|
||||
private String messageDesc;
|
||||
|
||||
/**
|
||||
* 사용처 (프로그램 : {PROG_ID}, 공통 : COMMON, 시스템 : SYSTEM)
|
||||
*/
|
||||
@NotBlank
|
||||
@Length(max = 128)
|
||||
@Column(name="TARGET", length = 128, nullable = false)
|
||||
private String target;
|
||||
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user