Commit 19b464e1 authored by Tu Bach's avatar Tu Bach

Merge branch 'master' into tubn

parents 888819be 085e1809
......@@ -49,8 +49,8 @@
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc7</artifactId>
<!-- <scope>system</scope>-->
<!-- <systemPath>${project.basedir}/lib/ojdbc7.jar</systemPath>-->
<scope>system</scope>
<systemPath>${project.basedir}/lib/ojdbc7.jar</systemPath>
<version>1.0</version>
</dependency>
<dependency>
......
......@@ -5,15 +5,18 @@ import lombok.Setter;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.Date;
@Entity
@Table(name = "CUSTOMER_CONTACT")
@Getter
@Setter
public class CustomerContact {
public class CustomerContact implements Serializable {
@Id
@Basic(optional = false)
@GeneratedValue(generator = "customer_contact_seq", strategy = GenerationType.IDENTITY)
@SequenceGenerator(name = "customer_contact_seq", sequenceName = "customer_contact_seq", allocationSize = 1)
@NotNull
@Column(name = "CONTACT_ID")
private Long contactId;
......
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);
}
......@@ -12,5 +12,5 @@ public interface CustomerContactRepository extends JpaRepository<CustomerContact
@Query("FROM CustomerContact WHERE status = 1 AND customerId = :customerId AND contactType = :contactType AND (contact IS NULL OR UPPER(contact) LIKE UPPER(concat('%', :contact, '%')))")
List<CustomerContact> findByCustomerIdAndAndContactTypeAndContact(@Param("customerId") Long customerId, @Param("contactType") Short contactType, @Param("contact") String contact, Pageable pageable);
CustomerContact findCustomerContactByContactTypeAndContactAndIsDirectLine(Short contactType, String contact, Short isDirectLine);
CustomerContact findCustomerContactByContactEquals(String contact);
}
......@@ -511,23 +511,19 @@ public class CampaignRepositoryImpl implements CampaignRepositoryCustom {
StringBuilder stringBuilder = new StringBuilder();
try {
// String sql = SQLBuilder.getSqlQueryById(SQLBuilder.SQL_MODULE_CAMPAIGN_MNG, "get-list-fields-not-show");
stringBuilder.append(" with column_name_temp as (");
stringBuilder.append(" select column_name columnName, 1 isFix from user_tab_columns, dual");
stringBuilder.append(" where table_name = 'CUSTOMER'");
stringBuilder.append(" )");
stringBuilder.append(" select * from column_name_temp");
stringBuilder.append(" where columnName not in (select column_name from campaign_customerlist_column where column_name is not null)");
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 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)");
String sql = "with column_name_temp as (\n" +
" select column_name columnName, null customizeFieldId, 1 isFix from user_tab_columns, dual\n" +
" where table_name = 'CUSTOMER'\n" +
")\n" +
"select * from column_name_temp where columnName not in (select column_name from campaign_customerlist_column where column_name is not null)\n" +
"union all\n" +
"select title columnName, customize_field_id customizeFieldId, 0 isFix from customize_fields, dual\n" +
"where function_code = 'CUSTOMER'\n" +
" and site_id = :p_company_site_id\n" +
" and customize_field_id not in (select customize_field_id from campaign_customerlist_column where campaign_customerlist_column.campaign_id = :p_campaign_id)\n";
params.put("p_company_site_id", dto.getCompanySiteId());
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.setDescription(Constants.ApiErrorDesc.SUCCESS);
resultDTO.setListData(list);
......@@ -548,15 +544,22 @@ public class CampaignRepositoryImpl implements CampaignRepositoryCustom {
StringBuilder sqlBuilder = new StringBuilder();
try {
// String sql = SQLBuilder.getSqlQueryById(SQLBuilder.SQL_MODULE_CAMPAIGN_MNG, "get-list-fields-to-show");
sqlBuilder.append(" select to_char(column_name) columnName, 1 isFix");
sqlBuilder.append(" from campaign_customerlist_column, dual");
sqlBuilder.append(" where campaign_id = :p_campaign_id and column_name is not null");
sqlBuilder.append(" union all");
sqlBuilder.append(" select customize_field_title columnName, 0 isFix");
sqlBuilder.append(" from campaign_customerlist_column");
sqlBuilder.append(" where campaign_id = :p_campaign_id");
String sql = "with field_name as (\n" +
"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" +
"from campaign_customerlist_column a, dual\n" +
"where a.campaign_id = :p_campaign_id\n" +
" and a.company_site_id = :p_company_site_id\n" +
" and column_name is not null\n" +
"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());
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.setDescription(Constants.ApiErrorDesc.SUCCESS);
resultDTO.setListData(list);
......
......@@ -64,6 +64,8 @@ public interface CampaignService {
ResultDTO addCustomerListToCampaign(CampaignRequestDTO dto);
ResultDTO deleteCustomerListFromCampaign(CampaignRequestDTO dto);
ResultDTO saveFieldCustomer(CampaignRequestDTO dto);
//</editor-fold>
}
......@@ -33,7 +33,7 @@ public interface CustomerService {
ResultDTO getAllCustomerList(int page, int pageSize, String sort, Long companySiteId);
ResultDTO createCustomerList(CustomerListDTO customerListDTO, String userName);
CustomerList createCustomerList(CustomerListDTO customerListDTO, String userName);
ResultDTO updateCustomerList(CustomerListDTO customerListDTO);
......
......@@ -67,6 +67,9 @@ public class CampaignServiceImpl implements CampaignService {
@Autowired
CampaignCustomerRepository campaignCustomerRepository;
@Autowired
CampaignCustomerListColumnRepository campaignCustomerListColumnRepository;
@Override
@Transactional(DataSourceQualify.CCMS_FULL)
public ResultDTO search(CampaignRequestDTO requestDto) {
......@@ -370,6 +373,7 @@ public class CampaignServiceImpl implements CampaignService {
return resultDTO;
}
@Override
@Transactional(DataSourceQualify.CCMS_FULL)
public ResultDTO updateCampaign(CampaignDTO dto) {
......@@ -561,6 +565,54 @@ public class CampaignServiceImpl implements CampaignService {
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
private Map<String, String> setMapData(Map<String, String> mapColumn, Locale locale) {
mapColumn.put("CUSTOMER_ID", BundleUtils.getLangString("CUSTOMER_ID", locale));
......
......@@ -50,7 +50,7 @@ public class CustomerServiceImpl implements CustomerService {
private static final Logger LOGGER = LoggerFactory.getLogger(CustomerServiceImpl.class);
@Autowired
@PersistenceContext( unitName= DataSourceQualify.JPA_UNIT_NAME_CCMS_FULL)
@PersistenceContext(unitName = DataSourceQualify.JPA_UNIT_NAME_CCMS_FULL)
EntityManager entityManager;
@Autowired
......@@ -595,37 +595,30 @@ public class CustomerServiceImpl implements CustomerService {
}
@Override
@Transactional(DataSourceQualify.CCMS_FULL)
public ResultDTO createCustomerList(CustomerListDTO customerListDTO, String userName) {
ResultDTO resultDTO = new ResultDTO();
CustomerListMapper customerListMapper = new CustomerListMapper();
CustomerList customerList = new CustomerList();
public CustomerList createCustomerList(CustomerListDTO customerListDTO, String userName) {
LOGGER.info("-----------CREATE CUSTOMER LIST--------------");
try {
if (customerListDTO != null) {
// insert
CustomerList findCustomer = customerListRepository.findByCustomerListCode(customerListDTO.getCustomerListCode());
if (findCustomer == null) {
customerListDTO.setCreateBy(userName);
customerList = customerListMapper.toPersistenceBean(customerListDTO);
customerListRepository.save(customerList);
resultDTO.setErrorCode(Constants.ApiErrorCode.SUCCESS);
resultDTO.setDescription(Constants.ApiErrorDesc.SUCCESS);
} else {
resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR);
resultDTO.setDescription(Constants.ApiErrorDesc.ERROR);
}
CustomerList cl = customerListRepository.findByCustomerListCode(customerListDTO.getCustomerListCode());
if (cl == null) {
cl = new CustomerList();
cl.setCustomerListCode(customerListDTO.getCustomerListCode());
cl.setCustomerListName(customerListDTO.getCustomerListName());
cl.setStatus((short) 1);
cl.setCreateBy(userName);
cl.setCreateAt(new Date());
cl.setUpdateBy(null);
cl.setUpdateAt(null);
cl.setSource(null);
cl.setDeptCreate(null);
cl.setCompanySiteId(customerListDTO.getCompanySiteId());
return customerListRepository.save(cl);
} else {
resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR);
resultDTO.setDescription(Constants.ApiErrorDesc.ERROR);
return null;
}
} catch (Exception e) {
e.printStackTrace();
LOGGER.error(e.getMessage());
return null;
}
return resultDTO;
}
@Override
......@@ -894,7 +887,8 @@ public class CustomerServiceImpl implements CustomerService {
public Map<String, Object> readAndValidateCustomer(String path, List<CustomizeFields> dynamicHeader, UserSession userSession, Long customerListId) {
LOGGER.info("------------READ AND VALIDATE--------------");
Locale locale = new Locale("vi", "VN");
SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
DataFormatter dataFormat = new DataFormatter();
SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
Map<String, Object> result = new HashMap<>();
StringBuilder sb = new StringBuilder();
boolean validateOk = false;
......@@ -970,14 +964,7 @@ public class CustomerServiceImpl implements CustomerService {
for (int j = 0; j < row.getPhysicalNumberOfCells(); j++) {
Cell dataCell = dataRow.getCell(j);
if (dataCell != null) {
switch (dataCell.getCellTypeEnum()) {
case NUMERIC:
obj[j] = dataCell.getNumericCellValue();
break;
default:
obj[j] = dataCell.getStringCellValue();
break;
}
obj[j] = dataFormat.formatCellValue(dataCell);
} else {
Cell headerCell = row.getCell(j);
if (headerCell.getStringCellValue().equals(BundleUtils.getLangString("customer.cusType", locale))) {
......@@ -1014,9 +1001,12 @@ public class CustomerServiceImpl implements CustomerService {
&& !rawDataList.get(i)[4].toString().trim().equals("")) {
String str = validatePhone(rawDataList.get(i)[2].toString().trim(), locale);
str.concat(validateLength(BundleUtils.getLangString("customer.secondPhone", locale).split("#")[0], rawDataList.get(i)[3].toString(), 50, locale));
if (validateEmail(rawDataList.get(i)[4].toString().trim())) {
str.concat(BundleUtils.getLangString("customer.emailMax50", locale));
if (!validateEmail(rawDataList.get(i)[4].toString().trim())) {
str.concat(BundleUtils.getLangString("customer.emailInvalid", locale));
} else {
str.concat(validateDuplicateEmail(rawDataList.get(i)[4].toString().trim(), locale));
}
sb.append(validateLength(BundleUtils.getLangString("customer.email", locale).split("#")[0], rawDataList.get(i)[4].toString(), 50, locale));
sb.append(str);
} else {
sb.append(BundleUtils.getLangString("customer.invalidCustomer", locale));
......@@ -1030,17 +1020,17 @@ public class CustomerServiceImpl implements CustomerService {
if (rawDataList.get(i).length > 8 && rawDataList.get(i)[8] != null) {
sb.append(validateLength(BundleUtils.getLangString("customer.description", locale).split("#")[0], rawDataList.get(i)[8].toString(), 2000, locale));
}
for (int j = 12; j < header.size(); j++) {
if (rawDataList.get(i).length > j && rawDataList.get(i)[j] != null) {
if (header.get(j).getType().equals("text")) {
sb.append(validateDynamicLength(header.get(j).getTitle(), rawDataList.get(i)[j].toString(), header.get(j).getMinLength(), header.get(j).getMaxLength(), locale));
} else if (header.get(j).getType().equals("date")) {
sb.append(validateUsingRegexp(header.get(j).getTitle(), rawDataList.get(i)[j].toString(), header.get(j).getRegexpForValidation(), locale));
} else if (header.get(j).getType().equals("number")) {
sb.append(validateDynamicLength(header.get(j).getTitle(), rawDataList.get(i)[j].toString(), header.get(j).getMin(), header.get(j).getMax(), locale));
}
}
}
// for (int j = 12; j < header.size(); j++) {
// if (rawDataList.get(i).length > j && rawDataList.get(i)[j] != null) {
// if (header.get(j).getType().equals("text")) {
// sb.append(validateDynamicLength(header.get(j).getTitle(), rawDataList.get(i)[j].toString(), header.get(j).getMinLength(), header.get(j).getMaxLength(), locale));
// } else if (header.get(j).getType().equals("date")) {
// sb.append(validateUsingRegexp(header.get(j).getTitle(), rawDataList.get(i)[j].toString(), header.get(j).getRegexpForValidation(), locale));
// } else if (header.get(j).getType().equals("number")) {
// sb.append(validateDynamicLength(header.get(j).getTitle(), rawDataList.get(i)[j].toString(), header.get(j).getMin(), header.get(j).getMax(), locale));
// }
// }
// }
Row dataRow = sheet.getRow(4 + i);
Cell resultCell = dataRow.createCell(row.getPhysicalNumberOfCells() - 1);
if (sb.length() > 0) {
......@@ -1105,11 +1095,12 @@ public class CustomerServiceImpl implements CustomerService {
}
c.setIpccStatus("active");
Customer saved = customerRepository.save(c);
CustomerContact cc = new CustomerContact();
cc.setCustomerId(saved.getCustomerId());
if (rawDataList.get(i).length > 2 && rawDataList.get(i)[2] != null) {
String[] mainPhone = rawDataList.get(i)[2].toString().split(";");
for (int j = 0; j < mainPhone.length; j++) {
CustomerContact cc = new CustomerContact();
cc.setCustomerId(saved.getCustomerId());
cc.setSiteId(userSession.getSiteId());
cc.setContactType((short) 5);
cc.setContact(mainPhone[j]);
cc.setIsDirectLine((short) 1);
......@@ -1124,6 +1115,9 @@ public class CustomerServiceImpl implements CustomerService {
if (rawDataList.get(i).length > 3 && rawDataList.get(i)[3] != null) {
String[] subPhone = rawDataList.get(i)[3].toString().split(";");
for (int j = 0; j < subPhone.length; j++) {
CustomerContact cc = new CustomerContact();
cc.setCustomerId(saved.getCustomerId());
cc.setSiteId(userSession.getSiteId());
cc.setContactType((short) 5);
cc.setContact(subPhone[j]);
cc.setIsDirectLine((short) 0);
......@@ -1136,8 +1130,11 @@ public class CustomerServiceImpl implements CustomerService {
}
}
if (rawDataList.get(i).length > 4 && rawDataList.get(i)[4] != null) {
String[] email = rawDataList.get(i)[3].toString().split(";");
String[] email = rawDataList.get(i)[4].toString().split(";");
for (int j = 0; j < email.length; j++) {
CustomerContact cc = new CustomerContact();
cc.setCustomerId(saved.getCustomerId());
cc.setSiteId(userSession.getSiteId());
cc.setContactType((short) 2);
cc.setContact(email[j]);
cc.setIsDirectLine((short) 1);
......@@ -1154,11 +1151,11 @@ public class CustomerServiceImpl implements CustomerService {
for (int j = 0; j < dynamicHeader.size(); j++) {
cfo.setCustomizeFieldId(dynamicHeader.get(j).getCustomizeFieldId());
if (rawDataList.get(i).length > (12 + j) && rawDataList.get(i)[12 + j] != null) {
switch (dynamicHeader.get(i).getType()) {
switch (dynamicHeader.get(j).getType()) {
case "combobox":
CustomizeFieldOptionValue cfov =
customizeFieldOptionValueRepository.findCustomizeFieldOptionValueByNameEqualsAndStatus(rawDataList.get(i)[12 + j].toString(), 1L);
cfo.setFieldOptionValueId(cfov.getFieldOptionValueId());
cfo.setFieldOptionValueId(cfov.getFieldOptionValueId());
break;
case "checkbox":
if (rawDataList.get(i)[12 + j].toString().equals(BundleUtils.getLangString("customer.yes", locale))) {
......@@ -1219,8 +1216,8 @@ public class CustomerServiceImpl implements CustomerService {
if (str.length() > 50) {
result = BundleUtils.getLangString("customer.phoneMax50", locale);
}
for (int i = 0; i < str.length(); i++) {
CustomerContact cc = customerContactRepository.findCustomerContactByContactTypeAndContactAndIsDirectLine((short)5, arr[i], (short)1);
for (int i = 0; i < arr.length; i++) {
CustomerContact cc = customerContactRepository.findCustomerContactByContactEquals(arr[i]);
if (cc != null) {
return result.concat(BundleUtils.getLangString("customer.phoneExists", locale));
}
......@@ -1228,6 +1225,18 @@ public class CustomerServiceImpl implements CustomerService {
return result;
}
private String validateDuplicateEmail(String str, Locale locale) {
String result = "";
String[] arr = str.split(";");
for (int i = 0; i < arr.length; i++) {
CustomerContact cc = customerContactRepository.findCustomerContactByContactEquals(arr[i]);
if (cc != null) {
return result.concat(BundleUtils.getLangString("customer.emailExists", locale));
}
}
return result;
}
private String validateUsingRegexp(String header, String data, String regexp, Locale locale) {
if (data.matches(regexp)) {
return header + " " + BundleUtils.getLangString("customer.notMatch", locale);
......@@ -1249,8 +1258,14 @@ public class CustomerServiceImpl implements CustomerService {
}
private boolean validateEmail(String str) {
String[] arr = str.split(";");
String regexp = "^[\\w-_\\.+]*[\\w-_\\.]\\@([\\w]+\\.)+[\\w]+[\\w]$";
return str.matches(regexp);
for (int i = 0; i < arr.length; i++) {
if (!arr[i].matches(regexp)) {
return false;
}
}
return true;
}
private boolean validateLetter(String str) {
......@@ -1315,14 +1330,14 @@ public class CustomerServiceImpl implements CustomerService {
constraint[j] = list.get(j).getName();
}
DataValidationConstraint comboboxConstraint = dataValidationHelper.createExplicitListConstraint(constraint);
CellRangeAddressList comboboxCellRange = new CellRangeAddressList(4,9999,12 + i, 12 + i);
DataValidation comboboxValidation = dataValidationHelper.createValidation(comboboxConstraint,comboboxCellRange);
CellRangeAddressList comboboxCellRange = new CellRangeAddressList(4, 9999, 12 + i, 12 + i);
DataValidation comboboxValidation = dataValidationHelper.createValidation(comboboxConstraint, comboboxCellRange);
comboboxValidation.setSuppressDropDownArrow(true);
comboboxValidation.setShowErrorBox(true);
sheet.addValidationData(comboboxValidation);
} else if (dynamicHeader.get(i).getType().equals("checkbox")) {
DataValidationConstraint yesNoConstraint = dataValidationHelper.createExplicitListConstraint(new String[]{BundleUtils.getLangString("customer.yes", locale), BundleUtils.getLangString("customer.not", locale)});
CellRangeAddressList checkboxCellRange = new CellRangeAddressList(4,9999,12 + i,12 + i);
CellRangeAddressList checkboxCellRange = new CellRangeAddressList(4, 9999, 12 + i, 12 + i);
DataValidation yesNoValidation = dataValidationHelper.createValidation(yesNoConstraint, checkboxCellRange);
yesNoValidation.setShowErrorBox(true);
yesNoValidation.setSuppressDropDownArrow(true);
......
......@@ -13,21 +13,13 @@ import java.io.Serializable;
@AllArgsConstructor
public class FieldsToShowDTO implements Serializable {
// private Long campaignCusListColId;
// private Long companySiteId;
// private Long campaignId;
private Long id;
private String columnName;
private String columnTitle;
// private Long orderIndex;
// private Long customizeFieldId;
// private String customizeFieldTitle;
private Boolean isFix;
private Long customizeFieldId;
}
......@@ -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.CustomerCustomDTO;
import com.viettel.campaign.web.dto.FieldsToShowDTO;
import lombok.Getter;
import lombok.Setter;
......@@ -51,5 +52,5 @@ public class CampaignRequestDTO extends BaseDTO {
String createTimeTo;
String createTimeFr;
String lstCustomerListId;
List<FieldsToShowDTO> lstFiedCustomer;
}
......@@ -298,6 +298,13 @@ public class CampaignController {
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)
public ResponseEntity<ResultDTO> renewCampaign(@RequestBody CampaignDTO campaignDTO) {
ResultDTO result = campaignService.renewCampaign(campaignDTO);
......
package com.viettel.campaign.web.rest;
import com.viettel.campaign.model.ccms_full.CustomerList;
import com.viettel.campaign.model.ccms_full.CustomizeFieldObject;
import com.viettel.campaign.model.ccms_full.CustomizeFields;
import com.viettel.campaign.service.CustomerService;
......@@ -103,15 +104,15 @@ public class CustomerController {
}
@PostMapping("/createCustomerList")
@ResponseBody
public ResultDTO createCustomerList(@RequestBody @Valid CustomerListDTO customerListDTO, HttpServletRequest request) {
ResultDTO result = new ResultDTO();
public ResponseEntity<?> createCustomerList(@RequestBody @Valid CustomerListDTO customerListDTO, HttpServletRequest request) {
String xAuthToken = request.getHeader("X-Auth-Token");
UserSession userSession = (UserSession) RedisUtil.getInstance().get(xAuthToken);
result = customerService.createCustomerList(customerListDTO, userSession.getUserName());
return result;
CustomerList cl = customerService.createCustomerList(customerListDTO, userSession.getUserName());
if (cl == null) {
return new ResponseEntity<>(HttpStatus.NOT_FOUND);
}
return new ResponseEntity<>(cl, HttpStatus.OK);
}
@PostMapping("/updateCustomerList")
......@@ -185,11 +186,11 @@ public class CustomerController {
@PostMapping(value = "/importFile")
public ResponseEntity<?> importFile(@RequestParam("file") MultipartFile file,
@RequestParam("customerListId") Long customerListId,
@RequestHeader("X-Auth-Token") String authToken) {
HttpServletRequest request) {
LOGGER.info("------------IMPORT FILE TEMPLATE--------------");
Locale locale = new Locale("vi", "VN");
try {
UserSession userSession = (UserSession) RedisUtil.getInstance().get(authToken);
UserSession userSession = (UserSession) RedisUtil.getInstance().get(request.getHeader("X-Auth-Token"));
if (file.isEmpty()) {
return new ResponseEntity<>(BundleUtils.getLangString("customer.fileNotSelected"), HttpStatus.OK);
}
......
......@@ -103,6 +103,8 @@ customer.notLessThan = not less than
customer.importCustomer = IMPORT CUSTOMER
customer.notice = Attention: A record is valid when Full Name is not null and one of three fields Main phone, secondary phone or email is not null
customer.fileNotSelected=Please select a file
customer.emailInvalid=Invalid email;
customer.emailExists=Email exists;
common.fileNotSelected=Please select a file
common.fileInvalidFormat=File invalid
......@@ -105,6 +105,8 @@ customer.notLessThan = không được nhỏ hơn
customer.importCustomer = IMPORT KHÁCH HÀNG
customer.notice = Chú ý: 1 bản ghi được coi là hợp lệ bắt buộc phải có thông tin Họ và Tên và 1 trong 3 thông tin liên lạc (số điện thoại chính, số điện thoại phụ hoặc email)
customer.fileNotSelected=Bạn chưa chọn file
customer.emailInvalid=Email không đúng định dạng;
customer.emailExists=Email đã tồn tại;
common.fileNotSelected=Bạn chưa chọn file
common.fileInvalidFormat=File không hợp lệ
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'
)
select * from column_name_temp where columnName not in (select column_name from campaign_customerlist_column where column_name is not null)
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'
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 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
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