Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
dataport-api
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
강현수
dataport-api
Commits
c1b44f4b
Commit
c1b44f4b
authored
Apr 07, 2023
by
hyunchu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactoring
parent
32a056b9
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
24 additions
and
24 deletions
+24
-24
config/application-prod.yml
config/application-prod.yml
+1
-1
src/main/java/net/herit/ami/commons/response/BackendServiceStatus.java
.../net/herit/ami/commons/response/BackendServiceStatus.java
+1
-4
src/main/java/net/herit/ami/features/stat/service/DefaultConnectService.java
...erit/ami/features/stat/service/DefaultConnectService.java
+13
-9
src/main/java/net/herit/ami/features/stat/service/ResponseService.java
.../net/herit/ami/features/stat/service/ResponseService.java
+0
-1
src/main/java/net/herit/ami/features/stat/service/smp/SmpService.java
...a/net/herit/ami/features/stat/service/smp/SmpService.java
+9
-9
No files found.
config/application-prod.yml
View file @
c1b44f4b
src/main/java/net/herit/ami/commons/response/BackendServiceStatus.java
View file @
c1b44f4b
...
@@ -10,10 +10,7 @@ public enum BackendServiceStatus {
...
@@ -10,10 +10,7 @@ public enum BackendServiceStatus {
RESPONSE_READ_SYSTEM_ERROR
(
500
,
501
,
"IOException"
),
RESPONSE_READ_SYSTEM_ERROR
(
500
,
501
,
"IOException"
),
MAPPER_ERROR
(
500
,
502
,
"Mapper pasing error"
),
MAPPER_ERROR
(
500
,
502
,
"Mapper pasing error"
),
JSON_PROCESS_ONE
(
500
,
503
,
"One Day Process JSON process Excetion"
),
JSON_PROCESS_ONE
(
500
,
503
,
"One Day Process JSON process Excetion"
),
INSERT_ERROR
(
500
,
504
,
"INSERT ERROR Parameters"
),
INSERT_ERROR
(
500
,
504
,
"INSERT ERROR Parameters"
);
;
private
int
statusCode
;
private
int
statusCode
;
private
int
detailCode
;
private
int
detailCode
;
...
...
src/main/java/net/herit/ami/features/stat/service/DefaultConnectService.java
View file @
c1b44f4b
...
@@ -33,6 +33,8 @@ public class DefaultConnectService implements ConnectionService{
...
@@ -33,6 +33,8 @@ public class DefaultConnectService implements ConnectionService{
private
final
HolidayRepository
holidayRepository
;
private
final
HolidayRepository
holidayRepository
;
private
final
OmsLogger
oms
;
private
final
OmsLogger
oms
;
private
final
ObjectMapper
mapper
=
new
ObjectMapper
();
private
final
ObjectMapper
mapper
=
new
ObjectMapper
();
private
static
final
int
MULTIPLE_ITEMS
=
1
;
private
static
final
int
SINGLE_ITEM
=
1
;
// 이 메소드는 CommonExeption을 던지는데, 이 메소드를 호출하는 부분에서는 예외처리를 안해주는것같아요
// 이 메소드는 CommonExeption을 던지는데, 이 메소드를 호출하는 부분에서는 예외처리를 안해주는것같아요
// 그렇다면 던지기보다는 책임을지고 예외처리를 하는게 어떨까 싶습니다
// 그렇다면 던지기보다는 책임을지고 예외처리를 하는게 어떨까 싶습니다
...
@@ -47,24 +49,26 @@ public class DefaultConnectService implements ConnectionService{
...
@@ -47,24 +49,26 @@ public class DefaultConnectService implements ConnectionService{
public
void
commonProcess
(
Response
connect
)
throws
CommonException
{
public
void
commonProcess
(
Response
connect
)
throws
CommonException
{
try
{
try
{
Map
<
String
,
String
>
map
=
segregate
(
builderResponseBody
(
connect
));
Map
<
String
,
String
>
map
=
segregate
(
builderResponseBody
(
connect
));
int
totalCount
=
Integer
.
parseInt
(
map
.
get
(
"item"
)
);
int
totalCount
=
extractTotalCount
(
map
);
if
(
totalCount
>
1
)
{
if
(
totalCount
>
MULTIPLE_ITEMS
)
{
HolidaRootResponse
resBody
=
mapper
.
readValue
(
map
.
get
(
"anotherDaybody"
),
HolidaRootResponse
.
class
);
HolidaRootResponse
resBody
=
mapper
.
readValue
(
map
.
get
(
"anotherDaybody"
),
HolidaRootResponse
.
class
);
// 메시지 체인2
anotherDayProcess
(
resBody
.
getHolidayData
(),
resBody
.
getHolidayTotalCount
());
anotherDayProcess
(
resBody
.
getHolidayData
(),
resBody
.
getHolidayTotalCount
());
}
else
if
(
totalCount
==
1
)
{
}
else
if
(
totalCount
==
SINGLE_ITEM
)
{
onlyDayProcess
(
map
.
get
(
"oneDayBody"
));
onlyDayProcess
(
map
.
get
(
"oneDayBody"
));
}
else
{
}
else
{
oms
.
addOmsData
(
OmsLogField
.
R1
,
"0"
);
oms
.
addOmsData
(
OmsLogField
.
R1
,
"0"
);
oms
.
addOmsData
(
OmsLogField
.
R2
,
"0"
);
oms
.
addOmsData
(
OmsLogField
.
R2
,
"0"
);
}
}
}
catch
(
Exception
ex
)
{
}
catch
(
Exception
ex
)
{
call
.
error
(
"Error Occurred with External Server request. cause: "
,
ex
);
call
.
error
(
"Error Occurred with External Server request. cause: "
,
ex
);
oms
.
addOmsData
(
OmsLogField
.
R1
,
getClass
().
getName
());
oms
.
addOmsData
(
OmsLogField
.
R1
,
getClass
().
getName
());
oms
.
addOmsDatat
(
OmsLogField
.
R2
,
BackendServiceStatus
.
SYSTEM_ERROR
);
oms
.
addOmsDatat
(
OmsLogField
.
R2
,
BackendServiceStatus
.
SYSTEM_ERROR
);
}
}
}
}
private
int
extractTotalCount
(
Map
<
String
,
String
>
map
)
{
return
Integer
.
parseInt
(
map
.
get
(
"item"
));
}
private
void
apiConnectLog
(
Response
connect
)
{
private
void
apiConnectLog
(
Response
connect
)
{
final
String
printRequest
=
connect
.
request
().
toString
();
final
String
printRequest
=
connect
.
request
().
toString
();
final
String
printResponse
=
connect
.
toBuilder
()
final
String
printResponse
=
connect
.
toBuilder
()
...
@@ -99,11 +103,11 @@ public class DefaultConnectService implements ConnectionService{
...
@@ -99,11 +103,11 @@ public class DefaultConnectService implements ConnectionService{
Map
<
String
,
String
>
buildMap
=
new
HashMap
<>();
Map
<
String
,
String
>
buildMap
=
new
HashMap
<>();
try
{
try
{
Map
<
String
,
Map
<
String
,
Object
>>
anotherDayb
ody
=
mapper
.
readValue
(
oneDayBody
,
new
TypeReference
<
Map
<
String
,
Map
<
String
,
Object
>>>()
{});
Map
<
String
,
Map
<
String
,
Object
>>
multipleDaysB
ody
=
mapper
.
readValue
(
oneDayBody
,
new
TypeReference
<
Map
<
String
,
Map
<
String
,
Object
>>>()
{});
Map
<
String
,
Object
>
itmeMap
=
mapper
.
readValue
(
mapper
.
writeValueAsString
(
anotherDayb
ody
.
get
(
"response"
).
get
(
"body"
)),
new
TypeReference
<
Map
<
String
,
Object
>>(){});
Map
<
String
,
Object
>
itmeMap
=
mapper
.
readValue
(
mapper
.
writeValueAsString
(
multipleDaysB
ody
.
get
(
"response"
).
get
(
"body"
)),
new
TypeReference
<
Map
<
String
,
Object
>>(){});
buildMap
.
put
(
"oneDayBody"
,
oneDayBody
);
buildMap
.
put
(
"oneDayBody"
,
oneDayBody
);
buildMap
.
put
(
"anotherDaybody"
,
anotherDayb
ody
.
toString
());
buildMap
.
put
(
"anotherDaybody"
,
multipleDaysB
ody
.
toString
());
buildMap
.
put
(
"item"
,
itmeMap
.
get
(
"totalCount"
).
toString
());
buildMap
.
put
(
"item"
,
itmeMap
.
get
(
"totalCount"
).
toString
());
...
...
src/main/java/net/herit/ami/features/stat/service/ResponseService.java
View file @
c1b44f4b
...
@@ -32,7 +32,6 @@ public class ResponseService {
...
@@ -32,7 +32,6 @@ public class ResponseService {
}
catch
(
IOException
ex
){
}
catch
(
IOException
ex
){
call
.
error
(
"Exceprion point {} , massge "
,
JOB_NAME
,
ex
.
getMessage
());
call
.
error
(
"Exceprion point {} , massge "
,
JOB_NAME
,
ex
.
getMessage
());
// CommonExeption을 던져도 받아서 처리해주는 부분은 없는것같아요
throw
new
CommonException
(
ExceptionType
.
RESPONE_CAUSE_EXCEPTION
);
throw
new
CommonException
(
ExceptionType
.
RESPONE_CAUSE_EXCEPTION
);
}
}
}
}
...
...
src/main/java/net/herit/ami/features/stat/service/smp/SmpService.java
View file @
c1b44f4b
...
@@ -16,6 +16,7 @@ import javax.xml.bind.JAXBException;
...
@@ -16,6 +16,7 @@ import javax.xml.bind.JAXBException;
import
javax.xml.bind.Unmarshaller
;
import
javax.xml.bind.Unmarshaller
;
import
java.io.StringReader
;
import
java.io.StringReader
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.List
;
@Service
@Service
@RequiredArgsConstructor
@RequiredArgsConstructor
...
@@ -26,12 +27,11 @@ public class SmpService {
...
@@ -26,12 +27,11 @@ public class SmpService {
private
final
ResponseService
responseService
;
private
final
ResponseService
responseService
;
private
final
SmpEnterFeignClient
smpEnterFeignClient
;
private
final
SmpEnterFeignClient
smpEnterFeignClient
;
public
int
GetSmpDataAndInsert
(
int
i
,
String
serviceKey
)
{
public
int
GetSmpDataAndInsert
(
int
area
,
String
serviceKey
)
{
ArrayList
<
SmpDTO
>
smpList
=
getResponseItme
(
i
,
serviceKey
);
List
<
SmpDTO
>
smpList
=
getResponseItmes
(
area
,
serviceKey
);
return
sendSmp
(
smpList
,
area
);
return
sendSmp
(
smpList
,
i
);
}
}
private
ArrayList
<
SmpDTO
>
getResponseItme
(
int
area
,
String
serviceKeys
)
{
private
List
<
SmpDTO
>
getResponseItmes
(
int
area
,
String
serviceKeys
)
{
try
{
try
{
JAXBContext
jaxbContext
=
JAXBContext
.
newInstance
(
SmpRoot
.
class
);
JAXBContext
jaxbContext
=
JAXBContext
.
newInstance
(
SmpRoot
.
class
);
Unmarshaller
unmarshaller
=
jaxbContext
.
createUnmarshaller
();
Unmarshaller
unmarshaller
=
jaxbContext
.
createUnmarshaller
();
...
@@ -39,12 +39,12 @@ public class SmpService {
...
@@ -39,12 +39,12 @@ public class SmpService {
SmpRoot
smpResponse
=
(
SmpRoot
)
unmarshaller
.
unmarshal
(
new
StringReader
(
ResponseXml
));
SmpRoot
smpResponse
=
(
SmpRoot
)
unmarshaller
.
unmarshal
(
new
StringReader
(
ResponseXml
));
return
smpResponse
.
getItem
();
return
smpResponse
.
getItem
();
}
catch
(
JAXBException
e
)
{
}
catch
(
JAXBException
e
)
{
call
.
error
(
"
ResponseService class in method explorerSnd JAXBException
: {}"
,
e
.
getMessage
());
call
.
error
(
"
JAXBException occurred in getResponseItems method of SmpService
: {}"
,
e
.
getMessage
());
throw
new
CommonException
(
e
.
getMessage
());
throw
new
CommonException
(
e
.
getMessage
());
}
}
}
}
private
int
sendSmp
(
Array
List
<
SmpDTO
>
smpList
,
int
areaCd
)
{
private
int
sendSmp
(
List
<
SmpDTO
>
smpList
,
int
areaCd
)
{
int
insertCount
=
0
;
int
insertCount
=
0
;
for
(
SmpDTO
value
:
smpList
){
for
(
SmpDTO
value
:
smpList
){
...
@@ -55,7 +55,6 @@ public class SmpService {
...
@@ -55,7 +55,6 @@ public class SmpService {
}
}
private
SmpDTO
buildSmpDto
(
SmpDTO
smpDTO
)
{
private
SmpDTO
buildSmpDto
(
SmpDTO
smpDTO
)
{
// 잘못된 빌더패턴 사용법인것같습니다.
return
SmpDTO
.
builder
().
idx
(
smpDTO
.
getIdx
())
return
SmpDTO
.
builder
().
idx
(
smpDTO
.
getIdx
())
.
areaCd
(
smpDTO
.
getAreaCd
())
.
areaCd
(
smpDTO
.
getAreaCd
())
.
smp
(
smpDTO
.
getSmp
())
.
smp
(
smpDTO
.
getSmp
())
...
@@ -65,12 +64,13 @@ public class SmpService {
...
@@ -65,12 +64,13 @@ public class SmpService {
build
();
build
();
}
}
private
int
insertCall
(
SmpDTO
params
){
private
int
insertCall
(
SmpDTO
params
){
int
success
=
0
;
int
success
=
0
;
try
{
try
{
success
=
smpRepository
.
insertSmp
(
params
);
success
=
smpRepository
.
insertSmp
(
params
);
}
catch
(
Exception
e
){
}
catch
(
Exception
e
){
oms
.
setStatusAndResult
(
BackendServiceStatus
.
DB_
INSERT_ERROR
);
oms
.
setStatusAndResult
(
BackendServiceStatus
.
INSERT_ERROR
);
}
}
return
success
;
return
success
;
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment