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
74231db4
Commit
74231db4
authored
Aug 07, 2019
by
Tu Bach
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tubn commit customer in campaign execute
parent
7ae90c84
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
151 additions
and
19 deletions
+151
-19
src/main/java/com/viettel/campaign/model/CustomerContact.java
...main/java/com/viettel/campaign/model/CustomerContact.java
+42
-0
src/main/java/com/viettel/campaign/repository/CustomerContactRepository.java
...iettel/campaign/repository/CustomerContactRepository.java
+7
-1
src/main/java/com/viettel/campaign/repository/CustomerRepository.java
...a/com/viettel/campaign/repository/CustomerRepository.java
+2
-0
src/main/java/com/viettel/campaign/repository/impl/CampaignRepositoryImpl.java
...ttel/campaign/repository/impl/CampaignRepositoryImpl.java
+19
-14
src/main/java/com/viettel/campaign/service/CustomerService.java
...in/java/com/viettel/campaign/service/CustomerService.java
+6
-0
src/main/java/com/viettel/campaign/service/impl/CustomerServiceImpl.java
...om/viettel/campaign/service/impl/CustomerServiceImpl.java
+41
-4
src/main/java/com/viettel/campaign/web/dto/CampaignDTO.java
src/main/java/com/viettel/campaign/web/dto/CampaignDTO.java
+1
-0
src/main/java/com/viettel/campaign/web/dto/CustomerContactDTO.java
...java/com/viettel/campaign/web/dto/CustomerContactDTO.java
+19
-0
src/main/java/com/viettel/campaign/web/rest/controller/CustomerController.java
...ttel/campaign/web/rest/controller/CustomerController.java
+14
-0
No files found.
src/main/java/com/viettel/campaign/model/CustomerContact.java
View file @
74231db4
package
com.viettel.campaign.model
;
import
lombok.Getter
;
import
lombok.Setter
;
import
javax.persistence.*
;
import
javax.validation.constraints.NotNull
;
import
java.util.Date
;
@Entity
@Table
(
name
=
"CUSTOMER_CONTACT"
)
@Getter
@Setter
public
class
CustomerContact
{
@Id
@Basic
(
optional
=
false
)
@NotNull
@Column
(
name
=
"CONTACT_ID"
)
private
Long
contactId
;
@Column
(
name
=
"CUSTOMER_ID"
)
private
Long
customerId
;
@Column
(
name
=
"CONTACT_TYPE"
)
private
Short
contactType
;
@Column
(
name
=
"CONTACT"
)
private
String
contact
;
@Column
(
name
=
"IS_DIRECT_LINE"
)
private
Short
isDirectLine
;
@Column
(
name
=
"STATUS"
)
private
Short
status
;
@Column
(
name
=
"CREATE_DATE"
)
@Temporal
(
TemporalType
.
TIMESTAMP
)
private
Date
createDate
;
@Column
(
name
=
"UPDATE_DATE"
)
@Temporal
(
TemporalType
.
TIMESTAMP
)
private
Date
updateDate
;
@Column
(
name
=
"CREATE_BY"
)
private
String
createBy
;
@Column
(
name
=
"UPDATE_BY"
)
private
String
updateBy
;
@Column
(
name
=
"START_DATE"
)
@Temporal
(
TemporalType
.
TIMESTAMP
)
private
Date
startDate
;
@Column
(
name
=
"END_DATE"
)
@Temporal
(
TemporalType
.
TIMESTAMP
)
private
Date
endDate
;
}
src/main/java/com/viettel/campaign/repository/CustomerContactRepository.java
View file @
74231db4
package
com.viettel.campaign.repository
;
public
class
CustomerContactRepository
{
import
com.viettel.campaign.model.CustomerContact
;
import
org.springframework.data.jpa.repository.JpaRepository
;
import
java.util.List
;
public
interface
CustomerContactRepository
extends
JpaRepository
<
CustomerContact
,
Long
>
{
List
<
CustomerContact
>
findByCustomerIdAndAndContactTypeAndContact
(
Long
customerId
,
Short
contactType
,
String
contact
);
}
src/main/java/com/viettel/campaign/repository/CustomerRepository.java
View file @
74231db4
...
...
@@ -16,6 +16,8 @@ public interface CustomerRepository extends JpaRepository<Customer, Long> {
Page
<
Customer
>
findAll
(
Pageable
pageable
);
List
<
Customer
>
findByCustomerId
(
Long
customerId
);
@Query
(
"FROM Customer WHERE name = ?1"
)
List
<
Customer
>
findByName
(
String
firstName
,
Pageable
pageable
);
...
...
src/main/java/com/viettel/campaign/repository/impl/CampaignRepositoryImpl.java
View file @
74231db4
...
...
@@ -39,18 +39,17 @@ public class CampaignRepositoryImpl implements CampaignRepositoryCustom {
ResultDTO
result
=
new
ResultDTO
();
List
<
CampaignDTO
>
lst
=
new
ArrayList
<>();
StringBuilder
expression
=
new
StringBuilder
()
.
append
(
" SELECT C.CAMPAIGN_CODE, C.CAMPAIGN_NAME, C.CONTENT, C.START_TIME, C.END_TIME, C.STATUS "
)
.
append
(
" SELECT C.CAMPAIGN_CODE, C.CAMPAIGN_NAME, C.CONTENT, C.START_TIME, C.END_TIME, C.STATUS
, CA.STATUS AS AGENT_STATUS
"
)
.
append
(
" FROM CAMPAIGN C INNER JOIN CAMPAIGN_AGENT CA ON C.CAMPAIGN_ID = CA.CAMPAIGN_ID "
)
.
append
(
" WHERE 1 = 1 "
)
.
append
(
" WHERE 1 = 1 "
)
;
//.append(" AND CA.AGENT_ID = :pAgentId ")
.
append
(
" AND C.STATUS IN (2,3) "
);
if
(!
DataUtil
.
isNullOrEmpty
(
campaignRequestDto
.
getCampaignCode
()))
{
expression
.
append
(
" AND C.CAMPAIGN_
ID IN (:pCampaingId
) "
);
expression
.
append
(
" AND C.CAMPAIGN_
CODE IN (:pCampaignCode
) "
);
}
if
(!
DataUtil
.
isNullOrEmpty
(
campaignRequestDto
.
getCampaignName
()))
{
expression
.
append
(
" AND UPPER(C.CAMPAIGN_NAME) LIKE
CONCAT('%',:pCampaignName,'%')
"
);
expression
.
append
(
" AND UPPER(C.CAMPAIGN_NAME) LIKE
:pCampaignName
"
);
}
if
(!
DataUtil
.
isNullOrZero
(
campaignRequestDto
.
getStatus
().
longValue
()))
{
...
...
@@ -90,40 +89,45 @@ public class CampaignRepositoryImpl implements CampaignRepositoryCustom {
if
(!
DataUtil
.
isNullOrEmpty
(
campaignRequestDto
.
getCampaignCode
()))
{
String
[]
lstCode
=
campaignRequestDto
.
getCampaignCode
().
split
(
","
);
query
.
setParameter
(
"
:pCampaingId
"
,
lstCode
);
query
.
setParameter
(
"
pCampaignCode
"
,
lstCode
);
}
if
(!
DataUtil
.
isNullOrEmpty
(
campaignRequestDto
.
getCampaignName
()))
{
query
.
setParameter
(
":pCampaignName"
,
campaignRequestDto
.
getCampaignName
().
toUpperCase
());
query
.
setParameter
(
"pCampaignName"
,
"%"
+
campaignRequestDto
.
getCampaignName
().
toUpperCase
()
.
replace
(
"\\"
,
"\\\\"
)
.
replaceAll
(
"%"
,
"\\\\%"
)
.
replaceAll
(
"_"
,
"\\\\_"
)
+
"%"
);
}
if
(!
DataUtil
.
isNullOrZero
(
campaignRequestDto
.
getStatus
().
longValue
()))
{
if
(
campaignRequestDto
.
getStatus
()
!=
0
)
query
.
setParameter
(
"
:
pStatus"
,
campaignRequestDto
.
getStatus
());
query
.
setParameter
(
"pStatus"
,
campaignRequestDto
.
getStatus
());
}
if
(!
DataUtil
.
isNullOrEmpty
(
campaignRequestDto
.
getFromDateFr
()))
{
query
.
setParameter
(
"
:
pStartTimeFr"
,
campaignRequestDto
.
getFromDateFr
());
query
.
setParameter
(
"pStartTimeFr"
,
campaignRequestDto
.
getFromDateFr
());
}
if
(!
DataUtil
.
isNullOrEmpty
(
campaignRequestDto
.
getFromDateTo
()))
{
query
.
setParameter
(
"
:
pStartTimeTo"
,
campaignRequestDto
.
getFromDateTo
());
query
.
setParameter
(
"pStartTimeTo"
,
campaignRequestDto
.
getFromDateTo
());
}
if
(!
DataUtil
.
isNullOrEmpty
(
campaignRequestDto
.
getToDateFr
()))
{
query
.
setParameter
(
"
:
pEndTimeFr"
,
campaignRequestDto
.
getToDateFr
());
query
.
setParameter
(
"pEndTimeFr"
,
campaignRequestDto
.
getToDateFr
());
}
if
(!
DataUtil
.
isNullOrEmpty
(
campaignRequestDto
.
getToDateTo
()))
{
query
.
setParameter
(
"
:
pEndTimeTo"
,
campaignRequestDto
.
getToDateTo
());
query
.
setParameter
(
"pEndTimeTo"
,
campaignRequestDto
.
getToDateTo
());
}
if
(!
DataUtil
.
isNullOrZero
(
campaignRequestDto
.
getNumOfCusFr
()))
{
query
.
setParameter
(
"
:
pCustNumFr"
,
campaignRequestDto
.
getNumOfCusFr
());
query
.
setParameter
(
"pCustNumFr"
,
campaignRequestDto
.
getNumOfCusFr
());
}
if
(!
DataUtil
.
isNullOrZero
(
campaignRequestDto
.
getNumOfCusTo
()))
{
query
.
setParameter
(
"
:
pCustNumTo"
,
campaignRequestDto
.
getNumOfCusTo
());
query
.
setParameter
(
"pCustNumTo"
,
campaignRequestDto
.
getNumOfCusTo
());
}
result
.
setTotalRow
(
query
.
getResultList
().
size
());
...
...
@@ -147,6 +151,7 @@ public class CampaignRepositoryImpl implements CampaignRepositoryCustom {
item
.
setStartTime
((
Date
)
obj
[
3
]);
item
.
setEndTime
((
Date
)
obj
[
4
]);
item
.
setStatus
(((
BigDecimal
)
obj
[
5
]).
shortValueExact
());
item
.
setAgentStatus
(((
BigDecimal
)
obj
[
6
]).
shortValueExact
());
lst
.
add
(
item
);
}
...
...
src/main/java/com/viettel/campaign/service/CustomerService.java
View file @
74231db4
...
...
@@ -12,6 +12,8 @@ public interface CustomerService {
Map
listAllCustomer
(
int
page
,
int
pageSize
,
String
sort
);
ResultDTO
getCustomerId
(
Long
customerId
);
Map
listCustByName
(
int
page
,
int
pageSize
,
String
sort
,
String
name
);
ResultDTO
createCustomer
(
CustomerDTO
customerDTO
);
...
...
@@ -33,4 +35,8 @@ public interface CustomerService {
ResultDTO
deleteCustomerListIds
(
List
<
Long
>
ids
);
ResultDTO
searchCustomerList
(
String
customerListCode
,
String
customerListName
,
Date
dateFrom
,
Date
dateTo
,
int
page
,
int
pageSize
,
String
sort
);
// ------------ customer list ------------ //
ResultDTO
getCustomerContact
(
Long
customerId
,
Short
contactType
,
String
contact
);
}
src/main/java/com/viettel/campaign/service/impl/CustomerServiceImpl.java
View file @
74231db4
package
com.viettel.campaign.service.impl
;
import
com.viettel.campaign.mapper.CustomerListMapper
;
import
com.viettel.campaign.model.CustomerContact
;
import
com.viettel.campaign.model.CustomerList
;
import
com.viettel.campaign.repository.CampaignCustomerListRepository
;
import
com.viettel.campaign.repository.CustomerListMappingRepository
;
import
com.viettel.campaign.repository.CustomerListRepository
;
import
com.viettel.campaign.repository.*
;
import
com.viettel.campaign.service.CustomerService
;
import
com.viettel.campaign.utils.Constants
;
import
com.viettel.campaign.utils.HibernateUtil
;
...
...
@@ -14,7 +13,6 @@ import com.viettel.campaign.web.dto.CustomerListDTO;
import
com.viettel.campaign.web.dto.ResultDTO
;
import
com.viettel.campaign.mapper.CustomerMapper
;
import
com.viettel.campaign.model.Customer
;
import
com.viettel.campaign.repository.CustomerRepository
;
import
com.viettel.campaign.utils.DataUtil
;
import
org.hibernate.SQLQuery
;
import
org.hibernate.Session
;
...
...
@@ -41,6 +39,9 @@ public class CustomerServiceImpl implements CustomerService {
@Autowired
CustomerListRepository
customerListRepository
;
@Autowired
CustomerContactRepository
customerContactRepository
;
@Autowired
CampaignCustomerListRepository
campaignCustomerListRepository
;
...
...
@@ -61,6 +62,24 @@ public class CustomerServiceImpl implements CustomerService {
return
result
;
}
@Override
public
ResultDTO
getCustomerId
(
Long
customerId
)
{
ResultDTO
resultDTO
=
new
ResultDTO
();
List
<
Customer
>
customer
=
customerRepository
.
findByCustomerId
(
customerId
);
if
(
customer
!=
null
)
{
resultDTO
.
setErrorCode
(
Constants
.
ApiErrorCode
.
SUCCESS
);
resultDTO
.
setDescription
(
"customer data"
);
resultDTO
.
setListData
(
customer
);
}
else
{
resultDTO
.
setErrorCode
(
Constants
.
ApiErrorCode
.
ERROR
);
resultDTO
.
setDescription
(
"customer data null"
);
}
return
resultDTO
;
}
@Override
public
Map
listCustByName
(
int
page
,
int
pageSize
,
String
sort
,
String
name
)
{
Map
result
=
new
HashMap
();
...
...
@@ -356,4 +375,22 @@ public class CustomerServiceImpl implements CustomerService {
return
resultDTO
;
}
@Override
public
ResultDTO
getCustomerContact
(
Long
customerId
,
Short
contactType
,
String
contact
)
{
ResultDTO
result
=
new
ResultDTO
();
List
<
CustomerContact
>
customer
=
customerContactRepository
.
findByCustomerIdAndAndContactTypeAndContact
(
customerId
,
contactType
,
contact
);
if
(
customer
!=
null
)
{
result
.
setErrorCode
(
Constants
.
ApiErrorCode
.
SUCCESS
);
result
.
setDescription
(
"customer contact data"
);
result
.
setListData
(
customer
);
}
else
{
result
.
setErrorCode
(
Constants
.
ApiErrorCode
.
ERROR
);
result
.
setDescription
(
"customer contact data null"
);
}
return
result
;
}
}
src/main/java/com/viettel/campaign/web/dto/CampaignDTO.java
View file @
74231db4
...
...
@@ -58,4 +58,5 @@ public class CampaignDTO extends BaseDTO {
private
Long
numOfNotJoinedCus
;
private
Long
numOfLockCus
;
private
String
campaignTypeName
;
private
Short
agentStatus
;
}
src/main/java/com/viettel/campaign/web/dto/CustomerContactDTO.java
View file @
74231db4
package
com.viettel.campaign.web.dto
;
import
lombok.Getter
;
import
lombok.Setter
;
import
java.util.Date
;
@Getter
@Setter
public
class
CustomerContactDTO
{
private
Long
contactId
;
private
Long
customerId
;
private
Short
contactType
;
private
String
contact
;
private
Short
isDirectLine
;
private
Short
status
;
private
Date
createDate
;
private
Date
updateDate
;
private
String
createBy
;
private
String
updateBy
;
private
Date
startDate
;
private
Date
endDate
;
}
src/main/java/com/viettel/campaign/web/rest/controller/CustomerController.java
View file @
74231db4
...
...
@@ -33,6 +33,13 @@ public class CustomerController {
return
new
ResponseEntity
<>(
result
,
HttpStatus
.
OK
);
}
@GetMapping
(
"/findCustomerId"
)
@ResponseBody
public
ResponseEntity
<
ResultDTO
>
findAllCustomerName
(
@RequestParam
(
"customerId"
)
Long
customerId
)
{
ResultDTO
result
=
customerService
.
getCustomerId
(
customerId
);
return
new
ResponseEntity
(
result
,
HttpStatus
.
OK
);
}
@GetMapping
(
"/findCustomerByName"
)
@ResponseBody
public
ResponseEntity
findAllCustomerName
(
@RequestParam
(
"page"
)
int
page
,
@RequestParam
(
"pageSize"
)
int
pageSize
,
@RequestParam
(
"sort"
)
String
sort
,
@RequestParam
(
"name"
)
String
name
)
{
...
...
@@ -146,4 +153,11 @@ public class CustomerController {
ResultDTO
result
=
customerService
.
searchCustomerList
(
customerListCode
,
customerListName
,
dateFrom
,
dateTo
,
page
,
pageSize
,
sort
);
return
new
ResponseEntity
<>(
result
,
HttpStatus
.
OK
);
}
@GetMapping
(
"/findCustomerContact"
)
@ResponseBody
public
ResponseEntity
<
ResultDTO
>
findAllCustomerContact
(
@RequestParam
(
"customerId"
)
Long
customerId
,
@RequestParam
(
"contactType"
)
Short
contactType
,
@RequestParam
(
"contact"
)
String
contact
)
{
ResultDTO
result
=
customerService
.
getCustomerContact
(
customerId
,
contactType
,
contact
);
return
new
ResponseEntity
(
result
,
HttpStatus
.
OK
);
}
}
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