Commit f28c3359 authored by ='s avatar =

hungtt-commit campaign customer list mng

parent 46504149
...@@ -22,4 +22,8 @@ public interface CampaignRepositoryCustom { ...@@ -22,4 +22,8 @@ public interface CampaignRepositoryCustom {
ResultDTO findCustomerListReallocation(CampaignRequestDTO dto); ResultDTO findCustomerListReallocation(CampaignRequestDTO dto);
//hungtt //hungtt
ResultDTO reallocationCustomer(CampaignRequestDTO dto); ResultDTO reallocationCustomer(CampaignRequestDTO dto);
//hungtt
ResultDTO getListFieldsNotShow(CampaignRequestDTO dto);
//hungtt
ResultDTO getListFieldsToShow(CampaignRequestDTO dto);
} }
...@@ -52,5 +52,9 @@ public interface CampaignService { ...@@ -52,5 +52,9 @@ public interface CampaignService {
ResultDTO findCustomerListReallocation(CampaignRequestDTO dto); ResultDTO findCustomerListReallocation(CampaignRequestDTO dto);
ResultDTO reallocationCustomer(CampaignRequestDTO dto); ResultDTO reallocationCustomer(CampaignRequestDTO dto);
ResultDTO getListFieldsNotShow(CampaignRequestDTO dto);
ResultDTO getListFieldsToShow(CampaignRequestDTO dto);
//</editor-fold> //</editor-fold>
} }
...@@ -390,9 +390,9 @@ public class CampaignServiceImpl implements CampaignService { ...@@ -390,9 +390,9 @@ public class CampaignServiceImpl implements CampaignService {
ResultDTO resultDTO = new ResultDTO(); ResultDTO resultDTO = new ResultDTO();
List<TimeZoneDialModeDTO> lstTimeZone = dto.getLstTimeZone(); List<TimeZoneDialModeDTO> lstTimeZone = dto.getLstTimeZone();
List<TimeRangeDialModeDTO> lstTimeRange = dto.getLstTimeRange(); List<TimeRangeDialModeDTO> lstTimeRange = dto.getLstTimeRange();
// Campaign campaignEntity = modelMapper.map(dto, Campaign.class);
Campaign campaignEntity = new Campaign(); Campaign campaignEntity = new Campaign();
campaignEntity.setCampaignId(dto.getCampaignId()); campaignEntity.setCampaignId(dto.getCampaignId());
campaignEntity.setCampaignCode(dto.getCampaignCode());
campaignEntity.setContent(dto.getContent()); campaignEntity.setContent(dto.getContent());
campaignEntity.setCustomerNumber(dto.getCustomerNumber()); campaignEntity.setCustomerNumber(dto.getCustomerNumber());
campaignEntity.setStartTime(dto.getStartTime()); campaignEntity.setStartTime(dto.getStartTime());
...@@ -458,6 +458,74 @@ public class CampaignServiceImpl implements CampaignService { ...@@ -458,6 +458,74 @@ public class CampaignServiceImpl implements CampaignService {
return campaignRepositoryCustom.reallocationCustomer(dto); return campaignRepositoryCustom.reallocationCustomer(dto);
} }
// hungtt
@Override
@Transactional(DataSourceQualify.CCMS_FULL)
public ResultDTO getListFieldsNotShow(CampaignRequestDTO dto) {
Locale locale = Locale.forLanguageTag("vi");
Map<String, String> mapColumn = new HashMap<>();
mapColumn = setMapData(mapColumn, locale);
ResultDTO resultDTO = campaignRepositoryCustom.getListFieldsNotShow(dto);
List<FieldsToShowDTO> list = (List<FieldsToShowDTO>)resultDTO.getListData();
for (FieldsToShowDTO fieldsToShowDTO : list) {
if (fieldsToShowDTO.getIsFix()) {
fieldsToShowDTO.setColumnTitle(mapColumn.get(fieldsToShowDTO.getColumnName()));
} else {
fieldsToShowDTO.setColumnTitle(fieldsToShowDTO.getColumnName());
}
}
resultDTO.setListData(list);
return resultDTO;
}
// hungtt
@Override
@Transactional(DataSourceQualify.CCMS_FULL)
public ResultDTO getListFieldsToShow(CampaignRequestDTO dto) {
Locale locale = Locale.forLanguageTag("vi");
Map<String, String> mapColumn = new HashMap<>();
mapColumn = setMapData(mapColumn, locale);
ResultDTO resultDTO = campaignRepositoryCustom.getListFieldsToShow(dto);
List<FieldsToShowDTO> list = (List<FieldsToShowDTO>)resultDTO.getListData();
for (FieldsToShowDTO fieldsToShowDTO : list) {
if (fieldsToShowDTO.getIsFix()) {
fieldsToShowDTO.setColumnTitle(mapColumn.get(fieldsToShowDTO.getColumnName()));
} else {
fieldsToShowDTO.setColumnTitle(fieldsToShowDTO.getColumnName());
}
}
resultDTO.setListData(list);
return resultDTO;
}
// hungtt
private Map<String, String> setMapData(Map<String, String> mapColumn, Locale locale) {
mapColumn.put("CUSTOMER_ID", BundleUtils.getLangString("CUSTOMER_ID", locale));
mapColumn.put("CODE", BundleUtils.getLangString("CODE", locale));
mapColumn.put("NAME", BundleUtils.getLangString("NAME", locale));
mapColumn.put("DESCRIPTION", BundleUtils.getLangString("DESCRIPTION", locale));
mapColumn.put("COMPANY_NAME", BundleUtils.getLangString("COMPANY_NAME", locale));
mapColumn.put("CUSTOMER_IMG", BundleUtils.getLangString("CUSTOMER_IMG", locale));
mapColumn.put("CREATE_DATE", BundleUtils.getLangString("CREATE_DATE", locale));
mapColumn.put("UPDATE_DATE", BundleUtils.getLangString("UPDATE_DATE", locale));
mapColumn.put("STATUS", BundleUtils.getLangString("STATUS", locale));
mapColumn.put("CREATE_BY", BundleUtils.getLangString("CREATE_BY", locale));
mapColumn.put("UPDATE_BY", BundleUtils.getLangString("UPDATE_BY", locale));
mapColumn.put("SITE_ID", BundleUtils.getLangString("SITE_ID", locale));
mapColumn.put("GENDER", BundleUtils.getLangString("GENDER", locale));
mapColumn.put("CURRENT_ADDRESS", BundleUtils.getLangString("CURRENT_ADDRESS", locale));
mapColumn.put("PLACE_OF_BIRTH", BundleUtils.getLangString("PLACE_OF_BIRTH", locale));
mapColumn.put("DATE_OF_BIRTH", BundleUtils.getLangString("DATE_OF_BIRTH", locale));
mapColumn.put("MOBILE_NUMBER", BundleUtils.getLangString("MOBILE_NUMBER", locale));
mapColumn.put("USERNAME", BundleUtils.getLangString("USERNAME", locale));
mapColumn.put("AREA_CODE", BundleUtils.getLangString("AREA_CODE", locale));
mapColumn.put("CALL_ALLOWED", BundleUtils.getLangString("CALL_ALLOWED", locale));
mapColumn.put("EMAIL_ALLOWED", BundleUtils.getLangString("EMAIL_ALLOWED", locale));
mapColumn.put("SMS_ALLOWED", BundleUtils.getLangString("SMS_ALLOWED", locale));
mapColumn.put("IPCC_STATUS", BundleUtils.getLangString("IPCC_STATUS", locale));
return mapColumn;
}
private String generateCampaignCode(String campaignType, Short chanel) { private String generateCampaignCode(String campaignType, Short chanel) {
int year = Calendar.getInstance().get(Calendar.YEAR); int year = Calendar.getInstance().get(Calendar.YEAR);
String maxIndexStr = campaignRepositoryCustom.getMaxCampaignIndex(); String maxIndexStr = campaignRepositoryCustom.getMaxCampaignIndex();
......
...@@ -18,23 +18,23 @@ public class SQLBuilder { ...@@ -18,23 +18,23 @@ public class SQLBuilder {
public static final String SQL_MODULE_CAMPAIGN_STATUS_MNG = "campaign-status-mng"; public static final String SQL_MODULE_CAMPAIGN_STATUS_MNG = "campaign-status-mng";
public static final String SQL_MODULE_CAMPAIGN_CUSTOMER_MNG = "campaign-customer-mng"; public static final String SQL_MODULE_CAMPAIGN_CUSTOMER_MNG = "campaign-customer-mng";
// public static String getSqlQueryById(String module, public static String getSqlQueryById(String module,
// String queryId) { String queryId) {
// File folder = null; File folder = null;
// try { try {
// folder = new ClassPathResource( folder = new ClassPathResource(
// "sql" + File.separator + module + File.separator + queryId + ".sql").getFile(); "sql" + File.separator + module + File.separator + queryId + ".sql").getFile();
//
// // Read file // Read file
// if (folder.isFile()) { if (folder.isFile()) {
// String sql = new String(Files.readAllBytes(Paths.get(folder.getAbsolutePath()))); String sql = new String(Files.readAllBytes(Paths.get(folder.getAbsolutePath())));
// return sql; return sql;
// } }
// } catch (IOException e) { } catch (IOException e) {
// return null; return null;
// } }
// return null; return null;
// } }
public static Pageable buildPageable(BaseDTO obj) { public static Pageable buildPageable(BaseDTO obj) {
Pageable pageable = null; Pageable pageable = null;
......
...@@ -21,4 +21,8 @@ public class CustomerCustomDTO { ...@@ -21,4 +21,8 @@ public class CustomerCustomDTO {
String ipccStatus; String ipccStatus;
String mobileNumber; String mobileNumber;
String email; String email;
String connectStatus;
String connectTime;
String customerName;
Long campaignCustomerId;
} }
package com.viettel.campaign.web.dto;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import java.io.Serializable;
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
public class FieldsToShowDTO extends BaseDTO implements Serializable {
private Long campaignCusListColId;
private Long companySiteId;
private Long campaignId;
private String columnName;
private String columnTitle;
private Long orderIndex;
private Long customizeFieldId;
private String customizeFieldTitle;
private Boolean isFix;
}
package com.viettel.campaign.web.dto.request_dto; package com.viettel.campaign.web.dto.request_dto;
import com.viettel.campaign.web.dto.BaseDTO; import com.viettel.campaign.web.dto.BaseDTO;
import com.viettel.campaign.web.dto.CustomerCustomDTO;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import java.util.List;
/** /**
* @author anhvd_itsol * @author anhvd_itsol
*/ */
...@@ -42,4 +45,6 @@ public class CampaignRequestDTO extends BaseDTO { ...@@ -42,4 +45,6 @@ public class CampaignRequestDTO extends BaseDTO {
String surveyStatus; String surveyStatus;
String roleUser; String roleUser;
String contactCustId; String contactCustId;
List<CustomerCustomDTO> customerCustomDTOList;
} }
...@@ -191,4 +191,32 @@ public class CampaignController { ...@@ -191,4 +191,32 @@ public class CampaignController {
ResultDTO resultDTO = campaignService.updateCampaign(dto); ResultDTO resultDTO = campaignService.updateCampaign(dto);
return new ResponseEntity<>(resultDTO, HttpStatus.OK); return new ResponseEntity<>(resultDTO, HttpStatus.OK);
} }
@PostMapping("/findCustomerListReallocation")
@ResponseBody
public ResponseEntity<?> findCustomerListReallocation(@RequestBody CampaignRequestDTO dto) {
ResultDTO result = campaignService.findCustomerListReallocation(dto);
return new ResponseEntity<>(result, HttpStatus.OK);
}
@PostMapping("/reallocationCustomer")
@ResponseBody
public ResponseEntity<?> reallocationCustomer(@RequestBody CampaignRequestDTO dto) {
ResultDTO result = campaignService.reallocationCustomer(dto);
return new ResponseEntity<>(result, HttpStatus.OK);
}
@PostMapping("/getListFieldsNotShow")
@ResponseBody
public ResponseEntity<?> getListFieldsNotShow(@RequestBody CampaignRequestDTO dto) {
ResultDTO resultDTO = campaignService.getListFieldsNotShow(dto);
return new ResponseEntity<>(resultDTO, HttpStatus.OK);
}
@PostMapping("/getListFieldsToShow")
@ResponseBody
public ResponseEntity<?> getListFieldsToShow(@RequestBody CampaignRequestDTO dto) {
ResultDTO resultDTO = campaignService.getListFieldsToShow(dto);
return new ResponseEntity<>(resultDTO, HttpStatus.OK);
}
} }
with campaign_type_list as (
select trim (regexp_substr(:p_list_compaign_type, '[^,]+', 1, level)) campaign_type
from dual
connect by level <= regexp_count(:p_list_compaign_type, ',') +1
),
contact_status_list as (
select trim (regexp_substr(:p_list_contact_status, '[^,]+', 1, level)) contact_status
from dual
connect by level <= regexp_count(:p_list_contact_status, ',') +1
),
survey_status_list as (
select trim (regexp_substr(:p_list_survey_status, '[^,]+', 1, level)) survey_status
from dual
connect by level <= regexp_count(:p_list_survey_status, ',') +1
),
record_status_list as (
select trim (regexp_substr(:p_list_record_status, '[^,]+', 1, level)) record_status
from dual
connect by level <= regexp_count(:p_list_record_status, ',') +1
),
campaign_id_list as (
select trim (regexp_substr(:p_list_campaign_id, '[^,]+', 1, level)) campaign_id
from dual
connect by level <= regexp_count(:p_list_campaign_id, ',') +1
),
data_temp as (
select b.campaign_code campaignCode, select b.campaign_code campaignCode,
b.campaign_name campaignName, b.campaign_name campaignName,
c.user_name userName, c.user_name userName,
...@@ -22,3 +48,18 @@ where a.status <> 0 ...@@ -22,3 +48,18 @@ where a.status <> 0
and a.create_time <= to_date(:p_date_to, 'DD/MM/YYYY') and a.create_time <= to_date(:p_date_to, 'DD/MM/YYYY')
and a.duration_call >= :p_call_time_from and a.duration_call >= :p_call_time_from
and a.duration_call <= :p_call_time_to and a.duration_call <= :p_call_time_to
and to_char(a.customer_id) like '%'||:p_customer_id||'%'
and b.campaign_type in (select campaign_type from campaign_type_list)
and to_char(a.contact_status) in (select contact_status from contact_status_list)
and to_char(a.call_status) in (select survey_status from survey_status_list)
and to_char(a.status) in (select record_status from record_status_list)
and (:p_phone_number is null or to_char(a.phone_number) like '%'||:p_phone_number||'%')
and (:p_list_campaign_id is null or b.campaign_code in (select campaign_id from campaign_id_list))
and (:p_campaign_name is null or upper(b.campaign_name) like '%'||:p_campaign_name||'%')
and (:p_user_name is null or upper(c.user_name) like '%'||:p_user_name||'%')
),
data as (
select a.*, rownum row_ from data_temp a
)
select * from data
where :p_page_size = 0 or (row_ >= ((:p_page_number - 1) * :p_page_size + 1) and row_ < (:p_page_number * :p_page_size + 1))
with contact as (
select customer_id, contact
from (
select * from customer_contact
where status = 1
and contact_type = 5
and is_direct_line = 1
order by create_date desc
)
where rownum = 1
),
connect_status as (
select complete_value, complete_name
from campaign_complete_code
where company_site_id = :p_company_site_id
and complete_type = 1
and complete_value <> 1
),
connect_status_list as (
select trim (regexp_substr(:p_list_connect_status, '[^,]+', 1, level)) connect_status
from dual
connect by level <= regexp_count(:p_list_connect_status, ',') +1
),
data as (
select a.campaign_customer_id campaignCustomerId,
b.name customerName,
c.contact mobileNumber,
to_char(a.call_time, 'DD/MM/YYYY HH24:MI:SS') connectTime,
d.complete_name connectStatus
from campaign_customer a
left join customer b on a.customer_id = b.customer_id
left join contact c on a.customer_id = c.customer_id
left join connect_status d on d.complete_value = a.status
where a.campaign_id = :p_campaign_id
and a.in_campaign_status = 1
and a.status in (select connect_status from connect_status_list)
order by connectTime desc, customerName
),
final_data as (
select a.*, rownum row_ from data a
)
select * from final_data
where row_ >= ((:p_page_number - 1) * :p_page_size + 1)
and row_ < (:p_page_number * :p_page_size + 1)
with column_name_temp as (
select column_name columnName, 1 isFix from user_tab_columns, dual
where table_name = 'CUSTOMER'
)
select * from column_name_temp where columnName not in (select column_name from campaign_customerlist_column)
union all
select title columnName, 0 isFix from customize_fields, dual
where function_code = 'CUSTOMER'
and site_id = :p_company_site_id
and customize_field_id not in (select customize_field_id from campaign_customerlist_column where campaign_customerlist_column.campaign_id = :p_campaign_id)
select to_char(column_name) columnName, 1 isFix from campaign_customerlist_column, dual where campaign_id = :p_campaign_id
union all
select customize_field_title columnName, 0 isFix from campaign_customerlist_column where campaign_id = :p_campaign_id
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment