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
81c79e34
Commit
81c79e34
authored
Aug 28, 2019
by
Tu Bach
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' into tubn
parents
6893fb8c
ce797e37
Changes
30
Hide whitespace changes
Inline
Side-by-side
Showing
30 changed files
with
662 additions
and
172 deletions
+662
-172
.DS_Store
.DS_Store
+0
-0
src/main/java/com/viettel/campaign/filter/CorsFilter.java
src/main/java/com/viettel/campaign/filter/CorsFilter.java
+21
-21
src/main/java/com/viettel/campaign/model/ccms_full/ApParam.java
...in/java/com/viettel/campaign/model/ccms_full/ApParam.java
+1
-1
src/main/java/com/viettel/campaign/repository/ccms_full/ApParamRepository.java
...ttel/campaign/repository/ccms_full/ApParamRepository.java
+9
-0
src/main/java/com/viettel/campaign/repository/ccms_full/CampaignCustomerRepository.java
...aign/repository/ccms_full/CampaignCustomerRepository.java
+5
-0
src/main/java/com/viettel/campaign/repository/ccms_full/CustomerQueryRepository.java
...ampaign/repository/ccms_full/CustomerQueryRepository.java
+9
-0
src/main/java/com/viettel/campaign/repository/ccms_full/CustomizeFieldsRepository.java
...paign/repository/ccms_full/CustomizeFieldsRepository.java
+7
-0
src/main/java/com/viettel/campaign/repository/ccms_full/impl/CampaignRepositoryImpl.java
...ign/repository/ccms_full/impl/CampaignRepositoryImpl.java
+1
-0
src/main/java/com/viettel/campaign/repository/ccms_full/impl/CustomerQueryRepositoryImpl.java
...epository/ccms_full/impl/CustomerQueryRepositoryImpl.java
+28
-0
src/main/java/com/viettel/campaign/service/CustomerService.java
...in/java/com/viettel/campaign/service/CustomerService.java
+13
-3
src/main/java/com/viettel/campaign/service/ScenarioService.java
...in/java/com/viettel/campaign/service/ScenarioService.java
+2
-1
src/main/java/com/viettel/campaign/service/impl/CampaignCfgServiceImpl.java
...viettel/campaign/service/impl/CampaignCfgServiceImpl.java
+1
-0
src/main/java/com/viettel/campaign/service/impl/CampaignServiceImpl.java
...om/viettel/campaign/service/impl/CampaignServiceImpl.java
+1
-0
src/main/java/com/viettel/campaign/service/impl/CustomerServiceImpl.java
...om/viettel/campaign/service/impl/CustomerServiceImpl.java
+302
-73
src/main/java/com/viettel/campaign/service/impl/ScenarioServiceImpl.java
...om/viettel/campaign/service/impl/ScenarioServiceImpl.java
+113
-19
src/main/java/com/viettel/campaign/web/dto/ApParamDTO.java
src/main/java/com/viettel/campaign/web/dto/ApParamDTO.java
+1
-1
src/main/java/com/viettel/campaign/web/dto/CampaignCustomerDTO.java
...ava/com/viettel/campaign/web/dto/CampaignCustomerDTO.java
+1
-0
src/main/java/com/viettel/campaign/web/dto/CustomerDTO.java
src/main/java/com/viettel/campaign/web/dto/CustomerDTO.java
+1
-0
src/main/java/com/viettel/campaign/web/dto/CustomizeFielObjectDTO.java
.../com/viettel/campaign/web/dto/CustomizeFielObjectDTO.java
+4
-1
src/main/java/com/viettel/campaign/web/dto/CustomizeFieldsDTO.java
...java/com/viettel/campaign/web/dto/CustomizeFieldsDTO.java
+32
-0
src/main/java/com/viettel/campaign/web/dto/ScenarioAnswerDTO.java
.../java/com/viettel/campaign/web/dto/ScenarioAnswerDTO.java
+2
-0
src/main/java/com/viettel/campaign/web/dto/ScenarioQuestionDTO.java
...ava/com/viettel/campaign/web/dto/ScenarioQuestionDTO.java
+1
-0
src/main/java/com/viettel/campaign/web/dto/request_dto/CustomerQueryDTO.java
...iettel/campaign/web/dto/request_dto/CustomerQueryDTO.java
+14
-0
src/main/java/com/viettel/campaign/web/dto/request_dto/CustomizeRequestDTo.java
...tel/campaign/web/dto/request_dto/CustomizeRequestDTo.java
+18
-2
src/main/java/com/viettel/campaign/web/dto/request_dto/RequestImportDTO.java
...iettel/campaign/web/dto/request_dto/RequestImportDTO.java
+15
-0
src/main/java/com/viettel/campaign/web/rest/CampaignController.java
...ava/com/viettel/campaign/web/rest/CampaignController.java
+0
-28
src/main/java/com/viettel/campaign/web/rest/CustomerController.java
...ava/com/viettel/campaign/web/rest/CustomerController.java
+34
-6
src/main/java/com/viettel/campaign/web/rest/ScenarioController.java
...ava/com/viettel/campaign/web/rest/ScenarioController.java
+17
-9
src/main/resources/i18n/language_en.properties
src/main/resources/i18n/language_en.properties
+1
-0
src/main/resources/i18n/language_vi.properties
src/main/resources/i18n/language_vi.properties
+8
-7
No files found.
.DS_Store
View file @
81c79e34
No preview for this file type
src/main/java/com/viettel/campaign/filter/CorsFilter.java
View file @
81c79e34
...
@@ -30,27 +30,27 @@ public class CorsFilter implements Filter {
...
@@ -30,27 +30,27 @@ public class CorsFilter implements Filter {
HttpServletRequest
request
=
(
HttpServletRequest
)
req
;
HttpServletRequest
request
=
(
HttpServletRequest
)
req
;
//
chain.doFilter(req, response);
chain
.
doFilter
(
req
,
response
);
if
(
"OPTIONS"
.
equalsIgnoreCase
(
request
.
getMethod
()))
{
//
if ("OPTIONS".equalsIgnoreCase(request.getMethod())) {
chain
.
doFilter
(
req
,
resp
);
//
chain.doFilter(req, resp);
return
;
//
return;
}
//
}
if
(
"/"
.
equals
(
request
.
getRequestURI
()))
{
//
if ("/".equals(request.getRequestURI())) {
chain
.
doFilter
(
req
,
resp
);
//
chain.doFilter(req, resp);
return
;
//
return;
}
//
}
String
xAuthToken
=
request
.
getHeader
(
"X-Auth-Token"
);
//
String xAuthToken = request.getHeader("X-Auth-Token");
if
(
xAuthToken
==
null
||
""
.
equals
(
xAuthToken
))
{
//
if (xAuthToken == null || "".equals(xAuthToken)) {
response
.
sendError
(
HttpServletResponse
.
SC_UNAUTHORIZED
,
"The token is null."
);
//
response.sendError(HttpServletResponse.SC_UNAUTHORIZED, "The token is null.");
return
;
//
return;
}
//
}
Object
obj
=
RedisUtil
.
getInstance
().
get
(
xAuthToken
);
//
Object obj = RedisUtil.getInstance().get(xAuthToken);
if
(
obj
instanceof
UserSession
)
{
//
if (obj instanceof UserSession) {
chain
.
doFilter
(
req
,
resp
);
//
chain.doFilter(req, resp);
}
else
{
//
} else {
response
.
sendError
(
HttpServletResponse
.
SC_UNAUTHORIZED
,
"The token is invalid."
);
//
response.sendError(HttpServletResponse.SC_UNAUTHORIZED, "The token is invalid.");
}
//
}
}
}
@Override
@Override
...
...
src/main/java/com/viettel/campaign/model/ccms_full/ApParam.java
View file @
81c79e34
...
@@ -32,7 +32,7 @@ public class ApParam implements Serializable {
...
@@ -32,7 +32,7 @@ public class ApParam implements Serializable {
private
String
parCode
;
private
String
parCode
;
@Column
(
name
=
"DESCRIPTION"
)
@Column
(
name
=
"DESCRIPTION"
)
private
Lo
ng
description
;
private
Stri
ng
description
;
@Column
(
name
=
"IS_DELETE"
)
@Column
(
name
=
"IS_DELETE"
)
private
Long
isDelete
;
private
Long
isDelete
;
...
...
src/main/java/com/viettel/campaign/repository/ccms_full/ApParamRepository.java
View file @
81c79e34
...
@@ -4,6 +4,7 @@ import com.viettel.campaign.model.ccms_full.ApParam;
...
@@ -4,6 +4,7 @@ import com.viettel.campaign.model.ccms_full.ApParam;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.data.jpa.repository.JpaRepository
;
import
org.springframework.data.jpa.repository.JpaRepository
;
import
org.springframework.data.jpa.repository.Modifying
;
import
org.springframework.data.jpa.repository.Query
;
import
org.springframework.data.jpa.repository.Query
;
import
org.springframework.data.repository.query.Param
;
import
org.springframework.data.repository.query.Param
;
import
org.springframework.stereotype.Repository
;
import
org.springframework.stereotype.Repository
;
...
@@ -23,4 +24,12 @@ public interface ApParamRepository extends JpaRepository<ApParam, Long> {
...
@@ -23,4 +24,12 @@ public interface ApParamRepository extends JpaRepository<ApParam, Long> {
@Query
(
value
=
"FROM ApParam WHERE status = 1 AND parType = :parType"
)
@Query
(
value
=
"FROM ApParam WHERE status = 1 AND parType = :parType"
)
List
<
ApParam
>
findAllParam
(
@Param
(
"parType"
)
String
parType
);
List
<
ApParam
>
findAllParam
(
@Param
(
"parType"
)
String
parType
);
// ----------- sql lay so thu tu bang customer list ------------ //
@Query
(
"select a from ApParam a where a.parType = 'CUSTOMER_LIST_SEQ'"
)
ApParam
getCustomerListSeq
();
@Modifying
@Query
(
"update ApParam a set a.parValue = :p_par_value, a.description = :p_description where a.parType = 'CUSTOMER_LIST_SEQ'"
)
int
updateCustomerListSeq
(
@Param
(
"p_par_value"
)
String
p_par_value
,
@Param
(
"p_description"
)
String
p_description
);
}
}
src/main/java/com/viettel/campaign/repository/ccms_full/CampaignCustomerRepository.java
View file @
81c79e34
...
@@ -88,4 +88,9 @@ public interface CampaignCustomerRepository extends JpaRepository<CampaignCustom
...
@@ -88,4 +88,9 @@ public interface CampaignCustomerRepository extends JpaRepository<CampaignCustom
" and customer_list_id = :p_cus_list_id\n"
+
" and customer_list_id = :p_cus_list_id\n"
+
" and (status = 0 or status in (select * from status_customer))"
,
nativeQuery
=
true
)
" and (status = 0 or status in (select * from status_customer))"
,
nativeQuery
=
true
)
List
<
CampaignCustomer
>
findListCustomerToDel
(
@Param
(
"p_company_site_id"
)
Long
companySiteId
,
@Param
(
"p_campaign_id"
)
Long
campaignId
,
@Param
(
"p_cus_list_id"
)
Long
customerListId
);
List
<
CampaignCustomer
>
findListCustomerToDel
(
@Param
(
"p_company_site_id"
)
Long
companySiteId
,
@Param
(
"p_campaign_id"
)
Long
campaignId
,
@Param
(
"p_cus_list_id"
)
Long
customerListId
);
CampaignCustomer
findCampaignCustomerByCampaignIdAndCompanySiteIdAndCustomerId
(
Long
campaignId
,
Long
companySiteId
,
Long
customerId
);
@Query
(
value
=
"select complete_value from campaign_complete_code where status = 1 and is_finish = 0 and is_recall = 0"
,
nativeQuery
=
true
)
List
<
Short
>
getStatus
();
}
}
src/main/java/com/viettel/campaign/repository/ccms_full/CustomerQueryRepository.java
0 → 100644
View file @
81c79e34
package
com.viettel.campaign.repository.ccms_full
;
import
com.viettel.campaign.model.ccms_full.Customer
;
import
java.util.List
;
public
interface
CustomerQueryRepository
{
List
<
Customer
>
findAll
(
String
rsqlQuery
);
}
src/main/java/com/viettel/campaign/repository/ccms_full/CustomizeFieldsRepository.java
View file @
81c79e34
package
com.viettel.campaign.repository.ccms_full
;
package
com.viettel.campaign.repository.ccms_full
;
import
com.viettel.campaign.config.DataSourceQualify
;
import
com.viettel.campaign.model.ccms_full.CustomizeFields
;
import
com.viettel.campaign.model.ccms_full.CustomizeFields
;
import
org.springframework.data.jpa.repository.JpaRepository
;
import
org.springframework.data.jpa.repository.JpaRepository
;
import
org.springframework.data.jpa.repository.Query
;
import
org.springframework.stereotype.Repository
;
import
org.springframework.stereotype.Repository
;
import
org.springframework.transaction.annotation.Transactional
;
import
java.util.List
;
import
java.util.List
;
@Repository
@Repository
@Transactional
(
DataSourceQualify
.
CCMS_FULL
)
public
interface
CustomizeFieldsRepository
extends
JpaRepository
<
CustomizeFields
,
Long
>
{
public
interface
CustomizeFieldsRepository
extends
JpaRepository
<
CustomizeFields
,
Long
>
{
List
<
CustomizeFields
>
findCustomizeFieldsByFunctionCodeEqualsAndStatusAndActiveAndSiteId
(
String
functionCode
,
Long
status
,
Long
active
,
Long
siteId
);
List
<
CustomizeFields
>
findCustomizeFieldsByFunctionCodeEqualsAndStatusAndActiveAndSiteId
(
String
functionCode
,
Long
status
,
Long
active
,
Long
siteId
);
List
<
CustomizeFields
>
findByFunctionCodeAndActiveAndStatusAndSiteId
(
String
functionCode
,
Long
active
,
Long
status
,
Long
siteId
);
}
}
src/main/java/com/viettel/campaign/repository/ccms_full/impl/CampaignRepositoryImpl.java
View file @
81c79e34
...
@@ -638,6 +638,7 @@ public class CampaignRepositoryImpl implements CampaignRepositoryCustom {
...
@@ -638,6 +638,7 @@ public class CampaignRepositoryImpl implements CampaignRepositoryCustom {
"),\n"
+
"),\n"
+
"data as (\n"
+
"data as (\n"
+
"select a.*, rownum row_ from data_temp a\n"
+
"select a.*, rownum row_ from data_temp a\n"
+
"where a.totalCusList > 0"
+
"),\n"
+
"),\n"
+
"count_data as (\n"
+
"count_data as (\n"
+
"select count(*) totalRow from data_temp\n"
+
"select count(*) totalRow from data_temp\n"
+
...
...
src/main/java/com/viettel/campaign/repository/ccms_full/impl/CustomerQueryRepositoryImpl.java
0 → 100644
View file @
81c79e34
package
com.viettel.campaign.repository.ccms_full.impl
;
import
com.github.tennaito.rsql.jpa.JpaCriteriaQueryVisitor
;
import
com.viettel.campaign.model.ccms_full.Customer
;
import
com.viettel.campaign.repository.ccms_full.CustomerQueryRepository
;
import
cz.jirutka.rsql.parser.RSQLParser
;
import
cz.jirutka.rsql.parser.ast.Node
;
import
cz.jirutka.rsql.parser.ast.RSQLVisitor
;
import
javax.persistence.EntityManager
;
import
javax.persistence.PersistenceContext
;
import
javax.persistence.criteria.CriteriaQuery
;
import
java.util.List
;
public
class
CustomerQueryRepositoryImpl
implements
CustomerQueryRepository
{
@PersistenceContext
private
EntityManager
entityManager
;
private
RSQLVisitor
<
CriteriaQuery
<
Customer
>,
EntityManager
>
visitor
=
new
JpaCriteriaQueryVisitor
<
Customer
>();
private
RSQLParser
parser
=
new
RSQLParser
();
@Override
public
List
<
Customer
>
findAll
(
String
rsqlQuery
)
{
Node
node
=
parser
.
parse
(
rsqlQuery
);
CriteriaQuery
<
Customer
>
query
=
node
.
accept
(
visitor
,
entityManager
);
return
entityManager
.
createQuery
(
query
).
getResultList
();
}
}
src/main/java/com/viettel/campaign/service/CustomerService.java
View file @
81c79e34
...
@@ -5,6 +5,7 @@ import com.viettel.campaign.model.ccms_full.CustomerList;
...
@@ -5,6 +5,7 @@ import com.viettel.campaign.model.ccms_full.CustomerList;
import
com.viettel.campaign.model.ccms_full.CustomizeFieldObject
;
import
com.viettel.campaign.model.ccms_full.CustomizeFieldObject
;
import
com.viettel.campaign.model.ccms_full.CustomizeFields
;
import
com.viettel.campaign.model.ccms_full.CustomizeFields
;
import
com.viettel.campaign.web.dto.*
;
import
com.viettel.campaign.web.dto.*
;
import
com.viettel.campaign.web.dto.request_dto.CustomerQueryDTO
;
import
com.viettel.campaign.web.dto.request_dto.CustomerRequestDTO
;
import
com.viettel.campaign.web.dto.request_dto.CustomerRequestDTO
;
import
com.viettel.campaign.web.dto.request_dto.CustomizeRequestDTo
;
import
com.viettel.campaign.web.dto.request_dto.CustomizeRequestDTo
;
import
com.viettel.campaign.web.dto.request_dto.SearchCustomerRequestDTO
;
import
com.viettel.campaign.web.dto.request_dto.SearchCustomerRequestDTO
;
...
@@ -38,7 +39,7 @@ public interface CustomerService {
...
@@ -38,7 +39,7 @@ public interface CustomerService {
// VIẾT ĐI VIẾT LẠI 4 LẦN RỒI ĐẤY
// VIẾT ĐI VIẾT LẠI 4 LẦN RỒI ĐẤY
ResultDTO
createCustomerList
(
CustomerListDTO
customerListDTO
,
String
userName
);
ResultDTO
createCustomerList
(
CustomerListDTO
customerListDTO
,
String
userName
);
ResultDTO
updateCustomerList
(
CustomerListDTO
customerListDTO
);
ResultDTO
updateCustomerList
(
CustomerListDTO
customerListDTO
,
String
userName
);
ResultDTO
deleteCustomerList
(
CustomerListDTO
customerListDTO
);
ResultDTO
deleteCustomerList
(
CustomerListDTO
customerListDTO
);
...
@@ -58,12 +59,15 @@ public interface CustomerService {
...
@@ -58,12 +59,15 @@ public interface CustomerService {
List
<
CustomerDTO
>
getIndividualCustomerInfo
(
CampaignCustomerDTO
campaignCustomerDTO
);
List
<
CustomerDTO
>
getIndividualCustomerInfo
(
CampaignCustomerDTO
campaignCustomerDTO
);
ResultDTO
deleteCustomerFromCampaign
(
CampaignCustomerDTO
campaignCustomerDTO
);
// ------------ customer ------------ //
// ------------ customer ------------ //
ResultDTO
getCustomerRecall
(
Long
campaignId
,
Long
customerId
);
ResultDTO
getCustomerRecall
(
Long
campaignId
,
Long
customerId
);
List
<
Customer
>
findAllByCondition
(
Long
siteId
,
Date
endTime
);
List
<
Customer
>
findAllByCondition
(
Long
siteId
,
Date
endTime
);
Customer
update
(
Customer
c
);
Customer
update
(
Customer
c
);
List
<
CustomizeFields
>
getDynamicHeader
(
Long
companySiteId
);
List
<
CustomizeFields
>
getDynamicHeader
(
Long
companySiteId
);
...
@@ -73,9 +77,15 @@ public interface CustomerService {
...
@@ -73,9 +77,15 @@ public interface CustomerService {
Map
<
String
,
Object
>
readAndValidateCustomer
(
String
path
,
List
<
CustomizeFields
>
headerDTOS
,
UserSession
userSession
,
Long
customerListId
);
Map
<
String
,
Object
>
readAndValidateCustomer
(
String
path
,
List
<
CustomizeFields
>
headerDTOS
,
UserSession
userSession
,
Long
customerListId
);
List
<
CustomizeFieldObject
>
getCustomizeField
(
Long
customerId
);
List
<
CustomizeFieldObject
>
getCustomizeField
(
Long
customerId
);
List
<
Customer
>
searchByQuery
(
String
queryString
);
List
<
Customer
>
searchByQuery
(
String
queryString
);
Long
countByQuery
(
String
queryString
);
Long
countByQuery
(
String
queryString
);
// Map<String, CustomizeRequestDTo> searchCustomer();
// Map<String, CustomizeRequestDTo> searchCustomer();
//// List<CustomizeFields> searchCustomize();
//// List<CustomizeFields> searchCustomize();
ResultDTO
searchCustomizeFields
(
CustomizeRequestDTo
customizeFields
);
ResultDTO
listCustomizeFields
(
CustomizeFieldsDTO
customizeFields
);
ResultDTO
searchCustomizeFields
(
int
page
,
int
pageSize
,
long
companySiteId
,
long
campaignId
,
CustomerQueryDTO
customerQueryDTO
);
}
}
src/main/java/com/viettel/campaign/service/ScenarioService.java
View file @
81c79e34
...
@@ -4,6 +4,7 @@ import com.viettel.campaign.model.ccms_full.Scenario;
...
@@ -4,6 +4,7 @@ import com.viettel.campaign.model.ccms_full.Scenario;
import
com.viettel.campaign.web.dto.*
;
import
com.viettel.campaign.web.dto.*
;
import
com.viettel.econtact.filter.UserSession
;
import
com.viettel.econtact.filter.UserSession
;
import
org.apache.poi.xssf.usermodel.XSSFWorkbook
;
import
org.apache.poi.xssf.usermodel.XSSFWorkbook
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
...
@@ -25,5 +26,5 @@ public interface ScenarioService {
...
@@ -25,5 +26,5 @@ public interface ScenarioService {
XSSFWorkbook
buildTemplate
();
XSSFWorkbook
buildTemplate
();
Map
<
String
,
Object
>
readAndValidateCustomer
(
String
path
,
UserSession
userSession
);
Map
<
String
,
Object
>
readAndValidateCustomer
(
String
path
,
Long
scenarioId
,
Long
campaignId
,
Long
companySiteId
);
}
}
src/main/java/com/viettel/campaign/service/impl/CampaignCfgServiceImpl.java
View file @
81c79e34
...
@@ -83,6 +83,7 @@ public class CampaignCfgServiceImpl implements CampaignCfgService {
...
@@ -83,6 +83,7 @@ public class CampaignCfgServiceImpl implements CampaignCfgService {
sb
.
append
(
" and COMPANY_SITE_ID = :p_company_site_id"
);
sb
.
append
(
" and COMPANY_SITE_ID = :p_company_site_id"
);
sb
.
append
(
" and COMPLETE_VALUE not in (1,2,3,4)"
);
sb
.
append
(
" and COMPLETE_VALUE not in (1,2,3,4)"
);
sb
.
append
(
"ORDER BY to_number(COMPLETE_VALUE) "
);
sb
.
append
(
"ORDER BY to_number(COMPLETE_VALUE) "
);
logger
.
info
(
"SQL statement: "
+
sb
);
...
...
src/main/java/com/viettel/campaign/service/impl/CampaignServiceImpl.java
View file @
81c79e34
...
@@ -555,6 +555,7 @@ public class CampaignServiceImpl implements CampaignService {
...
@@ -555,6 +555,7 @@ public class CampaignServiceImpl implements CampaignService {
List
<
CampaignCustomer
>
list
=
campaignCustomerRepository
.
findCustomerContacted
(
campaignId
,
companySiteId
,
Long
.
parseLong
(
cusListId
));
List
<
CampaignCustomer
>
list
=
campaignCustomerRepository
.
findCustomerContacted
(
campaignId
,
companySiteId
,
Long
.
parseLong
(
cusListId
));
for
(
CampaignCustomer
campaignCustomer:
list
)
{
for
(
CampaignCustomer
campaignCustomer:
list
)
{
campaignCustomer
.
setInCampaignStatus
((
short
)
0
);
campaignCustomer
.
setInCampaignStatus
((
short
)
0
);
campaignCustomerRepository
.
save
(
campaignCustomer
);
}
}
}
}
resultDTO
.
setErrorCode
(
Constants
.
ApiErrorCode
.
SUCCESS
);
resultDTO
.
setErrorCode
(
Constants
.
ApiErrorCode
.
SUCCESS
);
...
...
src/main/java/com/viettel/campaign/service/impl/CustomerServiceImpl.java
View file @
81c79e34
...
@@ -10,10 +10,7 @@ import com.viettel.campaign.repository.ccms_full.*;
...
@@ -10,10 +10,7 @@ import com.viettel.campaign.repository.ccms_full.*;
import
com.viettel.campaign.service.CustomerService
;
import
com.viettel.campaign.service.CustomerService
;
import
com.viettel.campaign.utils.*
;
import
com.viettel.campaign.utils.*
;
import
com.viettel.campaign.web.dto.*
;
import
com.viettel.campaign.web.dto.*
;
import
com.viettel.campaign.web.dto.request_dto.CustomerDetailRequestDTO
;
import
com.viettel.campaign.web.dto.request_dto.*
;
import
com.viettel.campaign.web.dto.request_dto.CustomerRequestDTO
;
import
com.viettel.campaign.web.dto.request_dto.CustomizeRequestDTo
;
import
com.viettel.campaign.web.dto.request_dto.SearchCustomerRequestDTO
;
import
com.viettel.econtact.filter.UserSession
;
import
com.viettel.econtact.filter.UserSession
;
import
cz.jirutka.rsql.parser.RSQLParser
;
import
cz.jirutka.rsql.parser.RSQLParser
;
import
cz.jirutka.rsql.parser.ast.Node
;
import
cz.jirutka.rsql.parser.ast.Node
;
...
@@ -48,6 +45,8 @@ import java.io.ByteArrayOutputStream;
...
@@ -48,6 +45,8 @@ import java.io.ByteArrayOutputStream;
import
java.io.File
;
import
java.io.File
;
import
java.io.FileInputStream
;
import
java.io.FileInputStream
;
import
java.io.FileOutputStream
;
import
java.io.FileOutputStream
;
import
java.lang.reflect.Array
;
import
java.text.DateFormat
;
import
java.text.SimpleDateFormat
;
import
java.text.SimpleDateFormat
;
import
java.util.*
;
import
java.util.*
;
...
@@ -94,6 +93,9 @@ public class CustomerServiceImpl implements CustomerService {
...
@@ -94,6 +93,9 @@ public class CustomerServiceImpl implements CustomerService {
@Autowired
@Autowired
CustomizeFieldOptionValueRepository
customizeFieldOptionValueRepository
;
CustomizeFieldOptionValueRepository
customizeFieldOptionValueRepository
;
@Autowired
ApParamRepository
apParamRepository
;
@Override
@Override
@Transactional
(
DataSourceQualify
.
CCMS_FULL
)
@Transactional
(
DataSourceQualify
.
CCMS_FULL
)
public
ResultDTO
getAllCustomer
(
int
page
,
int
pageSize
,
String
sort
,
long
customerListId
,
long
companySiteId
)
{
public
ResultDTO
getAllCustomer
(
int
page
,
int
pageSize
,
String
sort
,
long
customerListId
,
long
companySiteId
)
{
...
@@ -280,7 +282,7 @@ public class CustomerServiceImpl implements CustomerService {
...
@@ -280,7 +282,7 @@ public class CustomerServiceImpl implements CustomerService {
if
(!
DataUtil
.
isNullOrEmpty
(
name
))
{
if
(!
DataUtil
.
isNullOrEmpty
(
name
))
{
query
.
setParameter
(
"p_name"
,
"%"
+
query
.
setParameter
(
"p_name"
,
"%"
+
name
.
replace
(
"\\"
,
"\\\\"
)
name
.
trim
().
replace
(
"\\"
,
"\\\\"
)
.
replaceAll
(
"%"
,
"\\%"
)
.
replaceAll
(
"%"
,
"\\%"
)
.
replaceAll
(
"_"
,
"\\_"
)
.
replaceAll
(
"_"
,
"\\_"
)
+
"%"
);
+
"%"
);
...
@@ -288,7 +290,7 @@ public class CustomerServiceImpl implements CustomerService {
...
@@ -288,7 +290,7 @@ public class CustomerServiceImpl implements CustomerService {
if
(!
DataUtil
.
isNullOrEmpty
(
mobileNumber
))
{
if
(!
DataUtil
.
isNullOrEmpty
(
mobileNumber
))
{
query
.
setParameter
(
"p_mobile_number"
,
"%"
+
query
.
setParameter
(
"p_mobile_number"
,
"%"
+
mobileNumber
.
replace
(
"\\"
,
"\\\\"
)
mobileNumber
.
trim
().
replace
(
"\\"
,
"\\\\"
)
.
replaceAll
(
"%"
,
"\\%"
)
.
replaceAll
(
"%"
,
"\\%"
)
.
replaceAll
(
"_"
,
"\\_"
)
.
replaceAll
(
"_"
,
"\\_"
)
+
"%"
);
+
"%"
);
...
@@ -296,7 +298,7 @@ public class CustomerServiceImpl implements CustomerService {
...
@@ -296,7 +298,7 @@ public class CustomerServiceImpl implements CustomerService {
if
(!
DataUtil
.
isNullOrEmpty
(
email
))
{
if
(!
DataUtil
.
isNullOrEmpty
(
email
))
{
query
.
setParameter
(
"p_email"
,
"%"
+
query
.
setParameter
(
"p_email"
,
"%"
+
email
.
replace
(
"\\"
,
"\\\\"
)
email
.
trim
().
replace
(
"\\"
,
"\\\\"
)
.
replaceAll
(
"%"
,
"\\%"
)
.
replaceAll
(
"%"
,
"\\%"
)
.
replaceAll
(
"_"
,
"\\_"
)
.
replaceAll
(
"_"
,
"\\_"
)
+
"%"
);
+
"%"
);
...
@@ -600,6 +602,25 @@ public class CustomerServiceImpl implements CustomerService {
...
@@ -600,6 +602,25 @@ public class CustomerServiceImpl implements CustomerService {
@Override
@Override
@Transactional
(
DataSourceQualify
.
CCMS_FULL
)
@Transactional
(
DataSourceQualify
.
CCMS_FULL
)
public
ResultDTO
createCustomerList
(
CustomerListDTO
customerListDTO
,
String
userName
)
{
public
ResultDTO
createCustomerList
(
CustomerListDTO
customerListDTO
,
String
userName
)
{
ApParam
apParam
=
apParamRepository
.
getCustomerListSeq
();
DateFormat
dateFormat
=
new
SimpleDateFormat
(
"yyyy/MM/dd"
);
Date
currentDate
=
new
Date
(
dateFormat
.
format
(
new
Date
()));
Date
oldDate
=
new
Date
(
apParam
.
getDescription
());
Long
newDay
=
(
currentDate
.
getTime
()
-
oldDate
.
getTime
())
/
(
1000
*
60
*
60
*
24
);
String
convertDate
=
dateFormat
.
format
(
new
Date
());
String
[]
dateArray
=
convertDate
.
split
(
"/"
);
if
(
customerListDTO
.
getCustomerListCode
().
trim
().
length
()
==
0
)
{
if
(
newDay
==
0
)
{
apParamRepository
.
updateCustomerListSeq
(
String
.
valueOf
(
Integer
.
parseInt
(
apParam
.
getParValue
())
+
1
),
apParam
.
getDescription
());
customerListDTO
.
setCustomerListCode
(
dateArray
[
0
]
+
dateArray
[
2
]
+
dateArray
[
1
]
+
"_"
+
(
Integer
.
parseInt
(
apParam
.
getParValue
())
+
1
));
}
else
{
apParamRepository
.
updateCustomerListSeq
(
"1"
,
dateFormat
.
format
(
new
Date
()));
customerListDTO
.
setCustomerListCode
(
dateArray
[
0
]
+
dateArray
[
2
]
+
dateArray
[
1
]
+
"_1"
);
}
}
// THÍM NÀO MERGE CONFLICT THÌ GIỮ LẠI HỘ E CÁI METHOD NÀY VỚI
// THÍM NÀO MERGE CONFLICT THÌ GIỮ LẠI HỘ E CÁI METHOD NÀY VỚI
// VIẾT ĐI VIẾT LẠI 4 LẦN RỒI ĐẤY
// VIẾT ĐI VIẾT LẠI 4 LẦN RỒI ĐẤY
ResultDTO
resultDTO
=
new
ResultDTO
();
ResultDTO
resultDTO
=
new
ResultDTO
();
...
@@ -636,9 +657,8 @@ public class CustomerServiceImpl implements CustomerService {
...
@@ -636,9 +657,8 @@ public class CustomerServiceImpl implements CustomerService {
@Override
@Override
@Transactional
(
DataSourceQualify
.
CCMS_FULL
)
@Transactional
(
DataSourceQualify
.
CCMS_FULL
)
public
ResultDTO
updateCustomerList
(
CustomerListDTO
customerListDTO
)
{
public
ResultDTO
updateCustomerList
(
CustomerListDTO
customerListDTO
,
String
userName
)
{
ResultDTO
resultDTO
=
new
ResultDTO
();
ResultDTO
resultDTO
=
new
ResultDTO
();
CustomerListMapper
customerListMapper
=
new
CustomerListMapper
();
try
{
try
{
if
(
customerListDTO
!=
null
)
{
if
(
customerListDTO
!=
null
)
{
...
@@ -646,7 +666,19 @@ public class CustomerServiceImpl implements CustomerService {
...
@@ -646,7 +666,19 @@ public class CustomerServiceImpl implements CustomerService {
CustomerList
customerList
=
customerListRepository
.
findByCustomerListIdAndCompanySiteId
(
customerListDTO
.
getCustomerListId
(),
customerListDTO
.
getCompanySiteId
());
CustomerList
customerList
=
customerListRepository
.
findByCustomerListIdAndCompanySiteId
(
customerListDTO
.
getCustomerListId
(),
customerListDTO
.
getCompanySiteId
());
if
(
customerList
!=
null
)
{
if
(
customerList
!=
null
)
{
customerList
=
customerListMapper
.
toPersistenceBean
(
customerListDTO
);
// customerList.setCreateBy(customerListDTO.getCreateBy());
customerList
.
setCompanySiteId
(
customerListDTO
.
getCompanySiteId
());
// customerList.setCreateAt(customerListDTO.getCreateAt());
customerList
.
setCustomerListCode
(
customerListDTO
.
getCustomerListCode
());
customerList
.
setCustomerListName
(
customerListDTO
.
getCustomerListName
());
customerList
.
setDeptCreate
(
customerListDTO
.
getDeptCreate
());
customerList
.
setStatus
(
customerList
.
getStatus
());
customerList
.
setUpdateBy
(
userName
);
customerList
.
setUpdateAt
(
new
Date
());
customerList
.
setSource
(
customerListDTO
.
getSource
());
customerList
.
setCustomerListId
(
customerListDTO
.
getCustomerListId
());
customerListRepository
.
save
(
customerList
);
customerListRepository
.
save
(
customerList
);
resultDTO
.
setErrorCode
(
Constants
.
ApiErrorCode
.
SUCCESS
);
resultDTO
.
setErrorCode
(
Constants
.
ApiErrorCode
.
SUCCESS
);
...
@@ -741,31 +773,38 @@ public class CustomerServiceImpl implements CustomerService {
...
@@ -741,31 +773,38 @@ public class CustomerServiceImpl implements CustomerService {
StringBuilder
sb
=
new
StringBuilder
();
StringBuilder
sb
=
new
StringBuilder
();
sb
.
append
(
"SELECT"
);
sb
.
append
(
"SELECT"
);
sb
.
append
(
" CUSTOMER_LIST_ID customerListId,"
);
sb
.
append
(
" a.CUSTOMER_LIST_ID customerListId,"
);
sb
.
append
(
" COMPANY_SITE_ID companySiteId,"
);
sb
.
append
(
" a.COMPANY_SITE_ID companySiteId,"
);
sb
.
append
(
" CUSTOMER_LIST_CODE customerListCode,"
);
sb
.
append
(
" a.CUSTOMER_LIST_CODE customerListCode,"
);
sb
.
append
(
" CUSTOMER_LIST_NAME customerListName,"
);
sb
.
append
(
" a.CUSTOMER_LIST_NAME customerListName,"
);
sb
.
append
(
" STATUS status,"
);
sb
.
append
(
" a.STATUS status,"
);
sb
.
append
(
" CREATE_BY createBy,"
);
sb
.
append
(
" a.CREATE_BY createBy,"
);
sb
.
append
(
" CREATE_AT createAt,"
);
sb
.
append
(
" a.CREATE_AT createAt,"
);
sb
.
append
(
" UPDATE_BY updateBy,"
);
sb
.
append
(
" a.UPDATE_BY updateBy,"
);
sb
.
append
(
" UPDATE_AT updateAt,"
);
sb
.
append
(
" a.UPDATE_AT updateAt,"
);
sb
.
append
(
" SOURCE source,"
);
sb
.
append
(
" a.SOURCE source,"
);
sb
.
append
(
" DEPT_CREATE deptCreate"
);
sb
.
append
(
" a.DEPT_CREATE deptCreate,"
);
sb
.
append
(
" FROM CUSTOMER_LIST"
);
sb
.
append
(
" b.count count"
);
sb
.
append
(
" FROM CUSTOMER_LIST a"
);
sb
.
append
(
" LEFT JOIN (SELECT COUNT(CAMPAIGN_ID) as count, CUSTOMER_LIST_ID"
);
sb
.
append
(
" FROM CAMPAIGN_CUSTOMERLIST"
);
sb
.
append
(
" GROUP BY CUSTOMER_LIST_ID) b"
);
sb
.
append
(
" ON a.CUSTOMER_LIST_ID = b.CUSTOMER_LIST_ID"
);
sb
.
append
(
" WHERE 1 = 1"
);
sb
.
append
(
" WHERE 1 = 1"
);
sb
.
append
(
" AND STATUS = 1"
);
sb
.
append
(
" AND
a.
STATUS = 1"
);
sb
.
append
(
" AND COMPANY_SITE_ID = :p_company_site_id"
);
sb
.
append
(
" AND
a.
COMPANY_SITE_ID = :p_company_site_id"
);
sb
.
append
(
" AND
CREATE_AT BETWEEN to_date(:p_date_from, 'YYYYMMDD') AND
to_date(:p_date_to, 'YYYYMMDD')"
);
sb
.
append
(
" AND
to_date(CREATE_AT, 'DD-MM-RR') >= to_date(:p_date_from, 'YYYYMMDD') AND to_date(CREATE_AT, 'DD-MM-RR') <=
to_date(:p_date_to, 'YYYYMMDD')"
);
if
(!
DataUtil
.
isNullOrEmpty
(
searchCustomerRequestDTO
.
getCustomerListCode
()))
{
if
(!
DataUtil
.
isNullOrEmpty
(
searchCustomerRequestDTO
.
getCustomerListCode
()))
{
sb
.
append
(
" AND
CUSTOMER_LIST_CODE LIKE :p_list_code
"
);
sb
.
append
(
" AND
UPPER(CUSTOMER_LIST_CODE) LIKE UPPER(:p_list_code)
"
);
}
}
if
(!
DataUtil
.
isNullOrEmpty
(
searchCustomerRequestDTO
.
getCustomerListName
()))
{
if
(!
DataUtil
.
isNullOrEmpty
(
searchCustomerRequestDTO
.
getCustomerListName
()))
{
sb
.
append
(
" AND
CUSTOMER_LIST_NAME LIKE :p_list_name
"
);
sb
.
append
(
" AND
UPPER(CUSTOMER_LIST_NAME) LIKE UPPER(:p_list_name)
"
);
}
}
sb
.
append
(
" ORDER BY CREATE_AT DESC"
);
SQLQuery
query
=
session
.
createSQLQuery
(
sb
.
toString
());
SQLQuery
query
=
session
.
createSQLQuery
(
sb
.
toString
());
query
.
setParameter
(
"p_company_site_id"
,
searchCustomerRequestDTO
.
getCompanySiteId
());
query
.
setParameter
(
"p_company_site_id"
,
searchCustomerRequestDTO
.
getCompanySiteId
());
...
@@ -774,7 +813,7 @@ public class CustomerServiceImpl implements CustomerService {
...
@@ -774,7 +813,7 @@ public class CustomerServiceImpl implements CustomerService {
if
(!
DataUtil
.
isNullOrEmpty
(
searchCustomerRequestDTO
.
getCustomerListCode
()))
{
if
(!
DataUtil
.
isNullOrEmpty
(
searchCustomerRequestDTO
.
getCustomerListCode
()))
{
query
.
setParameter
(
"p_list_code"
,
"%"
+
query
.
setParameter
(
"p_list_code"
,
"%"
+
searchCustomerRequestDTO
.
getCustomerListCode
()
searchCustomerRequestDTO
.
getCustomerListCode
()
.
trim
()
.
replace
(
"\\"
,
"\\\\"
)
.
replace
(
"\\"
,
"\\\\"
)
.
replaceAll
(
"%"
,
"\\%"
)
.
replaceAll
(
"%"
,
"\\%"
)
.
replaceAll
(
"_"
,
"\\_"
)
.
replaceAll
(
"_"
,
"\\_"
)
...
@@ -783,7 +822,7 @@ public class CustomerServiceImpl implements CustomerService {
...
@@ -783,7 +822,7 @@ public class CustomerServiceImpl implements CustomerService {
if
(!
DataUtil
.
isNullOrEmpty
(
searchCustomerRequestDTO
.
getCustomerListName
()))
{
if
(!
DataUtil
.
isNullOrEmpty
(
searchCustomerRequestDTO
.
getCustomerListName
()))
{
query
.
setParameter
(
"p_list_name"
,
"%"
+
query
.
setParameter
(
"p_list_name"
,
"%"
+
searchCustomerRequestDTO
.
getCustomerListName
()
searchCustomerRequestDTO
.
getCustomerListName
()
.
trim
()
.
replace
(
"\\"
,
"\\\\"
)
.
replace
(
"\\"
,
"\\\\"
)
.
replaceAll
(
"%"
,
"\\%"
)
.
replaceAll
(
"%"
,
"\\%"
)
.
replaceAll
(
"_"
,
"\\_"
)
.
replaceAll
(
"_"
,
"\\_"
)
...
@@ -801,6 +840,7 @@ public class CustomerServiceImpl implements CustomerService {
...
@@ -801,6 +840,7 @@ public class CustomerServiceImpl implements CustomerService {
query
.
addScalar
(
"updateAt"
,
new
DateType
());
query
.
addScalar
(
"updateAt"
,
new
DateType
());
query
.
addScalar
(
"source"
,
new
StringType
());
query
.
addScalar
(
"source"
,
new
StringType
());
query
.
addScalar
(
"deptCreate"
,
new
StringType
());
query
.
addScalar
(
"deptCreate"
,
new
StringType
());
query
.
addScalar
(
"count"
,
new
StringType
());
query
.
setResultTransformer
(
Transformers
.
aliasToBean
(
CustomerListDTO
.
class
));
query
.
setResultTransformer
(
Transformers
.
aliasToBean
(
CustomerListDTO
.
class
));
int
count
=
0
;
int
count
=
0
;
...
@@ -1545,16 +1585,26 @@ public class CustomerServiceImpl implements CustomerService {
...
@@ -1545,16 +1585,26 @@ public class CustomerServiceImpl implements CustomerService {
sb
.
append
(
" from customer_contact cc"
);
sb
.
append
(
" from customer_contact cc"
);
sb
.
append
(
" where cc.contact_type = 2"
);
sb
.
append
(
" where cc.contact_type = 2"
);
sb
.
append
(
" and status = 1"
);
sb
.
append
(
" and status = 1"
);
sb
.
append
(
" ),"
+
"cusInCampaign as ("
+
"select * from campaign_customer "
+
"where campaign_id = :p_campaign_id "
+
"and company_site_id = :p_company_site_id "
+
"and customer_list_id is null "
+
"and in_campaign_status = 1"
);
sb
.
append
(
" ), datas as ("
);
sb
.
append
(
" ), datas as ("
);
sb
.
append
(
" select c.customer_id customerId,"
);
sb
.
append
(
" select c.customer_id customerId,"
);
sb
.
append
(
" c.name,"
);
sb
.
append
(
" c.name,"
);
sb
.
append
(
" cP.phone,"
);
sb
.
append
(
" cP.phone
mobileNumber
,"
);
sb
.
append
(
" cE.email,"
);
sb
.
append
(
" cE.email,"
);
sb
.
append
(
" c.customer_type cusType,"
);
sb
.
append
(
" c.customer_type cus
tomer
Type,"
);
sb
.
append
(
" c.company_name compName,"
);
sb
.
append
(
" c.company_name comp
any
Name,"
);
sb
.
append
(
" c.current_address currentAddress,"
);
sb
.
append
(
" c.current_address currentAddress,"
);
sb
.
append
(
" c.description"
);
sb
.
append
(
" c.description,"
);
sb
.
append
(
" c.ipcc_status ipccStatus,"
);
sb
.
append
(
" c.call_allowed customerDnc"
);
sb
.
append
(
" from customer c"
);
sb
.
append
(
" from customer c"
);
sb
.
append
(
" inner join cusInCampaign cc on c.customer_id = cc.customer_id"
);
sb
.
append
(
" left join cusPhone cP on c.customer_id = cP.cusId"
);
sb
.
append
(
" left join cusPhone cP on c.customer_id = cP.cusId"
);
sb
.
append
(
" left join cusEmail cE on c.customer_id = cE.cusId"
);
sb
.
append
(
" left join cusEmail cE on c.customer_id = cE.cusId"
);
sb
.
append
(
" )"
);
sb
.
append
(
" )"
);
...
@@ -1573,13 +1623,45 @@ public class CustomerServiceImpl implements CustomerService {
...
@@ -1573,13 +1623,45 @@ public class CustomerServiceImpl implements CustomerService {
Map
<
String
,
Object
>
param
=
new
HashMap
<>();
Map
<
String
,
Object
>
param
=
new
HashMap
<>();
param
.
put
(
"p_page_number"
,
campaignCustomerDTO
.
getPage
());
param
.
put
(
"p_page_number"
,
campaignCustomerDTO
.
getPage
());
param
.
put
(
"p_page_size"
,
campaignCustomerDTO
.
getPageSize
());
param
.
put
(
"p_page_size"
,
campaignCustomerDTO
.
getPageSize
());
param
.
put
(
"p_campaign_id"
,
campaignCustomerDTO
.
getCampaignId
());
param
.
put
(
"p_company_site_id"
,
campaignCustomerDTO
.
getCompanySiteId
());
customerList
=
namedParameterJdbcTemplate
.
query
(
sb
.
toString
(),
param
,
new
BeanPropertyRowMapper
<>(
CustomerDTO
.
class
));
customerList
=
namedParameterJdbcTemplate
.
query
(
sb
.
toString
(),
param
,
new
BeanPropertyRowMapper
<>(
CustomerDTO
.
class
));
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
LOGGER
.
error
(
e
.
getMessage
(),
e
);
return
null
;
return
null
;
}
}
return
customerList
;
return
customerList
;
}
}
@Override
@Transactional
(
DataSourceQualify
.
CCMS_FULL
)
public
ResultDTO
deleteCustomerFromCampaign
(
CampaignCustomerDTO
campaignCustomerDTO
)
{
ResultDTO
resultDTO
=
new
ResultDTO
();
Long
companySiteId
=
campaignCustomerDTO
.
getCompanySiteId
();
Long
campaignId
=
campaignCustomerDTO
.
getCampaignId
();
String
[]
lstCusId
=
campaignCustomerDTO
.
getLstCustomerId
().
split
(
","
);
List
<
Short
>
lstStatus
=
campaignCustomerRepository
.
getStatus
();
try
{
for
(
String
cusId
:
lstCusId
)
{
CampaignCustomer
entity
=
campaignCustomerRepository
.
findCampaignCustomerByCampaignIdAndCompanySiteIdAndCustomerId
(
campaignId
,
companySiteId
,
Long
.
parseLong
(
cusId
));
if
(
entity
.
getStatus
()
==
0
)
{
campaignCustomerRepository
.
delete
(
entity
);
}
else
if
(
lstStatus
.
contains
(
entity
.
getStatus
()))
{
entity
.
setInCampaignStatus
((
short
)
0
);
campaignCustomerRepository
.
save
(
entity
);
}
}
resultDTO
.
setErrorCode
(
Constants
.
ApiErrorCode
.
SUCCESS
);
resultDTO
.
setDescription
(
Constants
.
ApiErrorDesc
.
SUCCESS
);
}
catch
(
Exception
e
)
{
LOGGER
.
error
(
e
.
getMessage
(),
e
);
resultDTO
.
setErrorCode
(
Constants
.
ApiErrorCode
.
ERROR
);
resultDTO
.
setDescription
(
Constants
.
ApiErrorDesc
.
ERROR
);
}
return
resultDTO
;
}
@Override
@Override
@Transactional
(
DataSourceQualify
.
CCMS_FULL
)
@Transactional
(
DataSourceQualify
.
CCMS_FULL
)
public
List
<
Customer
>
findAllByCondition
(
Long
siteId
,
Date
endTime
)
{
public
List
<
Customer
>
findAllByCondition
(
Long
siteId
,
Date
endTime
)
{
...
@@ -1651,60 +1733,207 @@ public class CustomerServiceImpl implements CustomerService {
...
@@ -1651,60 +1733,207 @@ public class CustomerServiceImpl implements CustomerService {
// sb.append("");
// sb.append("");
// sb.append("");
// sb.append("");
@Override
@Override
public
ResultDTO
searchCustomizeFields
(
CustomizeRequestDTo
customizeFields
)
{
public
ResultDTO
listCustomizeFields
(
CustomizeFieldsDTO
customizeFields
)
{
ResultDTO
resultDTO
=
new
ResultDTO
();
ResultDTO
resultDTO
=
new
ResultDTO
();
Map
<
String
,
String
>
params
=
new
HashMap
<>();
Map
<
String
,
String
>
params
=
new
HashMap
<>();
List
<
FieldsToShowDTO
>
list
=
new
ArrayList
<>()
;
List
<
CustomizeFielObjectDTO
>
list
;
StringBuilder
stringBuilder
=
new
StringBuilder
();
StringBuilder
stringBuilder
=
new
StringBuilder
();
try
{
try
{
stringBuilder
.
append
(
" with column_name_temp as ("
);
List
<
CustomizeFields
>
lstCustomizeFields
=
customizeFieldsRepository
.
findByFunctionCodeAndActiveAndStatusAndSiteId
(
customizeFields
.
getFunctionCode
(),
customizeFields
.
getActive
(),
customizeFields
.
getStatus
(),
customizeFields
.
getSiteId
());
stringBuilder
.
append
(
" select 'CUSTOMER_ID' ,1 isFix from user_tab_columns, dual"
);
String
cf
[][]
=
{
stringBuilder
.
append
(
" union all"
);
{
"-1"
,
"Mã Khách Hàng"
,
"number"
},
stringBuilder
.
append
(
" select 'CUSTOMER_NAME' ,1 isFix from user_tab_columns, dual"
);
{
"-2"
,
"Tên khách hàng"
,
"text"
},
stringBuilder
.
append
(
" union all"
);
{
"-3"
,
"Tên công ty"
,
"text"
},
stringBuilder
.
append
(
" select 'CUSTOMER_TYPE' ,1 isFix from user_tab_columns, dual"
);
{
"-4"
,
"Giới tính"
,
"number"
},
stringBuilder
.
append
(
" union all"
);
{
"-5"
,
"Địa chỉ"
,
"text"
},
stringBuilder
.
append
(
" select 'NAME' ,1 isFix from user_tab_columns, dual"
);
{
"-6"
,
"Nơi sinh"
,
"text"
},
stringBuilder
.
append
(
" union all"
);
{
"-7"
,
"Ngày sinh"
,
"date"
},
stringBuilder
.
append
(
" select 'CURRENT_ADDRESS', 1 isFix from user_tab_columns, dual"
);
{
"-8"
,
"Số điện thoại"
,
"number"
},
stringBuilder
.
append
(
" union all"
);
{
"-9"
,
"email"
,
"text"
},
stringBuilder
.
append
(
" select 'PLACE_OF_BIRTH', 1 isFix from user_tab_columns, dual"
);
{
"-10"
,
"Tên đăng nhập"
,
"text"
},
stringBuilder
.
append
(
" union all"
);
{
"-11"
,
"Loại Khách hàng"
,
"number"
},
stringBuilder
.
append
(
" select 'DATE_OF_BIRTH', 1 isFix from user_tab_columns, dual"
);
};
stringBuilder
.
append
(
" union all"
);
for
(
int
x
=
0
;
x
<
11
;
x
++)
{
stringBuilder
.
append
(
" select 'MOBILE_NUMBER', 1 isFix from user_tab_columns, dual"
);
CustomizeFields
datafill
=
new
CustomizeFields
();
stringBuilder
.
append
(
" union all"
);
datafill
.
setCustomizeFieldId
(
Long
.
parseLong
(
cf
[
x
][
0
]));
stringBuilder
.
append
(
" select 'EMAIL', 1 isFix from user_tab_columns, dual"
);
datafill
.
setTitle
(
cf
[
x
][
1
]);
stringBuilder
.
append
(
" union all"
);
datafill
.
setType
(
cf
[
x
][
2
]);
stringBuilder
.
append
(
" select 'USERNAME', 1 isFix from user_tab_columns, dual"
);
lstCustomizeFields
.
add
(
datafill
);
stringBuilder
.
append
(
" union all"
);
}
stringBuilder
.
append
(
" select 'CUSTOMER_TYPE', 1 isFix from user_tab_columns, dual"
);
stringBuilder
.
append
(
" where table_name = 'CUSTOMER'"
);
// try {
stringBuilder
.
append
(
" )"
);
// stringBuilder.append(" with column_name_temp as (");
// stringBuilder.append(" select 'CUSTOMER_ID customerId' , from user_tab_columns, dual");
stringBuilder
.
append
(
" select * from column_name_temp"
);
// stringBuilder.append(" union all");
stringBuilder
.
append
(
" union all"
);
// stringBuilder.append(" select 'CUSTOMER_NAME customerName' , from user_tab_columns, dual");
stringBuilder
.
append
(
" select title columnName, 0 isFix "
);
// stringBuilder.append(" union all");
stringBuilder
.
append
(
" from customize_fields, dual"
);
// stringBuilder.append(" select 'CUSTOMER_TYPE customerType' , from user_tab_columns, dual");
stringBuilder
.
append
(
" where function_code = 'CUSTOMER'"
);
// stringBuilder.append(" union all");
stringBuilder
.
append
(
" and site_id = :p_company_site_id"
);
// stringBuilder.append(" select 'NAME name' , from user_tab_columns, dual");
stringBuilder
.
append
(
" and STATUS = 1"
);
// stringBuilder.append(" union all");
stringBuilder
.
append
(
" and active = 1 "
);
// stringBuilder.append(" select 'CURRENT_ADDRESS currentAddress', from user_tab_columns, dual");
params
.
put
(
"p_company_site_id"
,
customizeFields
.
getCompanySiteId
());
// stringBuilder.append(" union all");
params
.
put
(
"p_customer_id"
,
customizeFields
.
getCustomerId
());
// stringBuilder.append(" select 'PLACE_OF_BIRTH placeOfBirth', from user_tab_columns, dual");
list
=
namedParameterJdbcTemplate
.
query
(
stringBuilder
.
toString
(),
params
,
BeanPropertyRowMapper
.
newInstance
(
FieldsToShowDTO
.
class
));
// stringBuilder.append(" union all");
// stringBuilder.append(" select 'DATE_OF_BIRTH dateOfBirth', from user_tab_columns, dual");
// stringBuilder.append(" union all");
// stringBuilder.append(" select 'MOBILE_NUMBER mobileNumber', from user_tab_columns, dual");
// stringBuilder.append(" union all");
// stringBuilder.append(" select 'EMAIL email', from user_tab_columns, dual");
// stringBuilder.append(" union all");
// stringBuilder.append(" select 'USERNAME username', from user_tab_columns, dual");
// stringBuilder.append(" union all");
// stringBuilder.append(" select 'CUSTOMER_TYPE customerType', from user_tab_columns, dual");
// stringBuilder.append(" where table_name = 'CUSTOMER'");
// stringBuilder.append(" )");
//
// stringBuilder.append(" select * from column_name_temp");
// stringBuilder.append(" union all");
// stringBuilder.append(" select title columnName, 0 isFix ");
// stringBuilder.append(" from customize_fields, dual");
// stringBuilder.append(" where function_code = 'CUSTOMER'");
// stringBuilder.append(" and site_id = :p_company_site_id");
// stringBuilder.append(" and STATUS = 1");
// stringBuilder.append(" and active = 1 ");
// params.put("p_company_site_id", customizeFields.getSiteId());
// params.put("p_customer_id", customizeFields.getCustomerId());
// LOGGER.info("SQL statement: " + stringBuilder);
// list = namedParameterJdbcTemplate.query(stringBuilder.toString(), params, BeanPropertyRowMapper.newInstance(CustomizeFielObjectDTO.class));
resultDTO
.
setErrorCode
(
Constants
.
ApiErrorCode
.
SUCCESS
);
resultDTO
.
setErrorCode
(
Constants
.
ApiErrorCode
.
SUCCESS
);
resultDTO
.
setDescription
(
Constants
.
ApiErrorDesc
.
SUCCESS
);
resultDTO
.
setDescription
(
Constants
.
ApiErrorDesc
.
SUCCESS
);
resultDTO
.
setListData
(
l
ist
);
resultDTO
.
setListData
(
l
stCustomizeFields
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
LOGGER
.
error
(
e
.
getMessage
(),
e
);
LOGGER
.
error
(
e
.
getMessage
(),
e
);
resultDTO
.
setErrorCode
(
Constants
.
ApiErrorCode
.
ERROR
);
resultDTO
.
setErrorCode
(
Constants
.
ApiErrorCode
.
ERROR
);
resultDTO
.
setDescription
(
Constants
.
ApiErrorDesc
.
ERROR
);
resultDTO
.
setDescription
(
Constants
.
ApiErrorDesc
.
ERROR
);
}
}
return
resultDTO
;
return
resultDTO
;
}
}
@Override
public
ResultDTO
searchCustomizeFields
(
int
page
,
int
pageSize
,
long
SiteId
,
long
campaignId
,
CustomerQueryDTO
customerQueryDTO
)
{
ResultDTO
resultDTO
=
new
ResultDTO
();
SessionFactory
sessionFactory
=
HibernateUtil
.
getSessionFactory
();
Session
session
=
sessionFactory
.
openSession
();
session
.
beginTransaction
();
if
(
DataUtil
.
isNullOrZero
(
SiteId
))
{
resultDTO
.
setErrorCode
(
Constants
.
ApiErrorCode
.
ERROR
);
resultDTO
.
setDescription
(
Constants
.
ApiErrorDesc
.
ERROR
);
return
resultDTO
;
}
try
{
StringBuilder
sb
=
new
StringBuilder
();
sb
.
append
(
"select"
);
sb
.
append
(
" C.NAME name,"
);
sb
.
append
(
" C.CUSTOMER_ID customerID,"
);
sb
.
append
(
" C.USERNAME username,"
);
sb
.
append
(
" C.GENDER gender,"
);
sb
.
append
(
" C.COMPANY_NAME companyName,"
);
sb
.
append
(
" C.DATE_OF_BIRTH dateOfBirth,"
);
sb
.
append
(
" C.CUSTOMER_TYPE customerType,"
);
sb
.
append
(
" C.COMPANY_NAME companyName,"
);
sb
.
append
(
" C.PLACE_OF_BIRTH placeOfBirth,"
);
sb
.
append
(
" C.CUSTOMER_TYPE customerType,"
);
sb
.
append
(
" C.EMAIL email,"
);
sb
.
append
(
" C.USERNAME username,"
);
sb
.
append
(
" C.NAME name,"
);
sb
.
append
(
" C.MOBILE_NUMBER mobileNumber,"
);
sb
.
append
(
" C.STATUS status,"
);
sb
.
append
(
" C.SITE_ID siteId,"
);
sb
.
append
(
" CF.FUNCTION_CODE functionCode,"
);
sb
.
append
(
" CFO.ACTIVE active,"
);
sb
.
append
(
" CFO.*"
);
sb
.
append
(
"FROM CUSTOMER C"
);
sb
.
append
(
" INNER JOIN CUSTOMIZE_FIELD_OBJECT CFO ON C.CUSTOMER_ID = CFO.OBJECT_ID"
);
sb
.
append
(
" INNER JOIN CUSTOMIZE_FIELDS CF ON CF.CUSTOMIZE_FIELD_ID = CFO.CUSTOMIZE_FIELDS_ID\n"
+
"WHERE 1 = 1"
);
sb
.
append
(
" and CFO.STATUS = 1"
);
sb
.
append
(
" and active = 1 "
);
sb
.
append
(
" and CF.FUNCTION_CODE = 'CUSTOMER' "
);
List
<
CustomerQueryDTO
>
queryCustomer
=
new
ArrayList
<>();
for
(
int
i
=
0
;
i
<
queryCustomer
.
size
();
i
++)
{
sb
.
append
(
queryCustomer
.
get
(
i
).
getJoin
()
+
" "
+
queryCustomer
.
get
(
i
).
getOperator
()
+
" "
+
queryCustomer
.
get
(
i
).
getField
()
+
" "
+
queryCustomer
.
get
(
i
).
getCondition
());
}
SQLQuery
query
=
session
.
createSQLQuery
(
sb
.
toString
());
// query.setParameter("p_company_site_id", companySiteId);
// query.setParameter("p_customer_list_id", customerListId);
//
// if (!DataUtil.isNullOrEmpty(name)) {
// query.setParameter("p_name", "%" +
// name.replace("\\", "\\\\")
// .replaceAll("%", "\\%")
// .replaceAll("_", "\\_")
// + "%");
// }
//
// if (!DataUtil.isNullOrEmpty(mobileNumber)) {
// query.setParameter("p_mobile_number", "%" +
// mobileNumber.replace("\\", "\\\\")
// .replaceAll("%", "\\%")
// .replaceAll("_", "\\_")
// + "%");
// }
//
// if (!DataUtil.isNullOrEmpty(email)) {
// query.setParameter("p_email", "%" +
// email.replace("\\", "\\\\")
// .replaceAll("%", "\\%")
// .replaceAll("_", "\\_")
// + "%");
// }
query
.
addScalar
(
"customerID"
,
new
LongType
());
query
.
addScalar
(
"name"
,
new
StringType
());
query
.
addScalar
(
"username"
,
new
StringType
());
query
.
addScalar
(
"name"
,
new
StringType
());
query
.
addScalar
(
"description"
,
new
StringType
());
query
.
addScalar
(
"companyName"
,
new
StringType
());
query
.
addScalar
(
"customerType"
,
new
StringType
());
query
.
addScalar
(
"currentAddress"
,
new
StringType
());
query
.
addScalar
(
"mobileNumber"
,
new
StringType
());
query
.
addScalar
(
"email"
,
new
StringType
());
query
.
setResultTransformer
(
Transformers
.
aliasToBean
(
CustomizeRequestDTo
.
class
));
int
count
=
0
;
List
<
CustomerCustomDTO
>
dtoList
=
query
.
list
();
if
(
dtoList
.
size
()
>
0
)
{
count
=
query
.
list
().
size
();
}
Pageable
pageable
=
PageRequest
.
of
(
page
,
pageSize
);
if
(
pageable
!=
null
)
{
query
.
setFirstResult
(
pageable
.
getPageNumber
()
*
pageable
.
getPageSize
());
query
.
setMaxResults
(
pageable
.
getPageSize
());
}
List
<
CustomerCustomDTO
>
data
=
query
.
list
();
Page
<
CustomerCustomDTO
>
dataPage
=
new
PageImpl
<>(
data
,
pageable
,
count
);
resultDTO
.
setData
(
dataPage
);
resultDTO
.
setErrorCode
(
Constants
.
ApiErrorCode
.
SUCCESS
);
resultDTO
.
setDescription
(
Constants
.
ApiErrorDesc
.
SUCCESS
);
}
catch
(
Exception
e
)
{
resultDTO
.
setErrorCode
(
Constants
.
ApiErrorCode
.
ERROR
);
resultDTO
.
setDescription
(
Constants
.
ApiErrorDesc
.
ERROR
);
}
finally
{
session
.
close
();
}
return
resultDTO
;
}
}
}
src/main/java/com/viettel/campaign/service/impl/ScenarioServiceImpl.java
View file @
81c79e34
...
@@ -3,6 +3,7 @@ package com.viettel.campaign.service.impl;
...
@@ -3,6 +3,7 @@ package com.viettel.campaign.service.impl;
import
com.viettel.campaign.config.DataSourceQualify
;
import
com.viettel.campaign.config.DataSourceQualify
;
import
com.viettel.campaign.model.ccms_full.*
;
import
com.viettel.campaign.model.ccms_full.*
;
import
com.viettel.campaign.repository.ccms_full.*
;
import
com.viettel.campaign.repository.ccms_full.*
;
import
com.viettel.campaign.service.ScenarioQuestionService
;
import
com.viettel.campaign.service.ScenarioService
;
import
com.viettel.campaign.service.ScenarioService
;
import
com.viettel.campaign.utils.BundleUtils
;
import
com.viettel.campaign.utils.BundleUtils
;
import
com.viettel.campaign.utils.Constants
;
import
com.viettel.campaign.utils.Constants
;
...
@@ -52,6 +53,9 @@ public class ScenarioServiceImpl implements ScenarioService {
...
@@ -52,6 +53,9 @@ public class ScenarioServiceImpl implements ScenarioService {
@Autowired
@Autowired
ContactQuestResultRepository
questResultRepository
;
ContactQuestResultRepository
questResultRepository
;
@Autowired
ScenarioQuestionService
questionService
;
@Override
@Override
@Transactional
(
DataSourceQualify
.
CCMS_FULL
)
@Transactional
(
DataSourceQualify
.
CCMS_FULL
)
public
Scenario
findScenarioByCampaignIdAndCompanySiteId
(
Long
campaignId
,
Long
companySiteId
)
{
public
Scenario
findScenarioByCampaignIdAndCompanySiteId
(
Long
campaignId
,
Long
companySiteId
)
{
...
@@ -234,12 +238,12 @@ public class ScenarioServiceImpl implements ScenarioService {
...
@@ -234,12 +238,12 @@ public class ScenarioServiceImpl implements ScenarioService {
@Override
@Override
@Transactional
(
DataSourceQualify
.
CCMS_FULL
)
@Transactional
(
DataSourceQualify
.
CCMS_FULL
)
public
Map
<
String
,
Object
>
readAndValidateCustomer
(
String
path
,
UserSession
userSession
)
{
public
Map
<
String
,
Object
>
readAndValidateCustomer
(
String
path
,
Long
scenarioId
,
Long
campaignId
,
Long
companySiteId
)
{
Locale
locale
=
new
Locale
(
"vi"
,
"VN"
);
Locale
locale
=
new
Locale
(
"vi"
,
"VN"
);
SimpleDateFormat
dateFormat
=
new
SimpleDateFormat
(
"dd/MM/yyyy HH:mm:ss"
);
SimpleDateFormat
dateFormat
=
new
SimpleDateFormat
(
"dd/MM/yyyy HH:mm:ss"
);
Map
<
String
,
Object
>
result
=
new
HashMap
<>();
Map
<
String
,
Object
>
result
=
new
HashMap
<>();
StringBuilder
sb
=
new
StringBuilder
();
StringBuilder
sb
=
new
StringBuilder
();
boolean
isValid
=
fals
e
;
boolean
isValid
=
tru
e
;
try
{
try
{
List
<
String
>
fileHeaderList
=
new
ArrayList
<>();
List
<
String
>
fileHeaderList
=
new
ArrayList
<>();
fileHeaderList
.
add
(
BundleUtils
.
getLangString
(
"scenario.template.questionCode"
,
locale
));
fileHeaderList
.
add
(
BundleUtils
.
getLangString
(
"scenario.template.questionCode"
,
locale
));
...
@@ -294,7 +298,7 @@ public class ScenarioServiceImpl implements ScenarioService {
...
@@ -294,7 +298,7 @@ public class ScenarioServiceImpl implements ScenarioService {
List
<
Object
[]>
rawDataList
=
new
ArrayList
<>();
List
<
Object
[]>
rawDataList
=
new
ArrayList
<>();
//validate row
//validate row
for
(
int
i
=
3
;
i
<
sheet
.
getPhysicalNumberOfRows
();
i
++)
{
for
(
int
i
=
3
;
i
<
=
sheet
.
getPhysicalNumberOfRows
();
i
++)
{
Row
dataRow
=
sheet
.
getRow
(
i
);
Row
dataRow
=
sheet
.
getRow
(
i
);
if
(
dataRow
!=
null
)
{
if
(
dataRow
!=
null
)
{
Object
[]
obj
=
new
Object
[
row
.
getPhysicalNumberOfCells
()];
Object
[]
obj
=
new
Object
[
row
.
getPhysicalNumberOfCells
()];
...
@@ -311,15 +315,26 @@ public class ScenarioServiceImpl implements ScenarioService {
...
@@ -311,15 +315,26 @@ public class ScenarioServiceImpl implements ScenarioService {
}
}
}
}
}
}
rawDataList
.
add
(
obj
);
rawDataList
.
add
(
obj
);
}
}
}
}
//<editor-fold desc="Validate dữ liệu" defaultstate="collapsed">
//<editor-fold desc="Validate dữ liệu" defaultstate="collapsed">
String
selectedType
=
""
;
String
selectedType
=
""
;
List
<
String
>
lstImportQuestionCodes
=
new
ArrayList
<>();
String
tmpCurrentQuestionCode
=
null
;
rawDataList
.
forEach
(
item
->
{
if
(
item
[
0
]
!=
null
&&
!
item
[
0
].
toString
().
trim
().
equals
(
""
))
lstImportQuestionCodes
.
add
(
item
[
0
].
toString
().
trim
());
});
for
(
int
i
=
0
;
i
<
rawDataList
.
size
();
i
++)
{
for
(
int
i
=
0
;
i
<
rawDataList
.
size
();
i
++)
{
if
(
rawDataList
.
get
(
i
)[
0
]
!=
null
&&
!
rawDataList
.
get
(
i
)[
0
].
toString
().
trim
().
equals
(
""
))
if
(
rawDataList
.
get
(
i
)[
0
]
!=
null
&&
!
rawDataList
.
get
(
i
)[
0
].
toString
().
trim
().
equals
(
""
))
{
selectedType
=
rawDataList
.
get
(
i
)[
1
].
toString
().
trim
();
selectedType
=
rawDataList
.
get
(
i
)[
1
].
toString
().
trim
();
tmpCurrentQuestionCode
=
rawDataList
.
get
(
i
)[
0
].
toString
().
trim
();
}
//validate question
//validate question
if
((
rawDataList
.
get
(
i
)[
0
]
!=
null
&&
!
rawDataList
.
get
(
i
)[
0
].
toString
().
trim
().
equals
(
""
))
||
if
((
rawDataList
.
get
(
i
)[
0
]
!=
null
&&
!
rawDataList
.
get
(
i
)[
0
].
toString
().
trim
().
equals
(
""
))
||
(
rawDataList
.
get
(
i
)[
1
]
!=
null
&&
!
rawDataList
.
get
(
i
)[
1
].
toString
().
trim
().
equals
(
""
))
||
(
rawDataList
.
get
(
i
)[
1
]
!=
null
&&
!
rawDataList
.
get
(
i
)[
1
].
toString
().
trim
().
equals
(
""
))
||
...
@@ -350,9 +365,15 @@ public class ScenarioServiceImpl implements ScenarioService {
...
@@ -350,9 +365,15 @@ public class ScenarioServiceImpl implements ScenarioService {
if
((
rawDataList
.
get
(
i
)[
3
]
==
null
||
rawDataList
.
get
(
i
)[
3
].
toString
().
trim
().
equals
(
""
))
&&
(!
selectedType
.
equals
(
BundleUtils
.
getLangString
(
"scenario.template.text"
))))
{
if
((
rawDataList
.
get
(
i
)[
3
]
==
null
||
rawDataList
.
get
(
i
)[
3
].
toString
().
trim
().
equals
(
""
))
&&
(!
selectedType
.
equals
(
BundleUtils
.
getLangString
(
"scenario.template.text"
))))
{
sb
.
append
(
BundleUtils
.
getLangString
(
"scenario.answer.required"
));
sb
.
append
(
BundleUtils
.
getLangString
(
"scenario.answer.required"
));
}
}
if
(
rawDataList
.
get
(
i
)[
4
]
==
null
&&
rawDataList
.
get
(
i
)[
4
].
toString
().
trim
().
equals
(
""
))
{
if
(
rawDataList
.
get
(
i
)[
4
]
==
null
&&
rawDataList
.
get
(
i
)[
4
].
toString
().
trim
().
equals
(
""
))
{
sb
.
append
(
BundleUtils
.
getLangString
(
"scenario.hashInput.required"
));
sb
.
append
(
BundleUtils
.
getLangString
(
"scenario.hashInput.required"
));
}
}
if
((
rawDataList
.
get
(
i
)[
7
]
!=
null
&&
!
rawDataList
.
get
(
i
)[
7
].
toString
().
trim
().
equals
(
""
)))
{
if
((
rawDataList
.
get
(
i
)[
7
].
toString
().
trim
().
equals
(
tmpCurrentQuestionCode
))
||
validateMappingQuestion
(
rawDataList
.
get
(
i
)[
7
].
toString
().
trim
(),
tmpCurrentQuestionCode
,
lstImportQuestionCodes
))
sb
.
append
(
BundleUtils
.
getLangString
(
"scenario.mappingQuestion.invalid"
));
}
}
}
Row
dataRow
=
sheet
.
getRow
(
3
+
i
);
Row
dataRow
=
sheet
.
getRow
(
3
+
i
);
Cell
resultCell
=
dataRow
.
createCell
(
row
.
getPhysicalNumberOfCells
()
-
1
);
Cell
resultCell
=
dataRow
.
createCell
(
row
.
getPhysicalNumberOfCells
()
-
1
);
...
@@ -360,21 +381,26 @@ public class ScenarioServiceImpl implements ScenarioService {
...
@@ -360,21 +381,26 @@ public class ScenarioServiceImpl implements ScenarioService {
resultCell
.
setCellValue
(
sb
.
toString
());
resultCell
.
setCellValue
(
sb
.
toString
());
isValid
=
false
;
isValid
=
false
;
}
else
{
}
else
{
isValid
=
true
;
//
isValid = true;
resultCell
.
setCellValue
(
"Ok"
);
resultCell
.
setCellValue
(
"Ok"
);
}
}
sb
=
new
StringBuilder
();
sb
=
new
StringBuilder
();
}
}
selectedType
=
""
;
//</editor-fold>
//</editor-fold>
//insert data
//insert data
if
(
isValid
)
{
if
(
isValid
)
{
logger
.
info
(
"----- Data valid, start import scenario question -----"
);
logger
.
info
(
"----- Data valid, start import scenario question -----"
);
for
(
int
i
=
0
;
i
<
rawDataList
.
size
();
i
++)
{
List
<
ScenarioQuestionDTO
>
lstQuestion
=
buildQuestionsLst
(
rawDataList
,
scenarioId
,
campaignId
,
companySiteId
);
buildQuestionsLst
(
rawDataList
);
lstQuestion
.
forEach
(
question
->
{
}
// questionService.add(question);
}
else
{
});
FileOutputStream
fos
=
new
FileOutputStream
(
file
);
workbook
.
write
(
fos
);
result
.
put
(
"file"
,
file
);
result
.
put
(
"message"
,
BundleUtils
.
getLangString
(
"customer.importSuccess"
,
locale
));
}
else
{
logger
.
info
(
"----- Data invalid, can't import scenario question -----"
);
FileOutputStream
fos
=
new
FileOutputStream
(
file
);
FileOutputStream
fos
=
new
FileOutputStream
(
file
);
workbook
.
write
(
fos
);
workbook
.
write
(
fos
);
result
.
put
(
"file"
,
file
);
result
.
put
(
"file"
,
file
);
...
@@ -384,24 +410,92 @@ public class ScenarioServiceImpl implements ScenarioService {
...
@@ -384,24 +410,92 @@ public class ScenarioServiceImpl implements ScenarioService {
logger
.
info
(
ex
.
getMessage
(),
ex
);
logger
.
info
(
ex
.
getMessage
(),
ex
);
result
.
put
(
"message"
,
BundleUtils
.
getLangString
(
"customer.errorValidate"
,
locale
));
result
.
put
(
"message"
,
BundleUtils
.
getLangString
(
"customer.errorValidate"
,
locale
));
}
}
logger
.
info
(
"Import Questions result:"
,
result
);
logger
.
info
(
"Import Questions result:"
,
result
);
return
result
;
return
result
;
}
}
private
boolean
validateQuestionIndex
(
Object
index
)
{
private
boolean
validateMappingQuestion
(
String
mappingQuestion
,
String
currentQuestionCode
,
List
<
String
>
lstQuestionCode
)
{
if
(
index
!=
null
&&
DataUtil
.
isLong
(
index
.
toString
()))
return
true
;
if
(
mappingQuestion
==
currentQuestionCode
)
return
false
;
return
false
;
String
duplicateCode
=
lstQuestionCode
.
stream
().
filter
(
p
->
(
p
.
equals
(
mappingQuestion
)
&&
p
.
equals
(
currentQuestionCode
))).
findAny
().
orElse
(
null
);
if
(
duplicateCode
==
null
)
return
false
;
// String notMappedCode = lstQuestionCode.stream().filter(p -> (!p.equals(mappingQuestion))).findAny().orElse(null);
// if(notMappedCode != null) return false;
return
true
;
}
}
private
List
<
ScenarioQuestionDTO
>
buildQuestionsLst
(
List
<
Object
[]>
rawDatas
)
{
private
Long
questionOrderIndex
=
null
;
private
Integer
answerIndex
=
null
;
private
List
<
ScenarioQuestionDTO
>
buildQuestionsLst
(
List
<
Object
[]>
rawDatas
,
Long
scenarioId
,
Long
campaignId
,
Long
companySiteId
)
{
List
<
ScenarioQuestionDTO
>
lstQuestions
=
new
ArrayList
<>();
List
<
ScenarioQuestionDTO
>
lstQuestions
=
new
ArrayList
<>();
List
<
ScenarioAnswerDTO
>
lstAnswerOfQuestion
=
new
ArrayList
<>();
ScenarioQuestionDTO
questionDTO
=
null
;
ScenarioQuestionDTO
questionDTO
=
null
;
for
(
int
i
=
0
;
i
<
rawDatas
.
size
();
i
++)
{
String
questionCode
=
null
;
if
(
rawDatas
.
get
(
i
)[
0
]
!=
null
&&
!
rawDatas
.
get
(
i
)[
0
].
toString
().
trim
().
equals
(
""
))
{
for
(
int
i
=
0
;
i
<
rawDatas
.
size
();
i
++)
{
if
(
rawDatas
.
get
(
i
)[
0
]
!=
null
&&
!
rawDatas
.
get
(
i
)[
0
].
toString
().
trim
().
equals
(
""
))
{
questionCode
=
rawDatas
.
get
(
i
)[
0
].
toString
().
trim
();
questionDTO
=
new
ScenarioQuestionDTO
();
questionDTO
=
new
ScenarioQuestionDTO
();
// questionDTO.setCampaignId();
questionDTO
.
setScenarioId
(
scenarioId
);
questionDTO
.
setCampaignId
(
campaignId
);
questionDTO
.
setCompanySiteId
(
companySiteId
);
questionDTO
.
setImportCode
(
questionCode
);
if
(
rawDatas
.
get
(
i
)[
1
].
toString
().
trim
().
equals
(
BundleUtils
.
getLangString
(
"scenario.template.text"
)))
questionDTO
.
setType
((
short
)
0
);
else
if
(
rawDatas
.
get
(
i
)[
1
].
toString
().
trim
().
equals
(
BundleUtils
.
getLangString
(
"scenario.template.singleChoice"
)))
questionDTO
.
setType
((
short
)
1
);
else
questionDTO
.
setType
((
short
)
2
);
questionDTO
.
setQuestion
(
rawDatas
.
get
(
i
)[
2
].
toString
().
trim
());
if
(
rawDatas
.
get
(
i
)[
5
].
toString
().
trim
().
equals
(
BundleUtils
.
getLangString
(
"scenario.template.yes"
)))
questionDTO
.
setIsRequire
((
short
)
1
);
else
questionDTO
.
setIsRequire
((
short
)
0
);
if
(
rawDatas
.
get
(
i
)[
6
].
toString
().
trim
().
equals
(
BundleUtils
.
getLangString
(
"scenario.template.yes"
)))
questionDTO
.
setIsDefault
((
short
)
1
);
else
questionDTO
.
setIsDefault
((
short
)
0
);
lstQuestions
.
add
(
questionDTO
);
}
else
{
ScenarioAnswerDTO
answerDto
=
new
ScenarioAnswerDTO
();
answerDto
.
setAnswer
(
rawDatas
.
get
(
i
)[
3
].
toString
().
trim
());
if
(
rawDatas
.
get
(
i
)[
4
].
toString
().
trim
().
equals
(
BundleUtils
.
getLangString
(
"scenario.template.yes"
)))
answerDto
.
setHasInput
((
short
)
1
);
else
answerDto
.
setHasInput
((
short
)
0
);
if
(
rawDatas
.
get
(
i
)[
7
]
!=
null
&&
!
rawDatas
.
get
(
i
)[
7
].
toString
().
trim
().
equals
(
""
))
{
answerDto
.
setMappingQuestionCode
(
rawDatas
.
get
(
i
)[
7
].
toString
().
trim
());
}
answerDto
.
setImportQuestionCode
(
questionCode
);
answerDto
.
setCompanySiteId
(
companySiteId
);
lstAnswerOfQuestion
.
add
(
answerDto
);
}
}
}
}
questionOrderIndex
=
questionRepository
.
getMaxOrderId
(
scenarioId
,
campaignId
,
companySiteId
);
if
(
questionOrderIndex
==
null
)
questionOrderIndex
=
0L
;
lstQuestions
.
forEach
(
q
->
{
questionOrderIndex
+=
1
;
q
.
setOrderIndex
(
questionOrderIndex
);
q
.
setCode
(
campaignId
+
"_"
+
questionOrderIndex
);
answerIndex
=
0
;
List
<
ScenarioAnswerDTO
>
answers
=
new
ArrayList
<>();
lstAnswerOfQuestion
.
forEach
(
a
->
{
answerIndex
+=
1
;
a
.
setOrderIndex
(
answerIndex
);
if
(
a
.
getImportQuestionCode
().
equals
(
q
.
getImportCode
()))
answers
.
add
(
a
);
});
q
.
setLstAnswers
(
answers
);
});
questionOrderIndex
=
null
;
return
lstQuestions
;
return
lstQuestions
;
}
}
}
}
src/main/java/com/viettel/campaign/web/dto/ApParamDTO.java
View file @
81c79e34
...
@@ -12,7 +12,7 @@ public class ApParamDTO extends BaseDTO {
...
@@ -12,7 +12,7 @@ public class ApParamDTO extends BaseDTO {
private
String
parName
;
private
String
parName
;
private
String
parValue
;
private
String
parValue
;
private
String
parCode
;
private
String
parCode
;
private
Lo
ng
description
;
private
Stri
ng
description
;
private
Long
isDelete
;
private
Long
isDelete
;
private
Long
isDefault
;
private
Long
isDefault
;
private
Long
enableEdit
;
private
Long
enableEdit
;
...
...
src/main/java/com/viettel/campaign/web/dto/CampaignCustomerDTO.java
View file @
81c79e34
...
@@ -26,4 +26,5 @@ public class CampaignCustomerDTO extends BaseDTO{
...
@@ -26,4 +26,5 @@ public class CampaignCustomerDTO extends BaseDTO{
private
Long
callStatus
;
private
Long
callStatus
;
private
Long
companySiteId
;
private
Long
companySiteId
;
private
Long
complainId
;
private
Long
complainId
;
private
String
lstCustomerId
;
}
}
src/main/java/com/viettel/campaign/web/dto/CustomerDTO.java
View file @
81c79e34
...
@@ -34,4 +34,5 @@ public class CustomerDTO extends BaseDTO {
...
@@ -34,4 +34,5 @@ public class CustomerDTO extends BaseDTO {
private
Long
emailAllowed
;
private
Long
emailAllowed
;
private
Long
smsAllowed
;
private
Long
smsAllowed
;
private
String
ipccStatus
;
private
String
ipccStatus
;
private
String
customerDnc
;
}
}
src/main/java/com/viettel/campaign/web/dto/CustomizeFielObjectDTO.java
View file @
81c79e34
...
@@ -5,13 +5,14 @@ import lombok.Getter;
...
@@ -5,13 +5,14 @@ import lombok.Getter;
import
lombok.NoArgsConstructor
;
import
lombok.NoArgsConstructor
;
import
lombok.Setter
;
import
lombok.Setter
;
import
java.io.Serializable
;
import
java.util.Date
;
import
java.util.Date
;
@Getter
@Getter
@Setter
@Setter
@NoArgsConstructor
@NoArgsConstructor
@AllArgsConstructor
@AllArgsConstructor
public
class
CustomizeFielObjectDTO
{
public
class
CustomizeFielObjectDTO
implements
Serializable
{
private
Long
customerId
;
private
Long
customerId
;
private
String
name
;
private
String
name
;
private
String
companyName
;
private
String
companyName
;
...
@@ -40,4 +41,6 @@ public class CustomizeFielObjectDTO {
...
@@ -40,4 +41,6 @@ public class CustomizeFielObjectDTO {
private
Long
fieldOptionValueId
;
private
Long
fieldOptionValueId
;
private
String
title
;
private
String
title
;
private
String
functionCode
;
private
String
functionCode
;
private
String
active
;
}
}
src/main/java/com/viettel/campaign/web/dto/CustomizeFieldsDTO.java
0 → 100644
View file @
81c79e34
package
com.viettel.campaign.web.dto
;
import
lombok.Getter
;
import
lombok.Setter
;
import
java.util.Date
;
@Getter
@Setter
public
class
CustomizeFieldsDTO
extends
BaseDTO
{
private
Long
customizeFieldId
;
private
Long
siteId
;
private
String
functionCode
;
private
String
createBy
;
private
Date
createDate
;
private
String
updateBy
;
private
Date
updateDate
;
private
Long
status
;
private
String
type
;
private
String
title
;
private
String
placeholder
;
private
String
description
;
private
Long
position
;
private
Long
required
;
private
Long
fieldOptionsId
;
private
String
regexpForValidation
;
private
Long
maxLength
;
private
Long
minLength
;
private
Long
min
;
private
Long
max
;
private
Long
active
;
}
src/main/java/com/viettel/campaign/web/dto/ScenarioAnswerDTO.java
View file @
81c79e34
...
@@ -25,4 +25,6 @@ public class ScenarioAnswerDTO implements Serializable {
...
@@ -25,4 +25,6 @@ public class ScenarioAnswerDTO implements Serializable {
public
Date
deleteTime
;
public
Date
deleteTime
;
public
Long
mappingQuestionId
;
public
Long
mappingQuestionId
;
public
Long
campaignId
;
public
Long
campaignId
;
public
String
importQuestionCode
;
public
String
mappingQuestionCode
;
}
}
src/main/java/com/viettel/campaign/web/dto/ScenarioQuestionDTO.java
View file @
81c79e34
...
@@ -29,4 +29,5 @@ public class ScenarioQuestionDTO implements Serializable {
...
@@ -29,4 +29,5 @@ public class ScenarioQuestionDTO implements Serializable {
private
Short
isDefault
;
private
Short
isDefault
;
private
Short
answerIndex
;
private
Short
answerIndex
;
private
List
<
ScenarioAnswerDTO
>
lstAnswers
;
private
List
<
ScenarioAnswerDTO
>
lstAnswers
;
private
String
importCode
;
}
}
src/main/java/com/viettel/campaign/web/dto/request_dto/CustomerQueryDTO.java
0 → 100644
View file @
81c79e34
package
com.viettel.campaign.web.dto.request_dto
;
import
com.viettel.campaign.web.dto.BaseDTO
;
import
lombok.Getter
;
import
lombok.Setter
;
@Getter
@Setter
public
class
CustomerQueryDTO
extends
BaseDTO
{
String
join
;
String
field
;
String
operator
;
String
condition
;
}
src/main/java/com/viettel/campaign/web/dto/request_dto/CustomizeRequestDTo.java
View file @
81c79e34
...
@@ -5,13 +5,29 @@ import com.viettel.campaign.web.dto.BaseDTO;
...
@@ -5,13 +5,29 @@ import com.viettel.campaign.web.dto.BaseDTO;
import
lombok.Getter
;
import
lombok.Getter
;
import
lombok.Setter
;
import
lombok.Setter
;
import
java.util.Date
;
import
java.util.List
;
@Getter
@Getter
@Setter
@Setter
public
class
CustomizeRequestDTo
extends
BaseDTO
{
public
class
CustomizeRequestDTo
extends
BaseDTO
{
String
operatorLogic
;
String
operatorLogic
;
String
name
;
String
filterCustomer
;
String
filterCustomer
;
String
compare
;
String
compare
;
String
valueCustomer
;
String
valueCustomer
;
String
companySiteId
;
String
customerId
;
String
customerId
;
String
companyName
;
String
status
;
String
siteId
;
Short
gender
;
String
currentAddress
;
String
placeOfBirth
;
Date
dateOfBirth
;
String
mobileNumber
;
String
email
;
String
userName
;
Long
customerType
;
}
}
src/main/java/com/viettel/campaign/web/dto/request_dto/RequestImportDTO.java
0 → 100644
View file @
81c79e34
package
com.viettel.campaign.web.dto.request_dto
;
import
lombok.Getter
;
import
lombok.Setter
;
import
org.springframework.web.multipart.commons.CommonsMultipartFile
;
/**
* @author anhvd_itsol
*/
@Getter
@Setter
public
class
RequestImportDTO
{
CommonsMultipartFile
file
;
}
src/main/java/com/viettel/campaign/web/rest/CampaignController.java
View file @
81c79e34
...
@@ -227,32 +227,4 @@ public class CampaignController {
...
@@ -227,32 +227,4 @@ public class CampaignController {
return
new
ResponseEntity
<>(
result
,
HttpStatus
.
OK
);
return
new
ResponseEntity
<>(
result
,
HttpStatus
.
OK
);
}
}
@RequestMapping
(
value
=
"/import-file"
,
method
=
RequestMethod
.
POST
)
public
ResponseEntity
<?>
importFile
(
@RequestParam
(
"file"
)
MultipartFile
file
,
@RequestHeader
(
"X-Auth-Token"
)
String
authToken
)
{
Locale
locale
=
new
Locale
(
"vi"
,
"VN"
);
try
{
UserSession
userSession
=
(
UserSession
)
RedisUtil
.
getInstance
().
get
(
authToken
);
if
(
file
.
isEmpty
())
{
return
new
ResponseEntity
<>(
BundleUtils
.
getLangString
(
"common.fileNotSelected"
),
HttpStatus
.
OK
);
}
if
(!
Objects
.
equals
(
FilenameUtils
.
getExtension
(
file
.
getOriginalFilename
()),
Constants
.
FileType
.
xlsx
))
{
return
new
ResponseEntity
<>(
BundleUtils
.
getLangString
(
"common.fileInvalidFormat"
,
locale
),
HttpStatus
.
OK
);
}
//String path = saveUploadFile(file);
// List<CustomizeFields> dynamicHeaders = customerService.getDynamicHeader(userSession.getCompanySiteId());
// Map<String, Object> map = customerService.readAndValidateCustomer(path, dynamicHeaders, userSession, customerListId);
// File fileExport = (File) map.get("file");
// String message = (String) map.get("message");
// return ResponseEntity.ok()
// .header("Content-Type", Constants.MIME_TYPE.EXCEL_XLSX)
// .header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=template_import_customer.xlsx")
// .header("Message", message)
// .body(Files.readAllBytes(fileExport.toPath()));
return
new
ResponseEntity
<>(
null
,
HttpStatus
.
OK
);
}
catch
(
Exception
e
)
{
logger
.
error
(
e
.
getMessage
(),
e
);
return
new
ResponseEntity
<>(
HttpStatus
.
BAD_REQUEST
);
}
}
}
}
src/main/java/com/viettel/campaign/web/rest/CustomerController.java
View file @
81c79e34
package
com.viettel.campaign.web.rest
;
package
com.viettel.campaign.web.rest
;
import
com.viettel.campaign.model.ccms_full.CampaignCustomer
;
import
com.viettel.campaign.model.ccms_full.Customer
;
import
com.viettel.campaign.model.ccms_full.Customer
;
import
com.viettel.campaign.model.ccms_full.CustomizeFieldObject
;
import
com.viettel.campaign.model.ccms_full.CustomizeFieldObject
;
import
com.viettel.campaign.model.ccms_full.CustomizeFields
;
import
com.viettel.campaign.model.ccms_full.CustomizeFields
;
import
com.viettel.campaign.repository.ccms_full.CustomerQueryRepository
;
import
com.viettel.campaign.repository.ccms_full.impl.CustomerQueryRepositoryImpl
;
import
com.viettel.campaign.service.CustomerService
;
import
com.viettel.campaign.service.CustomerService
;
import
com.viettel.campaign.utils.BundleUtils
;
import
com.viettel.campaign.utils.BundleUtils
;
import
com.viettel.campaign.utils.Config
;
import
com.viettel.campaign.utils.Config
;
...
@@ -38,6 +41,7 @@ import java.util.*;
...
@@ -38,6 +41,7 @@ import java.util.*;
@RequestMapping
(
"/ipcc/customer"
)
@RequestMapping
(
"/ipcc/customer"
)
@CrossOrigin
(
origins
=
"*"
)
@CrossOrigin
(
origins
=
"*"
)
public
class
CustomerController
{
public
class
CustomerController
{
private
CustomerQueryRepository
customerQueryRepo
;
private
static
final
Logger
LOGGER
=
LoggerFactory
.
getLogger
(
CustomerController
.
class
);
private
static
final
Logger
LOGGER
=
LoggerFactory
.
getLogger
(
CustomerController
.
class
);
...
@@ -113,6 +117,7 @@ public class CustomerController {
...
@@ -113,6 +117,7 @@ public class CustomerController {
// VIẾT ĐI VIẾT LẠI 4 LẦN RỒI ĐẤY
// VIẾT ĐI VIẾT LẠI 4 LẦN RỒI ĐẤY
String
xAuthToken
=
request
.
getHeader
(
"X-Auth-Token"
);
String
xAuthToken
=
request
.
getHeader
(
"X-Auth-Token"
);
UserSession
userSession
=
(
UserSession
)
RedisUtil
.
getInstance
().
get
(
xAuthToken
);
UserSession
userSession
=
(
UserSession
)
RedisUtil
.
getInstance
().
get
(
xAuthToken
);
if
(
userSession
==
null
)
{
if
(
userSession
==
null
)
{
userSession
=
new
UserSession
();
userSession
=
new
UserSession
();
userSession
.
setSiteId
(
customerListDTO
.
getCompanySiteId
());
userSession
.
setSiteId
(
customerListDTO
.
getCompanySiteId
());
...
@@ -123,10 +128,15 @@ public class CustomerController {
...
@@ -123,10 +128,15 @@ public class CustomerController {
@PostMapping
(
"/updateCustomerList"
)
@PostMapping
(
"/updateCustomerList"
)
@ResponseBody
@ResponseBody
public
ResultDTO
updateCustomerList
(
@RequestBody
@Valid
CustomerListDTO
customerListDTO
)
{
public
ResultDTO
updateCustomerList
(
@RequestBody
@Valid
CustomerListDTO
customerListDTO
,
HttpServletRequest
request
)
{
ResultDTO
result
=
new
ResultDTO
();
String
xAuthToken
=
request
.
getHeader
(
"X-Auth-Token"
);
result
=
customerService
.
updateCustomerList
(
customerListDTO
);
UserSession
userSession
=
(
UserSession
)
RedisUtil
.
getInstance
().
get
(
xAuthToken
);
return
result
;
if
(
userSession
==
null
)
{
userSession
=
new
UserSession
();
userSession
.
setSiteId
(
customerListDTO
.
getCompanySiteId
());
userSession
.
setUserName
(
"its4"
);
}
return
customerService
.
updateCustomerList
(
customerListDTO
,
userSession
.
getUserName
());
}
}
@PostMapping
(
"/deleteCustomerList"
)
@PostMapping
(
"/deleteCustomerList"
)
...
@@ -243,6 +253,15 @@ public class CustomerController {
...
@@ -243,6 +253,15 @@ public class CustomerController {
return
new
ResponseEntity
<>(
data
,
HttpStatus
.
OK
);
return
new
ResponseEntity
<>(
data
,
HttpStatus
.
OK
);
}
}
@PostMapping
(
"/deleteCustomerFromCampaign"
)
@ResponseBody
public
ResponseEntity
<?>
deleteCustomerFromCampaign
(
@RequestBody
CampaignCustomerDTO
dto
)
{
ResultDTO
resultDTO
=
customerService
.
deleteCustomerFromCampaign
(
dto
);
return
new
ResponseEntity
<>(
resultDTO
,
HttpStatus
.
OK
);
}
private
String
saveUploadFile
(
MultipartFile
file
)
{
private
String
saveUploadFile
(
MultipartFile
file
)
{
try
{
try
{
String
currentTime
=
new
SimpleDateFormat
(
"yyyy_MM_dd_hh_mm_ss"
).
format
(
new
Date
());
String
currentTime
=
new
SimpleDateFormat
(
"yyyy_MM_dd_hh_mm_ss"
).
format
(
new
Date
());
...
@@ -262,6 +281,15 @@ public class CustomerController {
...
@@ -262,6 +281,15 @@ public class CustomerController {
}
}
return
null
;
return
null
;
}
}
// @GetMapping("/query")
// public ResponseEntity<List<Customer>> query(@RequestParam(value = "search") String query) {
// List<Customer> things = customerQueryRepo.findAll(query);
// if (things.isEmpty()) {
// return ResponseEntity.noContent().build();
// }
// return ResponseEntity.ok(things);
// }
@GetMapping
(
path
=
""
,
produces
=
{
MediaType
.
APPLICATION_JSON_VALUE
})
@GetMapping
(
path
=
""
,
produces
=
{
MediaType
.
APPLICATION_JSON_VALUE
})
public
ResponseEntity
<
List
<
Customer
>>
query
(
@RequestParam
(
value
=
"search"
)
String
query
)
{
public
ResponseEntity
<
List
<
Customer
>>
query
(
@RequestParam
(
value
=
"search"
)
String
query
)
{
List
<
Customer
>
result
=
null
;
List
<
Customer
>
result
=
null
;
...
@@ -276,8 +304,8 @@ public class CustomerController {
...
@@ -276,8 +304,8 @@ public class CustomerController {
}
}
@PostMapping
(
"/getCustomizeFields"
)
@PostMapping
(
"/getCustomizeFields"
)
@ResponseBody
@ResponseBody
public
ResponseEntity
<?>
getList
FieldsToShow
(
@RequestBody
CustomizeRequestDTo
customizeRequestDTo
)
{
public
ResponseEntity
<?>
getList
Customer
(
@RequestBody
CustomizeFieldsDTO
customizeRequestDTo
)
{
ResultDTO
resultDTO
=
customerService
.
search
CustomizeFields
(
customizeRequestDTo
);
ResultDTO
resultDTO
=
customerService
.
list
CustomizeFields
(
customizeRequestDTo
);
return
new
ResponseEntity
<>(
resultDTO
,
HttpStatus
.
OK
);
return
new
ResponseEntity
<>(
resultDTO
,
HttpStatus
.
OK
);
}
}
}
}
src/main/java/com/viettel/campaign/web/rest/ScenarioController.java
View file @
81c79e34
...
@@ -8,6 +8,7 @@ import com.viettel.campaign.utils.RedisUtil;
...
@@ -8,6 +8,7 @@ import com.viettel.campaign.utils.RedisUtil;
import
com.viettel.campaign.web.dto.ContactQuestResultDTO
;
import
com.viettel.campaign.web.dto.ContactQuestResultDTO
;
import
com.viettel.campaign.web.dto.ResultDTO
;
import
com.viettel.campaign.web.dto.ResultDTO
;
import
com.viettel.campaign.web.dto.ScenarioDTO
;
import
com.viettel.campaign.web.dto.ScenarioDTO
;
import
com.viettel.campaign.web.dto.request_dto.RequestImportDTO
;
import
com.viettel.econtact.filter.UserSession
;
import
com.viettel.econtact.filter.UserSession
;
import
org.apache.commons.io.FilenameUtils
;
import
org.apache.commons.io.FilenameUtils
;
import
org.apache.poi.xssf.usermodel.XSSFWorkbook
;
import
org.apache.poi.xssf.usermodel.XSSFWorkbook
;
...
@@ -21,6 +22,7 @@ import org.springframework.http.ResponseEntity;
...
@@ -21,6 +22,7 @@ import org.springframework.http.ResponseEntity;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.multipart.MultipartFile
;
import
org.springframework.web.multipart.MultipartFile
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.*
;
import
java.io.*
;
import
java.nio.file.Files
;
import
java.nio.file.Files
;
...
@@ -104,12 +106,11 @@ public class ScenarioController {
...
@@ -104,12 +106,11 @@ public class ScenarioController {
}
}
@RequestMapping
(
value
=
"/import-file"
,
method
=
RequestMethod
.
POST
)
@RequestMapping
(
value
=
"/import-file"
,
method
=
RequestMethod
.
POST
)
public
ResponseEntity
<?>
importFile
(
@RequestParam
MultipartFile
file
)
{
public
ResponseEntity
<?>
importFile
(
@RequestParam
MultipartFile
file
,
@RequestParam
Long
scenarioId
,
@RequestParam
Long
campaignId
,
HttpServletRequest
request
)
{
logger
.
info
(
"------------IMPORT FILE TEMPLATE--------------"
);
logger
.
info
(
"------------IMPORT FILE TEMPLATE--------------"
);
Locale
locale
=
new
Locale
(
"vi"
,
"VN"
);
Locale
locale
=
new
Locale
(
"vi"
,
"VN"
);
try
{
try
{
UserSession
userSession
=
new
UserSession
();
UserSession
userSession
=
(
UserSession
)
RedisUtil
.
getInstance
().
get
(
request
.
getHeader
(
"X-Auth-Token"
));
// UserSession userSession = (UserSession) RedisUtil.getInstance().get(authToken);
if
(
file
.
isEmpty
())
{
if
(
file
.
isEmpty
())
{
return
new
ResponseEntity
<>(
BundleUtils
.
getLangString
(
"common.fileNotSelected"
),
HttpStatus
.
OK
);
return
new
ResponseEntity
<>(
BundleUtils
.
getLangString
(
"common.fileNotSelected"
),
HttpStatus
.
OK
);
}
}
...
@@ -117,16 +118,23 @@ public class ScenarioController {
...
@@ -117,16 +118,23 @@ public class ScenarioController {
return
new
ResponseEntity
<>(
BundleUtils
.
getLangString
(
"common.fileInvalidFormat"
,
locale
),
HttpStatus
.
OK
);
return
new
ResponseEntity
<>(
BundleUtils
.
getLangString
(
"common.fileInvalidFormat"
,
locale
),
HttpStatus
.
OK
);
}
}
String
path
=
saveUploadFile
(
file
);
String
path
=
saveUploadFile
(
file
);
Map
<
String
,
Object
>
map
=
scenarioService
.
readAndValidateCustomer
(
path
,
userSession
);
Map
<
String
,
Object
>
map
=
scenarioService
.
readAndValidateCustomer
(
path
,
scenarioId
,
campaignId
,
userSession
.
getCompanySiteId
()
);
File
fileExport
=
(
File
)
map
.
get
(
"file"
);
File
fileExport
=
(
File
)
map
.
get
(
"file"
);
String
message
=
(
String
)
map
.
get
(
"message"
);
String
message
=
(
String
)
map
.
get
(
"message"
);
return
ResponseEntity
.
ok
()
ResultDTO
resultDTO
=
new
ResultDTO
();
.
header
(
"Content-Type"
,
Constants
.
MIME_TYPE
.
EXCEL_XLSX
)
resultDTO
.
setErrorCode
(
Constants
.
ApiErrorCode
.
SUCCESS
);
.
header
(
HttpHeaders
.
CONTENT_DISPOSITION
,
"attachment; filename=import_scenario_result.xlsx"
)
resultDTO
.
setDescription
(
message
);
.
header
(
"Message"
,
message
)
return
new
ResponseEntity
<>(
resultDTO
,
HttpStatus
.
OK
);
.
body
(
Files
.
readAllBytes
(
fileExport
.
toPath
()));
// return ResponseEntity.ok()
// .header("Content-Type", Constants.MIME_TYPE.EXCEL_XLSX)
// .header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=import_scenario_result.xlsx")
// .header("Message", message)
// .body(Files.readAllBytes(fileExport.toPath()));
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
logger
.
error
(
e
.
getMessage
());
logger
.
error
(
e
.
getMessage
());
ResultDTO
resultDTO
=
new
ResultDTO
();
resultDTO
.
setErrorCode
(
Constants
.
ApiErrorCode
.
ERROR
);
resultDTO
.
setDescription
(
Constants
.
ApiErrorDesc
.
ERROR
);
return
new
ResponseEntity
<>(
HttpStatus
.
BAD_REQUEST
);
return
new
ResponseEntity
<>(
HttpStatus
.
BAD_REQUEST
);
}
}
}
}
...
...
src/main/resources/i18n/language_en.properties
View file @
81c79e34
...
@@ -134,4 +134,5 @@ scenario.answer.required="Answer is required for SingleChoice or MultiChoice que
...
@@ -134,4 +134,5 @@ scenario.answer.required="Answer is required for SingleChoice or MultiChoice que
scenario.hashInput.required
=
"Has input is required"
scenario.hashInput.required
=
"Has input is required"
scenario.required.required
=
"Require is required"
scenario.required.required
=
"Require is required"
scenario.default.required
=
"Default is required"
scenario.default.required
=
"Default is required"
scenario.mappingQuestion.invalid
=
"Mapping question invalid"
src/main/resources/i18n/language_vi.properties
View file @
81c79e34
...
@@ -62,13 +62,13 @@ DATE_OF_BIRTH = Ngày sinh
...
@@ -62,13 +62,13 @@ DATE_OF_BIRTH = Ngày sinh
MOBILE_NUMBER
=
Số điện thoại
MOBILE_NUMBER
=
Số điện thoại
USERNAME
=
Tài khoản
USERNAME
=
Tài khoản
AREA_CODE
=
Khu vực
AREA_CODE
=
Khu vực
CALL_ALLOWED
=
C
ALL_ALLOWED
CALL_ALLOWED
=
C
ho phép gọi
EMAIL_ALLOWED
=
EMAIL_ALLOWED
EMAIL_ALLOWED
=
Cho phép gửi email
SMS_ALLOWED
=
SMS_ALLOWED
SMS_ALLOWED
=
Cho phép gửi sms
IPCC_STATUS
=
IPCC_STATUS
IPCC_STATUS
=
Trạng thái Ipcc
EMAIL
=
E
MAIL
EMAIL
=
E
mail
CUSTOMER_TYPE
=
CUSTOMER_TYPE
CUSTOMER_TYPE
=
Loại khách hàng
AVATAR_LINK
=
AVATAR_LINK
AVATAR_LINK
=
Đường dẫn ảnh đại diện
#Customer Excel Header
#Customer Excel Header
customer.no
=
STT
customer.no
=
STT
...
@@ -136,6 +136,7 @@ scenario.answer.required="Câu trả lời cho câu hỏi SingleChoice, MultiCho
...
@@ -136,6 +136,7 @@ scenario.answer.required="Câu trả lời cho câu hỏi SingleChoice, MultiCho
scenario.hashInput.required
=
"Trường Nhập text bắt buộc nhập"
scenario.hashInput.required
=
"Trường Nhập text bắt buộc nhập"
scenario.required.required
=
"Trường Bắt buộc bắt buộc nhập"
scenario.required.required
=
"Trường Bắt buộc bắt buộc nhập"
scenario.default.required
=
"Trường Mặc định bắt buộc nhập"
scenario.default.required
=
"Trường Mặc định bắt buộc nhập"
scenario.mappingQuestion.invalid
=
"Câu hỏi liên kết không hợp lệ"
...
...
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