Commit fcd4f077 authored by ='s avatar =

hungtt-commit customer-mng list

parent bf5364c2
[main] 22/08/2019 08:36:29 INFO RedisUtil: (38) : Start connect Redis: 10.60.156.82:8011,10.60.156.82:8012,10.60.156.82:8013,10.60.156.82:8014,10.60.156.82:8015,10.60.156.82:8016
[main] 22/08/2019 09:37:28 INFO RedisUtil: (38) : Start connect Redis: 10.60.156.82:8011,10.60.156.82:8012,10.60.156.82:8013,10.60.156.82:8014,10.60.156.82:8015,10.60.156.82:8016
[main] 22/08/2019 10:56:57 INFO RedisUtil: (38) : Start connect Redis: 10.60.156.82:8011,10.60.156.82:8012,10.60.156.82:8013,10.60.156.82:8014,10.60.156.82:8015,10.60.156.82:8016
[main] 22/08/2019 11:26:26 INFO RedisUtil: (38) : Start connect Redis: 10.60.156.82:8011,10.60.156.82:8012,10.60.156.82:8013,10.60.156.82:8014,10.60.156.82:8015,10.60.156.82:8016
[main] 22/08/2019 11:38:32 INFO RedisUtil: (38) : Start connect Redis: 10.60.156.82:8011,10.60.156.82:8012,10.60.156.82:8013,10.60.156.82:8014,10.60.156.82:8015,10.60.156.82:8016
[main] 22/08/2019 12:57:40 INFO RedisUtil: (38) : Start connect Redis: 10.60.156.82:8011,10.60.156.82:8012,10.60.156.82:8013,10.60.156.82:8014,10.60.156.82:8015,10.60.156.82:8016
This diff is collapsed.
...@@ -49,8 +49,8 @@ ...@@ -49,8 +49,8 @@
<dependency> <dependency>
<groupId>com.oracle</groupId> <groupId>com.oracle</groupId>
<artifactId>ojdbc7</artifactId> <artifactId>ojdbc7</artifactId>
<!-- <scope>system</scope>--> <scope>system</scope>
<!-- <systemPath>${project.basedir}/lib/ojdbc7.jar</systemPath>--> <systemPath>${project.basedir}/lib/ojdbc7.jar</systemPath>
<version>1.0</version> <version>1.0</version>
</dependency> </dependency>
<dependency> <dependency>
......
package com.viettel.campaign.repository.ccms_full;
import com.viettel.campaign.config.DataSourceQualify;
import com.viettel.campaign.model.ccms_full.CampaignCustomerListColumn;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
@Repository
@Transactional(DataSourceQualify.CCMS_FULL)
public interface CampaignCustomerListColumnRepository extends JpaRepository<CampaignCustomerListColumn, Long> {
List<CampaignCustomerListColumn> findByCampaignIdAndCompanySiteId(Long campaignId, Long companaySiteId);
CampaignCustomerListColumn findByCampaignCusListColId(Long campaignCusListColId);
}
...@@ -511,23 +511,19 @@ public class CampaignRepositoryImpl implements CampaignRepositoryCustom { ...@@ -511,23 +511,19 @@ public class CampaignRepositoryImpl implements CampaignRepositoryCustom {
StringBuilder stringBuilder = new StringBuilder(); StringBuilder stringBuilder = new StringBuilder();
try { try {
// String sql = SQLBuilder.getSqlQueryById(SQLBuilder.SQL_MODULE_CAMPAIGN_MNG, "get-list-fields-not-show"); // String sql = SQLBuilder.getSqlQueryById(SQLBuilder.SQL_MODULE_CAMPAIGN_MNG, "get-list-fields-not-show");
stringBuilder.append(" with column_name_temp as ("); String sql = "with column_name_temp as (\n" +
stringBuilder.append(" select column_name columnName, 1 isFix from user_tab_columns, dual"); " select column_name columnName, null customizeFieldId, 1 isFix from user_tab_columns, dual\n" +
stringBuilder.append(" where table_name = 'CUSTOMER'"); " where table_name = 'CUSTOMER'\n" +
stringBuilder.append(" )"); ")\n" +
stringBuilder.append(" select * from column_name_temp"); "select * from column_name_temp where columnName not in (select column_name from campaign_customerlist_column where column_name is not null)\n" +
stringBuilder.append(" where columnName not in (select column_name from campaign_customerlist_column where column_name is not null)"); "union all\n" +
stringBuilder.append(" union all"); "select title columnName, customize_field_id customizeFieldId, 0 isFix from customize_fields, dual\n" +
stringBuilder.append(" select title columnName, 0 isFix "); "where function_code = 'CUSTOMER'\n" +
stringBuilder.append(" from customize_fields, dual"); " and site_id = :p_company_site_id\n" +
stringBuilder.append(" where function_code = 'CUSTOMER'"); " and customize_field_id not in (select customize_field_id from campaign_customerlist_column where campaign_customerlist_column.campaign_id = :p_campaign_id)\n";
stringBuilder.append(" and site_id = :p_company_site_id");
stringBuilder.append(" and customize_field_id not in (select customize_field_id");
stringBuilder.append(" from campaign_customerlist_column");
stringBuilder.append(" where campaign_customerlist_column.campaign_id = :p_campaign_id)");
params.put("p_company_site_id", dto.getCompanySiteId()); params.put("p_company_site_id", dto.getCompanySiteId());
params.put("p_campaign_id", dto.getCampaignId()); params.put("p_campaign_id", dto.getCampaignId());
list = namedParameterJdbcTemplate.query(stringBuilder.toString(), params, BeanPropertyRowMapper.newInstance(FieldsToShowDTO.class)); list = namedParameterJdbcTemplate.query(sql, params, BeanPropertyRowMapper.newInstance(FieldsToShowDTO.class));
resultDTO.setErrorCode(Constants.ApiErrorCode.SUCCESS); resultDTO.setErrorCode(Constants.ApiErrorCode.SUCCESS);
resultDTO.setDescription(Constants.ApiErrorDesc.SUCCESS); resultDTO.setDescription(Constants.ApiErrorDesc.SUCCESS);
resultDTO.setListData(list); resultDTO.setListData(list);
...@@ -548,15 +544,22 @@ public class CampaignRepositoryImpl implements CampaignRepositoryCustom { ...@@ -548,15 +544,22 @@ public class CampaignRepositoryImpl implements CampaignRepositoryCustom {
StringBuilder sqlBuilder = new StringBuilder(); StringBuilder sqlBuilder = new StringBuilder();
try { try {
// String sql = SQLBuilder.getSqlQueryById(SQLBuilder.SQL_MODULE_CAMPAIGN_MNG, "get-list-fields-to-show"); // String sql = SQLBuilder.getSqlQueryById(SQLBuilder.SQL_MODULE_CAMPAIGN_MNG, "get-list-fields-to-show");
sqlBuilder.append(" select to_char(column_name) columnName, 1 isFix"); String sql = "with field_name as (\n" +
sqlBuilder.append(" from campaign_customerlist_column, dual"); "select a.campaign_cus_list_column_id id, to_char(a.column_name) columnName, a.order_index, a.customize_field_id customizeFieldId, 1 isFix\n" +
sqlBuilder.append(" where campaign_id = :p_campaign_id and column_name is not null"); "from campaign_customerlist_column a, dual\n" +
sqlBuilder.append(" union all"); "where a.campaign_id = :p_campaign_id\n" +
sqlBuilder.append(" select customize_field_title columnName, 0 isFix"); " and a.company_site_id = :p_company_site_id\n" +
sqlBuilder.append(" from campaign_customerlist_column"); " and column_name is not null\n" +
sqlBuilder.append(" where campaign_id = :p_campaign_id"); "union all\n" +
"select a.campaign_cus_list_column_id id, a.customize_field_title columnName, a.order_index, a.customize_field_id customizeFieldId, 0 isFix\n" +
"from campaign_customerlist_column a\n" +
"where a.campaign_id = :p_campaign_id\n" +
" and a.company_site_id = :p_company_site_id\n" +
")\n" +
"select id, columnName, customizeFieldId, isFix from field_name where columnName is not null order by order_index\n";
params.put("p_campaign_id", dto.getCampaignId()); params.put("p_campaign_id", dto.getCampaignId());
list = namedParameterJdbcTemplate.query(sqlBuilder.toString(), params, BeanPropertyRowMapper.newInstance(FieldsToShowDTO.class)); params.put("p_company_site_id", dto.getCompanySiteId());
list = namedParameterJdbcTemplate.query(sql, params, BeanPropertyRowMapper.newInstance(FieldsToShowDTO.class));
resultDTO.setErrorCode(Constants.ApiErrorCode.SUCCESS); resultDTO.setErrorCode(Constants.ApiErrorCode.SUCCESS);
resultDTO.setDescription(Constants.ApiErrorDesc.SUCCESS); resultDTO.setDescription(Constants.ApiErrorDesc.SUCCESS);
resultDTO.setListData(list); resultDTO.setListData(list);
......
...@@ -64,6 +64,8 @@ public interface CampaignService { ...@@ -64,6 +64,8 @@ public interface CampaignService {
ResultDTO addCustomerListToCampaign(CampaignRequestDTO dto); ResultDTO addCustomerListToCampaign(CampaignRequestDTO dto);
ResultDTO deleteCustomerListFromCampaign(CampaignRequestDTO dto); ResultDTO deleteCustomerListFromCampaign(CampaignRequestDTO dto);
ResultDTO saveFieldCustomer(CampaignRequestDTO dto);
//</editor-fold> //</editor-fold>
} }
...@@ -67,6 +67,9 @@ public class CampaignServiceImpl implements CampaignService { ...@@ -67,6 +67,9 @@ public class CampaignServiceImpl implements CampaignService {
@Autowired @Autowired
CampaignCustomerRepository campaignCustomerRepository; CampaignCustomerRepository campaignCustomerRepository;
@Autowired
CampaignCustomerListColumnRepository campaignCustomerListColumnRepository;
@Override @Override
@Transactional(DataSourceQualify.CCMS_FULL) @Transactional(DataSourceQualify.CCMS_FULL)
public ResultDTO search(CampaignRequestDTO requestDto) { public ResultDTO search(CampaignRequestDTO requestDto) {
...@@ -370,6 +373,7 @@ public class CampaignServiceImpl implements CampaignService { ...@@ -370,6 +373,7 @@ public class CampaignServiceImpl implements CampaignService {
return resultDTO; return resultDTO;
} }
@Override @Override
@Transactional(DataSourceQualify.CCMS_FULL) @Transactional(DataSourceQualify.CCMS_FULL)
public ResultDTO updateCampaign(CampaignDTO dto) { public ResultDTO updateCampaign(CampaignDTO dto) {
...@@ -561,6 +565,54 @@ public class CampaignServiceImpl implements CampaignService { ...@@ -561,6 +565,54 @@ public class CampaignServiceImpl implements CampaignService {
return resultDTO; return resultDTO;
} }
@Override
@Transactional(DataSourceQualify.CCMS_FULL)
public ResultDTO saveFieldCustomer(CampaignRequestDTO dto) {
ResultDTO resultDTO = new ResultDTO();
List<FieldsToShowDTO> list = dto.getLstFiedCustomer();
long campaignId = Long.parseLong(dto.getCampaignId());
long companySiteId = Long.parseLong(dto.getCompanySiteId());
List<CampaignCustomerListColumn> listColumns = campaignCustomerListColumnRepository.findByCampaignIdAndCompanySiteId(campaignId, companySiteId);
try {
// Them moi cac truong hien thi
for (FieldsToShowDTO fieldsToShowDTO : list) {
if (fieldsToShowDTO.getId() == null) {
CampaignCustomerListColumn entity = new CampaignCustomerListColumn();
entity.setCampaignId(campaignId);
entity.setCompanySiteId(companySiteId);
if (fieldsToShowDTO.getIsFix()) {
entity.setColumnName(fieldsToShowDTO.getColumnName());
} else {
entity.setCustomizeFieldId(fieldsToShowDTO.getCustomizeFieldId());
entity.setCustomizeFieldTitle(fieldsToShowDTO.getColumnTitle());
}
entity.setOrderIndex((long) (list.indexOf(fieldsToShowDTO) + 1));
campaignCustomerListColumnRepository.save(entity);
}
}
// Cap nhat cac truong da co san
for (FieldsToShowDTO fieldsToShowDTO : list) {
if (fieldsToShowDTO.getId() != null) {
listColumns.removeIf(p -> p.getCampaignCusListColId() == fieldsToShowDTO.getId());
CampaignCustomerListColumn entity = campaignCustomerListColumnRepository.findByCampaignCusListColId(fieldsToShowDTO.getId());
entity.setOrderIndex((long) (list.indexOf(fieldsToShowDTO) + 1));
campaignCustomerListColumnRepository.save(entity);
}
}
// Xoa cac truong khong con hien thi nua
for (CampaignCustomerListColumn entity : listColumns) {
campaignCustomerListColumnRepository.delete(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;
}
// hungtt // hungtt
private Map<String, String> setMapData(Map<String, String> mapColumn, Locale locale) { private Map<String, String> setMapData(Map<String, String> mapColumn, Locale locale) {
mapColumn.put("CUSTOMER_ID", BundleUtils.getLangString("CUSTOMER_ID", locale)); mapColumn.put("CUSTOMER_ID", BundleUtils.getLangString("CUSTOMER_ID", locale));
......
...@@ -13,21 +13,13 @@ import java.io.Serializable; ...@@ -13,21 +13,13 @@ import java.io.Serializable;
@AllArgsConstructor @AllArgsConstructor
public class FieldsToShowDTO implements Serializable { public class FieldsToShowDTO implements Serializable {
// private Long campaignCusListColId; private Long id;
// private Long companySiteId;
// private Long campaignId;
private String columnName; private String columnName;
private String columnTitle; private String columnTitle;
// private Long orderIndex;
// private Long customizeFieldId;
// private String customizeFieldTitle;
private Boolean isFix; private Boolean isFix;
private Long customizeFieldId;
} }
...@@ -2,6 +2,7 @@ package com.viettel.campaign.web.dto.request_dto; ...@@ -2,6 +2,7 @@ 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 com.viettel.campaign.web.dto.CustomerCustomDTO;
import com.viettel.campaign.web.dto.FieldsToShowDTO;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
...@@ -51,5 +52,5 @@ public class CampaignRequestDTO extends BaseDTO { ...@@ -51,5 +52,5 @@ public class CampaignRequestDTO extends BaseDTO {
String createTimeTo; String createTimeTo;
String createTimeFr; String createTimeFr;
String lstCustomerListId; String lstCustomerListId;
List<FieldsToShowDTO> lstFiedCustomer;
} }
...@@ -283,6 +283,14 @@ public class CampaignController { ...@@ -283,6 +283,14 @@ public class CampaignController {
ResultDTO resultDTO = campaignService.deleteCustomerListFromCampaign(campaignRequestDTO); ResultDTO resultDTO = campaignService.deleteCustomerListFromCampaign(campaignRequestDTO);
return new ResponseEntity<>(resultDTO, HttpStatus.OK); return new ResponseEntity<>(resultDTO, HttpStatus.OK);
} }
@PostMapping("/saveFieldCustomer")
@ResponseBody
public ResponseEntity saveFieldCustomer(@RequestBody CampaignRequestDTO campaignRequestDTO) {
ResultDTO resultDTO = campaignService.saveFieldCustomer(campaignRequestDTO);
return new ResponseEntity<>(resultDTO, HttpStatus.OK);
}
@RequestMapping(value = "/renewCampaign", method = RequestMethod.PUT) @RequestMapping(value = "/renewCampaign", method = RequestMethod.PUT)
public ResponseEntity<ResultDTO> renewCampaign(@RequestBody CampaignDTO campaignDTO) { public ResponseEntity<ResultDTO> renewCampaign(@RequestBody CampaignDTO campaignDTO) {
ResultDTO result = campaignService.renewCampaign(campaignDTO); ResultDTO result = campaignService.renewCampaign(campaignDTO);
......
with column_name_temp as ( with column_name_temp as (
select column_name columnName, 1 isFix from user_tab_columns, dual select column_name columnName, null customizeFieldId, 1 isFix from user_tab_columns, dual
where table_name = 'CUSTOMER' where table_name = 'CUSTOMER'
) )
select * from column_name_temp where columnName not in (select column_name from campaign_customerlist_column where column_name is not null) select * from column_name_temp where columnName not in (select column_name from campaign_customerlist_column where column_name is not null)
union all union all
select title columnName, 0 isFix from customize_fields, dual select title columnName, customize_field_id customizeFieldId, 0 isFix from customize_fields, dual
where function_code = 'CUSTOMER' where function_code = 'CUSTOMER'
and site_id = :p_company_site_id 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) 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 and column_name is not null with field_name as (
select a.campaign_cus_list_column_id id, to_char(a.column_name) columnName, a.order_index, a.customize_field_id customizeFieldId, 1 isFix
from campaign_customerlist_column a, dual
where a.campaign_id = :p_campaign_id
and a.company_site_id = :p_company_site_id
and column_name is not null
union all union all
select customize_field_title columnName, 0 isFix from campaign_customerlist_column where campaign_id = :p_campaign_id select a.campaign_cus_list_column_id id, a.customize_field_title columnName, a.order_index, a.customize_field_id customizeFieldId, 0 isFix
from campaign_customerlist_column a
where a.campaign_id = :p_campaign_id
and a.company_site_id = :p_company_site_id
)
select id, columnName, customizeFieldId, isFix from field_name where columnName is not null order by order_index
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