Commit 27be70ec authored by Vu Duy Anh's avatar Vu Duy Anh

anhvd commit search customer

parent cd1a567b
...@@ -774,6 +774,7 @@ public class CustomerServiceImpl implements CustomerService { ...@@ -774,6 +774,7 @@ public class CustomerServiceImpl implements CustomerService {
@Override @Override
@Transactional(DataSourceQualify.CCMS_FULL) @Transactional(DataSourceQualify.CCMS_FULL)
public ResultDTO searchCustomerList(SearchCustomerRequestDTO searchCustomerRequestDTO) { public ResultDTO searchCustomerList(SearchCustomerRequestDTO searchCustomerRequestDTO) {
TimeZone tzClient = TimeZoneUtils.getZoneMinutes((long) searchCustomerRequestDTO.getTimezoneOffset());
ResultDTO resultDTO = new ResultDTO(); ResultDTO resultDTO = new ResultDTO();
SessionFactory sessionFactory = HibernateUtil.getSessionFactory(); SessionFactory sessionFactory = HibernateUtil.getSessionFactory();
...@@ -814,7 +815,7 @@ public class CustomerServiceImpl implements CustomerService { ...@@ -814,7 +815,7 @@ public class CustomerServiceImpl implements CustomerService {
sb.append(" AND a.STATUS = 1"); sb.append(" AND a.STATUS = 1");
sb.append(" AND a.COMPANY_SITE_ID = :p_company_site_id"); sb.append(" AND a.COMPANY_SITE_ID = :p_company_site_id");
sb.append(" AND to_date(CREATE_AT, 'DD-MM-RR') >= to_date(:p_date_from, 'YYYYMMDD') AND to_date(CREATE_AT, 'DD-MM-RR') <= to_date(:p_date_to, 'YYYYMMDD')"); sb.append(" AND CREATE_AT >= to_date(:p_date_from, 'DD/MM/YYYY HH24:MI:SS') AND CREATE_AT <= to_date(:p_date_to, 'DD/MM/YYYY HH24:MI:SS')");
if (!DataUtil.isNullOrEmpty(searchCustomerRequestDTO.getCustomerListCode())) { if (!DataUtil.isNullOrEmpty(searchCustomerRequestDTO.getCustomerListCode())) {
sb.append(" AND UPPER(CUSTOMER_LIST_CODE) LIKE UPPER(:p_list_code)"); sb.append(" AND UPPER(CUSTOMER_LIST_CODE) LIKE UPPER(:p_list_code)");
...@@ -828,8 +829,8 @@ public class CustomerServiceImpl implements CustomerService { ...@@ -828,8 +829,8 @@ public class CustomerServiceImpl implements CustomerService {
SQLQuery query = session.createSQLQuery(sb.toString()); SQLQuery query = session.createSQLQuery(sb.toString());
query.setParameter("p_company_site_id", searchCustomerRequestDTO.getCompanySiteId()); query.setParameter("p_company_site_id", searchCustomerRequestDTO.getCompanySiteId());
query.setParameter("p_date_from", searchCustomerRequestDTO.getConvertedDateFrom()); query.setParameter("p_date_from", TimeZoneUtils.toDateStringWithTimeZone(DateTimeUtil.parseDate("YYYYMMdd",searchCustomerRequestDTO.getConvertedDateFrom()), tzClient));
query.setParameter("p_date_to", searchCustomerRequestDTO.getConvertedDateTo()); query.setParameter("p_date_to", TimeZoneUtils.toDateStringWithTimeZone(DateTimeUtil.parseDate("YYYYMMdd",searchCustomerRequestDTO.getConvertedDateTo()), tzClient));
if (!DataUtil.isNullOrEmpty(searchCustomerRequestDTO.getCustomerListCode())) { if (!DataUtil.isNullOrEmpty(searchCustomerRequestDTO.getCustomerListCode())) {
query.setParameter("p_list_code", "%" + query.setParameter("p_list_code", "%" +
...@@ -877,6 +878,10 @@ public class CustomerServiceImpl implements CustomerService { ...@@ -877,6 +878,10 @@ public class CustomerServiceImpl implements CustomerService {
List<CustomerListDTO> data = query.list(); List<CustomerListDTO> data = query.list();
Page<CustomerListDTO> dataPage = new PageImpl<>(data, pageable, count); Page<CustomerListDTO> dataPage = new PageImpl<>(data, pageable, count);
dataPage.forEach(item -> {
item.setCreateAt(DateTimeUtil.parseDate("dd/MM/yyyy HH:mm:ss",TimeZoneUtils.toDateStringWithTimeZone(item.getCreateAt(),tzClient)));
item.setUpdateAt(DateTimeUtil.parseDate("dd/MM/yyyy HH:mm:ss",TimeZoneUtils.toDateStringWithTimeZone(item.getUpdateAt(),tzClient)));
});
resultDTO.setData(dataPage); resultDTO.setData(dataPage);
resultDTO.setErrorCode(Constants.ApiErrorCode.SUCCESS); resultDTO.setErrorCode(Constants.ApiErrorCode.SUCCESS);
resultDTO.setDescription(Constants.ApiErrorDesc.SUCCESS); resultDTO.setDescription(Constants.ApiErrorDesc.SUCCESS);
......
...@@ -12,4 +12,5 @@ public class SearchCustomerRequestDTO extends BaseDTO { ...@@ -12,4 +12,5 @@ public class SearchCustomerRequestDTO extends BaseDTO {
String convertedDateFrom; String convertedDateFrom;
String convertedDateTo; String convertedDateTo;
String companySiteId; String companySiteId;
Integer timezoneOffset;
} }
server: server:
port: 1111 port: 9999
spring: spring:
application: application:
name: campaign name: campaign
......
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