Commit b8bd8545 authored by đinh thị đầm's avatar đinh thị đầm
parents b3ffd0ad 8fa16e94
......@@ -91,6 +91,8 @@ public interface CampaignCustomerRepository extends JpaRepository<CampaignCustom
CampaignCustomer findCampaignCustomerByCampaignIdAndCompanySiteIdAndCustomerId(Long campaignId, Long companySiteId, Long customerId);
List<CampaignCustomer> findCampaignCustomersByCampaignIdAndCompanySiteIdAndCustomerIdAndInCampaignStatus(Long campaignId, Long companySiteId, Long customerId, Short inCampaingStatus);
@Query(value = "select complete_value from campaign_complete_code where status = 1 and is_finish = 0 and is_recall = 0", nativeQuery = true)
List<Short> getStatus();
}
......@@ -301,32 +301,39 @@ public class AgentsServiceImpl implements AgentsService {
StringBuilder sqlStrBuilder = new StringBuilder();
sqlStrBuilder.append("SELECT");
sqlStrBuilder.append(" a.USER_ID userId,");
sqlStrBuilder.append(" a.USER_NAME userName,");
sqlStrBuilder.append(" a.STATUS status,");
sqlStrBuilder.append(" a.FULL_NAME fullName,");
sqlStrBuilder.append(" a.COMPANY_SITE_ID companySiteId,");
sqlStrBuilder.append(" b.FILTER_TYPE filterType,");
sqlStrBuilder.append(" b.CAMPAIGN_AGENT_ID campaignAgentId");
sqlStrBuilder.append(" FROM VSA_USERS a");
sqlStrBuilder.append(" LEFT JOIN CAMPAIGN_AGENT b on a.USER_ID = b.AGENT_ID");
sqlStrBuilder.append(" INNER JOIN USER_ROLE c on a.USER_ID = c.USER_ID");
sqlStrBuilder.append(" INNER JOIN ROLE d on c.ROLE_ID = d.ROLE_ID");
sqlStrBuilder.append(" vu.USER_ID userId,");
sqlStrBuilder.append(" vu.USER_NAME userName,");
sqlStrBuilder.append(" vu.STATUS status,");
sqlStrBuilder.append(" vu.FULL_NAME fullName,");
sqlStrBuilder.append(" vu.COMPANY_SITE_ID companySiteId,");
sqlStrBuilder.append(" r.ROLE_CODE roleCode");
sqlStrBuilder.append(" FROM VSA_USERS vu");
sqlStrBuilder.append(" INNER JOIN USER_ROLE ur on vu.USER_ID = ur.USER_ID");
sqlStrBuilder.append(" INNER JOIN ROLE r on ur.ROLE_ID = r.ROLE_ID");
sqlStrBuilder.append(" WHERE 1 = 1");
sqlStrBuilder.append(" AND a.COMPANY_SITE_ID = :p_company_site_id");
sqlStrBuilder.append(" AND vu.COMPANY_SITE_ID = :p_company_site_id");
sqlStrBuilder.append(" AND vu.STATUS = 1");
sqlStrBuilder.append(" AND r.ROLE_CODE IN ('AGENT', 'SUPERVISOR')");
sqlStrBuilder.append(" AND vu.USER_ID NOT IN (SELECT vu.USER_ID userId");
sqlStrBuilder.append(" FROM VSA_USERS vu");
sqlStrBuilder.append(" LEFT JOIN CAMPAIGN_AGENT ca on vu.USER_ID = ca.AGENT_ID");
sqlStrBuilder.append(" INNER JOIN USER_ROLE ur on vu.USER_ID = ur.USER_ID");
sqlStrBuilder.append(" INNER JOIN ROLE r on ur.ROLE_ID = r.ROLE_ID");
sqlStrBuilder.append(" WHERE 1 = 1");
sqlStrBuilder.append(" AND vu.COMPANY_SITE_ID = :p_company_site_id");
sqlStrBuilder.append(" AND vu.STATUS = 1");
sqlStrBuilder.append(" AND ca.CAMPAIGN_ID = :p_campaign_id");
sqlStrBuilder.append(" AND r.ROLE_CODE IN ('AGENT', 'SUPERVISOR'))");
if (!DataUtil.isNullOrEmpty(userName)) {
sqlStrBuilder.append(" AND UPPER(a.USER_NAME) LIKE UPPER(:p_user_name)");
sqlStrBuilder.append(" AND UPPER(vu.USER_NAME) LIKE UPPER(:p_user_name)");
}
if (!DataUtil.isNullOrEmpty(fullName)) {
sqlStrBuilder.append(" AND UPPER(a.FULL_NAME) LIKE UPPER(:p_full_name)");
sqlStrBuilder.append(" AND UPPER(vu.FULL_NAME) LIKE UPPER(:p_full_name)");
}
sqlStrBuilder.append(" AND d.ROLE_CODE IN ('AGENT', 'SUPERVISOR')");
sqlStrBuilder.append(" AND a.STATUS = 1");
sqlStrBuilder.append(" AND (b.CAMPAIGN_ID IS NULL OR b.CAMPAIGN_ID <> :p_campaign_id)");
sqlStrBuilder.append(" ORDER BY UPPER(a.FULL_NAME)");
sqlStrBuilder.append(" ORDER BY UPPER(vu.FULL_NAME)");
SQLQuery query = session.createSQLQuery(sqlStrBuilder.toString());
......@@ -356,8 +363,7 @@ public class AgentsServiceImpl implements AgentsService {
query.addScalar("status", new ShortType());
query.addScalar("fullName", new StringType());
query.addScalar("companySiteId", new LongType());
query.addScalar("filterType", new ShortType());
query.addScalar("campaignAgentId", new LongType());
query.addScalar("roleCode", new StringType());
query.setResultTransformer(Transformers.aliasToBean(VSAUsersDTO.class));
int count = 0;
......
......@@ -1414,10 +1414,10 @@ public class CustomerServiceImpl implements CustomerService {
//<editor-fold desc="Cho những trường tĩnh" defaultstate="collapsed">
DataValidationConstraint cusTypeConstraint = dataValidationHelper.createExplicitListConstraint(new String[]{BundleUtils.getLangString("customer.cusType.normal", locale), BundleUtils.getLangString("customer.cusType.vip", locale), BundleUtils.getLangString("customer.cusType.blacklist", locale)});
DataValidationConstraint isAllowConstraint = dataValidationHelper.createExplicitListConstraint(new String[]{BundleUtils.getLangString("customer.yes", locale), BundleUtils.getLangString("customer.not", locale)});
CellRangeAddressList cusTypeCellRangeAddressList = new CellRangeAddressList(3, 9999, 6, 6);
CellRangeAddressList callCellRangeAddressList = new CellRangeAddressList(3, 9999, 9, 9);
CellRangeAddressList emailCellRangeAddressList = new CellRangeAddressList(3, 9999, 10, 10);
CellRangeAddressList smsCellRangeAddressList = new CellRangeAddressList(3, 9999, 11, 11);
CellRangeAddressList cusTypeCellRangeAddressList = new CellRangeAddressList(4, 9999, 6, 6);
CellRangeAddressList callCellRangeAddressList = new CellRangeAddressList(4, 9999, 9, 9);
CellRangeAddressList emailCellRangeAddressList = new CellRangeAddressList(4, 9999, 10, 10);
CellRangeAddressList smsCellRangeAddressList = new CellRangeAddressList(4, 9999, 11, 11);
DataValidation cusTypeValidation = dataValidationHelper.createValidation(cusTypeConstraint, cusTypeCellRangeAddressList);
DataValidation callValidation = dataValidationHelper.createValidation(isAllowConstraint, callCellRangeAddressList);
DataValidation emailValidation = dataValidationHelper.createValidation(isAllowConstraint, emailCellRangeAddressList);
......@@ -1653,12 +1653,14 @@ public class CustomerServiceImpl implements CustomerService {
List<Short> lstStatus = campaignCustomerRepository.getStatus();
try {
for (String cusId : lstCusId) {
CampaignCustomer entity = campaignCustomerRepository.findCampaignCustomerByCampaignIdAndCompanySiteIdAndCustomerId(campaignId, companySiteId, Long.parseLong(cusId));
if (entity.getStatus() == 0) {
campaignCustomerRepository.delete(entity);
} else if (lstStatus.contains(entity.getStatus())) {
entity.setInCampaignStatus((short) 0);
campaignCustomerRepository.save(entity);
List<CampaignCustomer> listEntity = campaignCustomerRepository.findCampaignCustomersByCampaignIdAndCompanySiteIdAndCustomerIdAndInCampaignStatus(campaignId, companySiteId, Long.parseLong(cusId), (short) 1);
for (CampaignCustomer entity : listEntity) {
if (entity.getStatus() == 0) {
campaignCustomerRepository.delete(entity);
} else if (lstStatus.contains(entity.getStatus())) {
entity.setInCampaignStatus((short) 0);
campaignCustomerRepository.save(entity);
}
}
}
resultDTO.setErrorCode(Constants.ApiErrorCode.SUCCESS);
......@@ -1888,7 +1890,6 @@ public class CustomerServiceImpl implements CustomerService {
@Transactional(DataSourceQualify.CCMS_FULL)
public ResultDTO searchCustomizeFields(CampaignCustomerDTO campaignCustomerDTO) {
ResultDTO resultDTO = new ResultDTO();
CustomerDTO customerDTO = new CustomerDTO();
SessionFactory sessionFactory = HibernateUtil.getSessionFactory();
Session session = sessionFactory.openSession();
......@@ -2025,6 +2026,7 @@ public class CustomerServiceImpl implements CustomerService {
}
Pageable pageable = PageRequest.of(campaignCustomerDTO.getPage(), campaignCustomerDTO.getPageSize());
if (pageable != null) {
query.setFirstResult(pageable.getPageNumber() * pageable.getPageSize());
query.setMaxResults(pageable.getPageSize());
......@@ -2033,6 +2035,7 @@ public class CustomerServiceImpl implements CustomerService {
List<CustomerDTO>data = query.list();
Page<CustomerDTO> dataPage = new PageImpl<>(data, pageable, count);
resultDTO.setData(dataPage);
resultDTO.setTotalRow(count);
resultDTO.setErrorCode(Constants.ApiErrorCode.SUCCESS);
resultDTO.setDescription(Constants.ApiErrorDesc.SUCCESS);
} catch (Exception e) {
......
......@@ -240,7 +240,7 @@ public class ScenarioServiceImpl implements ScenarioService {
logger.error(e.getMessage());
return null;
}finally {
if (workbook != null) workbook.close();
//if (workbook != null) workbook.close();
}
}
......
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