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
89b8756b
Commit
89b8756b
authored
Aug 08, 2019
by
Vu Duy Anh
Browse files
Options
Browse Files
Download
Plain Diff
anhvd commit
parents
69d7839d
013f9821
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
118 additions
and
1 deletion
+118
-1
pom.xml
pom.xml
+12
-0
src/main/java/com/viettel/campaign/repository/CampaignRepository.java
...a/com/viettel/campaign/repository/CampaignRepository.java
+4
-0
src/main/java/com/viettel/campaign/service/CampaignService.java
...in/java/com/viettel/campaign/service/CampaignService.java
+2
-0
src/main/java/com/viettel/campaign/service/impl/CampaignServiceImpl.java
...om/viettel/campaign/service/impl/CampaignServiceImpl.java
+26
-1
src/main/java/com/viettel/campaign/web/rest/controller/CampaignController.java
...ttel/campaign/web/rest/controller/CampaignController.java
+7
-0
src/main/java/com/viettel/campaign/web/rest/controller/CustomerController.java
...ttel/campaign/web/rest/controller/CustomerController.java
+67
-0
src/main/resources/templates/test_download.xlsx
src/main/resources/templates/test_download.xlsx
+0
-0
No files found.
pom.xml
View file @
89b8756b
...
...
@@ -189,6 +189,18 @@
<artifactId>
modelmapper
</artifactId>
<version>
2.3.2
</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.poi/poi -->
<dependency>
<groupId>
org.apache.poi
</groupId>
<artifactId>
poi
</artifactId>
<version>
3.17
</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.poi/poi-ooxml -->
<dependency>
<groupId>
org.apache.poi
</groupId>
<artifactId>
poi-ooxml
</artifactId>
<version>
3.17
</version>
</dependency>
</dependencies>
<dependencyManagement>
...
...
src/main/java/com/viettel/campaign/repository/CampaignRepository.java
View file @
89b8756b
package
com.viettel.campaign.repository
;
import
com.viettel.campaign.model.Campaign
;
import
com.viettel.campaign.web.dto.CampaignDTO
;
import
com.viettel.campaign.web.dto.ResultDTO
;
import
org.springframework.data.jpa.repository.JpaRepository
;
import
org.springframework.data.jpa.repository.Query
;
import
org.springframework.data.repository.query.Param
;
...
...
@@ -16,4 +18,6 @@ public interface CampaignRepository extends JpaRepository<Campaign, Long>, Campa
" AND cc.recallTime <= sysdate "
+
" AND cc.agentId = :pAgentId"
)
Long
countRecallCustomer
(
@Param
(
"pCompanySiteId"
)
Long
pCompanySiteId
,
@Param
(
"pAgentId"
)
Long
pAgentId
);
Campaign
findCampaignByCampaignIdAndCompanySiteId
(
Long
campaignId
,
Long
companySiteId
);
}
src/main/java/com/viettel/campaign/service/CampaignService.java
View file @
89b8756b
...
...
@@ -18,4 +18,6 @@ public interface CampaignService {
Map
countRecallCustomer
(
Long
companySiteId
,
Long
agentId
);
ResultDTO
findCampaignById
(
Long
campaignId
);
ResultDTO
changeCampaignStatus
(
CampaignDTO
dto
);
}
src/main/java/com/viettel/campaign/service/impl/CampaignServiceImpl.java
View file @
89b8756b
...
...
@@ -126,7 +126,7 @@ public class CampaignServiceImpl implements CampaignService {
ResultDTO
resultDTO
=
new
ResultDTO
();
try
{
Campaign
campaign
=
campaignRepository
.
findById
(
campaignId
).
orElse
(
null
);
if
(
campaign
!=
null
)
{
if
(
campaign
!=
null
)
{
resultDTO
.
setErrorCode
(
Constants
.
ApiErrorCode
.
SUCCESS
);
resultDTO
.
setDescription
(
Constants
.
ApiErrorDesc
.
SUCCESS
);
resultDTO
.
setData
(
campaign
);
...
...
@@ -139,6 +139,31 @@ public class CampaignServiceImpl implements CampaignService {
return
resultDTO
;
}
@Override
public
ResultDTO
changeCampaignStatus
(
CampaignDTO
dto
)
{
ResultDTO
result
=
new
ResultDTO
();
try
{
Campaign
entity
=
campaignRepository
.
findCampaignByCampaignIdAndCompanySiteId
(
dto
.
getCampaignId
(),
dto
.
getCompanySiteId
());
if
(
entity
!=
null
)
{
entity
.
setStatus
(
dto
.
getStatus
().
longValue
());
entity
.
setUpdateTime
(
new
Date
());
entity
.
setUpdateBy
(
dto
.
getUpdateBy
());
campaignRepository
.
save
(
entity
);
result
.
setData
(
entity
);
result
.
setDescription
(
Constants
.
ApiErrorDesc
.
SUCCESS
);
result
.
setErrorCode
(
Constants
.
ApiErrorCode
.
SUCCESS
);
}
else
{
result
.
setErrorCode
(
Constants
.
ApiErrorCode
.
ERROR
);
result
.
setDescription
(
"Entity not found"
);
}
}
catch
(
Exception
e
)
{
logger
.
error
(
e
.
getMessage
(),
e
);
result
.
setErrorCode
(
Constants
.
ApiErrorCode
.
ERROR
);
result
.
setDescription
(
e
.
getMessage
());
}
return
result
;
}
private
String
generateCampaignCode
(
String
campaignType
,
Short
chanel
)
{
int
year
=
Calendar
.
getInstance
().
get
(
Calendar
.
YEAR
);
String
maxIndexStr
=
campaignRepository
.
getMaxCampaignIndex
();
...
...
src/main/java/com/viettel/campaign/web/rest/controller/CampaignController.java
View file @
89b8756b
...
...
@@ -64,10 +64,17 @@ public class CampaignController {
return
new
ResponseEntity
<>(
result
,
HttpStatus
.
OK
);
}
<<<<<<<
HEAD
@RequestMapping
(
value
=
"/find-campaign-by-id/{campaignId}"
,
method
=
RequestMethod
.
GET
)
public
ResponseEntity
<
ResultDTO
>
findCampaignById
(
@PathVariable
Long
campaignId
)
{
ResultDTO
resultDTO
=
campaignService
.
findCampaignById
(
campaignId
);
return
new
ResponseEntity
<>(
resultDTO
,
HttpStatus
.
OK
);
}
=======
@PostMapping
(
"/changeCampaignStatus"
)
public
ResultDTO
changeCampaignStatus
(
@RequestBody
CampaignDTO
dto
)
{
return
campaignService
.
changeCampaignStatus
(
dto
);
}
>>>>>>>
013
f98210fde3ae2b1cbd585f96db122812c2a8b
}
src/main/java/com/viettel/campaign/web/rest/controller/CustomerController.java
View file @
89b8756b
...
...
@@ -7,13 +7,24 @@ import com.viettel.campaign.service.CustomerService;
import
com.viettel.campaign.web.dto.request_dto.SearchCustomerRequestDTO
;
import
com.viettel.campaign.web.dto.request_dto.CustomerRequestDTO
;
import
org.apache.log4j.Logger
;
import
org.apache.poi.xssf.usermodel.XSSFRow
;
import
org.apache.poi.xssf.usermodel.XSSFSheet
;
import
org.apache.poi.xssf.usermodel.XSSFWorkbook
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.HttpHeaders
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.MediaType
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.util.ResourceUtils
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.multipart.MultipartFile
;
import
javax.validation.Valid
;
import
java.io.File
;
import
java.nio.file.Files
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Map
;
@Controller
...
...
@@ -159,4 +170,60 @@ public class CustomerController {
ResultDTO
result
=
customerService
.
getCustomerContact
(
customerId
,
contactType
,
contact
);
return
new
ResponseEntity
(
result
,
HttpStatus
.
OK
);
}
@GetMapping
(
value
=
"/downloadFileTemplate"
)
public
ResponseEntity
<
byte
[]>
downloadFileTemplate
()
{
LOGGER
.
debug
(
"--------DOWNLOAD FILE TEMPLATE---------"
);
try
{
File
file
=
ResourceUtils
.
getFile
(
"classpath:templates/test_download.xlsx"
);
byte
[]
content
=
Files
.
readAllBytes
(
file
.
toPath
());
return
ResponseEntity
.
ok
()
.
header
(
HttpHeaders
.
CONTENT_DISPOSITION
,
"attachment; filename="
+
file
.
getName
())
.
contentType
(
MediaType
.
APPLICATION_OCTET_STREAM
)
.
body
(
content
);
}
catch
(
Exception
e
)
{
LOGGER
.
error
(
e
.
getMessage
());
return
new
ResponseEntity
<>(
HttpStatus
.
BAD_REQUEST
);
}
}
@PostMapping
(
value
=
"/importFile"
)
public
ResponseEntity
<
byte
[]>
importFile
(
@RequestParam
(
"file"
)
MultipartFile
file
)
{
LOGGER
.
debug
(
"--------IMPORT FILE TEMPLATE---------"
);
try
{
List
<
CustomerDTO
>
listCustomer
=
new
ArrayList
<>();
XSSFWorkbook
workbook
=
new
XSSFWorkbook
(
file
.
getInputStream
());
XSSFSheet
sheet
=
workbook
.
getSheetAt
(
0
);
for
(
int
i
=
0
;
i
<
sheet
.
getPhysicalNumberOfRows
();
i
++)
{
CustomerDTO
customer
=
new
CustomerDTO
();
XSSFRow
row
=
sheet
.
getRow
(
i
);
customer
.
setCustomerId
(
Double
.
valueOf
(
row
.
getCell
(
0
).
getNumericCellValue
()).
longValue
());
customer
.
setCreateDate
(
row
.
getCell
(
1
).
getDateCellValue
());
customer
.
setName
(
row
.
getCell
(
2
).
getStringCellValue
());
listCustomer
.
add
(
customer
);
}
// for (int i = 0; i < listCustomer.size(); i++) {
// validate du lieu
// }
// if (okay) {
// for (int i = 0; i < listCustomer.size(); i++) {
// customerService.createCustomer(listCustomer.get(i));
// }
// return ResponseEntity.ok()
// .header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=" + file.getName())
// .contentType(MediaType.APPLICATION_OCTET_STREAM)
// .body(file.getBytes());
// } else {
// return ResponseEntity.ok()
// .header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=" + file.getName())
// .header("Message", "Validate failed!")
// .contentType(MediaType.APPLICATION_OCTET_STREAM)
// .body(file.getBytes());
// }
return
null
;
}
catch
(
Exception
e
)
{
LOGGER
.
error
(
e
.
getMessage
());
return
new
ResponseEntity
<>(
HttpStatus
.
BAD_REQUEST
);
}
}
}
src/main/resources/templates/test_download.xlsx
0 → 100644
View file @
89b8756b
File added
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