Commit cae4f155 authored by Phạm Duy Phi's avatar Phạm Duy Phi
parents e9a9358f 3c9f41ef
...@@ -173,6 +173,20 @@ ...@@ -173,6 +173,20 @@
<!--<executable>true</executable>--> <!--<executable>true</executable>-->
<!--</configuration>--> <!--</configuration>-->
</plugin> </plugin>
<!--<plugin>-->
<!--<groupId>org.sonarsource.scanner.maven</groupId>-->
<!--<artifactId>sonar-maven-plugin</artifactId>-->
<!--<version>3.3.0.603</version>-->
<!--<executions>-->
<!--<execution>-->
<!--<phase>verify</phase>-->
<!--<goals>-->
<!--<goal>sonar</goal>-->
<!--</goals>-->
<!--</execution>-->
<!--</executions>-->
<!--</plugin>-->
</plugins> </plugins>
</build> </build>
<repositories> <repositories>
......
...@@ -48,33 +48,34 @@ public class JobConfig implements SchedulingConfigurer { ...@@ -48,33 +48,34 @@ public class JobConfig implements SchedulingConfigurer {
// taskRegistrar.setTaskScheduler(threadPoolTaskScheduler); // taskRegistrar.setTaskScheduler(threadPoolTaskScheduler);
// } // }
private void job1(TaskScheduler scheduler) { // private void job1(TaskScheduler scheduler) {
job1 = scheduler.schedule(() -> { // job1 = scheduler.schedule(() -> {
log.info("processing job1 ..."); // log.info("processing job1 ...");
log.info(Thread.currentThread().getName() + " The Task1 executed at " + new Date()); // log.info(Thread.currentThread().getName() + " The Task1 executed at " + new Date());
try { // try {
Thread.sleep(10000); // Thread.sleep(10000);
} catch (InterruptedException e) { // } catch (InterruptedException e) {
// TODO Auto-generated catch block // // TODO Auto-generated catch block
e.printStackTrace(); //// e.printStackTrace();
} // log.error("Interrupted! ...${}", e);
}, triggerContext -> { // }
// }, triggerContext -> {
String cronExp = "0/5 * * * * ?";// Can be pulled from a db . //
return new CronTrigger(cronExp).nextExecutionTime(triggerContext); // String cronExp = "0/5 * * * * ?";// Can be pulled from a db .
}); // return new CronTrigger(cronExp).nextExecutionTime(triggerContext);
} // });
// }
private void job2(TaskScheduler scheduler) {
job2 = scheduler.schedule(() -> {
log.info(Thread.currentThread().getName() + " The Job executed at " + new Date());
campaignJob().process();
}, triggerContext -> { // private void job2(TaskScheduler scheduler) {
String cronExp = "0/1 * * * * ?";// Can be pulled from a db . This will run every minute // job2 = scheduler.schedule(() -> {
return new CronTrigger(cronExp).nextExecutionTime(triggerContext); // log.info(Thread.currentThread().getName() + " The Job executed at " + new Date());
}); // campaignJob().process();
} //
// }, triggerContext -> {
// String cronExp = "0/1 * * * * ?";// Can be pulled from a db . This will run every minute
// return new CronTrigger(cronExp).nextExecutionTime(triggerContext);
// });
// }
......
...@@ -19,7 +19,7 @@ import java.util.List; ...@@ -19,7 +19,7 @@ import java.util.List;
@Slf4j @Slf4j
public class CampaignJob { public class CampaignJob {
private static final SimpleDateFormat dateFormat = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss"); private SimpleDateFormat dateFormat = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss");
private static final String CUSTOMER_INACTIVE_DUARATION = "CUSTOMER_INACTIVE_DUARATION"; private static final String CUSTOMER_INACTIVE_DUARATION = "CUSTOMER_INACTIVE_DUARATION";
private static final String CRON_EXPRESSION_CHECK_START = "CRON_EXPRESSION_CHECK_START"; private static final String CRON_EXPRESSION_CHECK_START = "CRON_EXPRESSION_CHECK_START";
private static final String CRON_EXPRESSION_CHECK_END = "CRON_EXPRESSION_CHECK_END"; private static final String CRON_EXPRESSION_CHECK_END = "CRON_EXPRESSION_CHECK_END";
......
...@@ -15,7 +15,7 @@ import java.util.Date; ...@@ -15,7 +15,7 @@ import java.util.Date;
public class CustomerContact implements Serializable { public class CustomerContact implements Serializable {
@Id @Id
@Basic(optional = false) @Basic(optional = false)
@GeneratedValue(generator = "customer_contact_seq", strategy = GenerationType.IDENTITY) @GeneratedValue(generator = "customer_contact_seq")
@SequenceGenerator(name = "customer_contact_seq", sequenceName = "customer_contact_seq", allocationSize = 1) @SequenceGenerator(name = "customer_contact_seq", sequenceName = "customer_contact_seq", allocationSize = 1)
@NotNull @NotNull
@Column(name = "CONTACT_ID") @Column(name = "CONTACT_ID")
......
package com.viettel.campaign.model.ccms_full; package com.viettel.campaign.model.ccms_full;
import lombok.AllArgsConstructor; import lombok.*;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import javax.persistence.*; import javax.persistence.*;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
...@@ -67,8 +64,10 @@ public class CustomizeFields implements Serializable { ...@@ -67,8 +64,10 @@ public class CustomizeFields implements Serializable {
@Column(name = "ACTIVE") @Column(name = "ACTIVE")
private Long active; private Long active;
public CustomizeFields(String type, String title) { public CustomizeFields(@NotNull String type, @NotNull String title) {
this.type = type; this.type = type;
this.title = title; this.title = title;
} }
} }
...@@ -301,9 +301,9 @@ public class CampaignExecuteRepositoryImp implements CampaignExecuteRepository { ...@@ -301,9 +301,9 @@ public class CampaignExecuteRepositoryImp implements CampaignExecuteRepository {
if (!"AGENT".equals(dto.getRoleUser())) { // ko phải nhân viên if (!"AGENT".equals(dto.getRoleUser())) { // ko phải nhân viên
ContactCustResultDTO.setEnableEdit(true); ContactCustResultDTO.setEnableEdit(true);
} else { } else {
if ("2".equals(ContactCustResultDTO.getRecordStatus())) {// là nhân viên thường if (2 == ContactCustResultDTO.getRecordStatus()) {// là nhân viên thường
ContactCustResultDTO.setEnableEdit(true); ContactCustResultDTO.setEnableEdit(true);
} else if ("1".equals(ContactCustResultDTO.getRecordStatus()) && isLower24Hour(ContactCustResultDTO.getCreateTime())) { } else if (1 == ContactCustResultDTO.getRecordStatus() && isLower24Hour(ContactCustResultDTO.getCreateTime())) {
ContactCustResultDTO.setEnableEdit(true); ContactCustResultDTO.setEnableEdit(true);
} else { } else {
ContactCustResultDTO.setEnableEdit(false); ContactCustResultDTO.setEnableEdit(false);
...@@ -439,8 +439,8 @@ public class CampaignExecuteRepositoryImp implements CampaignExecuteRepository { ...@@ -439,8 +439,8 @@ public class CampaignExecuteRepositoryImp implements CampaignExecuteRepository {
logger.error(e.getMessage(), e); logger.error(e.getMessage(), e);
} finally { } finally {
session.close(); session.close();
return list;
} }
return list;
} }
@Override @Override
......
...@@ -57,8 +57,7 @@ public class CampaignRepositoryImpl implements CampaignRepositoryCustom { ...@@ -57,8 +57,7 @@ public class CampaignRepositoryImpl implements CampaignRepositoryCustom {
ResultDTO result = new ResultDTO(); ResultDTO result = new ResultDTO();
SessionFactory sessionFactory = HibernateUtil.getSessionFactory(); SessionFactory sessionFactory = HibernateUtil.getSessionFactory();
Session session = sessionFactory.openSession(); Session session = null;
session.beginTransaction();
if (DataUtil.isNullOrEmpty(requestDto.getCompanySiteId())) { if (DataUtil.isNullOrEmpty(requestDto.getCompanySiteId())) {
result.setErrorCode(Constants.ApiErrorCode.ERROR); result.setErrorCode(Constants.ApiErrorCode.ERROR);
...@@ -66,6 +65,9 @@ public class CampaignRepositoryImpl implements CampaignRepositoryCustom { ...@@ -66,6 +65,9 @@ public class CampaignRepositoryImpl implements CampaignRepositoryCustom {
return result; return result;
} }
try { try {
session = sessionFactory.openSession();
session.beginTransaction();
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
sb.append(" SELECT"); sb.append(" SELECT");
...@@ -256,8 +258,10 @@ public class CampaignRepositoryImpl implements CampaignRepositoryCustom { ...@@ -256,8 +258,10 @@ public class CampaignRepositoryImpl implements CampaignRepositoryCustom {
result.setDescription(Constants.ApiErrorDesc.ERROR); result.setDescription(Constants.ApiErrorDesc.ERROR);
logger.error(ex.getMessage(), ex); logger.error(ex.getMessage(), ex);
} finally { } finally {
if(null != session) {
session.close(); session.close();
} }
}
return result; return result;
} }
...@@ -267,8 +271,7 @@ public class CampaignRepositoryImpl implements CampaignRepositoryCustom { ...@@ -267,8 +271,7 @@ public class CampaignRepositoryImpl implements CampaignRepositoryCustom {
ResultDTO result = new ResultDTO(); ResultDTO result = new ResultDTO();
SessionFactory sessionFactory = HibernateUtil.getSessionFactory(); SessionFactory sessionFactory = HibernateUtil.getSessionFactory();
Session session = sessionFactory.openSession(); Session session = null;
session.beginTransaction();
if (DataUtil.isNullOrEmpty(requestDto.getCompanySiteId())) { if (DataUtil.isNullOrEmpty(requestDto.getCompanySiteId())) {
result.setErrorCode(Constants.ApiErrorCode.ERROR); result.setErrorCode(Constants.ApiErrorCode.ERROR);
...@@ -276,6 +279,8 @@ public class CampaignRepositoryImpl implements CampaignRepositoryCustom { ...@@ -276,6 +279,8 @@ public class CampaignRepositoryImpl implements CampaignRepositoryCustom {
return result; return result;
} }
try { try {
session = sessionFactory.openSession();
session.beginTransaction();
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
// sb.append(" SELECT CAMPAIGN_ID campaignId, " + // sb.append(" SELECT CAMPAIGN_ID campaignId, " +
// " CAMPAIGN_CODE campaignCode, " + // " CAMPAIGN_CODE campaignCode, " +
...@@ -343,7 +348,7 @@ public class CampaignRepositoryImpl implements CampaignRepositoryCustom { ...@@ -343,7 +348,7 @@ public class CampaignRepositoryImpl implements CampaignRepositoryCustom {
result.setErrorCode(Constants.ApiErrorCode.ERROR); result.setErrorCode(Constants.ApiErrorCode.ERROR);
result.setDescription(Constants.ApiErrorDesc.ERROR); result.setDescription(Constants.ApiErrorDesc.ERROR);
} finally { } finally {
session.close(); if(session != null) session.close();
} }
return result; return result;
} }
...@@ -353,9 +358,10 @@ public class CampaignRepositoryImpl implements CampaignRepositoryCustom { ...@@ -353,9 +358,10 @@ public class CampaignRepositoryImpl implements CampaignRepositoryCustom {
logger.info("Start search max campaign code index::"); logger.info("Start search max campaign code index::");
SessionFactory sessionFactory = HibernateUtil.getSessionFactory(); SessionFactory sessionFactory = HibernateUtil.getSessionFactory();
Session session = sessionFactory.openSession(); Session session = null;
session.beginTransaction();
try { try {
session = sessionFactory.openSession();
session.beginTransaction();
//StringBuilder sb = new StringBuilder(); //StringBuilder sb = new StringBuilder();
//sb.append(SQLBuilder.getSqlQueryById(SQLBuilder.SQL_MODULE_CAMPAIGN_MNG, "get-max-campaign-code-index")); //sb.append(SQLBuilder.getSqlQueryById(SQLBuilder.SQL_MODULE_CAMPAIGN_MNG, "get-max-campaign-code-index"));
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
...@@ -373,6 +379,8 @@ public class CampaignRepositoryImpl implements CampaignRepositoryCustom { ...@@ -373,6 +379,8 @@ public class CampaignRepositoryImpl implements CampaignRepositoryCustom {
} }
} catch (Exception ex) { } catch (Exception ex) {
logger.error(ex.getMessage(), ex); logger.error(ex.getMessage(), ex);
}finally {
if(session != null) session.close();
} }
return null; return null;
} }
...@@ -779,8 +787,8 @@ public class CampaignRepositoryImpl implements CampaignRepositoryCustom { ...@@ -779,8 +787,8 @@ public class CampaignRepositoryImpl implements CampaignRepositoryCustom {
resultDTO.setDescription(Constants.ApiErrorDesc.ERROR); resultDTO.setDescription(Constants.ApiErrorDesc.ERROR);
} finally { } finally {
session.close(); session.close();
return resultDTO;
} }
return resultDTO;
} }
@Override @Override
......
...@@ -6,6 +6,7 @@ import com.viettel.econtact.filter.UserSession; ...@@ -6,6 +6,7 @@ import com.viettel.econtact.filter.UserSession;
import org.apache.poi.xssf.usermodel.XSSFWorkbook; import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.io.IOException;
import java.util.List; import java.util.List;
@Service @Service
...@@ -17,7 +18,7 @@ public interface CampaignExecuteService { ...@@ -17,7 +18,7 @@ public interface CampaignExecuteService {
ResultDTO searchInteractiveResult(CampaignRequestDTO dto); ResultDTO searchInteractiveResult(CampaignRequestDTO dto);
XSSFWorkbook exportInteractiveResult(CampaignRequestDTO dto); XSSFWorkbook exportInteractiveResult(CampaignRequestDTO dto) throws IOException;
List<ContactCustResultDTO> getContactCustById(CampaignRequestDTO dto); List<ContactCustResultDTO> getContactCustById(CampaignRequestDTO dto);
//</editor-fold> //</editor-fold>
......
...@@ -11,6 +11,7 @@ import com.viettel.campaign.web.dto.request_dto.CustomizeRequestDTo; ...@@ -11,6 +11,7 @@ import com.viettel.campaign.web.dto.request_dto.CustomizeRequestDTo;
import com.viettel.campaign.web.dto.request_dto.SearchCustomerRequestDTO; import com.viettel.campaign.web.dto.request_dto.SearchCustomerRequestDTO;
import com.viettel.econtact.filter.UserSession; import com.viettel.econtact.filter.UserSession;
import java.io.IOException;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -76,9 +77,9 @@ public interface CustomerService { ...@@ -76,9 +77,9 @@ public interface CustomerService {
List<CustomizeFields> getDynamicHeader(Long companySiteId); List<CustomizeFields> getDynamicHeader(Long companySiteId);
byte[] buildTemplate(Long companySiteId); byte[] buildTemplate(Long companySiteId) throws IOException;
Map<String, Object> readAndValidateCustomer(String path, List<CustomizeFields> headerDTOS, UserSession userSession, Long customerListId); Map<String, Object> readAndValidateCustomer(String path, List<CustomizeFields> headerDTOS, UserSession userSession, Long customerListId) throws IOException;
List<CustomizeFieldObject> getCustomizeField(Long customerId); List<CustomizeFieldObject> getCustomizeField(Long customerId);
......
...@@ -6,6 +6,7 @@ import com.viettel.econtact.filter.UserSession; ...@@ -6,6 +6,7 @@ import com.viettel.econtact.filter.UserSession;
import org.apache.poi.xssf.usermodel.XSSFWorkbook; import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import java.io.IOException;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -24,7 +25,7 @@ public interface ScenarioService { ...@@ -24,7 +25,7 @@ public interface ScenarioService {
ResultDTO saveContacQuestResult(ContactQuestResultDTO dto); ResultDTO saveContacQuestResult(ContactQuestResultDTO dto);
XSSFWorkbook buildTemplate(); XSSFWorkbook buildTemplate() throws IOException;
Map<String, Object> readAndValidateCustomer(String path, Long scenarioId, Long campaignId, Long companySiteId); Map<String, Object> readAndValidateCustomer(String path, Long scenarioId, Long campaignId, Long companySiteId) throws IOException;
} }
...@@ -66,8 +66,7 @@ public class AgentsServiceImpl implements AgentsService { ...@@ -66,8 +66,7 @@ public class AgentsServiceImpl implements AgentsService {
ResultDTO resultDTO = new ResultDTO(); ResultDTO resultDTO = new ResultDTO();
SessionFactory sessionFactory = HibernateUtil.getSessionFactory(); SessionFactory sessionFactory = HibernateUtil.getSessionFactory();
Session session = sessionFactory.openSession(); Session session = null;
session.beginTransaction();
if (DataUtil.isNullOrZero(companySiteId)) { if (DataUtil.isNullOrZero(companySiteId)) {
resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR); resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR);
...@@ -76,6 +75,8 @@ public class AgentsServiceImpl implements AgentsService { ...@@ -76,6 +75,8 @@ public class AgentsServiceImpl implements AgentsService {
} }
try { try {
session = sessionFactory.openSession();
session.beginTransaction();
// StringBuilder sb = new StringBuilder(); // StringBuilder sb = new StringBuilder();
// sb.append(SQLBuilder.getSqlQueryById(SQLBuilder.SQL_MODULE_CAMPAIGN_MNG, "campaign-agents-by-params")); // sb.append(SQLBuilder.getSqlQueryById(SQLBuilder.SQL_MODULE_CAMPAIGN_MNG, "campaign-agents-by-params"));
...@@ -136,7 +137,7 @@ public class AgentsServiceImpl implements AgentsService { ...@@ -136,7 +137,7 @@ public class AgentsServiceImpl implements AgentsService {
resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR); resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR);
resultDTO.setDescription(Constants.ApiErrorDesc.ERROR); resultDTO.setDescription(Constants.ApiErrorDesc.ERROR);
} finally { } finally {
session.close(); if(session != null) session.close();
} }
return resultDTO; return resultDTO;
...@@ -147,8 +148,7 @@ public class AgentsServiceImpl implements AgentsService { ...@@ -147,8 +148,7 @@ public class AgentsServiceImpl implements AgentsService {
ResultDTO resultDTO = new ResultDTO(); ResultDTO resultDTO = new ResultDTO();
SessionFactory sessionFactory = HibernateUtil.getSessionFactory(); SessionFactory sessionFactory = HibernateUtil.getSessionFactory();
Session session = sessionFactory.openSession(); Session session = null;
session.beginTransaction();
if (DataUtil.isNullOrZero(companySiteId)) { if (DataUtil.isNullOrZero(companySiteId)) {
resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR); resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR);
...@@ -157,6 +157,8 @@ public class AgentsServiceImpl implements AgentsService { ...@@ -157,6 +157,8 @@ public class AgentsServiceImpl implements AgentsService {
} }
try { try {
session = sessionFactory.openSession();
session.beginTransaction();
// StringBuilder sb = new StringBuilder(); // StringBuilder sb = new StringBuilder();
// sb.append(SQLBuilder.getSqlQueryById(SQLBuilder.SQL_MODULE_CAMPAIGN_MNG, "campaign-agents-by-params")); // sb.append(SQLBuilder.getSqlQueryById(SQLBuilder.SQL_MODULE_CAMPAIGN_MNG, "campaign-agents-by-params"));
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
...@@ -214,7 +216,7 @@ public class AgentsServiceImpl implements AgentsService { ...@@ -214,7 +216,7 @@ public class AgentsServiceImpl implements AgentsService {
resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR); resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR);
resultDTO.setDescription(Constants.ApiErrorDesc.ERROR); resultDTO.setDescription(Constants.ApiErrorDesc.ERROR);
} finally { } finally {
session.close(); if(session != null) session.close();
} }
return resultDTO; return resultDTO;
...@@ -278,8 +280,7 @@ public class AgentsServiceImpl implements AgentsService { ...@@ -278,8 +280,7 @@ public class AgentsServiceImpl implements AgentsService {
ResultDTO resultDTO = new ResultDTO(); ResultDTO resultDTO = new ResultDTO();
SessionFactory sessionFactory = HibernateUtil.getSessionFactory(); SessionFactory sessionFactory = HibernateUtil.getSessionFactory();
Session session = sessionFactory.openSession(); Session session = null;
session.beginTransaction();
if (DataUtil.isNullOrZero(companySiteId)) { if (DataUtil.isNullOrZero(companySiteId)) {
resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR); resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR);
...@@ -288,6 +289,8 @@ public class AgentsServiceImpl implements AgentsService { ...@@ -288,6 +289,8 @@ public class AgentsServiceImpl implements AgentsService {
} }
try { try {
session = sessionFactory.openSession();
session.beginTransaction();
// StringBuilder sqlStrBuilder = new StringBuilder(); // StringBuilder sqlStrBuilder = new StringBuilder();
// sqlStrBuilder.append(SQLBuilder.getSqlQueryById(SQLBuilder.SQL_MODULE_CAMPAIGN_MNG, "campaign-agents-by-params")); // sqlStrBuilder.append(SQLBuilder.getSqlQueryById(SQLBuilder.SQL_MODULE_CAMPAIGN_MNG, "campaign-agents-by-params"));
StringBuilder sqlStrBuilder = new StringBuilder(); StringBuilder sqlStrBuilder = new StringBuilder();
...@@ -372,7 +375,7 @@ public class AgentsServiceImpl implements AgentsService { ...@@ -372,7 +375,7 @@ public class AgentsServiceImpl implements AgentsService {
resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR); resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR);
resultDTO.setDescription(Constants.ApiErrorDesc.ERROR); resultDTO.setDescription(Constants.ApiErrorDesc.ERROR);
} finally { } finally {
session.close(); if(session != null) session.close();
} }
return resultDTO; return resultDTO;
...@@ -383,8 +386,10 @@ public class AgentsServiceImpl implements AgentsService { ...@@ -383,8 +386,10 @@ public class AgentsServiceImpl implements AgentsService {
ResultDTO resultDTO = new ResultDTO(); ResultDTO resultDTO = new ResultDTO();
SessionFactory sessionFactory = HibernateUtil.getSessionFactory(); SessionFactory sessionFactory = HibernateUtil.getSessionFactory();
Session session = sessionFactory.openSession(); // Session session = sessionFactory.openSession();
session.beginTransaction(); // session.beginTransaction();
Session session = null;
if (DataUtil.isNullOrZero(companySiteId)) { if (DataUtil.isNullOrZero(companySiteId)) {
resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR); resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR);
...@@ -393,6 +398,8 @@ public class AgentsServiceImpl implements AgentsService { ...@@ -393,6 +398,8 @@ public class AgentsServiceImpl implements AgentsService {
} }
try { try {
session = sessionFactory.openSession();
session.beginTransaction();
// StringBuilder sb = new StringBuilder(); // StringBuilder sb = new StringBuilder();
// sb.append(SQLBuilder.getSqlQueryById(SQLBuilder.SQL_MODULE_CAMPAIGN_MNG, "campaign-agents-by-params")); // sb.append(SQLBuilder.getSqlQueryById(SQLBuilder.SQL_MODULE_CAMPAIGN_MNG, "campaign-agents-by-params"));
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
...@@ -477,8 +484,10 @@ public class AgentsServiceImpl implements AgentsService { ...@@ -477,8 +484,10 @@ public class AgentsServiceImpl implements AgentsService {
resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR); resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR);
resultDTO.setDescription(Constants.ApiErrorDesc.ERROR); resultDTO.setDescription(Constants.ApiErrorDesc.ERROR);
} finally { } finally {
if(null != session){
session.close(); session.close();
} }
}
return resultDTO; return resultDTO;
} }
......
...@@ -44,8 +44,7 @@ public class CampaignCfgServiceImpl implements CampaignCfgService { ...@@ -44,8 +44,7 @@ public class CampaignCfgServiceImpl implements CampaignCfgService {
ResultDTO resultDTO = new ResultDTO(); ResultDTO resultDTO = new ResultDTO();
SessionFactory sessionFactory = HibernateUtil.getSessionFactory(); SessionFactory sessionFactory = HibernateUtil.getSessionFactory();
Session session = sessionFactory.openSession(); Session session = null;
session.beginTransaction();
if (DataUtil.isNullOrZero(companySiteId)) { if (DataUtil.isNullOrZero(companySiteId)) {
resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR); resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR);
...@@ -54,6 +53,8 @@ public class CampaignCfgServiceImpl implements CampaignCfgService { ...@@ -54,6 +53,8 @@ public class CampaignCfgServiceImpl implements CampaignCfgService {
} }
try { try {
session = sessionFactory.openSession();
session.beginTransaction();
// StringBuilder sqlStrBuilder = new StringBuilder(); // StringBuilder sqlStrBuilder = new StringBuilder();
// sqlStrBuilder.append(SQLBuilder.getSqlQueryById(SQLBuilder.SQL_MODULE_CAMPAIGN_STATUS_MNG, "findAll-CampaignCompleteCode")); // sqlStrBuilder.append(SQLBuilder.getSqlQueryById(SQLBuilder.SQL_MODULE_CAMPAIGN_STATUS_MNG, "findAll-CampaignCompleteCode"));
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
...@@ -132,7 +133,7 @@ public class CampaignCfgServiceImpl implements CampaignCfgService { ...@@ -132,7 +133,7 @@ public class CampaignCfgServiceImpl implements CampaignCfgService {
resultDTO.setDescription(Constants.ApiErrorDesc.ERROR); resultDTO.setDescription(Constants.ApiErrorDesc.ERROR);
logger.error(e.getMessage(), e); logger.error(e.getMessage(), e);
} finally { } finally {
session.close(); if(session != null) session.close();
} }
return resultDTO; return resultDTO;
...@@ -278,8 +279,7 @@ public class CampaignCfgServiceImpl implements CampaignCfgService { ...@@ -278,8 +279,7 @@ public class CampaignCfgServiceImpl implements CampaignCfgService {
ResultDTO resultDTO = new ResultDTO(); ResultDTO resultDTO = new ResultDTO();
SessionFactory sessionFactory = HibernateUtil.getSessionFactory(); SessionFactory sessionFactory = HibernateUtil.getSessionFactory();
Session session = sessionFactory.openSession(); Session session = null;
session.beginTransaction();
if (DataUtil.isNullOrZero(completeCodeDTO.getCompanySiteId())) { if (DataUtil.isNullOrZero(completeCodeDTO.getCompanySiteId())) {
resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR); resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR);
...@@ -288,6 +288,8 @@ public class CampaignCfgServiceImpl implements CampaignCfgService { ...@@ -288,6 +288,8 @@ public class CampaignCfgServiceImpl implements CampaignCfgService {
} }
try { try {
session = sessionFactory.openSession();
session.beginTransaction();
// StringBuilder sqlStrBuilder = new StringBuilder(); // StringBuilder sqlStrBuilder = new StringBuilder();
// sqlStrBuilder.append(SQLBuilder.getSqlQueryById(SQLBuilder.SQL_MODULE_CAMPAIGN_STATUS_MNG, "get-max-value-completevalue")); // sqlStrBuilder.append(SQLBuilder.getSqlQueryById(SQLBuilder.SQL_MODULE_CAMPAIGN_STATUS_MNG, "get-max-value-completevalue"));
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
...@@ -323,9 +325,9 @@ public class CampaignCfgServiceImpl implements CampaignCfgService { ...@@ -323,9 +325,9 @@ public class CampaignCfgServiceImpl implements CampaignCfgService {
resultDTO.setDescription(Constants.ApiErrorDesc.ERROR); resultDTO.setDescription(Constants.ApiErrorDesc.ERROR);
logger.error(e.getMessage(), e); logger.error(e.getMessage(), e);
} finally { } finally {
session.close(); if(session != null) session.close();
return resultDTO;
} }
return resultDTO;
} }
@Override @Override
...@@ -367,8 +369,7 @@ public class CampaignCfgServiceImpl implements CampaignCfgService { ...@@ -367,8 +369,7 @@ public class CampaignCfgServiceImpl implements CampaignCfgService {
ResultDTO resultDTO = new ResultDTO(); ResultDTO resultDTO = new ResultDTO();
SessionFactory sessionFactory = HibernateUtil.getSessionFactory(); SessionFactory sessionFactory = HibernateUtil.getSessionFactory();
Session session = sessionFactory.openSession(); Session session = null;
session.beginTransaction();
if (DataUtil.isNullOrZero(campaignCompleteCodeId)) { if (DataUtil.isNullOrZero(campaignCompleteCodeId)) {
resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR); resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR);
...@@ -377,6 +378,8 @@ public class CampaignCfgServiceImpl implements CampaignCfgService { ...@@ -377,6 +378,8 @@ public class CampaignCfgServiceImpl implements CampaignCfgService {
} }
try { try {
session = sessionFactory.openSession();
session.beginTransaction();
// StringBuilder sqlStrBuilder = new StringBuilder(); // StringBuilder sqlStrBuilder = new StringBuilder();
// sqlStrBuilder.append(SQLBuilder.getSqlQueryById(SQLBuilder.SQL_MODULE_CAMPAIGN_STATUS_MNG,"findCampaignCodeById")); // sqlStrBuilder.append(SQLBuilder.getSqlQueryById(SQLBuilder.SQL_MODULE_CAMPAIGN_STATUS_MNG,"findCampaignCodeById"));
...@@ -437,7 +440,7 @@ public class CampaignCfgServiceImpl implements CampaignCfgService { ...@@ -437,7 +440,7 @@ public class CampaignCfgServiceImpl implements CampaignCfgService {
resultDTO.setDescription(Constants.ApiErrorDesc.ERROR); resultDTO.setDescription(Constants.ApiErrorDesc.ERROR);
logger.error(e.getMessage(), e); logger.error(e.getMessage(), e);
} finally { } finally {
session.close(); if(session != null) session.close();
} }
return resultDTO; return resultDTO;
......
...@@ -24,6 +24,9 @@ import org.springframework.data.domain.PageRequest; ...@@ -24,6 +24,9 @@ import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.io.IOException;
import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.*; import java.util.*;
...@@ -33,6 +36,8 @@ public class CampaignExecuteServiceImp implements CampaignExecuteService { ...@@ -33,6 +36,8 @@ public class CampaignExecuteServiceImp implements CampaignExecuteService {
private static final Logger logger = LoggerFactory.getLogger(CampaignExecuteServiceImp.class); private static final Logger logger = LoggerFactory.getLogger(CampaignExecuteServiceImp.class);
private SimpleDateFormat formatter = new SimpleDateFormat(Constants.DATE_FORMAT.FOMART_DATE_TYPE_1); private SimpleDateFormat formatter = new SimpleDateFormat(Constants.DATE_FORMAT.FOMART_DATE_TYPE_1);
private Random rand = SecureRandom.getInstanceStrong();
@Autowired @Autowired
ModelMapper modelMapper; ModelMapper modelMapper;
...@@ -66,6 +71,9 @@ public class CampaignExecuteServiceImp implements CampaignExecuteService { ...@@ -66,6 +71,9 @@ public class CampaignExecuteServiceImp implements CampaignExecuteService {
@Autowired @Autowired
CampaignCustomerListColumnRepository campaignCustomerListColumnRepository; CampaignCustomerListColumnRepository campaignCustomerListColumnRepository;
public CampaignExecuteServiceImp() throws NoSuchAlgorithmException {
}
//<editor-fold: hungtt> //<editor-fold: hungtt>
@Override @Override
@Transactional(DataSourceQualify.CCMS_FULL) @Transactional(DataSourceQualify.CCMS_FULL)
...@@ -119,14 +127,15 @@ public class CampaignExecuteServiceImp implements CampaignExecuteService { ...@@ -119,14 +127,15 @@ public class CampaignExecuteServiceImp implements CampaignExecuteService {
@Override @Override
@Transactional(DataSourceQualify.CCMS_FULL) @Transactional(DataSourceQualify.CCMS_FULL)
public XSSFWorkbook exportInteractiveResult(CampaignRequestDTO dto) { public XSSFWorkbook exportInteractiveResult(CampaignRequestDTO dto) throws IOException {
Locale locale = Locale.forLanguageTag("vi"); Locale locale = Locale.forLanguageTag("vi");
List<ContactCustResultDTO> list = campaignExecuteRepository.getExcelInteractiveResult(dto); List<ContactCustResultDTO> list = campaignExecuteRepository.getExcelInteractiveResult(dto);
XSSFWorkbook workbook = new XSSFWorkbook(); XSSFWorkbook workbook = null;
Sheet sheet; Sheet sheet;
try {
// create font style // create font style
workbook = new XSSFWorkbook();
Font defaultFont = workbook.createFont(); Font defaultFont = workbook.createFont();
defaultFont.setFontHeightInPoints((short) 13); defaultFont.setFontHeightInPoints((short) 13);
defaultFont.setFontName("Times New Roman"); defaultFont.setFontName("Times New Roman");
...@@ -217,6 +226,12 @@ public class CampaignExecuteServiceImp implements CampaignExecuteService { ...@@ -217,6 +226,12 @@ public class CampaignExecuteServiceImp implements CampaignExecuteService {
++rowIndex; ++rowIndex;
++count; ++count;
} }
}catch (Exception e){
}finally {
if (workbook != null) workbook.close();
}
return workbook; return workbook;
} }
...@@ -493,13 +508,13 @@ public class CampaignExecuteServiceImp implements CampaignExecuteService { ...@@ -493,13 +508,13 @@ public class CampaignExecuteServiceImp implements CampaignExecuteService {
@Override @Override
public ResultDTO getCallStatus(CampaignRequestDTO dto) { public ResultDTO getCallStatus(CampaignRequestDTO dto) {
ResultDTO result = new ResultDTO(); ResultDTO result = new ResultDTO();
Random r = new Random(); // Random r = new Random();
String[] arr = {"ACCEPT", "REJECT", "MISSING"}; String[] arr = {"ACCEPT", "REJECT", "MISSING"};
if (dto != null) { if (dto != null) {
result.setErrorCode(Constants.ApiErrorCode.SUCCESS); result.setErrorCode(Constants.ApiErrorCode.SUCCESS);
result.setDescription(Constants.ApiErrorDesc.SUCCESS); result.setDescription(Constants.ApiErrorDesc.SUCCESS);
result.setData(arr[r.nextInt(arr.length)]); result.setData(arr[this.rand.nextInt(arr.length)]);
} else { } else {
result.setErrorCode(Constants.ApiErrorCode.ERROR); result.setErrorCode(Constants.ApiErrorCode.ERROR);
result.setDescription(Constants.ApiErrorDesc.ERROR); result.setDescription(Constants.ApiErrorDesc.ERROR);
......
...@@ -596,7 +596,7 @@ public class CampaignServiceImpl implements CampaignService { ...@@ -596,7 +596,7 @@ public class CampaignServiceImpl implements CampaignService {
// Cap nhat cac truong da co san // Cap nhat cac truong da co san
for (FieldsToShowDTO fieldsToShowDTO : list) { for (FieldsToShowDTO fieldsToShowDTO : list) {
if (fieldsToShowDTO.getId() != null) { if (fieldsToShowDTO.getId() != null) {
listColumns.removeIf(p -> p.getCampaignCusListColId() == fieldsToShowDTO.getId()); listColumns.removeIf(p -> p.getCampaignCusListColId().equals(fieldsToShowDTO.getId()));
CampaignCustomerListColumn entity = campaignCustomerListColumnRepository.findByCampaignCusListColId(fieldsToShowDTO.getId()); CampaignCustomerListColumn entity = campaignCustomerListColumnRepository.findByCampaignCusListColId(fieldsToShowDTO.getId());
entity.setOrderIndex((long) (list.indexOf(fieldsToShowDTO) + 1)); entity.setOrderIndex((long) (list.indexOf(fieldsToShowDTO) + 1));
campaignCustomerListColumnRepository.save(entity); campaignCustomerListColumnRepository.save(entity);
......
...@@ -22,10 +22,12 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -22,10 +22,12 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.io.*;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.nio.file.Files;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.*; import java.util.*;
...@@ -160,12 +162,13 @@ public class ScenarioServiceImpl implements ScenarioService { ...@@ -160,12 +162,13 @@ public class ScenarioServiceImpl implements ScenarioService {
@Override @Override
@Transactional(DataSourceQualify.CCMS_FULL) @Transactional(DataSourceQualify.CCMS_FULL)
public XSSFWorkbook buildTemplate() { public XSSFWorkbook buildTemplate() throws IOException {
Locale locale = new Locale("vi", "VN"); Locale locale = new Locale("vi", "VN");
XSSFWorkbook workbook = null;
try { try {
XSSFWorkbook workbook = new XSSFWorkbook();
Sheet sheet;
Sheet sheet;
workbook = new XSSFWorkbook();
CellStyle styleTitle = WorkBookBuilder.buildDefaultStyleTitle(workbook); CellStyle styleTitle = WorkBookBuilder.buildDefaultStyleTitle(workbook);
CellStyle styleRowHeader = WorkBookBuilder.buildDefaultStyleRowHeader(workbook); CellStyle styleRowHeader = WorkBookBuilder.buildDefaultStyleRowHeader(workbook);
CellStyle styleRow = WorkBookBuilder.buildDefaultStyleRow(workbook); CellStyle styleRow = WorkBookBuilder.buildDefaultStyleRow(workbook);
...@@ -236,17 +239,20 @@ public class ScenarioServiceImpl implements ScenarioService { ...@@ -236,17 +239,20 @@ public class ScenarioServiceImpl implements ScenarioService {
} catch (Exception e) { } catch (Exception e) {
logger.error(e.getMessage()); logger.error(e.getMessage());
return null; return null;
}finally {
if (workbook != null) workbook.close();
} }
} }
@Override @Override
@Transactional(DataSourceQualify.CCMS_FULL) @Transactional(DataSourceQualify.CCMS_FULL)
public Map<String, Object> readAndValidateCustomer(String path, Long scenarioId, Long campaignId, Long companySiteId) { public Map<String, Object> readAndValidateCustomer (String path, Long scenarioId, Long campaignId, Long companySiteId) throws IOException{
Locale locale = new Locale("vi", "VN"); Locale locale = new Locale("vi", "VN");
SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss"); SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
Map<String, Object> result = new HashMap<>(); Map<String, Object> result = new HashMap<>();
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
boolean isValid = true; boolean isValid = true;
XSSFWorkbook workbook = null;
try { try {
List<String> fileHeaderList = new ArrayList<>(); List<String> fileHeaderList = new ArrayList<>();
fileHeaderList.add(BundleUtils.getLangString("scenario.template.questionCode", locale)); fileHeaderList.add(BundleUtils.getLangString("scenario.template.questionCode", locale));
...@@ -260,7 +266,9 @@ public class ScenarioServiceImpl implements ScenarioService { ...@@ -260,7 +266,9 @@ public class ScenarioServiceImpl implements ScenarioService {
File file = new File(path); File file = new File(path);
FileInputStream fis = new FileInputStream(file); FileInputStream fis = new FileInputStream(file);
XSSFWorkbook workbook = new XSSFWorkbook(fis); workbook = new XSSFWorkbook(fis);
workbook = new XSSFWorkbook(fis);
ByteArrayOutputStream os = new ByteArrayOutputStream();
Sheet sheet = workbook.getSheetAt(0); Sheet sheet = workbook.getSheetAt(0);
Row row = sheet.getRow(2); Row row = sheet.getRow(2);
...@@ -270,18 +278,26 @@ public class ScenarioServiceImpl implements ScenarioService { ...@@ -270,18 +278,26 @@ public class ScenarioServiceImpl implements ScenarioService {
resultFont.setFontHeightInPoints((short) 11); resultFont.setFontHeightInPoints((short) 11);
CellStyle resultStyle = workbook.createCellStyle(); CellStyle resultStyle = workbook.createCellStyle();
resultStyle.setFont(resultFont); resultStyle.setFont(resultFont);
resultStyle.setBorderLeft(BorderStyle.THIN); resultStyle.setAlignment(HorizontalAlignment.CENTER);
resultStyle.setFillForegroundColor(IndexedColors.LIGHT_GREEN.getIndex());
resultStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
resultStyle.setBorderRight(BorderStyle.THIN); resultStyle.setBorderRight(BorderStyle.THIN);
resultStyle.setRightBorderColor(IndexedColors.BLACK.getIndex());
resultStyle.setBorderBottom(BorderStyle.THIN); resultStyle.setBorderBottom(BorderStyle.THIN);
resultStyle.setBottomBorderColor(IndexedColors.BLACK.getIndex());
resultStyle.setBorderLeft(BorderStyle.THIN);
resultStyle.setLeftBorderColor(IndexedColors.BLACK.getIndex());
resultStyle.setBorderTop(BorderStyle.THIN); resultStyle.setBorderTop(BorderStyle.THIN);
resultStyle.setTopBorderColor(IndexedColors.BLACK.getIndex());
//</editor-fold> //</editor-fold>
//<editor-fold desc="Kiểm tra header của template" defaultstate="collapsed"> //<editor-fold desc="Kiểm tra header của template" defaultstate="collapsed">
for (int i = 0; i < fileHeaderList.size(); i++) { for (int i = 0; i < fileHeaderList.size(); i++) {
Cell cell = row.getCell(i); Cell cell = row.getCell(i);
if (!cell.getStringCellValue().equals(fileHeaderList.get(i).split("#")[0])) { if (!cell.getStringCellValue().equals(fileHeaderList.get(i).split("#")[0])) {
result.put("file", file); result.put("content", Files.readAllBytes(file.toPath()));
result.put("message", BundleUtils.getLangString("common.invalidTemplate", locale)); result.put("code", Constants.FILE_UPLOAD_RESP_CODE.INVALID_FORMAT);
return result; return result;
} }
} }
...@@ -289,8 +305,8 @@ public class ScenarioServiceImpl implements ScenarioService { ...@@ -289,8 +305,8 @@ public class ScenarioServiceImpl implements ScenarioService {
//kt file du lieu rong //kt file du lieu rong
if (sheet.getPhysicalNumberOfRows() == 2) { if (sheet.getPhysicalNumberOfRows() == 2) {
result.put("message", BundleUtils.getLangString("customer.noData", locale)); result.put("content", Files.readAllBytes(file.toPath()));
result.put("file", file); result.put("code", Constants.FILE_UPLOAD_RESP_CODE.EMPTY);
return result; return result;
} else { } else {
Cell resultCell = sheet.getRow(2).createCell(sheet.getRow(2).getPhysicalNumberOfCells()); Cell resultCell = sheet.getRow(2).createCell(sheet.getRow(2).getPhysicalNumberOfCells());
...@@ -385,7 +401,7 @@ public class ScenarioServiceImpl implements ScenarioService { ...@@ -385,7 +401,7 @@ public class ScenarioServiceImpl implements ScenarioService {
isValid = false; isValid = false;
} else { } else {
// isValid = true; // isValid = true;
resultCell.setCellValue("Ok"); resultCell.setCellValue(BundleUtils.getLangString("ok"));
} }
sb = new StringBuilder(); sb = new StringBuilder();
} }
...@@ -397,26 +413,32 @@ public class ScenarioServiceImpl implements ScenarioService { ...@@ -397,26 +413,32 @@ public class ScenarioServiceImpl implements ScenarioService {
lstQuestion.forEach(question -> { lstQuestion.forEach(question -> {
questionService.add(question); questionService.add(question);
}); });
FileOutputStream fos = new FileOutputStream(file); workbook.write(os);
workbook.write(fos); os.flush();
result.put("file", file); os.close();
result.put("message", BundleUtils.getLangString("customer.importSuccess", locale)); workbook.close();
result.put("content", os.toByteArray());
result.put("code", Constants.FILE_UPLOAD_RESP_CODE.SUCCESS);
} else { } else {
FileOutputStream fos = new FileOutputStream(file); workbook.write(os);
workbook.write(fos); os.flush();
result.put("file", file); os.close();
result.put("message", BundleUtils.getLangString("customer.importFailed", locale)); workbook.close();
result.put("content", os.toByteArray());
result.put("code", Constants.FILE_UPLOAD_RESP_CODE.ERROR);
} }
} catch (Exception ex) { } catch (Exception ex) {
logger.info(ex.getMessage(), ex); logger.info(ex.getMessage(), ex);
result.put("message", BundleUtils.getLangString("customer.errorValidate", locale)); result.put("message", BundleUtils.getLangString("customer.errorValidate", locale));
}finally {
if (workbook != null) workbook.close();
result.put("code", Constants.FILE_UPLOAD_RESP_CODE.ERROR);
} }
logger.info("Import Questions result:", result);
return result; return result;
} }
private boolean validateMappingQuestion(String mappingQuestion, String currentQuestionCode, List<String> lstQuestionCode) { private boolean validateMappingQuestion(String mappingQuestion, String currentQuestionCode, List<String> lstQuestionCode) {
if (mappingQuestion == currentQuestionCode) return false; if (mappingQuestion != null && mappingQuestion.equals(currentQuestionCode)) return false;
String duplicateCode = lstQuestionCode.stream(). String duplicateCode = lstQuestionCode.stream().
filter(p -> (p.equals(mappingQuestion) && p.equals(currentQuestionCode))). filter(p -> (p.equals(mappingQuestion) && p.equals(currentQuestionCode))).
......
...@@ -12,7 +12,7 @@ import java.util.ResourceBundle; ...@@ -12,7 +12,7 @@ import java.util.ResourceBundle;
*/ */
public class BundleUtils { public class BundleUtils {
protected static final Logger logger = LoggerFactory.getLogger(BundleUtils.class); protected static final Logger logger = LoggerFactory.getLogger(BundleUtils.class);
private static volatile ResourceBundle rsConfig = null; private static ResourceBundle rsConfig = null;
private static final String GLOBAL_CONFIG = "config/globalConfig"; private static final String GLOBAL_CONFIG = "config/globalConfig";
public static String getLangString(String key, Locale... locale) { public static String getLangString(String key, Locale... locale) {
......
...@@ -47,4 +47,11 @@ public class Constants { ...@@ -47,4 +47,11 @@ public class Constants {
public interface MIME_TYPE { public interface MIME_TYPE {
String EXCEL_XLSX = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; String EXCEL_XLSX = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
} }
public interface FILE_UPLOAD_RESP_CODE {
String SUCCESS = "00";
String ERROR = "01";
String INVALID_FORMAT = "02";
String EMPTY = "03";
}
} }
...@@ -127,17 +127,10 @@ public class DataUtil { ...@@ -127,17 +127,10 @@ public class DataUtil {
} }
public static boolean safeEqual(Long obj1, Long obj2) { public static boolean safeEqual(Long obj1, Long obj2) {
if (obj1 == obj2) { if (obj1.equals(obj2)) {
return true; return true;
} }
return ((obj1 != null) && (obj2 != null) && (obj1.compareTo(obj2) == 0)); return obj2 != null && obj1.compareTo(obj2) == 0;
}
public static boolean safeEqual(String obj1, String obj2) {
if (obj1 == obj2) {
return true;
}
return ((obj1 != null) && (obj2 != null) && obj1.equals(obj2));
} }
public static String convertDateToStringDDMMYYYYHHMISS(Date datetime) { public static String convertDateToStringDDMMYYYYHHMISS(Date datetime) {
......
...@@ -16,7 +16,8 @@ public class RedisUtil { ...@@ -16,7 +16,8 @@ public class RedisUtil {
private static final Logger logger = Logger.getLogger(RedisUtil.class); private static final Logger logger = Logger.getLogger(RedisUtil.class);
private static volatile RedisUtil INSTANCE = null; // private static volatile RedisUtil INSTANCE = null;
private static RedisUtil INSTANCE = null;
private JedisCluster jedisCluster; private JedisCluster jedisCluster;
private String redisAddress; private String redisAddress;
private int redisTimeout; private int redisTimeout;
......
...@@ -4,7 +4,7 @@ import org.apache.poi.ss.usermodel.*; ...@@ -4,7 +4,7 @@ import org.apache.poi.ss.usermodel.*;
import org.apache.poi.xssf.usermodel.XSSFWorkbook; import org.apache.poi.xssf.usermodel.XSSFWorkbook;
/** /**
* @author anhvd_itsol * @author anhvd_itsol 0ad5d5fb7aa141b4ac383bcb096e2ec3faba0b1b
*/ */
public class WorkBookBuilder { public class WorkBookBuilder {
public static Font buildDefaultFont(XSSFWorkbook workbook) { public static Font buildDefaultFont(XSSFWorkbook workbook) {
......
...@@ -8,7 +8,7 @@ import lombok.Setter; ...@@ -8,7 +8,7 @@ import lombok.Setter;
@Setter @Setter
public class CustomerQueryDTO extends BaseDTO { public class CustomerQueryDTO extends BaseDTO {
String join ; String join ;
String field; Long field;
String operator; String operator;
String condition; String condition;
......
...@@ -30,7 +30,10 @@ import java.nio.file.Files; ...@@ -30,7 +30,10 @@ import java.nio.file.Files;
import java.nio.file.Path; import java.nio.file.Path;
import java.nio.file.Paths; import java.nio.file.Paths;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.*; import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Objects;
@Controller @Controller
@RequestMapping("/ipcc/customer") @RequestMapping("/ipcc/customer")
...@@ -194,7 +197,6 @@ public class CustomerController { ...@@ -194,7 +197,6 @@ public class CustomerController {
@RequestPart("customerListId") String customerListId, @RequestPart("customerListId") String customerListId,
HttpServletRequest request) { HttpServletRequest request) {
LOGGER.info("------------IMPORT FILE TEMPLATE--------------"); LOGGER.info("------------IMPORT FILE TEMPLATE--------------");
Locale locale = new Locale("vi", "VN");
try { try {
UserSession userSession = (UserSession) RedisUtil.getInstance().get(request.getHeader("X-Auth-Token")); UserSession userSession = (UserSession) RedisUtil.getInstance().get(request.getHeader("X-Auth-Token"));
if (file.isEmpty()) { if (file.isEmpty()) {
......
...@@ -119,18 +119,11 @@ public class ScenarioController { ...@@ -119,18 +119,11 @@ public class ScenarioController {
} }
String path = saveUploadFile(file); String path = saveUploadFile(file);
Map<String, Object> map = scenarioService.readAndValidateCustomer(path, scenarioId, campaignId, userSession.getCompanySiteId()); Map<String, Object> map = scenarioService.readAndValidateCustomer(path, scenarioId, campaignId, userSession.getCompanySiteId());
File fileExport = (File) map.get("file"); String code = (String) map.get("code");
String message = (String) map.get("message"); byte[] content = (byte[]) map.get("content");
ResultDTO resultDTO= new ResultDTO();
resultDTO.setErrorCode("00");
resultDTO.setDescription(message);
resultDTO.setData(fileExport);
HttpHeaders headers = new HttpHeaders();
headers.add("Content-Type", Constants.MIME_TYPE.EXCEL_XLSX);
headers.add("Message", message);
return ResponseEntity.ok() return ResponseEntity.ok()
.headers(headers) .header("Message", code)
.body(Files.readAllBytes(fileExport.toPath())); .body(content);
} catch (Exception e) { } catch (Exception e) {
logger.error(e.getMessage()); logger.error(e.getMessage());
return new ResponseEntity<>(HttpStatus.BAD_REQUEST); return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
......
server: server:
port: 1111 port: 9999
spring: spring:
application: application:
name: campaign name: campaign
......
...@@ -134,3 +134,5 @@ scenario.required.required="Require is required" ...@@ -134,3 +134,5 @@ scenario.required.required="Require is required"
scenario.default.required="Default is required" scenario.default.required="Default is required"
scenario.mappingQuestion.invalid="Mapping question invalid" scenario.mappingQuestion.invalid="Mapping question invalid"
ok="Imported"
error="Error"
...@@ -136,6 +136,9 @@ scenario.required.required="Trường Bắt buộc bắt buộc nhập" ...@@ -136,6 +136,9 @@ scenario.required.required="Trường Bắt buộc bắt buộc nhập"
scenario.default.required="Trường Mặc định bắt buộc nhập" scenario.default.required="Trường Mặc định bắt buộc nhập"
scenario.mappingQuestion.invalid="Câu hỏi liên kết không hợp lệ" scenario.mappingQuestion.invalid="Câu hỏi liên kết không hợp lệ"
ok="Thành công"
error="Thất bại"
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