Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
service-campaign
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
Nguyen Ha
service-campaign
Commits
d779a33f
Commit
d779a33f
authored
Jul 02, 2019
by
Tu Bach
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
4d890fa1
Changes
21
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
21 changed files
with
1845 additions
and
150 deletions
+1845
-150
.idea/workspace.xml
.idea/workspace.xml
+478
-121
src/main/java/com/viettel/campaign/DTO/BaseDTO.java
src/main/java/com/viettel/campaign/DTO/BaseDTO.java
+16
-0
src/main/java/com/viettel/campaign/DTO/CustomerDTO.java
src/main/java/com/viettel/campaign/DTO/CustomerDTO.java
+232
-0
src/main/java/com/viettel/campaign/DTO/CustomerListDTO.java
src/main/java/com/viettel/campaign/DTO/CustomerListDTO.java
+113
-0
src/main/java/com/viettel/campaign/DTO/ResultDTO.java
src/main/java/com/viettel/campaign/DTO/ResultDTO.java
+44
-0
src/main/java/com/viettel/campaign/DTO/TicketSiteDTO.java
src/main/java/com/viettel/campaign/DTO/TicketSiteDTO.java
+106
-0
src/main/java/com/viettel/campaign/controller/ApParamController.java
...va/com/viettel/campaign/controller/ApParamController.java
+11
-12
src/main/java/com/viettel/campaign/controller/CustomerController.java
...a/com/viettel/campaign/controller/CustomerController.java
+34
-3
src/main/java/com/viettel/campaign/mapper/BaseMapper.java
src/main/java/com/viettel/campaign/mapper/BaseMapper.java
+41
-0
src/main/java/com/viettel/campaign/mapper/CustomerMapper.java
...main/java/com/viettel/campaign/mapper/CustomerMapper.java
+80
-0
src/main/java/com/viettel/campaign/model/Customer.java
src/main/java/com/viettel/campaign/model/Customer.java
+14
-0
src/main/java/com/viettel/campaign/model/CustomerList.java
src/main/java/com/viettel/campaign/model/CustomerList.java
+135
-0
src/main/java/com/viettel/campaign/model/CustomerListMapping.java
.../java/com/viettel/campaign/model/CustomerListMapping.java
+54
-0
src/main/java/com/viettel/campaign/model/TicketSite.java
src/main/java/com/viettel/campaign/model/TicketSite.java
+134
-0
src/main/java/com/viettel/campaign/repository/ApParamRepository.java
...va/com/viettel/campaign/repository/ApParamRepository.java
+7
-2
src/main/java/com/viettel/campaign/repository/CustomerRepository.java
...a/com/viettel/campaign/repository/CustomerRepository.java
+3
-0
src/main/java/com/viettel/campaign/service/ApParamService.java
...ain/java/com/viettel/campaign/service/ApParamService.java
+4
-2
src/main/java/com/viettel/campaign/service/ApParamServiceImpl.java
...java/com/viettel/campaign/service/ApParamServiceImpl.java
+11
-4
src/main/java/com/viettel/campaign/service/CustomerService.java
...in/java/com/viettel/campaign/service/CustomerService.java
+4
-0
src/main/java/com/viettel/campaign/service/CustomerServiceImpl.java
...ava/com/viettel/campaign/service/CustomerServiceImpl.java
+55
-6
src/main/java/com/viettel/campaign/utils/DataUtil.java
src/main/java/com/viettel/campaign/utils/DataUtil.java
+269
-0
No files found.
.idea/workspace.xml
View file @
d779a33f
This diff is collapsed.
Click to expand it.
src/main/java/com/viettel/campaign/DTO/BaseDTO.java
0 → 100644
View file @
d779a33f
package
com.viettel.campaign.DTO
;
import
java.io.Serializable
;
public
class
BaseDTO
implements
Serializable
{
protected
String
keySet
;
public
String
getKeySet
(){
return
keySet
;
}
public
void
setKeySet
(
String
keySet
)
{
this
.
keySet
=
keySet
;
}
}
src/main/java/com/viettel/campaign/DTO/CustomerDTO.java
0 → 100644
View file @
d779a33f
package
com.viettel.campaign.DTO
;
import
java.util.Date
;
public
class
CustomerDTO
extends
BaseDTO
{
private
Long
customerId
;
private
String
code
;
private
String
name
;
private
String
description
;
private
String
companyName
;
private
String
customerImg
;
private
Date
createDate
;
private
Date
updateDate
;
private
String
status
;
private
String
createBy
;
private
String
updateBy
;
private
Long
siteId
;
private
Short
gender
;
private
String
currentAddress
;
private
String
placeOfBirth
;
private
Date
dateOfBirth
;
private
String
mobileNumber
;
private
String
email
;
private
String
userName
;
private
String
areaCode
;
private
Long
customerType
;
private
String
callAllowed
;
private
Long
emailAllowed
;
private
Long
smsAllowed
;
private
String
ipccStatus
;
public
Long
getCustomerId
()
{
return
customerId
;
}
public
void
setCustomerId
(
Long
customerId
)
{
this
.
customerId
=
customerId
;
}
public
String
getCode
()
{
return
code
;
}
public
void
setCode
(
String
code
)
{
this
.
code
=
code
;
}
public
String
getName
()
{
return
name
;
}
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
public
String
getDescription
()
{
return
description
;
}
public
void
setDescription
(
String
description
)
{
this
.
description
=
description
;
}
public
String
getCompanyName
()
{
return
companyName
;
}
public
void
setCompanyName
(
String
companyName
)
{
this
.
companyName
=
companyName
;
}
public
String
getCustomerImg
()
{
return
customerImg
;
}
public
void
setCustomerImg
(
String
customerImg
)
{
this
.
customerImg
=
customerImg
;
}
public
Date
getCreateDate
()
{
return
createDate
;
}
public
void
setCreateDate
(
Date
createDate
)
{
this
.
createDate
=
createDate
;
}
public
Date
getUpdateDate
()
{
return
updateDate
;
}
public
void
setUpdateDate
(
Date
updateDate
)
{
this
.
updateDate
=
updateDate
;
}
public
String
getStatus
()
{
return
status
;
}
public
void
setStatus
(
String
status
)
{
this
.
status
=
status
;
}
public
String
getCreateBy
()
{
return
createBy
;
}
public
void
setCreateBy
(
String
createBy
)
{
this
.
createBy
=
createBy
;
}
public
String
getUpdateBy
()
{
return
updateBy
;
}
public
void
setUpdateBy
(
String
updateBy
)
{
this
.
updateBy
=
updateBy
;
}
public
Long
getSiteId
()
{
return
siteId
;
}
public
void
setSiteId
(
Long
siteId
)
{
this
.
siteId
=
siteId
;
}
public
Short
getGender
()
{
return
gender
;
}
public
void
setGender
(
Short
gender
)
{
this
.
gender
=
gender
;
}
public
String
getCurrentAddress
()
{
return
currentAddress
;
}
public
void
setCurrentAddress
(
String
currentAddress
)
{
this
.
currentAddress
=
currentAddress
;
}
public
String
getPlaceOfBirth
()
{
return
placeOfBirth
;
}
public
void
setPlaceOfBirth
(
String
placeOfBirth
)
{
this
.
placeOfBirth
=
placeOfBirth
;
}
public
Date
getDateOfBirth
()
{
return
dateOfBirth
;
}
public
void
setDateOfBirth
(
Date
dateOfBirth
)
{
this
.
dateOfBirth
=
dateOfBirth
;
}
public
String
getMobileNumber
()
{
return
mobileNumber
;
}
public
void
setMobileNumber
(
String
mobileNumber
)
{
this
.
mobileNumber
=
mobileNumber
;
}
public
String
getEmail
()
{
return
email
;
}
public
void
setEmail
(
String
email
)
{
this
.
email
=
email
;
}
public
String
getUserName
()
{
return
userName
;
}
public
void
setUserName
(
String
userName
)
{
this
.
userName
=
userName
;
}
public
String
getAreaCode
()
{
return
areaCode
;
}
public
void
setAreaCode
(
String
areaCode
)
{
this
.
areaCode
=
areaCode
;
}
public
Long
getCustomerType
()
{
return
customerType
;
}
public
void
setCustomerType
(
Long
customerType
)
{
this
.
customerType
=
customerType
;
}
public
String
getCallAllowed
()
{
return
callAllowed
;
}
public
void
setCallAllowed
(
String
callAllowed
)
{
this
.
callAllowed
=
callAllowed
;
}
public
Long
getEmailAllowed
()
{
return
emailAllowed
;
}
public
void
setEmailAllowed
(
Long
emailAllowed
)
{
this
.
emailAllowed
=
emailAllowed
;
}
public
Long
getSmsAllowed
()
{
return
smsAllowed
;
}
public
void
setSmsAllowed
(
Long
smsAllowed
)
{
this
.
smsAllowed
=
smsAllowed
;
}
public
String
getIpccStatus
()
{
return
ipccStatus
;
}
public
void
setIpccStatus
(
String
ipccStatus
)
{
this
.
ipccStatus
=
ipccStatus
;
}
}
src/main/java/com/viettel/campaign/DTO/CustomerListDTO.java
0 → 100644
View file @
d779a33f
package
com.viettel.campaign.DTO
;
public
class
CustomerListDTO
extends
BaseDTO
{
private
String
customerListId
;
private
String
customerListPK
;
private
String
customerSiteId
;
private
String
customerListCode
;
private
String
customerListName
;
private
String
status
;
private
String
createBy
;
private
String
createAt
;
private
String
updateBy
;
private
String
updateAt
;
private
String
source
;
private
String
deptCreate
;
public
String
getCustomerListId
()
{
return
customerListId
;
}
public
void
setCustomerListId
(
String
customerListId
)
{
this
.
customerListId
=
customerListId
;
}
public
String
getCustomerListPK
()
{
return
customerListPK
;
}
public
void
setCustomerListPK
(
String
customerListPK
)
{
this
.
customerListPK
=
customerListPK
;
}
public
String
getCustomerSiteId
()
{
return
customerSiteId
;
}
public
void
setCustomerSiteId
(
String
customerSiteId
)
{
this
.
customerSiteId
=
customerSiteId
;
}
public
String
getCustomerListCode
()
{
return
customerListCode
;
}
public
void
setCustomerListCode
(
String
customerListCode
)
{
this
.
customerListCode
=
customerListCode
;
}
public
String
getCustomerListName
()
{
return
customerListName
;
}
public
void
setCustomerListName
(
String
customerListName
)
{
this
.
customerListName
=
customerListName
;
}
public
String
getStatus
()
{
return
status
;
}
public
void
setStatus
(
String
status
)
{
this
.
status
=
status
;
}
public
String
getCreateBy
()
{
return
createBy
;
}
public
void
setCreateBy
(
String
createBy
)
{
this
.
createBy
=
createBy
;
}
public
String
getCreateAt
()
{
return
createAt
;
}
public
void
setCreateAt
(
String
createAt
)
{
this
.
createAt
=
createAt
;
}
public
String
getUpdateBy
()
{
return
updateBy
;
}
public
void
setUpdateBy
(
String
updateBy
)
{
this
.
updateBy
=
updateBy
;
}
public
String
getUpdateAt
()
{
return
updateAt
;
}
public
void
setUpdateAt
(
String
updateAt
)
{
this
.
updateAt
=
updateAt
;
}
public
String
getSource
()
{
return
source
;
}
public
void
setSource
(
String
source
)
{
this
.
source
=
source
;
}
public
String
getDeptCreate
()
{
return
deptCreate
;
}
public
void
setDeptCreate
(
String
deptCreate
)
{
this
.
deptCreate
=
deptCreate
;
}
}
src/main/java/com/viettel/campaign/DTO/ResultDTO.java
0 → 100644
View file @
d779a33f
package
com.viettel.campaign.DTO
;
import
java.util.ArrayList
;
import
java.util.List
;
public
class
ResultDTO
{
private
String
errorCode
;
private
String
description
;
private
List
listData
=
new
ArrayList
();
private
Object
data
;
public
String
getErrorCode
()
{
return
errorCode
;
}
public
void
setErrorCode
(
String
errorCode
)
{
this
.
errorCode
=
errorCode
;
}
public
String
getDescription
()
{
return
description
;
}
public
void
setDescription
(
String
description
)
{
this
.
description
=
description
;
}
public
List
getListData
()
{
return
listData
;
}
public
void
setListData
(
List
listData
)
{
this
.
listData
=
listData
;
}
public
Object
getData
()
{
return
data
;
}
public
void
setData
(
Object
data
)
{
this
.
data
=
data
;
}
}
src/main/java/com/viettel/campaign/DTO/TicketSiteDTO.java
0 → 100644
View file @
d779a33f
package
com.viettel.campaign.DTO
;
import
java.util.Date
;
public
class
TicketSiteDTO
extends
BaseDTO
{
private
Long
siteId
;
private
String
siteCode
;
private
String
siteName
;
private
Date
createDate
;
private
String
createBy
;
private
Date
updateDate
;
private
String
updateBy
;
private
Long
status
;
private
Long
parentId
;
private
String
accountKazooId
;
private
Long
servicePlanId
;
public
Long
getSiteId
()
{
return
siteId
;
}
public
void
setSiteId
(
Long
siteId
)
{
this
.
siteId
=
siteId
;
}
public
String
getSiteCode
()
{
return
siteCode
;
}
public
void
setSiteCode
(
String
siteCode
)
{
this
.
siteCode
=
siteCode
;
}
public
String
getSiteName
()
{
return
siteName
;
}
public
void
setSiteName
(
String
siteName
)
{
this
.
siteName
=
siteName
;
}
public
Date
getCreateDate
()
{
return
createDate
;
}
public
void
setCreateDate
(
Date
createDate
)
{
this
.
createDate
=
createDate
;
}
public
String
getCreateBy
()
{
return
createBy
;
}
public
void
setCreateBy
(
String
createBy
)
{
this
.
createBy
=
createBy
;
}
public
Date
getUpdateDate
()
{
return
updateDate
;
}
public
void
setUpdateDate
(
Date
updateDate
)
{
this
.
updateDate
=
updateDate
;
}
public
String
getUpdateBy
()
{
return
updateBy
;
}
public
void
setUpdateBy
(
String
updateBy
)
{
this
.
updateBy
=
updateBy
;
}
public
Long
getStatus
()
{
return
status
;
}
public
void
setStatus
(
Long
status
)
{
this
.
status
=
status
;
}
public
Long
getParentId
()
{
return
parentId
;
}
public
void
setParentId
(
Long
parentId
)
{
this
.
parentId
=
parentId
;
}
public
String
getAccountKazooId
()
{
return
accountKazooId
;
}
public
void
setAccountKazooId
(
String
accountKazooId
)
{
this
.
accountKazooId
=
accountKazooId
;
}
public
Long
getServicePlanId
()
{
return
servicePlanId
;
}
public
void
setServicePlanId
(
Long
servicePlanId
)
{
this
.
servicePlanId
=
servicePlanId
;
}
}
src/main/java/com/viettel/campaign/controller/ApParamController.java
View file @
d779a33f
package
com.viettel.campaign.controller
;
import
com.viettel.campaign.DTO.ApParamDTO
;
import
com.viettel.campaign.model.ApParam
;
import
com.viettel.campaign.service.ApParamService
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -12,29 +11,29 @@ import org.springframework.web.bind.annotation.*;
import
java.util.List
;
@Controller
@RequestMapping
(
"/ipcc"
)
@RequestMapping
(
"/ipcc
/apParam
"
)
public
class
ApParamController
{
@Autowired
(
required
=
true
)
@Autowired
(
required
=
true
)
ApParamService
apParamService
;
@GetMapping
(
path
=
"/
apParam/
findAlls"
)
@GetMapping
(
path
=
"/findAlls"
)
@ResponseBody
public
ResponseEntity
<
List
<
ApParam
>>
listAllCustomer
()
{
List
<
ApParam
>
listCustomer
=
(
List
<
ApParam
>)
apParamService
.
getAllParams
(
);
if
(
listCustomer
.
isEmpty
()
)
{
public
ResponseEntity
listAllCustomer
(
@RequestParam
(
"page"
)
int
page
,
@RequestParam
(
"pageSize"
)
int
pageSize
,
@RequestParam
(
"sort"
)
String
sort
)
{
Iterable
<
ApParam
>
listCustomer
=
apParamService
.
getAllParams
(
page
,
pageSize
,
sort
);
if
(
listCustomer
==
null
)
{
return
new
ResponseEntity
(
HttpStatus
.
NO_CONTENT
);
}
return
new
ResponseEntity
<
List
<
ApParam
>>(
listCustomer
,
HttpStatus
.
OK
);
return
new
ResponseEntity
(
listCustomer
.
iterator
()
,
HttpStatus
.
OK
);
}
@PostMapping
(
path
=
"/
apParam/
findByName"
)
@PostMapping
(
path
=
"/findByName"
)
@ResponseBody
public
ResponseEntity
<
List
<
ApParam
>>
searchParamByName
(
@RequestParam
(
name
=
"parName"
)
String
parName
)
{
List
<
ApParam
>
lst
=
apParamService
.
getParamByName
(
parName
);
public
ResponseEntity
searchParamByName
(
@RequestParam
(
"page"
)
int
page
,
@RequestParam
(
"pageSize"
)
int
pageSize
,
@RequestParam
(
"sort"
)
String
sort
,
@RequestParam
(
name
=
"parName"
)
String
parName
)
{
List
<
ApParam
>
lst
=
apParamService
.
getParamByName
(
pa
ge
,
pageSize
,
sort
,
pa
rName
);
if
(
lst
.
isEmpty
())
return
new
ResponseEntity
<>(
HttpStatus
.
NO_CONTENT
);
return
new
ResponseEntity
<
List
<
ApParam
>>
(
lst
,
HttpStatus
.
OK
);
return
new
ResponseEntity
(
lst
,
HttpStatus
.
OK
);
}
}
src/main/java/com/viettel/campaign/controller/CustomerController.java
View file @
d779a33f
package
com.viettel.campaign.controller
;
import
com.viettel.campaign.DTO.CustomerDTO
;
import
com.viettel.campaign.DTO.ResultDTO
;
import
com.viettel.campaign.model.Customer
;
import
com.viettel.campaign.repository.CustomerRepository
;
import
com.viettel.campaign.service.CustomerService
;
import
org.apache.log4j.Logger
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.web.bind.annotation.*
;
import
javax.validation.Valid
;
import
java.util.Date
;
import
java.util.Map
;
@Controller
@RequestMapping
(
"/ipcc"
)
@RequestMapping
(
"/ipcc
/customer
"
)
public
class
CustomerController
{
private
static
final
Logger
LOGGER
=
Logger
.
getLogger
(
CustomerController
.
class
);
@Autowired
(
required
=
true
)
CustomerService
customerService
;
@GetMapping
(
"/customer/findAll"
)
@Autowired
CustomerRepository
customerRepository
;
@GetMapping
(
"/findAll"
)
@ResponseBody
public
ResponseEntity
findAllCustomer
(
@RequestParam
(
"page"
)
int
page
,
@RequestParam
(
"pageSize"
)
int
pageSize
,
@RequestParam
(
"sort"
)
String
sort
)
{
Map
result
=
customerService
.
listAllCustomer
(
page
,
pageSize
,
sort
);
return
new
ResponseEntity
<>(
result
,
HttpStatus
.
OK
);
}
@GetMapping
(
"/
customer/
findCustName"
)
@GetMapping
(
"/findCustName"
)
@ResponseBody
public
ResponseEntity
findAllCustomerName
(
@RequestParam
(
"page"
)
int
page
,
@RequestParam
(
"pageSize"
)
int
pageSize
,
@RequestParam
(
"sort"
)
String
sort
,
@RequestParam
(
"name"
)
String
name
)
{
Map
result
=
customerService
.
listCustByName
(
page
,
pageSize
,
sort
,
name
);
return
new
ResponseEntity
(
result
,
HttpStatus
.
OK
);
}
@PostMapping
(
value
=
"/createCust"
)
@ResponseBody
public
ResultDTO
createCust
(
@RequestBody
@Valid
CustomerDTO
customerDTO
)
{
ResultDTO
result
=
new
ResultDTO
();
//LogUtil logUtil = new LogUtil();
//logUtil.initKpiLog("createCust");
try
{
//LOGGER.info("Returning createCustomer: start");
result
=
customerService
.
createCustomer
(
customerDTO
);
//LOGGER.info("Returning createCustomer:" + result.getErrorCode());
//logUtil.endKpiLog(customerDTO, 0, result.getErrorCode(), result.getDetail(), CustomerController.class, customerDTO.getAgentProcess(), this.serverPort);
}
catch
(
Exception
e
)
{
result
.
setErrorCode
(
"-1"
);
LOGGER
.
error
(
e
);
//logUtil.endKpiLog(customerDTO, 1, result.getErrorCode(), e.getMessage(), CustomerController.class, customerDTO.getAgentProcess(), this.serverPort);
}
return
result
;
}
}
src/main/java/com/viettel/campaign/mapper/BaseMapper.java
0 → 100644
View file @
d779a33f
package
com.viettel.campaign.mapper
;
import
com.viettel.campaign.DTO.BaseDTO
;
import
java.util.ArrayList
;
import
java.util.List
;
public
abstract
class
BaseMapper
<
Model
extends
Object
,
DTO
extends
BaseDTO
>
{
public
abstract
DTO
toDtoBean
(
Model
model
);
public
abstract
Model
toPersistenceBean
(
DTO
dtoBean
);
public
List
<
DTO
>
toDtoBean
(
Iterable
<
Model
>
models
)
{
List
<
DTO
>
dtoBeans
=
new
ArrayList
<>();
if
(
models
==
null
)
return
dtoBeans
;
for
(
Model
model
:
models
)
{
dtoBeans
.
add
(
toDtoBean
(
model
));
}
return
dtoBeans
;
}
public
List
<
DTO
>
toDtoBean
(
List
<
Model
>
models
)
{
List
<
DTO
>
dtoBeans
=
new
ArrayList
<>();
if
(
models
==
null
)
return
dtoBeans
;
for
(
Model
model
:
models
)
{
dtoBeans
.
add
(
toDtoBean
(
model
));
}
return
dtoBeans
;
}
public
List
<
Model
>
toPersistenceBean
(
List
<
DTO
>
dtoBeans
)
{
List
<
Model
>
models
=
new
ArrayList
<>();
if
(
dtoBeans
==
null
||
dtoBeans
.
isEmpty
())
return
models
;
for
(
DTO
dtoBean
:
dtoBeans
)
{
models
.
add
(
toPersistenceBean
(
dtoBean
));
}
return
models
;
}
}
src/main/java/com/viettel/campaign/mapper/CustomerMapper.java
0 → 100644
View file @
d779a33f
package
com.viettel.campaign.mapper
;
import
com.viettel.campaign.DTO.CustomerDTO
;
import
com.viettel.campaign.model.Customer
;
import
java.util.Date
;
public
class
CustomerMapper
extends
BaseMapper
<
Customer
,
CustomerDTO
>
{
@Override
public
CustomerDTO
toDtoBean
(
Customer
model
)
{
CustomerDTO
obj
=
null
;
if
(
model
!=
null
)
{
obj
=
new
CustomerDTO
();
obj
.
setUserName
(
model
.
getUserName
());
obj
.
setCompanyName
(
model
.
getCompanyName
());
obj
.
setCurrentAddress
(
model
.
getCurrentAddress
());
obj
.
setCustomerId
(
model
.
getCustomerId
());
obj
.
setCustomerImg
(
model
.
getCustomerImg
());
obj
.
setEmail
(
model
.
getEmail
());
obj
.
setGender
(
model
.
getGender
());
obj
.
setMobileNumber
(
model
.
getMobileNumber
());
obj
.
setName
(
model
.
getName
());
obj
.
setSiteId
(
model
.
getSiteId
());
obj
.
setStatus
(
model
.
getStatus
());
// String additionalInfo = "";
// if (model.getName() != null && !"".equals(model.getName())) {
// additionalInfo += model.getName();
// }
// if (model.getUserName() != null && !"".equals(model.getUserName())) {
// additionalInfo += "".equals(additionalInfo) ? model.getUserName() : " - " + model.getUserName();
// }
// if (model.getMobileNumber() != null && !"".equals(model.getMobileNumber())) {
// additionalInfo += "".equals(additionalInfo) ? model.getMobileNumber() : " - " + model.getMobileNumber();
// }
// if (model.getEmail() != null && !"".equals(model.getEmail())) {
// additionalInfo += "".equals(additionalInfo) ? model.getEmail() : " - " + model.getEmail();
// }
// obj.setAdditionalInfo(additionalInfo);
obj
.
setAreaCode
(
model
.
getAreaCode
());
obj
.
setCustomerType
(
model
.
getCustomerType
());
obj
.
setDescription
(
model
.
getDescription
());
}
return
obj
;
}
@Override
public
Customer
toPersistenceBean
(
CustomerDTO
dtoBean
)
{
Customer
obj
=
null
;
if
(
dtoBean
!=
null
)
{
obj
=
new
Customer
();
//obj.setCustomerId(dtoBean.getCustomerId() == null ? null : dtoBean.getCustomerId());
obj
.
setCode
(
dtoBean
.
getCode
());
obj
.
setName
(
dtoBean
.
getName
());
obj
.
setDescription
(
dtoBean
.
getDescription
());
obj
.
setCompanyName
(
dtoBean
.
getCompanyName
());
obj
.
setCustomerImg
(
dtoBean
.
getCustomerImg
());
obj
.
setCreateDate
(
dtoBean
.
getCreateDate
());
obj
.
setUpdateDate
(
dtoBean
.
getUpdateDate
());
obj
.
setStatus
(
dtoBean
.
getStatus
());
obj
.
setCreateBy
(
dtoBean
.
getCreateBy
());
obj
.
setUpdateBy
(
dtoBean
.
getUpdateBy
());
obj
.
setSiteId
(
dtoBean
.
getSiteId
());
obj
.
setGender
(
dtoBean
.
getGender
());
obj
.
setCurrentAddress
(
dtoBean
.
getCurrentAddress
());
obj
.
setPlaceOfBirth
(
dtoBean
.
getPlaceOfBirth
());
obj
.
setDateOfBirth
(
dtoBean
.
getDateOfBirth
());
obj
.
setMobileNumber
(
dtoBean
.
getMobileNumber
());
obj
.
setEmail
(
dtoBean
.
getEmail
());
obj
.
setUserName
(
dtoBean
.
getUserName
());
obj
.
setAreaCode
(
dtoBean
.
getAreaCode
());
obj
.
setCustomerType
(
dtoBean
.
getCustomerType
());
obj
.
setCallAllowed
(
dtoBean
.
getCallAllowed
());
obj
.
setEmailAllowed
(
dtoBean
.
getEmailAllowed
());
obj
.
setSmsAllowed
(
dtoBean
.
getSmsAllowed
());
obj
.
setIpccStatus
(
dtoBean
.
getIpccStatus
());
}
return
obj
;
}
}
src/main/java/com/viettel/campaign/model/Customer.java
View file @
d779a33f
...
...
@@ -2,6 +2,7 @@ package com.viettel.campaign.model;
import
javax.persistence.*
;
import
javax.validation.constraints.NotNull
;
import
javax.validation.constraints.Size
;
import
java.io.Serializable
;
import
java.util.Date
;
...
...
@@ -16,12 +17,16 @@ public class Customer implements Serializable {
@NotNull
@Column
(
name
=
"CUSTOMER_ID"
)
private
Long
customerId
;
@Size
(
max
=
1000
)
@Column
(
name
=
"CODE"
)
private
String
code
;
@Size
(
max
=
1000
)
@Column
(
name
=
"NAME"
)
private
String
name
;
@Size
(
max
=
2000
)
@Column
(
name
=
"DESCRIPTION"
)
private
String
description
;
@Size
(
max
=
100
)
@Column
(
name
=
"COMPANY_NAME"
)
private
String
companyName
;
@Column
(
name
=
"CUSTOMER_IMG"
)
...
...
@@ -36,27 +41,35 @@ public class Customer implements Serializable {
private
Date
updateDate
;
@Column
(
name
=
"STATUS"
)
private
String
status
;
@Size
(
max
=
50
)
@Column
(
name
=
"CREATE_BY"
)
private
String
createBy
;
@Size
(
max
=
50
)
@Column
(
name
=
"UPDATE_BY"
)
private
String
updateBy
;
@Column
(
name
=
"SITE_ID"
)
private
Long
siteId
;
@Column
(
name
=
"GENDER"
)
private
Short
gender
;
@Size
(
max
=
500
)
@Column
(
name
=
"CURRENT_ADDRESS"
)
private
String
currentAddress
;
@Size
(
max
=
500
)
@Column
(
name
=
"PLACE_OF_BIRTH"
)
private
String
placeOfBirth
;
@Column
(
name
=
"DATE_OF_BIRTH"
)
@Temporal
(
TemporalType
.
TIMESTAMP
)
private
Date
dateOfBirth
;
@Size
(
max
=
20
)
@Column
(
name
=
"MOBILE_NUMBER"
)
private
String
mobileNumber
;
@Size
(
max
=
500
)
@Column
(
name
=
"EMAIL"
)
private
String
email
;
@Size
(
max
=
200
)
@Column
(
name
=
"USERNAME"
)
private
String
userName
;
@Size
(
max
=
25
)
@Column
(
name
=
"AREA_CODE"
)
private
String
areaCode
;
@Column
(
name
=
"CUSTOMER_TYPE"
)
...
...
@@ -67,6 +80,7 @@ public class Customer implements Serializable {
private
Long
emailAllowed
;
@Column
(
name
=
"SMS_ALLOWED"
)
private
Long
smsAllowed
;
@Size
(
max
=
100
)
@Column
(
name
=
"IPCC_STATUS"
)
private
String
ipccStatus
;
...
...
src/main/java/com/viettel/campaign/model/CustomerList.java
0 → 100644
View file @
d779a33f
package
com.viettel.campaign.model
;
import
javax.persistence.*
;
import
javax.validation.constraints.NotNull
;
import
javax.validation.constraints.Size
;
import
java.io.Serializable
;
import
java.util.Date
;
@Entity
@Table
(
name
=
"CUSTOMER_LIST"
)
public
class
CustomerList
implements
Serializable
{
@Id
@GeneratedValue
(
generator
=
"customer_list_seq"
)
@SequenceGenerator
(
name
=
"customer_list_seq"
,
sequenceName
=
"customer_list_seq"
,
allocationSize
=
1
)
@Basic
(
optional
=
false
)
@NotNull
@Column
(
name
=
"CUSTOMER_LIST_ID"
)
private
Long
customerListId
;
@Column
(
name
=
"COMPANY_SITE_ID"
)
private
Long
customerSiteId
;
@Size
(
max
=
200
)
@Column
(
name
=
"CUSTOMER_LIST_CODE"
)
private
String
customerListCode
;
@Size
(
max
=
500
)
@Column
(
name
=
"CUSTOMER_LIST_NAME"
)
private
String
customerListName
;
@NotNull
@Column
(
name
=
"STATUS"
)
private
Short
status
;
@Size
(
max
=
200
)
@Column
(
name
=
"CREATE_BY"
)
private
String
createBy
;
@Column
(
name
=
"CREATE_AT"
)
private
Date
createAt
;
@Size
(
max
=
200
)
@Column
(
name
=
"UPDATE_BY"
)
private
String
updateBy
;
@Column
(
name
=
"UPDATE_AT"
)
private
Date
updateAt
;
@Size
(
max
=
100
)
@Column
(
name
=
"SOURCE"
)
private
String
source
;
@Size
(
max
=
100
)
@Column
(
name
=
"DEPT_CREATE"
)
private
String
deptCreate
;
public
Long
getCustomerListId
()
{
return
customerListId
;
}
public
void
setCustomerListId
(
Long
customerListId
)
{
this
.
customerListId
=
customerListId
;
}
public
Long
getCustomerSiteId
()
{
return
customerSiteId
;
}
public
void
setCustomerSiteId
(
Long
customerSiteId
)
{
this
.
customerSiteId
=
customerSiteId
;
}
public
String
getCustomerListCode
()
{
return
customerListCode
;
}
public
void
setCustomerListCode
(
String
customerListCode
)
{
this
.
customerListCode
=
customerListCode
;
}
public
String
getCustomerListName
()
{
return
customerListName
;
}
public
void
setCustomerListName
(
String
customerListName
)
{
this
.
customerListName
=
customerListName
;
}
public
Short
getStatus
()
{
return
status
;
}
public
void
setStatus
(
Short
status
)
{
this
.
status
=
status
;
}
public
String
getCreateBy
()
{
return
createBy
;
}
public
void
setCreateBy
(
String
createBy
)
{
this
.
createBy
=
createBy
;
}
public
Date
getCreateAt
()
{
return
createAt
;
}
public
void
setCreateAt
(
Date
createAt
)
{
this
.
createAt
=
createAt
;
}
public
String
getUpdateBy
()
{
return
updateBy
;
}
public
void
setUpdateBy
(
String
updateBy
)
{
this
.
updateBy
=
updateBy
;
}
public
Date
getUpdateAt
()
{
return
updateAt
;
}
public
void
setUpdateAt
(
Date
updateAt
)
{
this
.
updateAt
=
updateAt
;
}
public
String
getSource
()
{
return
source
;
}
public
void
setSource
(
String
source
)
{
this
.
source
=
source
;
}
public
String
getDeptCreate
()
{
return
deptCreate
;
}
public
void
setDeptCreate
(
String
deptCreate
)
{
this
.
deptCreate
=
deptCreate
;
}
}
src/main/java/com/viettel/campaign/model/CustomerListMapping.java
0 → 100644
View file @
d779a33f
package
com.viettel.campaign.model
;
import
javax.persistence.Column
;
import
javax.persistence.Entity
;
import
javax.persistence.Id
;
import
javax.persistence.Table
;
import
java.io.Serializable
;
@Entity
@Table
(
name
=
"CUSTOMER_LIST_MAPPING"
)
public
class
CustomerListMapping
implements
Serializable
{
@Id
@Column
(
name
=
"CUSTOMER_LIST_MAPPING_ID"
)
private
Long
customerListMappingId
;
@Column
(
name
=
"CUSTOMER_ID"
)
private
Long
customerId
;
@Column
(
name
=
"COMPANY_SITE_ID"
)
private
Long
companySiteId
;
@Column
(
name
=
"CUSTOMER_LIST_ID"
)
private
Long
customerListId
;
public
Long
getCustomerListMappingId
()
{
return
customerListMappingId
;
}
public
void
setCustomerListMappingId
(
Long
customerListMappingId
)
{
this
.
customerListMappingId
=
customerListMappingId
;
}
public
Long
getCustomerId
()
{
return
customerId
;
}
public
void
setCustomerId
(
Long
customerId
)
{
this
.
customerId
=
customerId
;
}
public
Long
getCompanySiteId
()
{
return
companySiteId
;
}
public
void
setCompanySiteId
(
Long
companySiteId
)
{
this
.
companySiteId
=
companySiteId
;
}
public
Long
getCustomerListId
()
{
return
customerListId
;
}
public
void
setCustomerListId
(
Long
customerListId
)
{
this
.
customerListId
=
customerListId
;
}
}
src/main/java/com/viettel/campaign/model/TicketSite.java
0 → 100644
View file @
d779a33f
package
com.viettel.campaign.model
;
import
javax.persistence.*
;
import
javax.validation.constraints.NotNull
;
import
javax.validation.constraints.Size
;
import
java.io.Serializable
;
import
java.util.Date
;
@Entity
@Table
(
name
=
"TICKET_SITE"
)
public
class
TicketSite
implements
Serializable
{
@Id
@GeneratedValue
(
strategy
=
GenerationType
.
AUTO
)
@Basic
(
optional
=
false
)
@NotNull
@Column
(
name
=
"SITE_ID"
)
private
Long
siteId
;
@Size
(
max
=
400
)
@Column
(
name
=
"SITE_CODE"
)
private
String
siteCode
;
@Size
(
max
=
400
)
@Column
(
name
=
"SITE_NAME"
)
private
String
siteName
;
@Column
(
name
=
"CREATE_DATE"
)
@Temporal
(
TemporalType
.
TIMESTAMP
)
private
Date
createDate
;
@Size
(
max
=
200
)
@Column
(
name
=
"CREATE_BY"
)
private
String
createBy
;
@Column
(
name
=
"UPDATE_DATE"
)
@Temporal
(
TemporalType
.
TIMESTAMP
)
private
Date
updateDate
;
@Size
(
max
=
200
)
@Column
(
name
=
"UPDATE_BY"
)
private
String
updateBy
;
@Column
(
name
=
"STATUS"
)
private
Long
status
;
@Column
(
name
=
"PARENT_ID"
)
private
Long
parentId
;
@Size
(
max
=
200
)
@Column
(
name
=
"ACCOUNT_KAZOO_ID"
)
private
String
accountKazooId
;
@Column
(
name
=
"SERVICE_PLAN_ID"
)
private
Long
servicePlanId
;
public
Long
getSiteId
()
{
return
siteId
;
}
public
void
setSiteId
(
Long
siteId
)
{
this
.
siteId
=
siteId
;
}
public
String
getSiteCode
()
{
return
siteCode
;
}
public
void
setSiteCode
(
String
siteCode
)
{
this
.
siteCode
=
siteCode
;
}
public
String
getSiteName
()
{
return
siteName
;
}
public
void
setSiteName
(
String
siteName
)
{
this
.
siteName
=
siteName
;
}
public
Date
getCreateDate
()
{
return
createDate
;
}
public
void
setCreateDate
(
Date
createDate
)
{
this
.
createDate
=
createDate
;
}
public
String
getCreateBy
()
{
return
createBy
;
}
public
void
setCreateBy
(
String
createBy
)
{
this
.
createBy
=
createBy
;
}
public
Date
getUpdateDate
()
{
return
updateDate
;
}
public
void
setUpdateDate
(
Date
updateDate
)
{
this
.
updateDate
=
updateDate
;
}
public
String
getUpdateBy
()
{
return
updateBy
;
}
public
void
setUpdateBy
(
String
updateBy
)
{
this
.
updateBy
=
updateBy
;
}
public
Long
getStatus
()
{
return
status
;
}
public
void
setStatus
(
Long
status
)
{
this
.
status
=
status
;
}
public
Long
getParentId
()
{
return
parentId
;
}
public
void
setParentId
(
Long
parentId
)
{
this
.
parentId
=
parentId
;
}
public
String
getAccountKazooId
()
{
return
accountKazooId
;
}
public
void
setAccountKazooId
(
String
accountKazooId
)
{
this
.
accountKazooId
=
accountKazooId
;
}
public
Long
getServicePlanId
()
{
return
servicePlanId
;
}
public
void
setServicePlanId
(
Long
servicePlanId
)
{
this
.
servicePlanId
=
servicePlanId
;
}
}
src/main/java/com/viettel/campaign/repository/ApParamRepository.java
View file @
d779a33f
package
com.viettel.campaign.repository
;
import
com.viettel.campaign.model.ApParam
;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.data.jpa.repository.JpaRepository
;
import
org.springframework.data.jpa.repository.Query
;
import
java.util.List
;
public
interface
ApParamRepository
extends
JpaRepository
<
ApParam
,
Long
>,
ApParamRepositoryCustom
{
@Query
(
value
=
"SELECT * FROM AP_PARAM p WHERE PAR_NAME LIKE %?1%"
,
nativeQuery
=
true
)
List
<
ApParam
>
findParamByName
(
String
parName
);
Page
<
ApParam
>
findAll
(
Pageable
pageable
);
@Query
(
value
=
"SELECT p FROM ApParam p WHERE parName LIKE %?1%"
)
List
<
ApParam
>
findParamByName
(
String
parName
,
Pageable
pageable
);
}
src/main/java/com/viettel/campaign/repository/CustomerRepository.java
View file @
d779a33f
...
...
@@ -14,4 +14,7 @@ public interface CustomerRepository extends JpaRepository<Customer, Long> {
@Query
(
"FROM Customer WHERE name = ?1"
)
List
<
Customer
>
findByName
(
String
firstName
,
Pageable
pageable
);
@Query
(
"SELECT COUNT(0) FROM Customer t WHERE t.mobileNumber = ?1 and t.siteId = ?2 and t.status = 1 "
)
Long
findByMobileNumberAndSiteId
(
String
mobileNumber
,
Long
siteId
);
}
src/main/java/com/viettel/campaign/service/ApParamService.java
View file @
d779a33f
...
...
@@ -5,6 +5,8 @@ import com.viettel.campaign.model.ApParam;
import
java.util.List
;
public
interface
ApParamService
{
Iterable
<
ApParam
>
getAllParams
();
List
<
ApParam
>
getParamByName
(
String
parName
);
Iterable
<
ApParam
>
getAllParams
(
int
page
,
int
pageSize
,
String
sort
);
List
<
ApParam
>
getParamByName
(
int
page
,
int
pageSize
,
String
sort
,
String
parName
);
}
src/main/java/com/viettel/campaign/service/ApParamServiceImpl.java
View file @
d779a33f
...
...
@@ -3,8 +3,11 @@ package com.viettel.campaign.service;
import
com.viettel.campaign.model.ApParam
;
import
com.viettel.campaign.repository.ApParamRepository
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.domain.PageRequest
;
import
org.springframework.data.domain.Sort
;
import
org.springframework.stereotype.Service
;
import
java.util.ArrayList
;
import
java.util.List
;
@Service
...
...
@@ -14,12 +17,16 @@ public class ApParamServiceImpl implements ApParamService {
ApParamRepository
apParamRepository
;
@Override
public
Iterable
<
ApParam
>
getAllParams
()
{
return
apParamRepository
.
findAll
();
public
Iterable
<
ApParam
>
getAllParams
(
int
page
,
int
pageSize
,
String
sort
)
{
return
apParamRepository
.
findAll
(
PageRequest
.
of
(
page
,
pageSize
,
Sort
.
by
(
sort
))
);
}
@Override
public
List
<
ApParam
>
getParamByName
(
String
parName
)
{
return
apParamRepository
.
findParamByName
(
parName
);
public
List
<
ApParam
>
getParamByName
(
int
page
,
int
pageSize
,
String
sort
,
String
parName
)
{
List
<
ApParam
>
lst
=
new
ArrayList
<>();
lst
=
apParamRepository
.
findParamByName
(
parName
,
PageRequest
.
of
(
page
,
pageSize
,
Sort
.
by
(
sort
)));
return
lst
;
}
}
src/main/java/com/viettel/campaign/service/CustomerService.java
View file @
d779a33f
package
com.viettel.campaign.service
;
import
com.viettel.campaign.DTO.CustomerDTO
;
import
com.viettel.campaign.DTO.ResultDTO
;
import
com.viettel.campaign.model.Customer
;
import
java.util.List
;
...
...
@@ -9,4 +11,6 @@ public interface CustomerService {
Map
listAllCustomer
(
int
page
,
int
pageSize
,
String
sort
);
Map
listCustByName
(
int
page
,
int
pageSize
,
String
sort
,
String
name
);
ResultDTO
createCustomer
(
CustomerDTO
customerDTO
);
}
src/main/java/com/viettel/campaign/service/CustomerServiceImpl.java
View file @
d779a33f
package
com.viettel.campaign.service
;
import
com.viettel.campaign.DTO.CustomerDTO
;
import
com.viettel.campaign.DTO.ResultDTO
;
import
com.viettel.campaign.mapper.CustomerMapper
;
import
com.viettel.campaign.model.Customer
;
import
com.viettel.campaign.repository.CustomerRepository
;
import
org.hibernate.Session
;
import
org.hibernate.SessionFactory
;
import
com.viettel.campaign.utils.DataUtil
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.PageRequest
;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.data.domain.Sort
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
javax.persistence.EntityManager
;
import
javax.persistence.Query
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.*
;
@Service
public
class
CustomerServiceImpl
implements
CustomerService
{
...
...
@@ -53,4 +53,53 @@ public class CustomerServiceImpl implements CustomerService {
return
result
;
}
@Override
@Transactional
public
ResultDTO
createCustomer
(
CustomerDTO
customerDTO
)
{
ResultDTO
resultDTO
=
new
ResultDTO
();
CustomerMapper
customerMapper
=
new
CustomerMapper
();
Date
today
=
new
Date
();
Customer
customer
=
new
Customer
();
try
{
if
(
customerDTO
!=
null
)
{
//check trung mobile number
Long
cusExist
=
customerRepository
.
findByMobileNumberAndSiteId
(
customerDTO
.
getMobileNumber
(),
customerDTO
.
getSiteId
());
if
(
cusExist
>
0
)
{
resultDTO
.
setErrorCode
(
"-7"
);
resultDTO
.
setDescription
(
"Mobile number is existed"
);
return
resultDTO
;
}
// insert
customer
=
customerMapper
.
toPersistenceBean
(
customerDTO
);
customer
.
setCreateDate
(
new
Date
());
customer
=
customerRepository
.
save
(
customer
);
resultDTO
.
setErrorCode
(
customer
.
getCustomerId
()
+
""
);
resultDTO
.
setDescription
(
"customer created"
);
}
else
{
resultDTO
.
setErrorCode
(
"-2"
);
resultDTO
.
setDescription
(
"customerDTO null"
);
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
return
resultDTO
;
}
public
Date
getSysdate
()
{
try
{
Query
query
=
entityManager
.
createNativeQuery
(
"SELECT to_char(sysdate, 'dd/MM/YYYY hh24:mi:ss') FROM DUAL "
);
List
list
=
query
.
getResultList
();
if
(
list
!=
null
&&
list
.
size
()
>
0
)
{
return
DataUtil
.
convertStringToDateDDMMYYYYHHMISS
(
DataUtil
.
safeToString
(
list
.
get
(
0
)));
}
}
catch
(
Exception
e
)
{
//logger.info(e.getMessage(), e);
e
.
printStackTrace
();
}
return
new
Date
();
}
}
src/main/java/com/viettel/campaign/utils/DataUtil.java
0 → 100644
View file @
d779a33f
package
com.viettel.campaign.utils
;
import
java.io.BufferedReader
;
import
java.io.IOException
;
import
java.io.Reader
;
import
java.math.BigDecimal
;
import
java.sql.Clob
;
import
java.sql.SQLException
;
import
java.text.Format
;
import
java.text.SimpleDateFormat
;
import
java.util.Date
;
public
class
DataUtil
{
private
static
final
org
.
apache
.
log4j
.
Logger
logger
=
org
.
apache
.
log4j
.
Logger
.
getLogger
(
DataUtil
.
class
);
public
static
boolean
isNullOrZero
(
Long
value
)
{
return
(
value
==
null
||
value
.
equals
(
0L
));
}
public
static
boolean
isNullOrEmpty
(
String
value
)
{
return
(
value
==
null
||
value
.
isEmpty
());
}
public
static
boolean
isNullOrZero
(
BigDecimal
value
)
{
return
(
value
==
null
||
value
.
compareTo
(
BigDecimal
.
ZERO
)
==
0
);
}
public
static
Long
safeToLong
(
Object
obj1
,
Long
defaultValue
)
{
Long
result
=
defaultValue
;
if
(
obj1
!=
null
)
{
try
{
result
=
Long
.
parseLong
(
obj1
.
toString
());
}
catch
(
Exception
ex
)
{
logger
.
error
(
ex
.
getMessage
(),
ex
);
}
}
return
result
;
}
public
static
Long
safeToLong
(
Object
obj1
)
{
Long
result
=
null
;
if
(
obj1
!=
null
)
{
try
{
result
=
Long
.
parseLong
(
obj1
.
toString
());
}
catch
(
Exception
ex
)
{
logger
.
error
(
ex
.
getMessage
(),
ex
);
}
}
return
result
;
}
public
static
BigDecimal
safeToBigDecimal
(
Object
obj1
)
{
BigDecimal
result
=
new
BigDecimal
(
0
);
if
(
obj1
!=
null
)
{
try
{
result
=
BigDecimal
.
valueOf
(
Long
.
parseLong
(
obj1
.
toString
()));
}
catch
(
Exception
ex
)
{
logger
.
error
(
ex
.
getMessage
(),
ex
);
}
}
return
result
;
}
public
static
Double
safeToDouble
(
Object
obj1
)
{
Double
result
=
null
;
if
(
obj1
!=
null
)
{
try
{
result
=
Double
.
parseDouble
(
obj1
.
toString
());
}
catch
(
Exception
ex
)
{
logger
.
error
(
ex
.
getMessage
(),
ex
);
}
}
return
result
;
}
public
static
Short
safeToShort
(
Object
obj1
)
{
Short
result
=
0
;
if
(
obj1
!=
null
)
{
try
{
result
=
Short
.
parseShort
(
obj1
.
toString
());
}
catch
(
Exception
ex
)
{
logger
.
error
(
ex
.
getMessage
(),
ex
);
}
}
return
result
;
}
public
static
int
safeToInt
(
Object
obj1
)
{
int
result
=
0
;
if
(
obj1
==
null
)
{
return
0
;
}
try
{
result
=
Integer
.
parseInt
(
obj1
.
toString
());
}
catch
(
Exception
ex
)
{
logger
.
error
(
ex
.
getMessage
(),
ex
);
}
return
result
;
}
public
static
String
safeToString
(
Object
obj1
)
{
if
(
obj1
==
null
)
{
return
""
;
}
return
obj1
.
toString
();
}
public
static
Date
safeToDate
(
Object
obj1
)
{
Date
result
=
null
;
if
(
obj1
==
null
)
{
return
null
;
}
try
{
result
=
(
Date
)
obj1
;
}
catch
(
Exception
ex
)
{
logger
.
error
(
ex
.
getMessage
(),
ex
);
}
return
result
;
}
public
static
boolean
safeEqual
(
Long
obj1
,
Long
obj2
)
{
if
(
obj1
==
obj2
)
{
return
true
;
}
return
((
obj1
!=
null
)
&&
(
obj2
!=
null
)
&&
(
obj1
.
compareTo
(
obj2
)
==
0
));
}
public
static
boolean
safeEqual
(
String
obj1
,
String
obj2
)
{
if
(
obj1
==
obj2
)
{
return
true
;
}
return
((
obj1
!=
null
)
&&
(
obj2
!=
null
)
&&
obj1
.
equals
(
obj2
));
}
public
static
String
convertDateToStringDDMMYYYYHHMISS
(
Date
datetime
)
{
String
s
=
null
;
if
(
datetime
!=
null
)
{
Format
formatter
=
new
SimpleDateFormat
(
"dd/MM/yyyy HH:mm:ss"
);
s
=
formatter
.
format
(
datetime
);
}
return
s
;
}
public
static
Date
convertStringToDateDDMMYYYYHHMISS
(
String
str
)
{
Date
dateTime
=
null
;
try
{
if
(
str
!=
null
)
{
SimpleDateFormat
formatter
=
new
SimpleDateFormat
(
"dd/MM/yyyy HH:mm:ss"
);
dateTime
=
formatter
.
parse
(
str
);
}
}
catch
(
Exception
e
)
{
logger
.
error
(
e
);
}
return
dateTime
;
}
public
static
String
safeToClob
(
Clob
clobValue
)
{
String
result
=
null
;
if
(
clobValue
!=
null
)
{
StringBuilder
sb
=
new
StringBuilder
();
try
{
Reader
reader
=
clobValue
.
getCharacterStream
();
BufferedReader
br
=
new
BufferedReader
(
reader
);
String
line
;
while
(
null
!=
(
line
=
br
.
readLine
()))
{
sb
.
append
(
line
);
}
br
.
close
();
}
catch
(
SQLException
|
IOException
e
)
{
logger
.
error
(
e
.
getMessage
(),
e
);
}
result
=
sb
.
toString
();
}
return
result
;
}
public
static
Date
toDatefromStringFormat
(
String
value
,
String
format
)
{
Date
date
=
null
;
try
{
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
format
);
date
=
sdf
.
parse
(
value
);
if
(!
value
.
equals
(
sdf
.
format
(
date
)))
{
date
=
null
;
}
}
catch
(
Exception
ex
)
{
logger
.
error
(
ex
.
getMessage
(),
ex
);
}
return
date
;
}
public
static
boolean
isNumber
(
String
strId
)
{
return
strId
.
matches
(
"-?\\d+(\\.\\d+)?"
);
}
public
static
boolean
isLong
(
String
strId
)
{
return
strId
.
matches
(
"\\d*"
);
}
public
static
String
standardPhone
(
String
mobilePhone
)
{
if
(
mobilePhone
!=
null
)
{
if
(
mobilePhone
.
startsWith
(
"0"
))
{
mobilePhone
=
mobilePhone
.
substring
(
1
,
mobilePhone
.
length
());
}
else
if
(
mobilePhone
.
startsWith
(
"84"
))
{
mobilePhone
=
mobilePhone
.
substring
(
2
,
mobilePhone
.
length
());
}
}
return
mobilePhone
;
}
public
static
String
tohhmmss
(
Long
conferenctime
)
{
String
fmt
=
"0"
;
try
{
if
(
conferenctime
==
0
)
{
return
"0"
;
}
// conferencetime: tinh theo s
long
mmt
=
conferenctime
/
60
;
long
ss
=
conferenctime
%
60
;
long
mm
=
mmt
%
60
;
long
hh
=
mmt
/
60
;
fmt
=
replace
(
hh
)
+
":"
+
replace
(
mm
)
+
":"
+
replace
(
ss
);
}
catch
(
Exception
ex
)
{
logger
.
error
(
ex
);
}
return
fmt
;
}
public
static
String
replace
(
long
m
)
{
String
mt
=
String
.
valueOf
(
m
);
mt
=
(
m
>=
10
)
?
mt
:
'0'
+
mt
;
return
mt
;
}
public
static
String
getSafeFileName
(
String
input
)
{
StringBuilder
sb
=
new
StringBuilder
();
for
(
int
i
=
0
;
i
<
input
.
length
();
i
++)
{
char
c
=
input
.
charAt
(
i
);
if
(
c
!=
'/'
&&
c
!=
'\\'
&&
c
!=
0
)
{
sb
.
append
(
c
);
}
}
return
sb
.
toString
();
}
// public static void main(String[] args) {
//// Date rs = DataUtil.toDatefromStringFormat("20170702", "yyyyMMdd");
//// System.out.println(rs);
// String rs = standardPhoneNew("000953478578358");
// System.out.println(rs);
// }
public
static
String
standardPhoneNew
(
String
input
)
{
if
(
input
==
null
)
{
return
null
;
}
while
(
input
.
startsWith
(
"0"
))
{
input
=
input
.
substring
(
1
,
input
.
length
());
}
return
input
;
}
}
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