Commit c134ad00 authored by Tu Bach's avatar Tu Bach

Merge branch 'master' into tubn

# Conflicts:
#	src/main/java/com/viettel/campaign/service/impl/CampaignExecuteServiceImp.java
parents ec2a22d9 ea662bf4
......@@ -173,6 +173,20 @@
<!--<executable>true</executable>-->
<!--</configuration>-->
</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>
</build>
<repositories>
......
......@@ -48,33 +48,34 @@ public class JobConfig implements SchedulingConfigurer {
// taskRegistrar.setTaskScheduler(threadPoolTaskScheduler);
// }
private void job1(TaskScheduler scheduler) {
job1 = scheduler.schedule(() -> {
log.info("processing job1 ...");
log.info(Thread.currentThread().getName() + " The Task1 executed at " + new Date());
try {
Thread.sleep(10000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}, 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();
// private void job1(TaskScheduler scheduler) {
// job1 = scheduler.schedule(() -> {
// log.info("processing job1 ...");
// log.info(Thread.currentThread().getName() + " The Task1 executed at " + new Date());
// try {
// Thread.sleep(10000);
// } catch (InterruptedException e) {
// // TODO Auto-generated catch block
//// e.printStackTrace();
// log.error("Interrupted! ...${}", e);
// }
// }, triggerContext -> {
//
// String cronExp = "0/5 * * * * ?";// Can be pulled from a db .
// return new CronTrigger(cronExp).nextExecutionTime(triggerContext);
// });
// }
}, triggerContext -> {
String cronExp = "0/1 * * * * ?";// Can be pulled from a db . This will run every minute
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 -> {
// 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;
@Slf4j
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 CRON_EXPRESSION_CHECK_START = "CRON_EXPRESSION_CHECK_START";
private static final String CRON_EXPRESSION_CHECK_END = "CRON_EXPRESSION_CHECK_END";
......
......@@ -15,7 +15,7 @@ import java.util.Date;
public class CustomerContact implements Serializable {
@Id
@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)
@NotNull
@Column(name = "CONTACT_ID")
......
package com.viettel.campaign.model.ccms_full;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.*;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
......@@ -67,8 +64,10 @@ public class CustomizeFields implements Serializable {
@Column(name = "ACTIVE")
private Long active;
public CustomizeFields(String type, String title) {
public CustomizeFields(@NotNull String type, @NotNull String title) {
this.type = type;
this.title = title;
}
}
......@@ -27,4 +27,6 @@ public interface ScenarioAnswerRepository extends JpaRepository<ScenarioAnswer,
@Query(value = "SELECT COUNT(1) FROM ScenarioAnswer WHERE 1 = 1 AND code = :code AND scenarioQuestionId = :scenarioQuestionId AND scenarioAnswerId <> :scenarioAnswerId")
Integer countDuplicateScenarioCode(@Param("code") String code, @Param("scenarioQuestionId") Long scenarioQuestionId, @Param("scenarioAnswerId") Long scenarioAnswerId);
ScenarioAnswer findScenarioAnswerByScenarioQuestionIdAndCode(Long questionId, String code);
}
......@@ -23,4 +23,6 @@ public interface ScenarioQuestionRepository extends JpaRepository<ScenarioQuesti
Integer countDuplicateQuestionCode(@Param("code") String code, @Param("scenarioId") Long scenarioId, @Param("campaignId") Long campaignId, @Param("companySiteId") Long companySiteId);
ScenarioQuestion findScenarioQuestionByScenarioQuestionId(Long scenarioQuestionId);
ScenarioQuestion findScenarioQuestionByCodeAndCompanySiteId(String code, Long companySiteId);
}
......@@ -301,9 +301,9 @@ public class CampaignExecuteRepositoryImp implements CampaignExecuteRepository {
if (!"AGENT".equals(dto.getRoleUser())) { // ko phải nhân viên
ContactCustResultDTO.setEnableEdit(true);
} 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);
} else if ("1".equals(ContactCustResultDTO.getRecordStatus()) && isLower24Hour(ContactCustResultDTO.getCreateTime())) {
} else if (1 == ContactCustResultDTO.getRecordStatus() && isLower24Hour(ContactCustResultDTO.getCreateTime())) {
ContactCustResultDTO.setEnableEdit(true);
} else {
ContactCustResultDTO.setEnableEdit(false);
......@@ -439,8 +439,8 @@ public class CampaignExecuteRepositoryImp implements CampaignExecuteRepository {
logger.error(e.getMessage(), e);
} finally {
session.close();
return list;
}
return list;
}
private boolean isLower24Hour(Date createTime) {
......
......@@ -57,8 +57,7 @@ public class CampaignRepositoryImpl implements CampaignRepositoryCustom {
ResultDTO result = new ResultDTO();
SessionFactory sessionFactory = HibernateUtil.getSessionFactory();
Session session = sessionFactory.openSession();
session.beginTransaction();
Session session = null;
if (DataUtil.isNullOrEmpty(requestDto.getCompanySiteId())) {
result.setErrorCode(Constants.ApiErrorCode.ERROR);
......@@ -66,6 +65,9 @@ public class CampaignRepositoryImpl implements CampaignRepositoryCustom {
return result;
}
try {
session = sessionFactory.openSession();
session.beginTransaction();
StringBuilder sb = new StringBuilder();
sb.append(" SELECT");
......@@ -256,7 +258,9 @@ public class CampaignRepositoryImpl implements CampaignRepositoryCustom {
result.setDescription(Constants.ApiErrorDesc.ERROR);
logger.error(ex.getMessage(), ex);
} finally {
session.close();
if(null != session) {
session.close();
}
}
return result;
}
......@@ -267,8 +271,7 @@ public class CampaignRepositoryImpl implements CampaignRepositoryCustom {
ResultDTO result = new ResultDTO();
SessionFactory sessionFactory = HibernateUtil.getSessionFactory();
Session session = sessionFactory.openSession();
session.beginTransaction();
Session session = null;
if (DataUtil.isNullOrEmpty(requestDto.getCompanySiteId())) {
result.setErrorCode(Constants.ApiErrorCode.ERROR);
......@@ -276,6 +279,8 @@ public class CampaignRepositoryImpl implements CampaignRepositoryCustom {
return result;
}
try {
session = sessionFactory.openSession();
session.beginTransaction();
StringBuilder sb = new StringBuilder();
// sb.append(" SELECT CAMPAIGN_ID campaignId, " +
// " CAMPAIGN_CODE campaignCode, " +
......@@ -343,7 +348,7 @@ public class CampaignRepositoryImpl implements CampaignRepositoryCustom {
result.setErrorCode(Constants.ApiErrorCode.ERROR);
result.setDescription(Constants.ApiErrorDesc.ERROR);
} finally {
session.close();
if(session != null) session.close();
}
return result;
}
......@@ -353,9 +358,10 @@ public class CampaignRepositoryImpl implements CampaignRepositoryCustom {
logger.info("Start search max campaign code index::");
SessionFactory sessionFactory = HibernateUtil.getSessionFactory();
Session session = sessionFactory.openSession();
session.beginTransaction();
Session session = null;
try {
session = sessionFactory.openSession();
session.beginTransaction();
//StringBuilder sb = new StringBuilder();
//sb.append(SQLBuilder.getSqlQueryById(SQLBuilder.SQL_MODULE_CAMPAIGN_MNG, "get-max-campaign-code-index"));
StringBuilder sb = new StringBuilder();
......@@ -373,6 +379,8 @@ public class CampaignRepositoryImpl implements CampaignRepositoryCustom {
}
} catch (Exception ex) {
logger.error(ex.getMessage(), ex);
}finally {
if(session != null) session.close();
}
return null;
}
......@@ -746,10 +754,10 @@ public class CampaignRepositoryImpl implements CampaignRepositoryCustom {
SQLQuery query = session.createSQLQuery(sb.toString());
query.setParameter("p_company_site_id", dto.getCompanySiteId());
query.setParameter("p_campaign_id", dto.getCampaignId());
query.setParameter("p_cus_list_code", DataUtil.isNullOrEmpty(dto.getCustListCode()) ? null : dto.getCustListCode().trim().toUpperCase());
query.setParameter("p_cus_list_name", DataUtil.isNullOrEmpty(dto.getCustListName()) ? null : dto.getCustListName().trim().toUpperCase());
query.setParameter("p_to_date", DataUtil.isNullOrEmpty(dto.getCustListCode()) ? null : dto.getCreateTimeTo());
query.setParameter("p_from_date", DataUtil.isNullOrEmpty(dto.getCustListCode()) ? null : dto.getCreateTimeFr());
query.setParameter("p_cus_list_code", DataUtil.isNullOrEmpty(dto.getCustListCode()) ? null : dto.getCustListCode().trim().replace("\\", "\\\\").replaceAll("%", "\\%").replaceAll("_", "\\_").toUpperCase());
query.setParameter("p_cus_list_name", DataUtil.isNullOrEmpty(dto.getCustListName()) ? null : dto.getCustListName().trim().replace("\\", "\\\\").replaceAll("%", "\\%").replaceAll("_", "\\_").toUpperCase());
query.setParameter("p_to_date", DataUtil.isNullOrEmpty(dto.getCreateTimeTo()) ? null : dto.getCreateTimeTo());
query.setParameter("p_from_date", DataUtil.isNullOrEmpty(dto.getCreateTimeFr()) ? null : dto.getCreateTimeFr());
query.setParameter("p_page_number", dto.getPage());
query.setParameter("p_page_size", dto.getPageSize());
......@@ -779,8 +787,8 @@ public class CampaignRepositoryImpl implements CampaignRepositoryCustom {
resultDTO.setDescription(Constants.ApiErrorDesc.ERROR);
} finally {
session.close();
return resultDTO;
}
return resultDTO;
}
@Override
......
......@@ -7,6 +7,7 @@ import com.viettel.econtact.filter.UserSession;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.stereotype.Service;
import java.io.IOException;
import java.util.List;
@Service
......@@ -18,7 +19,7 @@ public interface CampaignExecuteService {
ResultDTO searchInteractiveResult(CampaignRequestDTO dto);
XSSFWorkbook exportInteractiveResult(CampaignRequestDTO dto);
XSSFWorkbook exportInteractiveResult(CampaignRequestDTO dto) throws IOException;
ResultDTO searchCampaignExecute(CampaignRequestDTO requestDto, String xAuthToken);
......
......@@ -5,12 +5,11 @@ 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.web.dto.*;
import com.viettel.campaign.web.dto.request_dto.CustomerQueryDTO;
import com.viettel.campaign.web.dto.request_dto.CustomerRequestDTO;
import com.viettel.campaign.web.dto.request_dto.CustomizeRequestDTo;
import com.viettel.campaign.web.dto.request_dto.SearchCustomerRequestDTO;
import com.viettel.econtact.filter.UserSession;
import java.io.IOException;
import java.util.Date;
import java.util.List;
import java.util.Map;
......@@ -65,6 +64,8 @@ public interface CustomerService {
ResultDTO addCustomerToCampaign(CampaignCustomerDTO campaignCustomerDTO);
ResultDTO getDataForCombobox(CampaignCustomerDTO campaignCustomerDTO);
// ------------ customer ------------ //
......@@ -76,9 +77,9 @@ public interface CustomerService {
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);
......
......@@ -6,6 +6,7 @@ import com.viettel.econtact.filter.UserSession;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.web.bind.annotation.RequestParam;
import java.io.IOException;
import java.util.List;
import java.util.Map;
......@@ -24,7 +25,7 @@ public interface ScenarioService {
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 {
ResultDTO resultDTO = new ResultDTO();
SessionFactory sessionFactory = HibernateUtil.getSessionFactory();
Session session = sessionFactory.openSession();
session.beginTransaction();
Session session = null;
if (DataUtil.isNullOrZero(companySiteId)) {
resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR);
......@@ -76,6 +75,8 @@ public class AgentsServiceImpl implements AgentsService {
}
try {
session = sessionFactory.openSession();
session.beginTransaction();
// StringBuilder sb = new StringBuilder();
// sb.append(SQLBuilder.getSqlQueryById(SQLBuilder.SQL_MODULE_CAMPAIGN_MNG, "campaign-agents-by-params"));
......@@ -136,7 +137,7 @@ public class AgentsServiceImpl implements AgentsService {
resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR);
resultDTO.setDescription(Constants.ApiErrorDesc.ERROR);
} finally {
session.close();
if(session != null) session.close();
}
return resultDTO;
......@@ -147,8 +148,7 @@ public class AgentsServiceImpl implements AgentsService {
ResultDTO resultDTO = new ResultDTO();
SessionFactory sessionFactory = HibernateUtil.getSessionFactory();
Session session = sessionFactory.openSession();
session.beginTransaction();
Session session = null;
if (DataUtil.isNullOrZero(companySiteId)) {
resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR);
......@@ -157,6 +157,8 @@ public class AgentsServiceImpl implements AgentsService {
}
try {
session = sessionFactory.openSession();
session.beginTransaction();
// StringBuilder sb = new StringBuilder();
// sb.append(SQLBuilder.getSqlQueryById(SQLBuilder.SQL_MODULE_CAMPAIGN_MNG, "campaign-agents-by-params"));
StringBuilder sb = new StringBuilder();
......@@ -214,7 +216,7 @@ public class AgentsServiceImpl implements AgentsService {
resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR);
resultDTO.setDescription(Constants.ApiErrorDesc.ERROR);
} finally {
session.close();
if(session != null) session.close();
}
return resultDTO;
......@@ -278,8 +280,7 @@ public class AgentsServiceImpl implements AgentsService {
ResultDTO resultDTO = new ResultDTO();
SessionFactory sessionFactory = HibernateUtil.getSessionFactory();
Session session = sessionFactory.openSession();
session.beginTransaction();
Session session = null;
if (DataUtil.isNullOrZero(companySiteId)) {
resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR);
......@@ -288,6 +289,8 @@ public class AgentsServiceImpl implements AgentsService {
}
try {
session = sessionFactory.openSession();
session.beginTransaction();
// StringBuilder sqlStrBuilder = new StringBuilder();
// sqlStrBuilder.append(SQLBuilder.getSqlQueryById(SQLBuilder.SQL_MODULE_CAMPAIGN_MNG, "campaign-agents-by-params"));
StringBuilder sqlStrBuilder = new StringBuilder();
......@@ -372,7 +375,7 @@ public class AgentsServiceImpl implements AgentsService {
resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR);
resultDTO.setDescription(Constants.ApiErrorDesc.ERROR);
} finally {
session.close();
if(session != null) session.close();
}
return resultDTO;
......@@ -383,8 +386,10 @@ public class AgentsServiceImpl implements AgentsService {
ResultDTO resultDTO = new ResultDTO();
SessionFactory sessionFactory = HibernateUtil.getSessionFactory();
Session session = sessionFactory.openSession();
session.beginTransaction();
// Session session = sessionFactory.openSession();
// session.beginTransaction();
Session session = null;
if (DataUtil.isNullOrZero(companySiteId)) {
resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR);
......@@ -393,6 +398,8 @@ public class AgentsServiceImpl implements AgentsService {
}
try {
session = sessionFactory.openSession();
session.beginTransaction();
// StringBuilder sb = new StringBuilder();
// sb.append(SQLBuilder.getSqlQueryById(SQLBuilder.SQL_MODULE_CAMPAIGN_MNG, "campaign-agents-by-params"));
StringBuilder sb = new StringBuilder();
......@@ -477,7 +484,9 @@ public class AgentsServiceImpl implements AgentsService {
resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR);
resultDTO.setDescription(Constants.ApiErrorDesc.ERROR);
} finally {
session.close();
if(null != session){
session.close();
}
}
return resultDTO;
......
......@@ -44,8 +44,7 @@ public class CampaignCfgServiceImpl implements CampaignCfgService {
ResultDTO resultDTO = new ResultDTO();
SessionFactory sessionFactory = HibernateUtil.getSessionFactory();
Session session = sessionFactory.openSession();
session.beginTransaction();
Session session = null;
if (DataUtil.isNullOrZero(companySiteId)) {
resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR);
......@@ -54,6 +53,8 @@ public class CampaignCfgServiceImpl implements CampaignCfgService {
}
try {
session = sessionFactory.openSession();
session.beginTransaction();
// StringBuilder sqlStrBuilder = new StringBuilder();
// sqlStrBuilder.append(SQLBuilder.getSqlQueryById(SQLBuilder.SQL_MODULE_CAMPAIGN_STATUS_MNG, "findAll-CampaignCompleteCode"));
StringBuilder sb = new StringBuilder();
......@@ -132,7 +133,7 @@ public class CampaignCfgServiceImpl implements CampaignCfgService {
resultDTO.setDescription(Constants.ApiErrorDesc.ERROR);
logger.error(e.getMessage(), e);
} finally {
session.close();
if(session != null) session.close();
}
return resultDTO;
......@@ -278,8 +279,7 @@ public class CampaignCfgServiceImpl implements CampaignCfgService {
ResultDTO resultDTO = new ResultDTO();
SessionFactory sessionFactory = HibernateUtil.getSessionFactory();
Session session = sessionFactory.openSession();
session.beginTransaction();
Session session = null;
if (DataUtil.isNullOrZero(completeCodeDTO.getCompanySiteId())) {
resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR);
......@@ -288,6 +288,8 @@ public class CampaignCfgServiceImpl implements CampaignCfgService {
}
try {
session = sessionFactory.openSession();
session.beginTransaction();
// StringBuilder sqlStrBuilder = new StringBuilder();
// sqlStrBuilder.append(SQLBuilder.getSqlQueryById(SQLBuilder.SQL_MODULE_CAMPAIGN_STATUS_MNG, "get-max-value-completevalue"));
StringBuilder sb = new StringBuilder();
......@@ -323,9 +325,9 @@ public class CampaignCfgServiceImpl implements CampaignCfgService {
resultDTO.setDescription(Constants.ApiErrorDesc.ERROR);
logger.error(e.getMessage(), e);
} finally {
session.close();
return resultDTO;
if(session != null) session.close();
}
return resultDTO;
}
@Override
......@@ -372,8 +374,7 @@ public class CampaignCfgServiceImpl implements CampaignCfgService {
ResultDTO resultDTO = new ResultDTO();
SessionFactory sessionFactory = HibernateUtil.getSessionFactory();
Session session = sessionFactory.openSession();
session.beginTransaction();
Session session = null;
if (DataUtil.isNullOrZero(campaignCompleteCodeId)) {
resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR);
......@@ -382,6 +383,8 @@ public class CampaignCfgServiceImpl implements CampaignCfgService {
}
try {
session = sessionFactory.openSession();
session.beginTransaction();
// StringBuilder sqlStrBuilder = new StringBuilder();
// sqlStrBuilder.append(SQLBuilder.getSqlQueryById(SQLBuilder.SQL_MODULE_CAMPAIGN_STATUS_MNG,"findCampaignCodeById"));
......@@ -442,7 +445,7 @@ public class CampaignCfgServiceImpl implements CampaignCfgService {
resultDTO.setDescription(Constants.ApiErrorDesc.ERROR);
logger.error(e.getMessage(), e);
} finally {
session.close();
if(session != null) session.close();
}
return resultDTO;
......
......@@ -596,7 +596,7 @@ public class CampaignServiceImpl implements CampaignService {
// Cap nhat cac truong da co san
for (FieldsToShowDTO fieldsToShowDTO : list) {
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());
entity.setOrderIndex((long) (list.indexOf(fieldsToShowDTO) + 1));
campaignCustomerListColumnRepository.save(entity);
......
......@@ -12,7 +12,7 @@ import java.util.ResourceBundle;
*/
public class BundleUtils {
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";
public static String getLangString(String key, Locale... locale) {
......
......@@ -47,4 +47,11 @@ public class Constants {
public interface MIME_TYPE {
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 {
}
public static boolean safeEqual(Long obj1, Long obj2) {
if (obj1 == obj2) {
if (obj1.equals(obj2)) {
return true;
}
return ((obj1 != null) && (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));
return obj2 != null && obj1.compareTo(obj2) == 0;
}
public static String convertDateToStringDDMMYYYYHHMISS(Date datetime) {
......
......@@ -16,7 +16,8 @@ public class RedisUtil {
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 String redisAddress;
private int redisTimeout;
......
......@@ -4,7 +4,7 @@ import org.apache.poi.ss.usermodel.*;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
/**
* @author anhvd_itsol
* @author anhvd_itsol 0ad5d5fb7aa141b4ac383bcb096e2ec3faba0b1b
*/
public class WorkBookBuilder {
public static Font buildDefaultFont(XSSFWorkbook workbook) {
......
......@@ -30,6 +30,6 @@ public class CampaignCustomerDTO extends BaseDTO{
private Long complainId;
private String lstCustomerId;
private List<CustomerQueryDTO> listQuery;
private Long field;
}
package com.viettel.campaign.web.dto;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
@Setter
@Getter
@NoArgsConstructor
@AllArgsConstructor
public class ComboboxDTO {
private String key;
private String value;
}
......@@ -6,6 +6,7 @@ import lombok.Setter;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
* @author anhvd_itsol
......
......@@ -8,7 +8,7 @@ import lombok.Setter;
@Setter
public class CustomerQueryDTO extends BaseDTO {
String join ;
String field;
Long field;
String operator;
String condition;
......
......@@ -30,7 +30,10 @@ import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Objects;
@Controller
@RequestMapping("/ipcc/customer")
......@@ -194,7 +197,6 @@ public class CustomerController {
@RequestPart("customerListId") String customerListId,
HttpServletRequest request) {
LOGGER.info("------------IMPORT FILE TEMPLATE--------------");
Locale locale = new Locale("vi", "VN");
try {
UserSession userSession = (UserSession) RedisUtil.getInstance().get(request.getHeader("X-Auth-Token"));
if (file.isEmpty()) {
......@@ -257,6 +259,13 @@ public class CustomerController {
return new ResponseEntity<>(resultDTO, HttpStatus.OK);
}
@PostMapping("/getDataForCombobox")
@ResponseBody
public ResponseEntity<?> getDataForCombobox(@RequestBody CampaignCustomerDTO dto) {
ResultDTO resultDTO = customerService.getDataForCombobox(dto);
return new ResponseEntity<>(resultDTO, HttpStatus.OK);
}
private String saveUploadFile(MultipartFile file) {
......@@ -299,6 +308,7 @@ public class CustomerController {
return ResponseEntity.status(HttpStatus.OK)
.body(result);
}
@PostMapping("/getCustomizeFields")
@ResponseBody
public ResponseEntity<?> getListCustomer(@RequestBody CustomizeFieldsDTO customizeRequestDTo) {
......
......@@ -119,18 +119,11 @@ public class ScenarioController {
}
String path = saveUploadFile(file);
Map<String, Object> map = scenarioService.readAndValidateCustomer(path, scenarioId, campaignId, userSession.getCompanySiteId());
File fileExport = (File) map.get("file");
String message = (String) map.get("message");
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);
String code = (String) map.get("code");
byte[] content = (byte[]) map.get("content");
return ResponseEntity.ok()
.headers(headers)
.body(Files.readAllBytes(fileExport.toPath()));
.header("Message", code)
.body(content);
} catch (Exception e) {
logger.error(e.getMessage());
return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
......
......@@ -134,3 +134,5 @@ scenario.required.required="Require is required"
scenario.default.required="Default is required"
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"
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ệ"
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