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
d69ad242
Commit
d69ad242
authored
Aug 02, 2019
by
Vu Duy Anh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
anhvd commit campaign mng service
parent
9584ba55
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
94 additions
and
60 deletions
+94
-60
src/main/java/com/viettel/campaign/repository/CampaignRepositoryCustom.java
...viettel/campaign/repository/CampaignRepositoryCustom.java
+1
-0
src/main/java/com/viettel/campaign/repository/impl/CampaignRepositoryImpl.java
...ttel/campaign/repository/impl/CampaignRepositoryImpl.java
+72
-5
src/main/java/com/viettel/campaign/service/CampaignService.java
...in/java/com/viettel/campaign/service/CampaignService.java
+1
-0
src/main/java/com/viettel/campaign/service/impl/CampaignServiceImpl.java
...om/viettel/campaign/service/impl/CampaignServiceImpl.java
+10
-0
src/main/java/com/viettel/campaign/service/impl/CampaignServiceImpl.java~HEAD
...ettel/campaign/service/impl/CampaignServiceImpl.java~HEAD
+0
-50
src/main/java/com/viettel/campaign/web/dto/request_dto/CampaignRequestDTO.java
...ttel/campaign/web/dto/request_dto/CampaignRequestDTO.java
+1
-2
src/main/java/com/viettel/campaign/web/rest/controller/CampaignController.java
...ttel/campaign/web/rest/controller/CampaignController.java
+7
-3
src/main/resources/sql/campaign-mng/search-campaign-by-params.sql
.../resources/sql/campaign-mng/search-campaign-by-params.sql
+2
-0
No files found.
src/main/java/com/viettel/campaign/repository/CampaignRepositoryCustom.java
View file @
d69ad242
...
@@ -10,4 +10,5 @@ import java.util.List;
...
@@ -10,4 +10,5 @@ import java.util.List;
public
interface
CampaignRepositoryCustom
{
public
interface
CampaignRepositoryCustom
{
List
<
CampaignDTO
>
searchCampaignExecute
(
String
agentId
,
Pageable
pageable
);
List
<
CampaignDTO
>
searchCampaignExecute
(
String
agentId
,
Pageable
pageable
);
ResultDTO
search
(
CampaignRequestDTO
requestDto
);
ResultDTO
search
(
CampaignRequestDTO
requestDto
);
ResultDTO
findByCompanySiteId
(
CampaignRequestDTO
requestDTO
);
}
}
src/main/java/com/viettel/campaign/repository/impl/CampaignRepositoryImpl.java
View file @
d69ad242
...
@@ -5,7 +5,6 @@ import com.viettel.campaign.utils.*;
...
@@ -5,7 +5,6 @@ import com.viettel.campaign.utils.*;
import
com.viettel.campaign.web.dto.CampaignDTO
;
import
com.viettel.campaign.web.dto.CampaignDTO
;
import
com.viettel.campaign.web.dto.ResultDTO
;
import
com.viettel.campaign.web.dto.ResultDTO
;
import
com.viettel.campaign.web.dto.request_dto.CampaignRequestDTO
;
import
com.viettel.campaign.web.dto.request_dto.CampaignRequestDTO
;
import
org.bouncycastle.util.test.FixedSecureRandom
;
import
org.hibernate.SQLQuery
;
import
org.hibernate.SQLQuery
;
import
org.hibernate.Session
;
import
org.hibernate.Session
;
import
org.hibernate.SessionFactory
;
import
org.hibernate.SessionFactory
;
...
@@ -62,6 +61,11 @@ public class CampaignRepositoryImpl implements CampaignRepositoryCustom {
...
@@ -62,6 +61,11 @@ public class CampaignRepositoryImpl implements CampaignRepositoryCustom {
Session
session
=
sessionFactory
.
openSession
();
Session
session
=
sessionFactory
.
openSession
();
session
.
beginTransaction
();
session
.
beginTransaction
();
if
(
DataUtil
.
isNullOrEmpty
(
requestDto
.
getCompanySiteId
()))
{
result
.
setErrorCode
(
Constants
.
ApiErrorCode
.
ERROR
);
result
.
setDescription
(
Constants
.
ApiErrorDesc
.
ERROR
);
return
result
;
}
try
{
try
{
StringBuilder
sqlStr
=
new
StringBuilder
();
StringBuilder
sqlStr
=
new
StringBuilder
();
sqlStr
.
append
(
SQLBuilder
.
getSqlQueryById
(
SQLBuilder
.
SQL_MODULE_CAMPAIGN_MNG
,
"search-campaign-by-params"
));
sqlStr
.
append
(
SQLBuilder
.
getSqlQueryById
(
SQLBuilder
.
SQL_MODULE_CAMPAIGN_MNG
,
"search-campaign-by-params"
));
...
@@ -77,11 +81,11 @@ public class CampaignRepositoryImpl implements CampaignRepositoryCustom {
...
@@ -77,11 +81,11 @@ public class CampaignRepositoryImpl implements CampaignRepositoryCustom {
if
(!
DataUtil
.
isNullOrEmpty
(
requestDto
.
getFromDateFr
()))
{
if
(!
DataUtil
.
isNullOrEmpty
(
requestDto
.
getFromDateFr
()))
{
sqlStr
.
append
(
" AND TO_DATE(a.START_TIME, 'DD/MM/YYYY') >= :p_frDateFr"
);
sqlStr
.
append
(
" AND TO_DATE(a.START_TIME, 'DD/MM/YYYY') >= :p_frDateFr"
);
}
}
if
(!
DataUtil
.
isNullOrEmpty
(
requestDto
.
getFromDateTo
()))
{
sqlStr
.
append
(
" AND TO_DATE(a.START_TIME, 'DD/MM/YYYY') <= :p_frDateTo"
);
}
if
(!
DataUtil
.
isNullOrEmpty
(
requestDto
.
getToDateFr
()))
{
if
(!
DataUtil
.
isNullOrEmpty
(
requestDto
.
getToDateFr
()))
{
sqlStr
.
append
(
" AND TO_DATE(a.END_TIME, 'DD/MM/YYYY') >= :p_toDateFr"
);
sqlStr
.
append
(
" AND TO_DATE(a.START_TIME, 'DD/MM/YYYY') <= :p_toDateFr"
);
}
if
(!
DataUtil
.
isNullOrEmpty
(
requestDto
.
getFromDateTo
()))
{
sqlStr
.
append
(
" AND TO_DATE(a.END_TIME, 'DD/MM/YYYY') >= :p_frDateTo"
);
}
}
if
(!
DataUtil
.
isNullOrEmpty
(
requestDto
.
getToDateTo
()))
{
if
(!
DataUtil
.
isNullOrEmpty
(
requestDto
.
getToDateTo
()))
{
sqlStr
.
append
(
" AND TO_DATE(a.END_TIME, 'DD/MM/YYYY') <= :p_toDateTo"
);
sqlStr
.
append
(
" AND TO_DATE(a.END_TIME, 'DD/MM/YYYY') <= :p_toDateTo"
);
...
@@ -126,6 +130,8 @@ public class CampaignRepositoryImpl implements CampaignRepositoryCustom {
...
@@ -126,6 +130,8 @@ public class CampaignRepositoryImpl implements CampaignRepositoryCustom {
+
"%"
);
+
"%"
);
}
}
query
.
setParameter
(
"p_company_site_id"
,
requestDto
.
getCompanySiteId
());
if
(
requestDto
.
getStatus
()
!=
null
&&
requestDto
.
getStatus
()
>
0
)
{
if
(
requestDto
.
getStatus
()
!=
null
&&
requestDto
.
getStatus
()
>
0
)
{
query
.
setParameter
(
"p_status"
,
requestDto
.
getStatus
());
query
.
setParameter
(
"p_status"
,
requestDto
.
getStatus
());
}
}
...
@@ -193,6 +199,67 @@ public class CampaignRepositoryImpl implements CampaignRepositoryCustom {
...
@@ -193,6 +199,67 @@ public class CampaignRepositoryImpl implements CampaignRepositoryCustom {
return
result
;
return
result
;
}
}
@Override
public
ResultDTO
findByCompanySiteId
(
CampaignRequestDTO
requestDto
)
{
ResultDTO
result
=
new
ResultDTO
();
SessionFactory
sessionFactory
=
HibernateUtil
.
getSessionFactory
();
Session
session
=
sessionFactory
.
openSession
();
session
.
beginTransaction
();
if
(
DataUtil
.
isNullOrEmpty
(
requestDto
.
getCompanySiteId
()))
{
result
.
setErrorCode
(
Constants
.
ApiErrorCode
.
ERROR
);
result
.
setDescription
(
Constants
.
ApiErrorDesc
.
ERROR
);
return
result
;
}
try
{
StringBuilder
sqlStr
=
new
StringBuilder
();
sqlStr
.
append
(
" SELECT CAMPAIGN_ID campaignId, "
+
" CAMPAIGN_CODE campaignCode, "
+
" CAMPAIGN_NAME campaignName, "
+
" START_TIME startTime,"
+
" END_TIME endTime, "
+
" STATUS status "
+
" FROM CAMPAIGN"
+
" WHERE COMPANY_SITE_ID = :p_company_site_id AND STATUS <> -1 "
);
sqlStr
.
append
(
" ORDER BY START_TIME DESC "
);
SQLQuery
query
=
session
.
createSQLQuery
(
sqlStr
.
toString
());
query
.
setParameter
(
"p_company_site_id"
,
requestDto
.
getCompanySiteId
());
query
.
addScalar
(
"campaignId"
,
new
BigDecimalType
());
query
.
addScalar
(
"campaignCode"
,
new
StringType
());
query
.
addScalar
(
"campaignName"
,
new
StringType
());
query
.
addScalar
(
"startTime"
,
new
DateType
());
query
.
addScalar
(
"endTime"
,
new
DateType
());
query
.
addScalar
(
"status"
,
new
ShortType
());
query
.
setResultTransformer
(
Transformers
.
aliasToBean
(
CampaignDTO
.
class
));
int
count
=
0
;
List
<
CampaignDTO
>
list
=
query
.
list
();
if
(
list
.
size
()
>
0
)
{
count
=
query
.
list
().
size
();
}
Pageable
pageable
=
buildPageable
(
requestDto
);
if
(
pageable
!=
null
)
{
query
.
setFirstResult
(
pageable
.
getPageNumber
()
*
pageable
.
getPageSize
());
query
.
setMaxResults
(
pageable
.
getPageSize
());
}
List
<
CampaignDTO
>
data
=
query
.
list
();
Page
<
CampaignDTO
>
dataPage
=
new
PageImpl
<>(
data
,
pageable
,
count
);
result
.
setData
(
dataPage
);
result
.
setErrorCode
(
Constants
.
ApiErrorCode
.
SUCCESS
);
result
.
setDescription
(
Constants
.
ApiErrorDesc
.
SUCCESS
);
session
.
close
();
return
result
;
}
catch
(
Exception
ex
)
{
session
.
close
();
}
result
.
setErrorCode
(
Constants
.
ApiErrorCode
.
ERROR
);
result
.
setDescription
(
Constants
.
ApiErrorDesc
.
ERROR
);
return
result
;
}
private
Pageable
buildPageable
(
CampaignRequestDTO
obj
)
{
private
Pageable
buildPageable
(
CampaignRequestDTO
obj
)
{
Pageable
pageable
=
null
;
Pageable
pageable
=
null
;
if
(
DataUtil
.
isNullOrEmpty
(
obj
.
getSort
())){
if
(
DataUtil
.
isNullOrEmpty
(
obj
.
getSort
())){
...
...
src/main/java/com/viettel/campaign/service/CampaignService.java
View file @
d69ad242
...
@@ -9,4 +9,5 @@ import java.util.Map;
...
@@ -9,4 +9,5 @@ import java.util.Map;
public
interface
CampaignService
{
public
interface
CampaignService
{
Map
searchCampaignExecute
(
int
page
,
int
pageSize
,
String
sort
,
String
agentId
);
Map
searchCampaignExecute
(
int
page
,
int
pageSize
,
String
sort
,
String
agentId
);
ResultDTO
search
(
CampaignRequestDTO
requestDto
);
ResultDTO
search
(
CampaignRequestDTO
requestDto
);
ResultDTO
findByCompanySiteId
(
CampaignRequestDTO
requestDTO
);
}
}
src/main/java/com/viettel/campaign/service/impl/CampaignServiceImpl.java
View file @
d69ad242
package
com.viettel.campaign.service.impl
;
package
com.viettel.campaign.service.impl
;
import
com.viettel.campaign.model.Campaign
;
import
com.viettel.campaign.repository.CampaignRepository
;
import
com.viettel.campaign.repository.CampaignRepository
;
import
com.viettel.campaign.web.dto.CampaignDTO
;
import
com.viettel.campaign.web.dto.CampaignDTO
;
...
@@ -42,4 +43,13 @@ public class CampaignServiceImpl implements CampaignService {
...
@@ -42,4 +43,13 @@ public class CampaignServiceImpl implements CampaignService {
public
ResultDTO
search
(
CampaignRequestDTO
requestDto
)
{
public
ResultDTO
search
(
CampaignRequestDTO
requestDto
)
{
return
campaignRepository
.
search
(
requestDto
);
return
campaignRepository
.
search
(
requestDto
);
}
}
@Override
public
ResultDTO
findByCompanySiteId
(
CampaignRequestDTO
requestDTO
)
{
requestDTO
.
setCompanySiteId
(
"663192"
);
requestDTO
.
setPage
(
0
);
requestDTO
.
setPageSize
(
10
);
Pageable
pageable
=
PageRequest
.
of
(
requestDTO
.
getPage
(),
requestDTO
.
getPageSize
(),
null
);
return
campaignRepository
.
findByCompanySiteId
(
requestDTO
);
}
}
}
src/main/java/com/viettel/campaign/service/impl/CampaignServiceImpl.java~HEAD
deleted
100644 → 0
View file @
9584ba55
package
com
.
viettel
.
campaign
.
service
.
impl
;
<<<<<<<
HEAD
:
src
/
main
/
java
/
com
/
viettel
/
campaign
/
service
/
CampaignServiceImpl
.
java
import
com
.
viettel
.
campaign
.
repository
.
CampaignRepository
;
import
com
.
viettel
.
campaign
.
web
.
dto
.
CampaignDTO
;
=======
import
com
.
viettel
.
campaign
.
dto
.
CampaignDTO
;
import
com
.
viettel
.
campaign
.
dto
.
ResultDTO
;
import
com
.
viettel
.
campaign
.
dto
.
request_dto
.
CampaignRequestDTO
;
import
com
.
viettel
.
campaign
.
model
.
Campaign
;
import
com
.
viettel
.
campaign
.
repository
.
CampaignRepository
;
import
com
.
viettel
.
campaign
.
service
.
CampaignService
;
>>>>>>>
anhvd_campaign_mng
:
src
/
main
/
java
/
com
/
viettel
/
campaign
/
service
/
impl
/
CampaignServiceImpl
.
java
import
org
.
springframework
.
beans
.
factory
.
annotation
.
Autowired
;
import
org
.
springframework
.
data
.
domain
.
Page
;
import
org
.
springframework
.
data
.
domain
.
PageRequest
;
import
org
.
springframework
.
data
.
domain
.
Pageable
;
import
org
.
springframework
.
data
.
domain
.
Sort
;
import
org
.
springframework
.
stereotype
.
Service
;
import
java
.
util
.
ArrayList
;
import
java
.
util
.
HashMap
;
import
java
.
util
.
List
;
import
java
.
util
.
Map
;
@
Service
public
class
CampaignServiceImpl
implements
CampaignService
{
@
Autowired
(
required
=
true
)
CampaignRepository
campaignRepository
;
@
Override
public
Map
searchCampaignExecute
(
int
page
,
int
pageSize
,
String
sort
,
String
agentId
)
{
Map
result
=
new
HashMap
();
List
<
CampaignDTO
>
lst
=
new
ArrayList
<>();
Pageable
pageable
=
PageRequest
.
of
(
page
,
pageSize
,
Sort
.
by
(
sort
));
lst
=
campaignRepository
.
searchCampaignExecute
(
agentId
,
pageable
);
result
.
put
(
"totalItem"
,
lst
.
size
());
result
.
put
(
"data"
,
lst
);
return
result
;
}
@
Override
public
ResultDTO
search
(
CampaignRequestDTO
requestDto
)
{
return
campaignRepository
.
search
(
requestDto
);
}
}
src/main/java/com/viettel/campaign/web/dto/request_dto/CampaignRequestDTO.java
View file @
d69ad242
...
@@ -4,8 +4,6 @@ import com.viettel.campaign.web.dto.BaseDTO;
...
@@ -4,8 +4,6 @@ import com.viettel.campaign.web.dto.BaseDTO;
import
lombok.Getter
;
import
lombok.Getter
;
import
lombok.Setter
;
import
lombok.Setter
;
import
java.util.Date
;
/**
/**
* @author anhvd_itsol
* @author anhvd_itsol
*/
*/
...
@@ -25,4 +23,5 @@ public class CampaignRequestDTO extends BaseDTO {
...
@@ -25,4 +23,5 @@ public class CampaignRequestDTO extends BaseDTO {
Long
numOfCusTo
;
Long
numOfCusTo
;
Short
type
;
Short
type
;
Short
chanel
;
Short
chanel
;
String
companySiteId
;
}
}
src/main/java/com/viettel/campaign/web/rest/controller/CampaignController.java
View file @
d69ad242
package
com.viettel.campaign.web.rest.controller
;
package
com.viettel.campaign.web.rest.controller
;
import
com.viettel.campaign.model.Campaign
;
import
com.viettel.campaign.service.CampaignService
;
import
com.viettel.campaign.service.CampaignService
;
import
com.viettel.campaign.web.dto.ResultDTO
;
import
com.viettel.campaign.web.dto.ResultDTO
;
import
com.viettel.campaign.web.dto.request_dto.CampaignRequestDTO
;
import
com.viettel.campaign.web.dto.request_dto.CampaignRequestDTO
;
...
@@ -7,11 +8,9 @@ import org.apache.log4j.Logger;
...
@@ -7,11 +8,9 @@ import org.apache.log4j.Logger;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.data.domain.Page
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
@RestController
@RestController
...
@@ -37,4 +36,9 @@ public class CampaignController {
...
@@ -37,4 +36,9 @@ public class CampaignController {
return
new
ResponseEntity
<>(
result
,
HttpStatus
.
OK
);
return
new
ResponseEntity
<>(
result
,
HttpStatus
.
OK
);
}
}
@RequestMapping
(
value
=
"/findByCompanySiteId"
,
method
=
RequestMethod
.
POST
)
public
ResultDTO
findByCompanySiteId
(
CampaignRequestDTO
dto
)
{
return
campaignService
.
findByCompanySiteId
(
dto
);
}
}
}
src/main/resources/sql/campaign-mng/search-campaign-by-params.sql
View file @
d69ad242
...
@@ -30,3 +30,5 @@ LEFT JOIN (SELECT cc.campaign_id, count(*) AS SLKHDoNotCall_Khoa
...
@@ -30,3 +30,5 @@ LEFT JOIN (SELECT cc.campaign_id, count(*) AS SLKHDoNotCall_Khoa
GROUP
BY
cc
.
CAMPAIGN_ID
)
d
GROUP
BY
cc
.
CAMPAIGN_ID
)
d
ON
d
.
CAMPAIGN_ID
=
a
.
CAMPAIGN_ID
ON
d
.
CAMPAIGN_ID
=
a
.
CAMPAIGN_ID
WHERE
1
=
1
WHERE
1
=
1
AND
COMPANY_SITE_ID
=
:
p_company_site_id
AND
a
.
STATUS
<>
-
1
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