Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
ddms-masterdata-h3-module-slave
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Arie Valdano
ddms-masterdata-h3-module-slave
Commits
aefc1024
Commit
aefc1024
authored
Feb 20, 2025
by
Arie Valdano
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
DEVELOP: developing DGI API End Point and Service V1.2 and V1.3
parent
b2706f2d
Changes
10
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
1473 additions
and
147 deletions
+1473
-147
pom.xml
pom.xml
+6
-0
DGIDpHLORESTController.java
...rdata/controller/apidgi/dphlo/DGIDpHLORESTController.java
+200
-0
DGIInvoiceNjbNscRESTController.java
.../apidgi/invoicenjbnsc/DGIInvoiceNjbNscRESTController.java
+113
-30
DGIManagePartSalesRESTController.java
...dgi/managepartsales/DGIManagePartSalesRESTController.java
+130
-0
DGIManageWORESTController.java
...controller/apidgi/managewo/DGIManageWORESTController.java
+134
-0
DGIPartInboundRESTController.java
...ller/apidgi/partinbound/DGIPartInboundRESTController.java
+132
-0
DGIPartInvoiceRESTController.java
...ller/apidgi/partinvoice/DGIPartInvoiceRESTController.java
+146
-0
DGIUnpaidHLORESTController.java
...ntroller/apidgi/unpaidhlo/DGIUnpaidHLORESTController.java
+135
-0
DGIService.java
src/main/java/com/eksad/masterdata/service/DGIService.java
+477
-0
DGIInvoiceNjbNscService.java
...erdata/service/invoicenjbnsc/DGIInvoiceNjbNscService.java
+0
-117
No files found.
pom.xml
View file @
aefc1024
...
@@ -98,6 +98,12 @@
...
@@ -98,6 +98,12 @@
<version>
1.0-SNAPSHOT
</version>
<version>
1.0-SNAPSHOT
</version>
<type>
jar
</type>
<type>
jar
</type>
</dependency>
</dependency>
<dependency>
<groupId>
com.eksad.ddms
</groupId>
<artifactId>
ddms-masterdata-h3-dto
</artifactId>
<version>
1.0-SNAPSHOT
</version>
<type>
jar
</type>
</dependency>
</dependencies>
</dependencies>
<build>
<build>
...
...
src/main/java/com/eksad/masterdata/controller/apidgi/dphlo/DGIDpHLORESTController.java
0 → 100644
View file @
aefc1024
package
com
.
eksad
.
masterdata
.
controller
.
apidgi
.
dphlo
;
import
com.eksad.ddms.common.dto.GatewayDPHLODTO
;
import
com.eksad.ddms.common.dto.GatewayDPHLODetailDTO
;
import
com.eksad.ddms.common.h2.dto.ui.ResponseErrorDTO
;
import
com.eksad.ddms.common.h3.dto.dphlopull.DPHLOPullHeaderDTO
;
import
com.eksad.ddms.common.h3.dto.dphlopull.DPHLOPullParamDTO
;
import
com.eksad.ddms.common.h3.dto.dphlopull.ResponseDPHLOPullDTO
;
import
com.eksad.ddms.masterdata.h3.dto.dgi.DealerGroupMappingNewDTO
;
import
com.eksad.ddms.masterdata.h3.dto.dgi.DgiResponseDTO
;
import
com.eksad.masterdata.service.DGIService
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.MediaType
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.web.bind.annotation.*
;
import
java.text.ParseException
;
import
java.util.*
;
import
java.util.logging.Level
;
import
java.util.logging.Logger
;
@RestController
@Slf4j
public
class
DGIDpHLORESTController
{
@Autowired
DGIService
pullService
;
@RequestMapping
(
value
=
"/dgi-api/v1/dphlo/read"
,
method
=
RequestMethod
.
POST
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<
Object
>
getDPHLO
(
@RequestHeader
(
"GvtDealerId"
)
String
dealerId
,
@RequestBody
DPHLOPullParamDTO
dto
)
throws
ParseException
{
try
{
System
.
out
.
println
(
new
ObjectMapper
().
writeValueAsString
(
dto
));
pullService
.
exceptionHelper
(
dto
.
getFromTime
(),
"yyyy-MM-dd HH:mm:ss"
,
"fromTime"
);
pullService
.
exceptionHelperNotMandatory
(
dto
.
getToTime
(),
"yyyy-MM-dd HH:mm:ss"
,
"toTime"
);
if
(
pullService
.
isNotValidDate
(
dto
.
getFromTime
())){
throw
new
Exception
(
"format toTime tidak sesuai, seharusnya YYYY-MM-DD hh:mm:ss"
);
}
else
if
(
pullService
.
isNotValidDate
(
dto
.
getToTime
()))
{
throw
new
Exception
(
"format toTime tidak sesuai, seharusnya YYYY-MM-DD hh:mm:ss"
);
}
pullService
.
checkToTimeIs7Days
(
dto
.
getFromTime
(),
dto
.
getToTime
());
pullService
.
dealerValidation
(
dealerId
,
dto
.
getDealerId
());
}
catch
(
Exception
ex
)
{
Logger
.
getLogger
(
DGIDpHLORESTController
.
class
.
getName
()).
log
(
Level
.
SEVERE
,
null
,
ex
);
ResponseErrorDTO
res
=
new
ResponseErrorDTO
();
res
.
setMessage
(
ex
.
getMessage
());
res
.
setStatus
(
HttpStatus
.
BAD_REQUEST
.
value
());
res
.
setError
(
HttpStatus
.
BAD_REQUEST
.
getReasonPhrase
());
return
ResponseEntity
.
badRequest
().
body
(
res
);
}
return
pullService
.
postRequestDPHLO
(
dto
);
}
@RequestMapping
(
value
=
"/dgi-api/v1/dphlo/add"
,
method
=
RequestMethod
.
POST
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<
Object
>
postDPHLOApi
(
@RequestHeader
(
"GvtDealerId"
)
String
dealerId
,
@RequestBody
GatewayDPHLODTO
dto
)
throws
ParseException
{
try
{
System
.
out
.
println
(
new
ObjectMapper
().
writeValueAsString
(
dto
));
pullService
.
nullEmptyExceptionHelper
(
dto
,
new
ArrayList
<>());
pullService
.
exceptionHelper
(
dto
.
getTanggalPemesananHLO
(),
"dd/MM/yyyy"
,
"tanggalPemesananHLO"
);
pullService
.
exceptionHelper
(
dto
.
getCreatedTime
(),
"dd/MM/yyyy HH:mm:ss"
,
"createdTime"
);
pullService
.
exceptionHelper
(
dto
.
getModifiedTime
(),
"dd/MM/yyyy HH:mm:ss"
,
"modifiedTime"
);
pullService
.
dealerValidation
(
dealerId
,
dto
.
getDealerId
());
if
(!
dto
.
getParts
().
isEmpty
()
||
dto
.
getParts
()
!=
null
){
for
(
GatewayDPHLODetailDTO
parts:
dto
.
getParts
()){
pullService
.
exceptionHelperNotMandatory
(
parts
.
getCreatedTime
(),
"dd/MM/yyyy HH:mm:ss"
,
"parts createdTime"
);
pullService
.
exceptionHelperNotMandatory
(
parts
.
getModifiedTime
(),
"dd/MM/yyyy HH:mm:ss"
,
"parts modifiedTime"
);
}
}
}
catch
(
Exception
ex
)
{
Logger
.
getLogger
(
DGIDpHLORESTController
.
class
.
getName
()).
log
(
Level
.
SEVERE
,
null
,
ex
);
ResponseErrorDTO
res
=
new
ResponseErrorDTO
();
res
.
setMessage
(
ex
.
getMessage
());
res
.
setStatus
(
HttpStatus
.
BAD_REQUEST
.
value
());
res
.
setError
(
HttpStatus
.
BAD_REQUEST
.
getReasonPhrase
());
return
ResponseEntity
.
badRequest
().
body
(
res
);
}
return
pullService
.
postRequestPullDPHLO
(
dto
);
}
@RequestMapping
(
value
=
"/dgi-api/v1.3/dphlo/read"
,
method
=
RequestMethod
.
POST
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<
Object
>
getDPHLO
(
@RequestHeader
(
"GvtDealerId"
)
String
dealerId
,
@RequestBody
DPHLOPullParamDTO
dto
,
Boolean
dgi
)
throws
ParseException
{
try
{
System
.
out
.
println
(
"disini payload dgi-api/v1.3/dphlo/read"
+
new
ObjectMapper
().
writeValueAsString
(
dto
));
DgiResponseDTO
dgiNew
=
pullService
.
dgiv1_3Validator
(
dto
.
getDealerId
(),
dealerId
);
System
.
out
.
println
(
"v1.3 dphlo/read"
);
System
.
out
.
println
(
new
ObjectMapper
().
writeValueAsString
(
dgiNew
));
if
(
dgiNew
.
getStatus
().
equals
(
0
)
||
dgiNew
.
getStatus
().
equals
(
"0"
))
{
//return here
return
ResponseEntity
.
ok
().
body
(
dgiNew
);
}
List
<?>
dataDgi
=
dgiNew
.
getData
();
List
<
DealerGroupMappingNewDTO
>
ob
=
Arrays
.
asList
(
new
ObjectMapper
().
convertValue
(
dataDgi
.
toArray
(),
DealerGroupMappingNewDTO
[].
class
));
List
<
DPHLOPullHeaderDTO
>
data
=
new
ArrayList
<>();
List
<
String
>
listDealer
=
new
ArrayList
<>();
ob
.
forEach
(
x
->
{
listDealer
.
add
(
x
.
getDealerAhmCode
());
});
for
(
String
y
:
listDealer
){
dto
.
setDealerId
(
y
);
ResponseDPHLOPullDTO
pullDPHLO
=
pullService
.
postRequestDPHLO_v1_3
(
dto
);
System
.
out
.
println
(
"v1.3/dphlo/read "
+
new
ObjectMapper
().
writeValueAsString
(
pullDPHLO
));
if
(
pullDPHLO
!=
null
&&
pullDPHLO
.
getData
()
!=
null
&&
!
pullDPHLO
.
getData
().
isEmpty
())
{
data
.
addAll
(
pullDPHLO
.
getData
());
}
}
if
(
data
.
isEmpty
())
{
dgiNew
.
setStatus
(
1
);
dgiNew
.
setData
(
null
);
dgiNew
.
putError
(
"data tidak ditemukan"
);
return
ResponseEntity
.
ok
(
dgiNew
);
}
Map
<
String
,
DPHLOPullHeaderDTO
>
map
=
new
HashMap
<>();
data
.
forEach
(
x
->
map
.
put
(
x
.
getIdHLODocument
(),
x
));
List
<
DPHLOPullHeaderDTO
>
listDataDistinct
=
new
ArrayList
<>(
map
.
values
());
dgiNew
.
setData
(
listDataDistinct
);
return
ResponseEntity
.
ok
(
dgiNew
);
}
catch
(
Exception
ex
)
{
Logger
.
getLogger
(
DGIDpHLORESTController
.
class
.
getName
()).
log
(
Level
.
SEVERE
,
null
,
ex
);
ResponseErrorDTO
res
=
new
ResponseErrorDTO
();
res
.
setMessage
(
ex
.
getMessage
());
// res.setStatus(HttpStatus.BAD_REQUEST.value());
res
.
setStatus
(
0
);
res
.
setError
(
HttpStatus
.
BAD_REQUEST
.
getReasonPhrase
());
return
ResponseEntity
.
badRequest
().
body
(
res
);
}
}
@RequestMapping
(
value
=
"/dgi-api/v1.3/dphlo/add"
,
method
=
RequestMethod
.
POST
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<
Object
>
postDPHLOApi
(
@RequestHeader
(
"GvtDealerId"
)
String
dealerId
,
@RequestBody
GatewayDPHLODTO
dto
,
Boolean
dgi
)
throws
ParseException
{
try
{
pullService
.
nullEmptyExceptionHelper
(
dto
,
new
ArrayList
<>());
pullService
.
exceptionHelper
(
dto
.
getTanggalPemesananHLO
(),
"dd/MM/yyyy"
,
"tanggalPemesananHLO"
);
pullService
.
exceptionHelper
(
dto
.
getCreatedTime
(),
"dd/MM/yyyy HH:mm:ss"
,
"createdTime"
);
pullService
.
exceptionHelper
(
dto
.
getModifiedTime
(),
"dd/MM/yyyy HH:mm:ss"
,
"modifiedTime"
);
if
(!
dto
.
getParts
().
isEmpty
()
||
dto
.
getParts
()
!=
null
)
{
for
(
GatewayDPHLODetailDTO
parts
:
dto
.
getParts
())
{
pullService
.
exceptionHelperNotMandatory
(
parts
.
getCreatedTime
(),
"dd/MM/yyyy HH:mm:ss"
,
"parts createdTime"
);
pullService
.
exceptionHelperNotMandatory
(
parts
.
getModifiedTime
(),
"dd/MM/yyyy HH:mm:ss"
,
"parts modifiedTime"
);
}
}
DgiResponseDTO
dgiNew
=
new
DgiResponseDTO
();
if
(
dto
.
getDealerId
()
==
null
||
dto
.
getDealerId
().
trim
().
equals
(
""
))
{
dgiNew
.
setData
(
null
);
dgiNew
.
putError
(
"dealerId Kosong"
);
dgiNew
.
setStatus
(
0
);
return
ResponseEntity
.
ok
(
dgiNew
);
}
System
.
out
.
println
(
"disini payload dgi-api/v1.3/dphlo/add"
+
new
ObjectMapper
().
writeValueAsString
(
dto
));
dgiNew
=
pullService
.
dgiv1_3Validator
(
dto
.
getDealerId
(),
dealerId
);
System
.
out
.
println
(
"v1.3 dphlo/add"
);
System
.
out
.
println
(
new
ObjectMapper
().
writeValueAsString
(
dgiNew
));
if
(
dgiNew
.
getStatus
().
equals
(
0
)
||
dgiNew
.
getStatus
().
equals
(
"0"
))
{
//return here
return
ResponseEntity
.
ok
().
body
(
dgiNew
);
}
return
pullService
.
postRequestPullDPHLO
(
dto
);
}
catch
(
Exception
ex
)
{
Logger
.
getLogger
(
DGIDpHLORESTController
.
class
.
getName
()).
log
(
Level
.
SEVERE
,
null
,
ex
);
ResponseErrorDTO
res
=
new
ResponseErrorDTO
();
res
.
setMessage
(
ex
.
getMessage
());
res
.
setStatus
(
HttpStatus
.
BAD_REQUEST
.
value
());
res
.
setError
(
HttpStatus
.
BAD_REQUEST
.
getReasonPhrase
());
return
ResponseEntity
.
badRequest
().
body
(
res
);
}
}
}
src/main/java/com/eksad/masterdata/controller/apidgi/invoicenjbnsc/DGIInvoiceNjbNscRESTController.java
View file @
aefc1024
package
com
.
eksad
.
masterdata
.
controller
.
apidgi
.
invoicenjbnsc
;
package
com
.
eksad
.
masterdata
.
controller
.
apidgi
.
invoicenjbnsc
;
import
com.eksad.masterdata.service.invoicenjbnsc.DGIInvoiceNjbNscService
;
import
com.eksad.ddms.common.dto.GatewayOrafinDTO
;
import
com.eksad.ddms.common.dto.GatewayPartOrafinDTO
;
import
com.eksad.ddms.common.dto.GatewayServiceOrafinDTO
;
import
com.eksad.masterdata.service.DGIService
;
import
com.eksad.ddms.common.h2.dto.apigateway.request.PullNotaJBSCRequestDTO
;
import
com.eksad.ddms.common.h2.dto.apigateway.request.PullNotaJBSCRequestDTO
;
import
com.eksad.ddms.common.h2.dto.ui.ResponseErrorDTO
;
import
com.eksad.ddms.common.h2.dto.ui.ResponseErrorDTO
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.MediaType
;
import
org.springframework.http.MediaType
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.*
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
java.
text.DateFormat
;
import
java.
io.IOException
;
import
java.text.ParseException
;
import
java.text.ParseException
;
import
java.text.SimpleDateFormat
;
import
java.util.ArrayList
;
import
java.time.Duration
;
import
java.util.List
;
import
java.time.LocalDateTime
;
import
java.time.ZoneId
;
import
java.time.format.DateTimeFormatter
;
import
java.util.Date
;
import
java.util.Locale
;
import
java.util.logging.Level
;
import
java.util.logging.Level
;
import
java.util.logging.Logger
;
import
java.util.logging.Logger
;
...
@@ -29,25 +26,7 @@ import java.util.logging.Logger;
...
@@ -29,25 +26,7 @@ import java.util.logging.Logger;
public
class
DGIInvoiceNjbNscRESTController
{
public
class
DGIInvoiceNjbNscRESTController
{
@Autowired
@Autowired
DGIInvoiceNjbNscService
pullService
;
DGIService
pullService
;
@Value
(
"${dam.token.key.path}"
)
private
String
TOKEN
;
@Value
(
"${dam.masterdata.h1}"
)
private
String
md_h1_url
;
@Value
(
"${dam.portal.daya.path}"
)
private
String
PORTAL_DAM_URL
;
@Value
(
"${dam.portal.daya.inv}"
)
private
String
PORTAL_DAM_INV_URL
;
@Value
(
"${daw.portal.daya.inv}"
)
private
String
PORTAL_DAW_INV_URL
;
@Value
(
"${md.portal.profile}"
)
public
String
MD_PROFILE
;
@RequestMapping
(
value
=
"/dgi-api/v1/inv2/read"
,
@RequestMapping
(
value
=
"/dgi-api/v1/inv2/read"
,
method
=
RequestMethod
.
POST
,
method
=
RequestMethod
.
POST
,
...
@@ -78,6 +57,110 @@ public class DGIInvoiceNjbNscRESTController {
...
@@ -78,6 +57,110 @@ public class DGIInvoiceNjbNscRESTController {
return
pullService
.
postRequestPullNJBNSC
(
dto
);
return
pullService
.
postRequestPullNJBNSC
(
dto
);
}
}
@RequestMapping
(
value
=
"/dgi-api/v1/inv2/add"
,
method
=
RequestMethod
.
POST
,
consumes
=
MediaType
.
APPLICATION_JSON_VALUE
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<
Object
>
postWorkOrderOrafin
(
@RequestHeader
(
"GvtDealerId"
)
String
dealerid
,
@RequestBody
GatewayOrafinDTO
dto
)
throws
IOException
{
try
{
System
.
out
.
println
(
new
ObjectMapper
().
writeValueAsString
(
dto
));
List
<
String
>
pass
=
new
ArrayList
<>();
if
(
dto
.
getNoWorkOrder
().
contains
(
"WO"
))
{
//kalo wo njb wajib
if
(
dto
.
getNoNJB
()
==
null
||
dto
.
getNoNJB
().
isEmpty
())
{
throw
new
Exception
(
"No NJB Tidak Boleh Kosong, Mohon Periksa Kembali Data"
);
}
if
(
dto
.
getTanggalNJB
()
==
null
||
dto
.
getTanggalNJB
().
isEmpty
())
{
throw
new
Exception
(
"Tanggal NJB Tidak Boleh Kosong, Mohon Periksa Kembali Data"
);
}
if
(
dto
.
getTotalHargaNJB
()
==
null
||
dto
.
getTotalHargaNJB
()
==
0
||
dto
.
getTotalHargaNJB
().
isNaN
())
{
throw
new
Exception
(
"Total Harga NJB Tidak Boleh Kosong, Mohon Periksa Kembali Data"
);
}
if
(
dto
.
getHondaIdSA
()
==
null
||
dto
.
getHondaIdSA
().
isEmpty
())
{
throw
new
Exception
(
"Honda Id SA Tidak Boleh Kosong, Mohon Periksa Kembali Data"
);
}
if
(
dto
.
getHondaIdMekanik
()
==
null
||
dto
.
getHondaIdMekanik
().
isEmpty
())
{
throw
new
Exception
(
"Honda Id Mekanik Tidak Boleh Kosong, Mohon Periksa Kembali Data"
);
}
if
(
dto
.
getNjb
().
isEmpty
()
||
dto
.
getNjb
()
==
null
)
{
throw
new
Exception
(
"NJB Tidak Boleh Kosong, Mohon Periksa Kembali Data"
);
}
if
(
dto
.
getNoNSC
()
==
null
||
dto
.
getNoNSC
().
isEmpty
()
&&
!
dto
.
getTanggalNSC
().
isEmpty
())
{
throw
new
Exception
(
"No NSC harus dilengkapi"
);
}
else
if
(
dto
.
getNoNSC
()
==
null
||
dto
.
getNoNSC
().
isEmpty
()
&&
dto
.
getTotalHargaNSC
()
!=
0
)
{
throw
new
Exception
(
"NO NSC harus dilengkapi"
);
}
else
if
(
dto
.
getNoNSC
()
==
null
||
dto
.
getNoNSC
().
isEmpty
()
&&
!
dto
.
getNsc
().
isEmpty
())
{
throw
new
Exception
(
"No NSC harus dilengkapi"
);
}
else
if
(!
dto
.
getNoNSC
().
isEmpty
()
&&
dto
.
getTanggalNSC
().
isEmpty
())
{
throw
new
Exception
(
"Tanggal NSC harus dilengkapi"
);
}
else
if
(!
dto
.
getNoNSC
().
isEmpty
()
&&
dto
.
getTotalHargaNSC
()
==
0
)
{
throw
new
Exception
(
"Total Harga NSC harus dilengkapi"
);
}
else
if
(!
dto
.
getNoNSC
().
isEmpty
()
&&
dto
.
getNsc
().
isEmpty
())
{
throw
new
Exception
(
"NSC harus dilengkapi"
);
}
}
if
(
dto
.
getNoWorkOrder
().
contains
(
"SO"
))
{
//kalo so nsc wajib
if
(
dto
.
getNoNSC
()
==
null
||
dto
.
getNoNSC
().
isEmpty
())
{
throw
new
Exception
(
"No NSC Tidak Boleh Kosong, Mohon Periksa Kembali Data"
);
}
if
(
dto
.
getTanggalNSC
()
==
null
||
dto
.
getTanggalNSC
().
isEmpty
())
{
throw
new
Exception
(
"Tanggal NSC Tidak Boleh Kosong, Mohon Periksa Kembali Data"
);
}
if
(
dto
.
getTotalHargaNSC
()
==
null
||
dto
.
getTotalHargaNSC
()
==
0
||
dto
.
getTotalHargaNSC
().
isNaN
())
{
throw
new
Exception
(
"Total Harga Tidak Boleh Kosong, Mohon Periksa Kembali Data"
);
}
if
(
dto
.
getNoNJB
()
==
null
||
dto
.
getNoNJB
().
isEmpty
()
&&
!
dto
.
getTanggalNJB
().
isEmpty
())
{
throw
new
Exception
(
"No NJB harus dilengkapi"
);
}
else
if
(
dto
.
getNoNJB
()
==
null
||
dto
.
getNoNJB
().
isEmpty
()
&&
dto
.
getTotalHargaNJB
()
!=
0
)
{
throw
new
Exception
(
"No NJB harus dilengkapi"
);
}
else
if
(
dto
.
getNoNJB
()
==
null
||
dto
.
getNoNJB
().
isEmpty
()
&&
!
dto
.
getHondaIdMekanik
().
isEmpty
())
{
throw
new
Exception
(
"No NJB harus dilengkapi"
);
}
else
if
(
dto
.
getNoNJB
()
==
null
||
dto
.
getNoNJB
().
isEmpty
()
&&
!
dto
.
getHondaIdSA
().
isEmpty
())
{
throw
new
Exception
(
"No NJB harus dilengkapi"
);
}
else
if
(
dto
.
getNoNJB
()
==
null
||
dto
.
getNoNJB
().
isEmpty
()
&&
!
dto
.
getNjb
().
isEmpty
())
{
throw
new
Exception
(
"No NJB harus dilengkapi"
);
}
else
if
(!
dto
.
getNoNJB
().
isEmpty
()
&&
dto
.
getTanggalNJB
().
isEmpty
())
{
throw
new
Exception
(
"Tanggal NJB harus dilengkapi"
);
}
else
if
(!
dto
.
getNoNJB
().
isEmpty
()
&&
dto
.
getTotalHargaNJB
()
==
0
)
{
throw
new
Exception
(
"Total Harga NJB harus dilengkapi"
);
}
else
if
(!
dto
.
getNoNJB
().
isEmpty
()
&&
dto
.
getHondaIdMekanik
().
isEmpty
())
{
throw
new
Exception
(
"Honda Id Mekanik harus dilengkapi"
);
}
else
if
(!
dto
.
getNoNJB
().
isEmpty
()
&&
dto
.
getHondaIdSA
().
isEmpty
())
{
throw
new
Exception
(
"Honda Id SA harus dilengkapi"
);
}
else
if
(!
dto
.
getNoNJB
().
isEmpty
()
&&
dto
.
getNjb
().
isEmpty
())
{
throw
new
Exception
(
"NJB harus dilengkapi"
);
}
}
// nullEmptyExceptionHelper(dto,pass);
pullService
.
exceptionHelperNotMandatory
(
dto
.
getCreatedTime
(),
"dd/MM/yyyy HH:mm:ss"
,
"createdTime"
);
pullService
.
exceptionHelperNotMandatory
(
dto
.
getModifiedTime
(),
"dd/MM/yyyy HH:mm:ss"
,
"modifiedTime"
);
pullService
.
exceptionHelperNotMandatory
(
dto
.
getTanggalNJB
(),
"dd/MM/yyyy HH:mm:ss"
,
"tanggalNJB"
);
pullService
.
exceptionHelperNotMandatory
(
dto
.
getTanggalNSC
(),
"dd/MM/yyyy HH:mm:ss"
,
"tanggalNSC"
);
pullService
.
dealerValidation
(
dealerid
,
dto
.
getDealerId
());
if
(!
dto
.
getNjb
().
isEmpty
()
||
dto
.
getNjb
()
!=
null
)
{
for
(
GatewayServiceOrafinDTO
njb
:
dto
.
getNjb
())
{
pullService
.
exceptionHelperNotMandatory
(
njb
.
getCreatedTime
(),
"dd/MM/yyyy HH:mm:ss"
,
"njb createdTime"
);
pullService
.
exceptionHelperNotMandatory
(
njb
.
getModifiedTime
(),
"dd/MM/yyyy HH:mm:ss"
,
"njb modifiedTime"
);
}
}
if
(!
dto
.
getNsc
().
isEmpty
()
||
dto
.
getNsc
()
!=
null
)
{
for
(
GatewayPartOrafinDTO
nsc
:
dto
.
getNsc
())
{
pullService
.
exceptionHelperNotMandatory
(
nsc
.
getCreatedTime
(),
"dd/MM/yyyy HH:mm:ss"
,
"nsc createdTime"
);
pullService
.
exceptionHelperNotMandatory
(
nsc
.
getModifiedTime
(),
"dd/MM/yyyy HH:mm:ss"
,
"nsc modifiedTime"
);
}
}
}
catch
(
Exception
ex
)
{
Logger
.
getLogger
(
DGIInvoiceNjbNscRESTController
.
class
.
getName
()).
log
(
Level
.
SEVERE
,
null
,
ex
);
ResponseErrorDTO
res
=
new
ResponseErrorDTO
();
res
.
setMessage
(
ex
.
getMessage
());
res
.
setStatus
(
HttpStatus
.
BAD_REQUEST
.
value
());
res
.
setError
(
HttpStatus
.
BAD_REQUEST
.
getReasonPhrase
());
return
ResponseEntity
.
badRequest
().
body
(
res
);
}
return
pullService
.
postWorkOrderOrafin
(
dto
);
}
}
}
src/main/java/com/eksad/masterdata/controller/apidgi/managepartsales/DGIManagePartSalesRESTController.java
0 → 100644
View file @
aefc1024
package
com
.
eksad
.
masterdata
.
controller
.
apidgi
.
managepartsales
;
import
com.eksad.ddms.common.h2.dto.ui.ResponseErrorDTO
;
import
com.eksad.ddms.common.h3.dto.managepartsales.HeaderSOManagePartSalesDTO
;
import
com.eksad.ddms.common.h3.dto.managepartsales.ParamManageSalesDTO
;
import
com.eksad.ddms.common.h3.dto.managepartsales.ResponseManagePartSalesDTO
;
import
com.eksad.ddms.masterdata.h3.dto.dgi.DealerGroupMappingNewDTO
;
import
com.eksad.ddms.masterdata.h3.dto.dgi.DgiResponseDTO
;
import
com.eksad.masterdata.service.DGIService
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.MediaType
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.web.bind.annotation.*
;
import
java.text.ParseException
;
import
java.util.*
;
import
java.util.logging.Level
;
import
java.util.logging.Logger
;
@RestController
@Slf4j
public
class
DGIManagePartSalesRESTController
{
@Autowired
DGIService
pullService
;
@RequestMapping
(
value
=
"/dgi-api/v1/prsl/read"
,
method
=
RequestMethod
.
POST
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<
Object
>
getSO
(
@RequestHeader
(
"GvtDealerId"
)
String
dealerId
,
@RequestBody
ParamManageSalesDTO
dto
)
throws
ParseException
{
try
{
System
.
out
.
println
(
new
ObjectMapper
().
writeValueAsString
(
dto
));
pullService
.
exceptionHelper
(
dto
.
getFromTime
(),
"yyyy-MM-dd HH:mm:ss"
,
"fromTime"
);
pullService
.
exceptionHelperNotMandatory
(
dto
.
getToTime
(),
"yyyy-MM-dd HH:mm:ss"
,
"toTime"
);
if
(
pullService
.
isNotValidDate
(
dto
.
getFromTime
())){
throw
new
Exception
(
"format toTime tidak sesuai, seharusnya YYYY-MM-DD hh:mm:ss"
);
}
else
if
(
pullService
.
isNotValidDate
(
dto
.
getToTime
())){
throw
new
Exception
(
"format toTime tidak sesuai, seharusnya YYYY-MM-DD hh:mm:ss"
);
}
pullService
.
checkToTimeIs7Days
(
dto
.
getFromTime
(),
dto
.
getToTime
());
pullService
.
dealerValidation
(
dealerId
,
dto
.
getDealerId
());
}
catch
(
Exception
ex
)
{
Logger
.
getLogger
(
DGIManagePartSalesRESTController
.
class
.
getName
()).
log
(
Level
.
SEVERE
,
null
,
ex
);
ResponseErrorDTO
res
=
new
ResponseErrorDTO
();
res
.
setMessage
(
ex
.
getMessage
());
res
.
setStatus
(
HttpStatus
.
BAD_REQUEST
.
value
());
res
.
setError
(
HttpStatus
.
BAD_REQUEST
.
getReasonPhrase
());
return
ResponseEntity
.
badRequest
().
body
(
res
);
}
return
pullService
.
postRequestPullManagePartSales
(
dto
);
}
@RequestMapping
(
value
=
"/dgi-api/v1.3/prsl/read"
,
method
=
RequestMethod
.
POST
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<
Object
>
getSO
(
@RequestHeader
(
"GvtDealerId"
)
String
dealerId
,
@RequestBody
ParamManageSalesDTO
dto
,
Boolean
dgi
)
throws
ParseException
{
try
{
// if(StringUtil.hasValue(dto.getDealerId()) && StringUtil.hasValue(dto.getNoSO())){
System
.
out
.
println
(
new
ObjectMapper
().
writeValueAsString
(
dto
));
pullService
.
exceptionHelper
(
dto
.
getFromTime
(),
"yyyy-MM-dd HH:mm:ss"
,
"fromTime"
);
pullService
.
exceptionHelperNotMandatory
(
dto
.
getToTime
(),
"yyyy-MM-dd HH:mm:ss"
,
"toTime"
);
if
(
pullService
.
isNotValidDate
(
dto
.
getFromTime
()))
{
throw
new
Exception
(
"format toTime tidak sesuai, seharusnya YYYY-MM-DD hh:mm:ss"
);
}
else
if
(
pullService
.
isNotValidDate
(
dto
.
getToTime
()))
{
throw
new
Exception
(
"format toTime tidak sesuai, seharusnya YYYY-MM-DD hh:mm:ss"
);
}
pullService
.
checkToTimeIs7Days
(
dto
.
getFromTime
(),
dto
.
getToTime
());
System
.
out
.
println
(
"disini payload dgi-api/v1.3/prsl/read"
+
new
ObjectMapper
().
writeValueAsString
(
dto
));
DgiResponseDTO
dgiNew
=
pullService
.
dgiv1_3Validator
(
dto
.
getDealerId
(),
dealerId
);
System
.
out
.
println
(
"v1.3 prsl/read"
);
System
.
out
.
println
(
new
ObjectMapper
().
writeValueAsString
(
dgiNew
));
if
(
dgiNew
.
getStatus
().
equals
(
0
)
||
dgiNew
.
getStatus
().
equals
(
"0"
))
{
//return here
return
ResponseEntity
.
ok
().
body
(
dgiNew
);
}
List
<?>
dataDgi
=
dgiNew
.
getData
();
List
<
DealerGroupMappingNewDTO
>
ob
=
Arrays
.
asList
(
new
ObjectMapper
().
convertValue
(
dataDgi
.
toArray
(),
DealerGroupMappingNewDTO
[].
class
));
List
<
HeaderSOManagePartSalesDTO
>
data
=
new
ArrayList
<>();
List
<
String
>
listDealer
=
new
ArrayList
<>();
ob
.
forEach
(
x
->
{
listDealer
.
add
(
x
.
getDealerAhmCode
());
});
for
(
String
y:
listDealer
){
dto
.
setDealerId
(
y
);
ResponseManagePartSalesDTO
pullManagePartSales
=
new
ResponseManagePartSalesDTO
();
pullManagePartSales
=
pullService
.
postRequestPullManagePartSales_v1_3
(
dto
);
System
.
out
.
println
(
"v1.3/prsl/read "
+
new
ObjectMapper
().
writeValueAsString
(
pullManagePartSales
));
if
(
pullManagePartSales
!=
null
&&
pullManagePartSales
.
getData
()
!=
null
&&
!
pullManagePartSales
.
getData
().
isEmpty
())
{
data
.
addAll
(
pullManagePartSales
.
getData
());
}
}
if
(
data
.
isEmpty
())
{
dgiNew
.
setStatus
(
1
);
dgiNew
.
setData
(
null
);
dgiNew
.
putError
(
"data tidak ditemukan"
);
return
ResponseEntity
.
ok
(
dgiNew
);
}
Map
<
String
,
HeaderSOManagePartSalesDTO
>
map
=
new
HashMap
<>();
data
.
forEach
(
x
->
map
.
put
(
x
.
getNoSO
(),
x
));
List
<
HeaderSOManagePartSalesDTO
>
listDataDistinct
=
new
ArrayList
<>(
map
.
values
());
dgiNew
.
setData
(
listDataDistinct
);
return
ResponseEntity
.
ok
(
dgiNew
);
}
catch
(
Exception
ex
)
{
Logger
.
getLogger
(
DGIManagePartSalesRESTController
.
class
.
getName
()).
log
(
Level
.
SEVERE
,
null
,
ex
);
ResponseErrorDTO
res
=
new
ResponseErrorDTO
();
res
.
setMessage
(
ex
.
getMessage
());
res
.
setStatus
(
0
);
res
.
setError
(
HttpStatus
.
BAD_REQUEST
.
getReasonPhrase
());
return
ResponseEntity
.
badRequest
().
body
(
res
);
}
}
}
src/main/java/com/eksad/masterdata/controller/apidgi/managewo/DGIManageWORESTController.java
0 → 100644
View file @
aefc1024
package
com
.
eksad
.
masterdata
.
controller
.
apidgi
.
managewo
;
import
com.eksad.ddms.common.h2.dto.apigateway.ManageWorkOrderParamDTO
;
import
com.eksad.ddms.common.h2.dto.ui.ResponseErrorDTO
;
import
com.eksad.ddms.common.h3.dto.managepartinbounds.PartsManageInboundParamDTO
;
import
com.eksad.ddms.common.h3.dto.managepartinbounds.ReceivingManagePartsInboundDTO
;
import
com.eksad.ddms.common.h3.dto.managepartinbounds.ResponseManagePartsInboundDTO
;
import
com.eksad.ddms.masterdata.h3.dto.dgi.DealerGroupMappingNewDTO
;
import
com.eksad.ddms.masterdata.h3.dto.dgi.DgiResponseDTO
;
import
com.eksad.masterdata.service.DGIService
;
import
com.fasterxml.jackson.core.JsonProcessingException
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.MediaType
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.web.bind.annotation.*
;
import
java.text.ParseException
;
import
java.util.*
;
import
java.util.logging.Level
;
import
java.util.logging.Logger
;
@RestController
@Slf4j
public
class
DGIManageWORESTController
{
@Autowired
DGIService
pullService
;
@RequestMapping
(
value
=
"/dgi-api/v1/pkb/read"
,
method
=
RequestMethod
.
POST
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<
Object
>
ManageWorkOrderAPIGATEWAYV1
(
@RequestHeader
(
"GvtDealerId"
)
String
dealerId
,
@RequestBody
ManageWorkOrderParamDTO
dto
)
throws
ParseException
{
try
{
// if(StringUtil.hasValue(dto.getNoWorkOrder())){
System
.
out
.
println
(
new
ObjectMapper
().
writeValueAsString
(
dto
));
pullService
.
exceptionHelper
(
dto
.
getFromTime
(),
"yyyy-MM-dd HH:mm:ss"
,
"fromTime"
);
pullService
.
exceptionHelperNotMandatory
(
dto
.
getToTime
(),
"yyyy-MM-dd HH:mm:ss"
,
"toTime"
);
if
(
pullService
.
isNotValidDate
(
dto
.
getFromTime
()))
{
throw
new
Exception
(
"format toTime tidak sesuai, seharusnya YYYY-MM-DD hh:mm:ss"
);
}
else
if
(
pullService
.
isNotValidDate
(
dto
.
getToTime
()))
{
throw
new
Exception
(
"format toTime tidak sesuai, seharusnya YYYY-MM-DD hh:mm:ss"
);
}
pullService
.
checkToTimeIs7Days
(
dto
.
getFromTime
(),
dto
.
getToTime
());
pullService
.
dealerValidation
(
dealerId
,
dto
.
getDealerId
());
}
catch
(
Exception
ex
)
{
Logger
.
getLogger
(
DGIManageWORESTController
.
class
.
getName
()).
log
(
Level
.
SEVERE
,
null
,
ex
);
ResponseErrorDTO
res
=
new
ResponseErrorDTO
();
res
.
setMessage
(
ex
.
getMessage
());
res
.
setStatus
(
HttpStatus
.
BAD_REQUEST
.
value
());
res
.
setError
(
HttpStatus
.
BAD_REQUEST
.
getReasonPhrase
());
return
ResponseEntity
.
badRequest
().
body
(
res
);
}
return
pullService
.
postRequestPullManageWorkOrder
(
dto
);
}
@RequestMapping
(
value
=
"/dgi-api/v1.3/pinb/read"
,
method
=
RequestMethod
.
POST
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<
Object
>
getPartManageInbound
(
@RequestHeader
(
"GvtDealerId"
)
String
dealerId
,
@RequestBody
PartsManageInboundParamDTO
dto
,
Boolean
dgi
)
throws
ParseException
,
JsonProcessingException
{
try
{
pullService
.
exceptionHelper
(
dto
.
getFromTime
(),
"yyyy-MM-dd HH:mm:ss"
,
"fromTime"
);
pullService
.
exceptionHelperNotMandatory
(
dto
.
getToTime
(),
"yyyy-MM-dd HH:mm:ss"
,
"toTime"
);
if
(
pullService
.
isNotValidDate
(
dto
.
getFromTime
()))
{
throw
new
Exception
(
"format toTime tidak sesuai, seharusnya YYYY-MM-DD hh:mm:ss"
);
}
else
if
(
pullService
.
isNotValidDate
(
dto
.
getToTime
()))
{
throw
new
Exception
(
"format toTime tidak sesuai, seharusnya YYYY-MM-DD hh:mm:ss"
);
}
pullService
.
checkToTimeIs7Days
(
dto
.
getFromTime
(),
dto
.
getToTime
());
System
.
out
.
println
(
"disini payload dgi-api/v1.3/pinb/read"
+
new
ObjectMapper
().
writeValueAsString
(
dto
));
DgiResponseDTO
dgiNew
=
pullService
.
dgiv1_3Validator
(
dto
.
getDealerId
(),
dealerId
);
System
.
out
.
println
(
"v1.3 pinb/read"
);
System
.
out
.
println
(
new
ObjectMapper
().
writeValueAsString
(
dgiNew
));
if
(
dgiNew
.
getStatus
().
equals
(
0
)
||
dgiNew
.
getStatus
().
equals
(
"0"
))
{
//return here
return
ResponseEntity
.
ok
().
body
(
dgiNew
);
}
List
<?>
dataDgi
=
dgiNew
.
getData
();
List
<
DealerGroupMappingNewDTO
>
ob
=
Arrays
.
asList
(
new
ObjectMapper
().
convertValue
(
dataDgi
.
toArray
(),
DealerGroupMappingNewDTO
[].
class
));
List
<
ReceivingManagePartsInboundDTO
>
data
=
new
ArrayList
<>();
System
.
out
.
println
(
"ddd"
+
new
ObjectMapper
().
writeValueAsString
(
ob
));
List
<
String
>
dealerList
=
new
ArrayList
<>();
ob
.
forEach
(
x
->
{
dealerList
.
add
(
x
.
getDealerAhmCode
());
});
System
.
out
.
println
(
"dealerList "
+
new
ObjectMapper
().
writeValueAsString
(
dealerList
));
for
(
String
y
:
dealerList
)
{
dto
.
setDealerId
(
y
);
ResponseManagePartsInboundDTO
pullManagePartInbound
=
pullService
.
postRequestPullManagePartInbound_v1_3
(
dto
);
if
(
pullManagePartInbound
!=
null
||
pullManagePartInbound
.
getData
()
!=
null
||
!
pullManagePartInbound
.
getData
().
isEmpty
()){
data
.
addAll
(
pullManagePartInbound
.
getData
());
}
}
if
(
data
.
isEmpty
())
{
dgiNew
.
setStatus
(
1
);
dgiNew
.
setData
(
null
);
dgiNew
.
putError
(
"data tidak ditemukan"
);
return
ResponseEntity
.
ok
(
dgiNew
);
}
Map
<
String
,
ReceivingManagePartsInboundDTO
>
map
=
new
HashMap
<>();
data
.
forEach
(
x
->
map
.
put
(
x
.
getNoPenerimaan
(),
x
));
List
<
ReceivingManagePartsInboundDTO
>
listDataDistinct
=
new
ArrayList
<>(
map
.
values
());
dgiNew
.
setData
(
listDataDistinct
);
return
ResponseEntity
.
ok
(
dgiNew
);
}
catch
(
Exception
ex
)
{
Logger
.
getLogger
(
DGIManageWORESTController
.
class
.
getName
()).
log
(
Level
.
SEVERE
,
null
,
ex
);
ResponseErrorDTO
res
=
new
ResponseErrorDTO
();
res
.
setMessage
(
ex
.
getMessage
());
// res.setStatus(HttpStatus.BAD_REQUEST.value());
res
.
setStatus
(
0
);
res
.
setError
(
HttpStatus
.
BAD_REQUEST
.
getReasonPhrase
());
return
ResponseEntity
.
badRequest
().
body
(
res
);
}
}
}
src/main/java/com/eksad/masterdata/controller/apidgi/partinbound/DGIPartInboundRESTController.java
0 → 100644
View file @
aefc1024
package
com
.
eksad
.
masterdata
.
controller
.
apidgi
.
partinbound
;
import
com.eksad.ddms.common.h2.dto.ui.ResponseErrorDTO
;
import
com.eksad.ddms.common.h3.dto.managepartinbounds.PartsManageInboundParamDTO
;
import
com.eksad.ddms.common.h3.dto.managepartinbounds.ReceivingManagePartsInboundDTO
;
import
com.eksad.ddms.common.h3.dto.managepartinbounds.ResponseManagePartsInboundDTO
;
import
com.eksad.ddms.masterdata.h3.dto.dgi.DealerGroupMappingNewDTO
;
import
com.eksad.ddms.masterdata.h3.dto.dgi.DgiResponseDTO
;
import
com.eksad.masterdata.service.DGIService
;
import
com.fasterxml.jackson.core.JsonProcessingException
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.MediaType
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.web.bind.annotation.*
;
import
java.text.ParseException
;
import
java.util.*
;
import
java.util.logging.Level
;
import
java.util.logging.Logger
;
@RestController
@Slf4j
public
class
DGIPartInboundRESTController
{
@Autowired
DGIService
pullService
;
@RequestMapping
(
value
=
"/dgi-api/v1/pinb/read"
,
method
=
RequestMethod
.
POST
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<
Object
>
getPartManageInbound
(
@RequestHeader
(
"GvtDealerId"
)
String
dealerId
,
@RequestBody
PartsManageInboundParamDTO
dto
)
throws
ParseException
,
JsonProcessingException
{
try
{
System
.
out
.
println
(
new
ObjectMapper
().
writeValueAsString
(
dto
));
pullService
.
exceptionHelper
(
dto
.
getFromTime
(),
"yyyy-MM-dd HH:mm:ss"
,
"fromTime"
);
pullService
.
exceptionHelperNotMandatory
(
dto
.
getToTime
(),
"yyyy-MM-dd HH:mm:ss"
,
"toTime"
);
if
(
pullService
.
isNotValidDate
(
dto
.
getFromTime
()))
{
throw
new
Exception
(
"format toTime tidak sesuai, seharusnya YYYY-MM-DD hh:mm:ss"
);
}
else
if
(
pullService
.
isNotValidDate
(
dto
.
getToTime
()))
{
throw
new
Exception
(
"format toTime tidak sesuai, seharusnya YYYY-MM-DD hh:mm:ss"
);
}
pullService
.
checkToTimeIs7Days
(
dto
.
getFromTime
(),
dto
.
getToTime
());
pullService
.
dealerValidation
(
dealerId
,
dto
.
getDealerId
());
}
catch
(
Exception
ex
)
{
Logger
.
getLogger
(
DGIPartInboundRESTController
.
class
.
getName
()).
log
(
Level
.
SEVERE
,
null
,
ex
);
ResponseErrorDTO
res
=
new
ResponseErrorDTO
();
res
.
setMessage
(
ex
.
getMessage
());
res
.
setStatus
(
HttpStatus
.
BAD_REQUEST
.
value
());
res
.
setError
(
HttpStatus
.
BAD_REQUEST
.
getReasonPhrase
());
return
ResponseEntity
.
badRequest
().
body
(
res
);
}
return
pullService
.
postRequestPullManagePartInbound
(
dto
);
// return null;
}
@RequestMapping
(
value
=
"/dgi-api/v1.3/pinb/read"
,
method
=
RequestMethod
.
POST
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<
Object
>
getPartManageInbound
(
@RequestHeader
(
"GvtDealerId"
)
String
dealerId
,
@RequestBody
PartsManageInboundParamDTO
dto
,
Boolean
dgi
)
throws
ParseException
,
JsonProcessingException
{
try
{
pullService
.
exceptionHelper
(
dto
.
getFromTime
(),
"yyyy-MM-dd HH:mm:ss"
,
"fromTime"
);
pullService
.
exceptionHelperNotMandatory
(
dto
.
getToTime
(),
"yyyy-MM-dd HH:mm:ss"
,
"toTime"
);
if
(
pullService
.
isNotValidDate
(
dto
.
getFromTime
()))
{
throw
new
Exception
(
"format toTime tidak sesuai, seharusnya YYYY-MM-DD hh:mm:ss"
);
}
else
if
(
pullService
.
isNotValidDate
(
dto
.
getToTime
()))
{
throw
new
Exception
(
"format toTime tidak sesuai, seharusnya YYYY-MM-DD hh:mm:ss"
);
}
pullService
.
checkToTimeIs7Days
(
dto
.
getFromTime
(),
dto
.
getToTime
());
System
.
out
.
println
(
"disini payload dgi-api/v1.3/pinb/read"
+
new
ObjectMapper
().
writeValueAsString
(
dto
));
DgiResponseDTO
dgiNew
=
pullService
.
dgiv1_3Validator
(
dto
.
getDealerId
(),
dealerId
);
System
.
out
.
println
(
"v1.3 pinb/read"
);
System
.
out
.
println
(
new
ObjectMapper
().
writeValueAsString
(
dgiNew
));
if
(
dgiNew
.
getStatus
().
equals
(
0
)
||
dgiNew
.
getStatus
().
equals
(
"0"
))
{
//return here
return
ResponseEntity
.
ok
().
body
(
dgiNew
);
}
List
<?>
dataDgi
=
dgiNew
.
getData
();
List
<
DealerGroupMappingNewDTO
>
ob
=
Arrays
.
asList
(
new
ObjectMapper
().
convertValue
(
dataDgi
.
toArray
(),
DealerGroupMappingNewDTO
[].
class
));
List
<
ReceivingManagePartsInboundDTO
>
data
=
new
ArrayList
<>();
System
.
out
.
println
(
"ddd"
+
new
ObjectMapper
().
writeValueAsString
(
ob
));
List
<
String
>
dealerList
=
new
ArrayList
<>();
ob
.
forEach
(
x
->
{
dealerList
.
add
(
x
.
getDealerAhmCode
());
});
System
.
out
.
println
(
"dealerList "
+
new
ObjectMapper
().
writeValueAsString
(
dealerList
));
for
(
String
y
:
dealerList
)
{
dto
.
setDealerId
(
y
);
ResponseManagePartsInboundDTO
pullManagePartInbound
=
pullService
.
postRequestPullManagePartInbound_v1_3
(
dto
);
if
(
pullManagePartInbound
!=
null
||
pullManagePartInbound
.
getData
()
!=
null
||
!
pullManagePartInbound
.
getData
().
isEmpty
()){
data
.
addAll
(
pullManagePartInbound
.
getData
());
}
}
if
(
data
.
isEmpty
())
{
dgiNew
.
setStatus
(
1
);
dgiNew
.
setData
(
null
);
dgiNew
.
putError
(
"data tidak ditemukan"
);
return
ResponseEntity
.
ok
(
dgiNew
);
}
Map
<
String
,
ReceivingManagePartsInboundDTO
>
map
=
new
HashMap
<>();
data
.
forEach
(
x
->
map
.
put
(
x
.
getNoPenerimaan
(),
x
));
List
<
ReceivingManagePartsInboundDTO
>
listDataDistinct
=
new
ArrayList
<>(
map
.
values
());
dgiNew
.
setData
(
listDataDistinct
);
return
ResponseEntity
.
ok
(
dgiNew
);
}
catch
(
Exception
ex
)
{
Logger
.
getLogger
(
DGIPartInboundRESTController
.
class
.
getName
()).
log
(
Level
.
SEVERE
,
null
,
ex
);
ResponseErrorDTO
res
=
new
ResponseErrorDTO
();
res
.
setMessage
(
ex
.
getMessage
());
// res.setStatus(HttpStatus.BAD_REQUEST.value());
res
.
setStatus
(
0
);
res
.
setError
(
HttpStatus
.
BAD_REQUEST
.
getReasonPhrase
());
return
ResponseEntity
.
badRequest
().
body
(
res
);
}
}
}
src/main/java/com/eksad/masterdata/controller/apidgi/partinvoice/DGIPartInvoiceRESTController.java
0 → 100644
View file @
aefc1024
package
com
.
eksad
.
masterdata
.
controller
.
apidgi
.
partinvoice
;
import
com.eksad.ddms.masterdata.h3.dto.dgi.*
;
import
com.eksad.masterdata.service.DGIService
;
import
com.fasterxml.jackson.core.JsonProcessingException
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.web.bind.annotation.*
;
import
java.time.LocalDateTime
;
import
java.time.format.DateTimeFormatter
;
import
java.time.format.DateTimeParseException
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.LinkedHashMap
;
import
java.util.List
;
import
static
java
.
time
.
temporal
.
ChronoUnit
.
DAYS
;
@RestController
@Slf4j
public
class
DGIPartInvoiceRESTController
{
@Autowired
DGIService
pullService
;
@RequestMapping
(
value
=
"/dgi-api/v1.3/mdinvh3/read"
,
method
=
RequestMethod
.
POST
)
public
ResponseEntity
<?>
getPartsInvoice
(
@RequestHeader
(
"GvtDealerId"
)
String
dealerID
,
@RequestBody
PartsInvoiceRequestDTO
request
,
Boolean
dgi
)
throws
Exception
{
PartsInvoiceResponseDTO
response
=
new
PartsInvoiceResponseDTO
();
DateTimeFormatter
dateTimeFormatter
=
DateTimeFormatter
.
ofPattern
(
"yyyy-MM-dd HH:mm:ss"
);
LinkedHashMap
<
String
,
String
>
errorList
=
new
LinkedHashMap
<>();
Integer
errorNumber
=
0
;
DgiResponseDTO
dgiNew
=
new
DgiResponseDTO
();
System
.
out
.
println
(
"disini payload dgi-api/v1.3/mdinvh3/read "
+
new
ObjectMapper
().
writeValueAsString
(
request
));
dgiNew
=
pullService
.
dgiv1_3Validator
(
request
.
getDealerId
(),
dealerID
);
System
.
out
.
println
(
"v1.3 mdinvh3/read"
);
System
.
out
.
println
(
new
ObjectMapper
().
writeValueAsString
(
dgiNew
));
if
(
dgiNew
.
getStatus
().
equals
(
0
)
||
dgiNew
.
getStatus
().
equals
(
"0"
))
{
//return here
return
ResponseEntity
.
ok
().
body
(
dgiNew
);
}
List
<
String
>
groupDealer
=
new
ArrayList
<>();
List
<?>
dataDgi
=
dgiNew
.
getData
();
List
<
DealerGroupMappingNewDTO
>
ob
=
Arrays
.
asList
(
new
ObjectMapper
().
convertValue
(
dataDgi
.
toArray
(),
DealerGroupMappingNewDTO
[].
class
));
ob
.
forEach
(
x
->
{
groupDealer
.
add
(
x
.
getDealerAhmCode
());
});
//Validasi fromTime
if
(
request
.
getFromTime
()
==
null
)
{
errorNumber
++;
errorList
.
put
(
"message"
+
errorNumber
,
"fromTime tidak boleh kosong"
);
}
else
{
String
fromTime
=
request
.
getFromTime
();
try
{
LocalDateTime
localFromTime
=
LocalDateTime
.
parse
(
fromTime
,
dateTimeFormatter
);
}
catch
(
DateTimeParseException
dte
)
{
errorNumber
++;
errorList
.
put
(
"message"
+
errorNumber
,
"Format fromTime salah. Seharusnya yyyy-MM-dd HH:mm:ss"
);
}
}
//Validasi toTime
if
(
request
.
getToTime
()
==
null
)
{
LocalDateTime
currTime
=
LocalDateTime
.
now
();
String
formattedDate
=
currTime
.
format
(
dateTimeFormatter
);
request
.
setToTime
(
formattedDate
);
}
else
{
String
toTime
=
request
.
getToTime
();
try
{
LocalDateTime
localFromTime
=
LocalDateTime
.
parse
(
toTime
,
dateTimeFormatter
);
}
catch
(
DateTimeParseException
dte
)
{
errorNumber
++;
errorList
.
put
(
"message"
+
errorNumber
,
"Format toTime salah. Seharusnya yyyy-MM-dd HH:mm:ss"
);
}
}
//Validasi range
if
(
request
.
getFromTime
()
!=
null
&&
request
.
getToTime
()
!=
null
)
{
try
{
LocalDateTime
localfTime
=
LocalDateTime
.
parse
(
request
.
getFromTime
(),
dateTimeFormatter
);
LocalDateTime
localtTime
=
LocalDateTime
.
parse
(
request
.
getToTime
(),
dateTimeFormatter
);
Long
daysBetween
=
DAYS
.
between
(
localfTime
,
localtTime
);
if
(
daysBetween
>
7
)
{
errorNumber
++;
errorList
.
put
(
"message"
+
errorNumber
,
"Range hari tidak boleh lebih dari 7 hari"
);
}
if
(
localfTime
.
isAfter
(
localtTime
))
{
errorNumber
++;
errorList
.
put
(
"message"
+
errorNumber
,
"toTime tidak boleh sebelum fromTime"
);
}
}
catch
(
DateTimeParseException
dte
)
{
}
}
if
(
errorNumber
>
0
)
{
dgiNew
.
setStatus
(
0
);
dgiNew
.
setMessage
(
errorList
);
dgiNew
.
setData
(
null
);
return
ResponseEntity
.
ok
(
dgiNew
);
}
List
<
PartsInvoiceDataDTO
>
dataRes
=
new
ArrayList
<>();
for
(
String
y
:
groupDealer
)
{
request
.
setDealerId
(
y
);
request
.
setNoPO
(
request
.
getNoPO
()==
null
?
""
:
request
.
getNoPO
());
PartsInvoiceResponseDTO
dd
=
pullService
.
postPortalDamParts
(
request
);
try
{
System
.
out
.
println
(
"dimarih "
+
new
ObjectMapper
().
writeValueAsString
(
dd
));
}
catch
(
JsonProcessingException
e
)
{
throw
new
RuntimeException
(
e
);
}
if
(
dd
!=
null
&&
dd
.
getData
()
!=
null
)
{
if
(!
dd
.
getData
().
isEmpty
())
{
dataRes
.
addAll
(
dd
.
getData
());
}
}
}
dgiNew
.
setStatus
(
1
);
dgiNew
.
setMessage
(
null
);
if
(
dataRes
.
isEmpty
()){
dgiNew
.
setData
(
null
);
dgiNew
.
putError
(
"data tidak ditemukan"
);
}
else
{
dgiNew
.
setData
(
dataRes
);
}
return
ResponseEntity
.
ok
(
dgiNew
);
}
}
src/main/java/com/eksad/masterdata/controller/apidgi/unpaidhlo/DGIUnpaidHLORESTController.java
0 → 100644
View file @
aefc1024
package
com
.
eksad
.
masterdata
.
controller
.
apidgi
.
unpaidhlo
;
import
com.eksad.ddms.common.h2.dto.apigateway.UnpaidDPHLOPullHeaderV2ResponseDTO
;
import
com.eksad.ddms.common.h2.dto.apigateway.UnpaidDPHLOPullParamDTO
;
import
com.eksad.ddms.common.h2.dto.apigateway.UnpaidDPHLOPullResponseDTO
;
import
com.eksad.ddms.common.h2.dto.ui.ResponseErrorDTO
;
import
com.eksad.ddms.masterdata.h3.dto.dgi.DealerGroupMappingNewDTO
;
import
com.eksad.ddms.masterdata.h3.dto.dgi.DgiResponseDTO
;
import
com.eksad.masterdata.service.DGIService
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.MediaType
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestHeader
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
java.text.ParseException
;
import
java.util.*
;
import
java.util.logging.Level
;
import
java.util.logging.Logger
;
public
class
DGIUnpaidHLORESTController
{
@Autowired
DGIService
pullService
;
@RequestMapping
(
value
=
"/dgi-api/v1/unpaidhlo/read"
,
method
=
RequestMethod
.
POST
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<?>
UnpaidDPHLOApigateway
(
@RequestHeader
(
"GvtDealerId"
)
String
dealerId
,
@RequestBody
UnpaidDPHLOPullParamDTO
dto
)
throws
ParseException
{
try
{
System
.
out
.
println
(
new
ObjectMapper
().
writeValueAsString
(
dto
));
pullService
.
exceptionHelper
(
dto
.
getFromTime
(),
"yyyy-MM-dd HH:mm:ss"
,
"fromTime"
);
pullService
.
exceptionHelperNotMandatory
(
dto
.
getToTime
(),
"yyyy-MM-dd HH:mm:ss"
,
"toTime"
);
if
(
pullService
.
isNotValidDate
(
dto
.
getFromTime
())){
throw
new
Exception
(
"format toTime tidak sesuai, seharusnya YYYY-MM-DD hh:mm:ss"
);
}
else
if
(
pullService
.
isNotValidDate
(
dto
.
getToTime
())){
throw
new
Exception
(
"format toTime tidak sesuai, seharusnya YYYY-MM-DD hh:mm:ss"
);
}
pullService
.
checkToTimeIs7Days
(
dto
.
getFromTime
(),
dto
.
getToTime
());
pullService
.
dealerValidation
(
dealerId
,
dto
.
getDealerId
());
}
catch
(
Exception
ex
)
{
Logger
.
getLogger
(
DGIUnpaidHLORESTController
.
class
.
getName
()).
log
(
Level
.
SEVERE
,
null
,
ex
);
ResponseErrorDTO
res
=
new
ResponseErrorDTO
();
res
.
setMessage
(
ex
.
getMessage
());
res
.
setStatus
(
HttpStatus
.
BAD_REQUEST
.
value
());
res
.
setError
(
HttpStatus
.
BAD_REQUEST
.
getReasonPhrase
());
return
ResponseEntity
.
badRequest
().
body
(
res
);
}
return
pullService
.
postRequestPullUnpaidHLO
(
dto
);
}
@RequestMapping
(
value
=
"/dgi-api/v1.3/unpaidhlo/read"
,
method
=
RequestMethod
.
POST
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<?>
UnpaidDPHLOApigatewayIn
(
@RequestHeader
(
"GvtDealerId"
)
String
dealerId
,
@RequestBody
UnpaidDPHLOPullParamDTO
dto
)
throws
ParseException
{
try
{
System
.
out
.
println
(
new
ObjectMapper
().
writeValueAsString
(
dto
));
pullService
.
exceptionHelper
(
dto
.
getFromTime
(),
"yyyy-MM-dd HH:mm:ss"
,
"fromTime"
);
pullService
.
exceptionHelperNotMandatory
(
dto
.
getToTime
(),
"yyyy-MM-dd HH:mm:ss"
,
"toTime"
);
if
(
pullService
.
isNotValidDate
(
dto
.
getFromTime
())){
throw
new
Exception
(
"format toTime tidak sesuai, seharusnya YYYY-MM-DD hh:mm:ss"
);
}
else
if
(
pullService
.
isNotValidDate
(
dto
.
getToTime
())){
throw
new
Exception
(
"format toTime tidak sesuai, seharusnya YYYY-MM-DD hh:mm:ss"
);
}
pullService
.
checkToTimeIs7Days
(
dto
.
getFromTime
(),
dto
.
getToTime
());
System
.
out
.
println
(
"disini payload dgi-api/v1.3/unpaidhlo/read"
+
new
ObjectMapper
().
writeValueAsString
(
dto
));
DgiResponseDTO
dgiNew
=
pullService
.
dgiv1_3Validator
(
dto
.
getDealerId
(),
dealerId
);
System
.
out
.
println
(
"v1.3 unpaidhlo/read"
);
System
.
out
.
println
(
new
ObjectMapper
().
writeValueAsString
(
dgiNew
));
if
(
dgiNew
.
getStatus
().
equals
(
0
)
||
dgiNew
.
getStatus
().
equals
(
"0"
))
{
//return here
return
ResponseEntity
.
ok
().
body
(
dgiNew
);
}
List
<?>
dataDgi
=
dgiNew
.
getData
();
List
<
DealerGroupMappingNewDTO
>
ob
=
Arrays
.
asList
(
new
ObjectMapper
().
convertValue
(
dataDgi
.
toArray
(),
DealerGroupMappingNewDTO
[].
class
));
List
<
String
>
dealerList
=
new
ArrayList
<>();
ob
.
forEach
(
x
->
{
dealerList
.
add
(
x
.
getDealerAhmCode
());
});
System
.
out
.
println
(
"dealerList "
+
new
ObjectMapper
().
writeValueAsString
(
dealerList
));
UnpaidDPHLOPullHeaderV2ResponseDTO
res
=
new
UnpaidDPHLOPullHeaderV2ResponseDTO
();
List
<
UnpaidDPHLOPullResponseDTO
>
listData
=
new
ArrayList
<>();
for
(
String
y
:
dealerList
)
{
dto
.
setDealerId
(
y
);
List
<
UnpaidDPHLOPullResponseDTO
>
listRes
=
pullService
.
postRequestPullUnpaidHLO
(
dto
).
getBody
().
getData
();
listData
.
addAll
(
listRes
!=
null
?
listRes
:
new
ArrayList
<>());
}
Map
<
String
,
UnpaidDPHLOPullResponseDTO
>
map
=
new
HashMap
<>();
listData
.
forEach
(
x
->
map
.
put
(
x
.
getIdHLODocument
(),
x
));
List
<
UnpaidDPHLOPullResponseDTO
>
listDataDistinct
=
new
ArrayList
<>(
map
.
values
());
if
(
listData
.
isEmpty
()){
res
.
setMessage
(
"Terdapat kesalahan, Data Tidak Dapat Ditemukan"
);
res
.
setStatus
(
0
);
res
.
setData
(
null
);
}
else
{
res
.
setStatus
(
1
);
res
.
setMessage
(
null
);
res
.
setData
(
listDataDistinct
);
}
return
ResponseEntity
.
status
(
HttpStatus
.
OK
).
body
(
res
);
}
catch
(
Exception
ex
)
{
Logger
.
getLogger
(
DGIUnpaidHLORESTController
.
class
.
getName
()).
log
(
Level
.
SEVERE
,
null
,
ex
);
ResponseErrorDTO
res
=
new
ResponseErrorDTO
();
res
.
setMessage
(
ex
.
getMessage
());
// res.setStatus(HttpStatus.BAD_REQUEST.value());
res
.
setStatus
(
0
);
res
.
setError
(
HttpStatus
.
BAD_REQUEST
.
getReasonPhrase
());
return
ResponseEntity
.
badRequest
().
body
(
res
);
}
}
}
src/main/java/com/eksad/masterdata/service/DGIService.java
0 → 100644
View file @
aefc1024
This diff is collapsed.
Click to expand it.
src/main/java/com/eksad/masterdata/service/invoicenjbnsc/DGIInvoiceNjbNscService.java
deleted
100644 → 0
View file @
b2706f2d
package
com
.
eksad
.
masterdata
.
service
.
invoicenjbnsc
;
import
com.eksad.ddms.common.h2.dto.apigateway.request.PullNotaJBSCRequestDTO
;
import
com.eksad.ddms.common.uri.apigateway.APIGatewayURI
;
import
com.eksad.masterdata.common.RequestUtil
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.http.HttpEntity
;
import
org.springframework.http.HttpMethod
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.stereotype.Service
;
import
org.springframework.web.client.RestTemplate
;
import
java.text.DateFormat
;
import
java.text.ParseException
;
import
java.text.SimpleDateFormat
;
import
java.time.Duration
;
import
java.time.LocalDateTime
;
import
java.time.ZoneId
;
import
java.time.format.DateTimeFormatter
;
import
java.util.Date
;
import
java.util.Locale
;
@Service
public
class
DGIInvoiceNjbNscService
{
DateTimeFormatter
dateTimeFormatter
=
DateTimeFormatter
.
ofPattern
(
"yyyy-MM-dd HH:mm:ss"
,
Locale
.
getDefault
());
private
RestTemplate
restTemplate
=
new
RestTemplate
();
@Value
(
"${dam.masterdata.h2}"
)
private
String
md_h2_url
;
@Value
(
"${dam.gigr.h3}"
)
private
String
gigr_h3_url
;
@Value
(
"${dam.custpurch.h3}"
)
private
String
custpurch_h3_url
;
@Autowired
private
RequestUtil
requestUtil
;
public
ResponseEntity
<
Object
>
postRequestPullNJBNSC
(
PullNotaJBSCRequestDTO
dto
)
throws
ParseException
{
Object
data
=
pullNJBNSC
(
dto
);
if
(
data
!=
null
){
return
ResponseEntity
.
status
(
HttpStatus
.
OK
).
body
(
data
);
}
return
null
;
}
private
Object
pullNJBNSC
(
PullNotaJBSCRequestDTO
dto
)
{
ResponseEntity
<
Object
>
response
=
restTemplate
.
exchange
(
md_h2_url
+
APIGatewayURI
.
PULL_NSC_NJB
.
getUri
(),
HttpMethod
.
POST
,
new
HttpEntity
<>(
dto
,
requestUtil
.
getPreFormattedRequestWithToken
().
getHeaders
()),
Object
.
class
);
return
response
.
getBody
();
}
public
void
checkToTimeIs7Days
(
String
fromTime
,
String
toTime
)
throws
Exception
{
DateFormat
dateFormat
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
Date
from
=
dateFormat
.
parse
(
fromTime
);
Date
to
=
dateFormat
.
parse
(
toTime
);
LocalDateTime
fromLocal
=
from
.
toInstant
().
atZone
(
ZoneId
.
of
(
"Asia/Jakarta"
)).
toLocalDateTime
();
LocalDateTime
toLocal
=
to
.
toInstant
().
atZone
(
ZoneId
.
of
(
"Asia/Jakarta"
)).
toLocalDateTime
();
Duration
durasi
=
Duration
.
between
(
fromLocal
,
toLocal
);
long
dayDifference
=
Math
.
abs
(
durasi
.
toHours
());
if
(
dayDifference
>
(
7
*
24
)
+
1
)
{
// if duration greater than 24*7 + 1 hours
throw
new
Exception
(
"tenggat waktu hanya diperbolehkan 7 hari"
);
}
}
public
void
exceptionHelper
(
String
time
,
String
format
,
String
message
)
throws
Exception
{
if
(
time
==
null
||
time
.
trim
().
isEmpty
())
{
throw
new
Exception
(
message
+
" tidak boleh kosong"
);
}
try
{
SimpleDateFormat
dateFormat
=
new
SimpleDateFormat
(
format
);
dateFormat
.
parse
(
time
);
}
catch
(
ParseException
e
)
{
throw
new
Exception
(
"format "
+
message
.
concat
(
" tidak sesuai, seharusnya "
).
concat
(
format
));
}
}
public
void
exceptionHelperNotMandatory
(
String
time
,
String
format
,
String
message
)
throws
Exception
{
if
(
time
!=
null
&&
!
time
.
trim
().
isEmpty
())
{
try
{
SimpleDateFormat
dateFormat
=
new
SimpleDateFormat
(
format
);
dateFormat
.
parse
(
time
);
}
catch
(
ParseException
e
)
{
throw
new
Exception
(
"format "
+
message
.
concat
(
" tidak sesuai, seharusnya "
).
concat
(
format
));
}
}
}
public
boolean
isNotValidDate
(
String
input
)
{
try
{
dateTimeFormatter
.
parse
(
input
);
return
false
;
}
catch
(
Exception
e
)
{
return
true
;
}
}
public
void
dealerValidation
(
String
dealerHeader
,
String
dealerRequest
)
throws
Exception
{
if
(
dealerHeader
!=
null
&&
dealerHeader
!=
dealerRequest
)
{
if
(!
dealerHeader
.
equalsIgnoreCase
(
dealerRequest
))
{
throw
new
Exception
(
"gagal dealerId "
+
dealerRequest
+
" tidak sesuai"
);
}
}
}
}
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