Commit 5d1f332e authored by Phạm Duy Phi's avatar Phạm Duy Phi
parents d215eceb 1e80dcc1
package com.viettel.campaign.config;
//import com.viettel.campaign.job.CampaignJob;
import com.viettel.campaign.job.CampaignJob;
import com.viettel.campaign.service.ApParamService;
import lombok.extern.slf4j.Slf4j;
......@@ -25,19 +26,19 @@ import java.util.concurrent.ScheduledFuture;
* @project campaign
*/
@Slf4j
@EnableScheduling
@Configuration
public class JobConfig implements SchedulingConfigurer {
TaskScheduler taskScheduler;
private ScheduledFuture<?> job1;
private ScheduledFuture<?> job2;
@Bean
public CampaignJob campaignJob(){
return new CampaignJob();
}
//@Slf4j
//@EnableScheduling
//@Configuration
//public class JobConfig implements SchedulingConfigurer {
//
// TaskScheduler taskScheduler;
// private ScheduledFuture<?> job1;
// private ScheduledFuture<?> job2;
//
// @Bean
// public CampaignJob campaignJob(){
// return new CampaignJob();
// }
// @Override
// public void configureTasks(ScheduledTaskRegistrar taskRegistrar) {
......@@ -52,47 +53,47 @@ 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();
}, triggerContext -> {
String cronExp = "0/1 * * * * ?";// Can be pulled from a db . This will run every minute
return new CronTrigger(cronExp).nextExecutionTime(triggerContext);
});
}
@Override
public void configureTasks(ScheduledTaskRegistrar scheduledTaskRegistrar) {
ThreadPoolTaskScheduler threadPoolTaskScheduler = new ThreadPoolTaskScheduler();
threadPoolTaskScheduler.setPoolSize(10);
threadPoolTaskScheduler.setThreadNamePrefix("scheduler-thread");
threadPoolTaskScheduler.initialize();
scheduledTaskRegistrar.setTaskScheduler(threadPoolTaskScheduler);
// scheduledTaskRegistrar.addTriggerTask(() -> campaignJob().process(), (TriggerContext triggerContext) -> yourService.getCron());
scheduledTaskRegistrar.addTriggerTask(() -> campaignJob().process(), triggerContext -> {
CronTrigger trigger = new CronTrigger("0/5 * * * * ?");
return trigger.nextExecutionTime(triggerContext);
});
}
}
// 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();
//
// }, triggerContext -> {
// String cronExp = "0/1 * * * * ?";// Can be pulled from a db . This will run every minute
// return new CronTrigger(cronExp).nextExecutionTime(triggerContext);
// });
// }
//
//
//
// @Override
// public void configureTasks(ScheduledTaskRegistrar scheduledTaskRegistrar) {
// ThreadPoolTaskScheduler threadPoolTaskScheduler = new ThreadPoolTaskScheduler();
// threadPoolTaskScheduler.setPoolSize(10);
// threadPoolTaskScheduler.setThreadNamePrefix("scheduler-thread");
// threadPoolTaskScheduler.initialize();
// scheduledTaskRegistrar.setTaskScheduler(threadPoolTaskScheduler);
//// scheduledTaskRegistrar.addTriggerTask(() -> campaignJob().process(), (TriggerContext triggerContext) -> yourService.getCron());
// scheduledTaskRegistrar.addTriggerTask(() -> campaignJob().process(), triggerContext -> {
// CronTrigger trigger = new CronTrigger("0/5 * * * * ?");
// return trigger.nextExecutionTime(triggerContext);
// });
// }
//}
package com.viettel.campaign.model.ccms_full;
import lombok.Getter;
import lombok.Setter;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.Date;
/**
* @author anhvd_itsol
*/
@Entity
@Table(name = "SCENARIO")
@Getter
@Setter
public class Scenario implements Serializable {
@Id
@NotNull
@GeneratedValue(generator = "SCENARIO_SEQ")
@SequenceGenerator(name = "SCENARIO_SEQ", sequenceName = "SCENARIO_SEQ", allocationSize = 1)
@Basic(optional = false)
@Column(name = "SCENARIO_ID")
private Long scenarioId;
@Column(name = "COMPANY_SITE_ID")
private Long companySiteId;
@Column(name = "CAMPAIGN_ID")
private Long campaignId;
@Column(name = "CODE")
private String code;
@Column(name = "DESCRIPTION")
private String description;
@Column(name = "CREATE_BY")
private String createBy;
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "CREATE_TIME")
private Date createTime;
@Column(name = "UPDATE_BY")
private Long updateBy;
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "UPDATE_TIME")
private Date updateTime;
}
package com.viettel.campaign.model.ccms_full;
import lombok.Getter;
import lombok.Setter;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.Date;
/**
* @author anhvd_itsol
*/
@Entity
@Table(name = "SCENARIO_QUESTION")
@Getter
@Setter
public class ScenarioQuestion implements Serializable {
@Id
@NotNull
@GeneratedValue(generator = "SCENARIO_QES_SEQ")
@SequenceGenerator(name = "SCENARIO_QES_SEQ", sequenceName = "SCENARIO_QES_SEQ", allocationSize = 1)
@Basic(optional = false)
@Column(name = "SCENARIO_QUESTION_ID")
private Long scenarioQuestionId;
@Column(name = "COMPANY_SITE_ID")
private Long companySiteId;
@Column(name = "CAMPAIGN_ID")
private Long campaignId;
@Column(name = "SCENARIO_ID")
private Long scenarioId;
@Column(name = "CODE")
private String code;
@Column(name = "TYPE")
private Short type;
@Column(name = "QUESTION")
private String question;
@Column(name = "ORDER_INDEX")
private Long orderIndex;
@Column(name = "STATUS")
private Short status;
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "CREATE_TIME")
private Date createTime;
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "DELETE_TIME")
private Date deleteTime;
@Column(name = "IS_REQUIRE")
private Short isRequire;
@Column(name = "IS_DEFAULT")
private Short isDefault;
@Column(name = "ANSWER_INDEX")
private Short answerIndex;
}
......@@ -27,7 +27,7 @@ public class TimeRangeDialMode implements Serializable {
@Column(name = "COMPANY_SITE_ID")
private Long companySiteId;
@Temporal(TemporalType.DATE)
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "START_TIME")
private Date startTime;
......
......@@ -17,7 +17,6 @@ public interface CampaignCompleteCodeRepository extends JpaRepository<CampaignCo
@Query(" select u FROM CampaignCompleteCode u WHERE u.status = 1")
Page<CampaignCompleteCode> findAll(Pageable pageable);
// Page<CampaignCompleteCode> findAllByStatus(String status, Pageable pageable);
@Query("FROM CampaignCompleteCode WHERE completeName LIKE concat('%', :name, '%') ")
List<CampaignCompleteCode> findByName(@Param("name") String name, Pageable pageable);
......@@ -25,24 +24,24 @@ public interface CampaignCompleteCodeRepository extends JpaRepository<CampaignCo
List<CampaignCompleteCode> findByCompleteNameContains(String name, Pageable pageable);
@Modifying
@Query("update CampaignCompleteCode c set c.status = 0 where c.campaignCompleteCodeId in (:ids)")
int deleteds(@Param("ids") List<Long> ids);
@Query("update CampaignCompleteCode c set c.status = 0 where c.campaignCompleteCodeId in (:p_ids) and c.companySiteId=:p_company_site_id" )
int deletedList(@Param("p_ids") List<Long> p_ids, @Param("p_company_site_id") Long p_company_site_id);
// @Query(value="SELECT max(completeValue) FROM CampaignCompleteCode WHERE companySiteId = :companySiteId GROUP BY companySiteId")
// Short findByMaxCompanySiteId(Long companySiteId);
List<CampaignCompleteCode> findCampaignCompleteCodesByCompanySiteId(Long companySiteId);
@Query(value="SELECT max(completeValue) FROM CampaignCompleteCode WHERE companySiteId = :companySiteId GROUP BY companySiteId")
Short findByMaxCompanySiteId(Long companySiteId);
// List<CampaignCompleteCode> findCampaignCompleteCodesByCompanySiteId(Long companySiteId);
// List<CampaignCompleteCode> findByCampaignIdContainsAndChanel(Long campaignId, String chanel);
@Modifying
@Query("update CampaignCompleteCode c set c.status = 0 where c.campaignCompleteCodeId=:p_campaignCompleteCode_list_id and c.companySiteId=:p_company_site_id")
int deleteCampaignCompleteCodeBy(@Param("p_campaignCompleteCode_list_id") Long p_campaignCompleteCode_list_id, @Param("p_company_site_id") Long p_company_site_id);
@Query(value = "FROM CampaignCompleteCode WHERE status = 1 AND completeValue = :completeValue AND completeType = :completeType AND companySiteId = :companySiteId")
List<CampaignCompleteCode> getCustomerStatus(@Param("completeValue") String completeValue, @Param("completeType") Short completeType, @Param("companySiteId") Long companySiteId);
@Query(value = "FROM CampaignCompleteCode WHERE status = 1 AND completeValue <> :completeValue AND completeType = :completeType AND companySiteId = :companySiteId")
List<CampaignCompleteCode> getCustomerStatusWithoutValue(@Param("completeValue") String completeValue, @Param("completeType") Short completeType, @Param("companySiteId") Long companySiteId);
@Query("select c from CampaignCompleteCode c where c.companySiteId =:p_company_site_id")
List<CampaignCompleteCode> findAllCampaignCompleteCode();
}
package com.viettel.campaign.repository.ccms_full;
import com.viettel.campaign.model.ccms_full.Scenario;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
/**
* @author anhvd_itsol
*/
@Repository
public interface ScenarioRepository extends JpaRepository<Scenario, Long> {
Scenario findScenarioByCampaignIdAndCompanySiteId(Long campaignId, Long companySiteId);
}
package com.viettel.campaign.repository.ccms_full;
/**
* @author anhvd_itsol
*/
public interface ScenarioRepositoryCustom {
}
package com.viettel.campaign.repository.ccms_full;
import com.viettel.campaign.config.DataSourceQualify;
import com.viettel.campaign.web.dto.ResultDTO;
import com.viettel.campaign.web.dto.UserActionLogDTO;
import org.springframework.transaction.annotation.Transactional;
/**
* @author anhvd_itsol
*/
public interface UserActionLogRepositoryCustom {
@Transactional(DataSourceQualify.CCMS_FULL)
ResultDTO insertToUserActionLog(UserActionLogDTO userActionLogDTO);
}
package com.viettel.campaign.repository.ccms_full.impl;
import com.viettel.campaign.repository.ccms_full.ScenarioRepositoryCustom;
import org.springframework.stereotype.Repository;
/**
* @author anhvd_itsol
*/
@Repository
public class ScenarioRepositoryImpl implements ScenarioRepositoryCustom {
}
......@@ -2,13 +2,14 @@ package com.viettel.campaign.service;
import com.viettel.campaign.web.dto.CampaignCompleteCodeDTO;
import com.viettel.campaign.web.dto.ResultDTO;
import com.viettel.campaign.web.dto.request_dto.CampaignCompleteCodeRequestDTO;
import java.util.List;
import java.util.Map;
public interface CampaignCompleteCodeService {
Map listAllCompleteCode(int page, int pageSize, String sort);
ResultDTO listAllCompleteCode(int page, int pageSize, String sort,Long companySiteId);
Map listCompleteCodeByName(int page, int pageSize, String sort, String name);
......@@ -16,9 +17,9 @@ public interface CampaignCompleteCodeService {
ResultDTO updateCompleteCode(CampaignCompleteCodeDTO completeCodeDTO);
ResultDTO deleteCompleteCode(CampaignCompleteCodeDTO completeCodeDTO);
ResultDTO deleteCompleteCode(CampaignCompleteCodeRequestDTO completeCodeDTO);
ResultDTO deleteList(List<Long> completeCodeDtos);
ResultDTO deleteList(CampaignCompleteCodeRequestDTO campaignCompleteCodeRequestDTO);
ResultDTO deleteById(Long id);
......@@ -28,4 +29,6 @@ public interface CampaignCompleteCodeService {
ResultDTO getListStatusWithoutType(String completeValue, Short completeType, Long companySiteId);
ResultDTO editCampaignCompleteCode (Long campaignCompleteCodeId);
}
......@@ -44,4 +44,8 @@ public interface CampaignService {
List<TimeRangeDialMode> getCampaignTimeRangeMode (Long campaignId, Long companySiteId);
List<TimeZoneDialMode> getCampaignTimeZoneMode (Long campaignId, Long companySiteId);
ResultDTO renewCampaign(CampaignDTO campaignDTO);
ResultDTO updateCampaign(CampaignDTO dto);
}
......@@ -6,6 +6,7 @@ import com.viettel.campaign.web.dto.*;
import com.viettel.campaign.web.dto.request_dto.CustomerRequestDTO;
import com.viettel.campaign.web.dto.request_dto.SearchCustomerRequestDTO;
import java.io.File;
import java.util.Date;
import java.util.List;
......@@ -57,8 +58,11 @@ public interface CustomerService {
ResultDTO getCustomerRecall(Long campaignId, Long customerId);
List<Customer> findAllByCondition(Long siteId, Date endTime);
Customer update(Customer c);
List<DynamicExcelHeaderDTO> getDynamicHeader(Long companySiteId);
void buildTemplate(Long companySiteId);
List<CustomizeFieldDTO> getCustomizeField(Long customerId);
}
package com.viettel.campaign.service;
import com.viettel.campaign.model.ccms_full.Scenario;
/**
* @author anhvd_itsol
*/
public interface ScenarioService {
Scenario findScenarioByCampaignIdAndCompanySiteId(Long campaignId, Long companySiteId);
}
......@@ -15,6 +15,7 @@ import com.viettel.campaign.utils.DataUtil;
import com.viettel.campaign.utils.WorkBookBuilder;
import com.viettel.campaign.web.dto.*;
import com.viettel.campaign.web.dto.request_dto.CampaignRequestDTO;
import oracle.jdbc.driver.Const;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.poi.ss.usermodel.*;
......@@ -228,20 +229,14 @@ public class CampaignServiceImpl implements CampaignService {
userActionLog.setObjectId(entity.getCampaignId());
if (dto.getStatus().equals((short) -1)) {
userActionLog.setActionType((short) 2);
}
else if(dto.getStatus().equals((short) 4)) {
userActionLog.setActionType((short) 7);
}
else if(dto.getStatus().equals((short) 3)) {
} else if (dto.getStatus().equals((short) 1)) {
userActionLog.setActionType((short) 3);
} else if (dto.getStatus().equals((short) 2)) {
userActionLog.setActionType((short) 5);
} else if (dto.getStatus().equals((short) 3)) {
userActionLog.setActionType((short) 4);
}
else if(dto.getStatus().equals((short) 2)) {
} else if (dto.getStatus().equals((short) 5)) {
userActionLog.setActionType((short) 7);
} else if (dto.getStatus().equals((short) 4)) {
userActionLog.setActionType((short) 4);
} else if (dto.getStatus().equals((short) 3)) {
userActionLog.setActionType((short) 5);
userActionLog.setActionType((short) 7);
}
userActionLogRepository.insertToUserActionLog(userActionLog);
......@@ -276,7 +271,7 @@ public class CampaignServiceImpl implements CampaignService {
XSSFWorkbook workbook = new XSSFWorkbook();
Sheet sheet;
CellStyle styleTitle = WorkBookBuilder.buildDefaultStyleTitle(workbook);
CellStyle styleRowHeader = WorkBookBuilder.buildDefaultStyleRowHeader(workbook);
CellStyle styleRow = WorkBookBuilder.buildDefaultStyleRow(workbook);
......@@ -340,15 +335,113 @@ public class CampaignServiceImpl implements CampaignService {
}
@Override
@Transactional(DataSourceQualify.CCMS_FULL)
public List<TimeRangeDialMode> getCampaignTimeRangeMode(Long campaignId, Long companySiteId) {
return timeRangeDialModeRepository.findTimeRangeDialModeByCampaignIdAndCompanySiteId(campaignId, companySiteId);
}
@Override
@Transactional(DataSourceQualify.CCMS_FULL)
public List<TimeZoneDialMode> getCampaignTimeZoneMode(Long campaignId, Long companySiteId) {
return timeZoneDialModeRepository.findTimeZoneDialModeByCampaignIdAndCompanySiteId(campaignId, companySiteId);
}
@Override
@Transactional(DataSourceQualify.CCMS_FULL)
public ResultDTO renewCampaign(CampaignDTO campaignDTO) {
ResultDTO resultDTO = new ResultDTO();
try {
Campaign entity = campaignRepository.findCampaignByCampaignIdAndCompanySiteId(campaignDTO.getCampaignId(), campaignDTO.getCompanySiteId());
if (entity != null) {
entity.setStatus(campaignDTO.getStatus().longValue());
entity.setUpdateTime(new Date());
entity.setUpdateBy(campaignDTO.getUpdateBy());
entity.setEndTime(campaignDTO.getEndTime());
campaignRepository.save(entity);
UserActionLogDTO userActionLog = new UserActionLogDTO();
userActionLog.setAgentId(null);
userActionLog.setSessionId(campaignDTO.getSessionId());
userActionLog.setCompanySiteId(campaignDTO.getCompanySiteId());
userActionLog.setDescription(null);
userActionLog.setStartTime(new Date());
userActionLog.setEndTime(null);
userActionLog.setObjectId(entity.getCampaignId());
userActionLog.setActionType((short) 6);
userActionLogRepository.insertToUserActionLog(userActionLog);
resultDTO.setData(entity);
resultDTO.setDescription(Constants.ApiErrorDesc.SUCCESS);
resultDTO.setErrorCode(Constants.ApiErrorCode.SUCCESS);
}
} catch (Exception ex) {
logger.error(ex.getMessage(), ex);
resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR);
resultDTO.setDescription(Constants.ApiErrorDesc.ERROR);
}
return resultDTO;
}
@Override
@Transactional(DataSourceQualify.CCMS_FULL)
public ResultDTO updateCampaign(CampaignDTO dto) {
ResultDTO resultDTO = new ResultDTO();
List<TimeZoneDialModeDTO> lstTimeZone = dto.getLstTimeZone();
List<TimeRangeDialModeDTO> lstTimeRange = dto.getLstTimeRange();
// Campaign campaignEntity = modelMapper.map(dto, Campaign.class);
Campaign campaignEntity = new Campaign();
campaignEntity.setCampaignId(dto.getCampaignId());
campaignEntity.setContent(dto.getContent());
campaignEntity.setCustomerNumber(dto.getCustomerNumber());
campaignEntity.setStartTime(dto.getStartTime());
campaignEntity.setEndTime(dto.getEndTime());
campaignEntity.setMaxRecall(dto.getMaxRecall());
campaignEntity.setRecallType(dto.getRecallType());
campaignEntity.setRecallDuration(dto.getRecallDuration());
campaignEntity.setUpdateBy(dto.getUpdateBy());
campaignEntity.setUpdateTime(dto.getUpdateTime());
campaignEntity.setCampaignType(dto.getCampaignType());
campaignEntity.setProcessStatus(null);
campaignEntity.setDialMode(null);
campaignEntity.setTimeRange(null);
campaignEntity.setCurrentTimeMode(dto.getCurrentTimeMode());
campaignEntity.setIsApplyCustLock(dto.getIsApplyCustLock());
campaignEntity.setWrapupTimeConnect(dto.getWrapupTimeConnect());
campaignEntity.setWrapupTimeDisconnect(dto.getWrapupTimeDisconnect());
campaignEntity.setPreviewTime(dto.getPreviewTime());
campaignEntity.setRateDial(dto.getRateDial());
campaignEntity.setRateMiss(dto.getRateMiss());
campaignEntity.setAvgTimeProcess(dto.getAvgTimeProcess());
campaignEntity.setMusicList(dto.getMusicList());
campaignEntity.setTimePlayMusic(dto.getTimePlayMusic());
campaignEntity.setCampaignStart(dto.getCampaignStart());
campaignEntity.setCampaignEnd(dto.getCampaignEnd());
campaignEntity.setTimeWaitAgent(null);
campaignEntity.setQuestIndex(null);
try {
// Save campaign to database
campaignRepository.save(campaignEntity);
// Save time dial
for (TimeRangeDialModeDTO timeRangeDto : lstTimeRange) {
timeRangeDto.setCampaignId(dto.getCampaignId());
TimeRangeDialMode timeRangeEntity = modelMapper.map(timeRangeDto, TimeRangeDialMode.class);
timeRangeDialModeRepository.save(timeRangeEntity);
}
for (TimeZoneDialModeDTO timeZoneDto : lstTimeZone) {
timeZoneDto.setCampaignId(dto.getCampaignId());
TimeZoneDialMode timeZoneEntity = modelMapper.map(timeZoneDto, TimeZoneDialMode.class);
timeZoneDialModeRepository.save(timeZoneEntity);
}
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;
}
private String generateCampaignCode(String campaignType, Short chanel) {
int year = Calendar.getInstance().get(Calendar.YEAR);
String maxIndexStr = campaignRepositoryCustom.getMaxCampaignIndex();
......@@ -362,9 +455,9 @@ public class CampaignServiceImpl implements CampaignService {
public String getCampaignTypeName(List<ApParam> lstApParams, String type) {
String name = "";
if(!DataUtil.isNullOrEmpty(type)) {
for(int i = 0; i < lstApParams.size(); i++) {
if(type.equals(lstApParams.get(i).getParValue())) {
if (!DataUtil.isNullOrEmpty(type)) {
for (int i = 0; i < lstApParams.size(); i++) {
if (type.equals(lstApParams.get(i).getParValue())) {
name = lstApParams.get(i).getParName();
break;
}
......
......@@ -17,6 +17,11 @@ import com.viettel.campaign.utils.SQLBuilder;
import com.viettel.campaign.web.dto.*;
import com.viettel.campaign.web.dto.request_dto.CustomerRequestDTO;
import com.viettel.campaign.web.dto.request_dto.SearchCustomerRequestDTO;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.xssf.usermodel.XSSFCell;
import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.hibernate.SQLQuery;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
......@@ -34,11 +39,17 @@ import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.ResourceUtils;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
import javax.sql.DataSource;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.OutputStream;
import java.nio.file.Files;
import java.util.*;
@Service
......@@ -682,6 +693,54 @@ public class CustomerServiceImpl implements CustomerService {
return result;
}
@Override
public List<DynamicExcelHeaderDTO> getDynamicHeader(Long companySiteId) {
List<DynamicExcelHeaderDTO> headerList;
try {
String sql = SQLBuilder.getSqlQueryById(SQLBuilder.SQL_MODULE_CAMPAIGN_CUSTOMER_MNG, "get-dynamic-header");
Map<String, Object> param = new HashMap<>();
param.put("p_company_site_id", companySiteId);
headerList = namedParameterJdbcTemplate.query(sql, param, new BeanPropertyRowMapper<>(DynamicExcelHeaderDTO.class));
} catch (Exception e) {
return null;
}
return headerList;
}
@Override
public void buildTemplate(Long companySiteId) {
try {
List<DynamicExcelHeaderDTO> headerList = getDynamicHeader(companySiteId);
FileInputStream fis = new FileInputStream(ResourceUtils.getFile("classpath:templates/import_customer_template.xlsx"));
XSSFWorkbook workbook = new XSSFWorkbook(fis);
XSSFSheet sheet = workbook.getSheetAt(0);
Row row = sheet.getRow(2);
Cell cell = row.createCell(row.getPhysicalNumberOfCells());
cell.setCellType(CellType.STRING);
cell.setCellValue("test");
FileOutputStream fos = new FileOutputStream(ResourceUtils.getFile("classpath:templates/import_customer_template.xlsx"));
workbook.write(fos);
fos.close();
workbook.close();
} catch (Exception e) {
}
}
@Override
public List<CustomizeFieldDTO> getCustomizeField(Long customerId) {
List<CustomizeFieldDTO> customizeFieldDTOList;
try {
String sql = SQLBuilder.getSqlQueryById(SQLBuilder.SQL_MODULE_CAMPAIGN_MNG, "get-customize-field");
Map<String, Object> param = new HashMap<>();
param.put("p_customer_id", customerId);
customizeFieldDTOList = namedParameterJdbcTemplate.query(sql, param, new BeanPropertyRowMapper<>(CustomizeFieldDTO.class));
} catch (Exception e) {
return null;
}
return customizeFieldDTOList;
}
@Override
@Transactional(DataSourceQualify.CCMS_FULL)
public List<CustomerListDTO> getCustomerListInfo(CampaignCustomerDTO campaignCustomerDTO) {
......
package com.viettel.campaign.service.impl;
import com.viettel.campaign.config.DataSourceQualify;
import com.viettel.campaign.model.ccms_full.Scenario;
import com.viettel.campaign.repository.ccms_full.ScenarioRepository;
import com.viettel.campaign.service.ScenarioService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
/**
* @author anhvd_itsol
*/
@Service
@Transactional(rollbackFor = Exception.class)
public class ScenarioServiceImpl implements ScenarioService {
private static final Logger logger = LogManager.getLogger(ScenarioServiceImpl.class);
@Autowired
ScenarioRepository scenarioRepository;
@Override
@Transactional(DataSourceQualify.CCMS_FULL)
public Scenario findScenarioByCampaignIdAndCompanySiteId(Long campaignId, Long companySiteId) {
try {
return scenarioRepository.findScenarioByCampaignIdAndCompanySiteId(campaignId, companySiteId);
} catch (Exception ex) {
logger.error(ex.getMessage(), ex);
}
return null;
}
}
......@@ -16,6 +16,7 @@ import org.springframework.data.domain.Sort;
public class SQLBuilder {
public static final String SQL_MODULE_CAMPAIGN_MNG = "campaign-mng";
public static final String SQL_MODULE_CAMPAIGN_STATUS_MNG = "campaign-status-mng";
public static final String SQL_MODULE_CAMPAIGN_CUSTOMER_MNG = "campaign-customer-mng";
public static String getSqlQueryById(String module,
String queryId) {
......
package com.viettel.campaign.web.dto;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import java.util.Date;
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
public class CustomizeFieldDTO {
private Long customizeFieldObjectId;
private Long objectId;
private Long customizeFieldId;
private String valueText;
private Long valueNumber;
private Date valueDate;
private Long valueCheckbox;
private Date createBy;
private Date createDate;
private String updateBy;
private Date updateDate;
private Long status;
private Long fieldOptionValueId;
private String title;
private String functionCode;
}
package com.viettel.campaign.web.dto;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import java.util.Date;
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
public class DynamicExcelHeaderDTO {
private Long customizeFieldId;
private Long siteId;
private String functionCode;
private String createBy;
private Date createDate;
private String updateBy;
private Date updateDate;
private Long status;
private String type;
private String title;
private String placeholder;
private String description;
private Long position;
private Long required;
private Long fieldOptionsId;
private String regexpForValidation;
private Long maxLength;
private Long minLength;
private Long min;
private Long max;
private Long active;
}
package com.viettel.campaign.web.dto.request_dto;
import lombok.Getter;
import lombok.Setter;
import java.util.List;
@Getter
@Setter
public class CampaignCompleteCodeRequestDTO {
List<Long> listId;
Long companySiteId;
Long campaignCompleteCodeID;
}
......@@ -3,6 +3,7 @@ package com.viettel.campaign.web.rest;
import com.viettel.campaign.web.dto.CampaignCompleteCodeDTO;
import com.viettel.campaign.web.dto.ResultDTO;
import com.viettel.campaign.service.CampaignCompleteCodeService;
import com.viettel.campaign.web.dto.request_dto.CampaignCompleteCodeRequestDTO;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
......@@ -24,8 +25,8 @@ public class CampaignCompleteCodeController {
@GetMapping("/findAll")
@ResponseBody
public ResponseEntity findAllCompleteCode(@RequestParam("page") int page, @RequestParam("pageSize") int pageSize, @RequestParam("sort") String sort) {
Map result = completeCodeService.listAllCompleteCode(page, pageSize, sort);
public ResponseEntity findAllCompleteCode(@RequestParam("page") int page, @RequestParam("pageSize") int pageSize, @RequestParam("sort") String sort,@RequestParam("companySiteId") Long companySiteId) {
ResultDTO result = completeCodeService.listAllCompleteCode(page, pageSize, sort,companySiteId);
return new ResponseEntity<>(result, HttpStatus.OK);
}
......@@ -57,7 +58,8 @@ public class CampaignCompleteCodeController {
@PostMapping("/update")
@ResponseBody
public ResultDTO updateCompleteCode(@RequestBody @Valid CampaignCompleteCodeDTO completeCodeDTO) {
public ResultDTO updateCompleteCode(@RequestBody @Valid CampaignCompleteCodeDTO completeCodeDTO
) {
ResultDTO result = new ResultDTO();
try {
result = completeCodeService.updateCompleteCode(completeCodeDTO);
......@@ -69,19 +71,31 @@ public class CampaignCompleteCodeController {
}
return result;
}
@GetMapping("/edit")
@ResponseBody
public ResultDTO findCampaignCodeById(@RequestParam("campaignCompleteCodeId") Long campaignCompleteCodeId){
ResultDTO resultDTO = new ResultDTO();
try{
resultDTO = completeCodeService.editCampaignCompleteCode(campaignCompleteCodeId);
}catch (Exception e){
resultDTO.setErrorCode("-1");
LOGGER.error(e);
}
return resultDTO;
}
@PostMapping("/delete")
@ResponseBody
public ResultDTO deleteCompleteCode(@RequestBody @Valid CampaignCompleteCodeDTO completeCodeDTO) {
public ResultDTO deleteCompleteCode(@RequestBody @Valid CampaignCompleteCodeRequestDTO campaignCompleteCodeRequestDTO) {
ResultDTO result = new ResultDTO();
result = completeCodeService.deleteCompleteCode(completeCodeDTO);
result = completeCodeService.deleteCompleteCode(campaignCompleteCodeRequestDTO);
return result;
}
@PostMapping("/listDelete")
@ResponseBody
public ResponseEntity<ResultDTO> deleteList(@RequestBody @Valid List<Long>completeCodeDtos ){
ResultDTO resultDTO = completeCodeService.deleteList(completeCodeDtos);
public ResponseEntity<ResultDTO> deleteLists(@RequestBody @Valid CampaignCompleteCodeRequestDTO campaignCompleteCodeRequestDTO){
ResultDTO resultDTO = completeCodeService.deleteList(campaignCompleteCodeRequestDTO);
return new ResponseEntity<>(resultDTO, HttpStatus.OK);
}
......
package com.viettel.campaign.web.rest;
import com.viettel.campaign.model.ccms_full.TimeRangeDialMode;
import com.viettel.campaign.model.ccms_full.TimeZoneDialMode;
import com.viettel.campaign.service.CampaignExecuteService;
import com.viettel.campaign.service.CampaignService;
import com.viettel.campaign.web.dto.CampaignDTO;
......@@ -21,6 +23,7 @@ import javax.servlet.http.HttpServletResponse;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.List;
import java.util.Map;
@RestController
......@@ -73,6 +76,20 @@ public class CampaignController {
return new ResponseEntity<>(result, HttpStatus.OK);
}
@GetMapping("/findCampaignTimeRangeMode")
@ResponseBody
public ResponseEntity<?> findCampaignTimeRangeMode(@RequestParam("campaignId") Long campaignId, @RequestParam("companySiteId") Long companySiteId) {
List<TimeRangeDialMode> list = campaignService.getCampaignTimeRangeMode(campaignId, companySiteId);
return new ResponseEntity<>(list, HttpStatus.OK);
}
@GetMapping("/findCampaignTimeZoneMode")
@ResponseBody
public ResponseEntity<?> findCampaignTimeZoneMode(@RequestParam("campaignId") Long campaignId, @RequestParam("companySiteId") Long companySiteId) {
List<TimeZoneDialMode> list = campaignService.getCampaignTimeZoneMode(campaignId, companySiteId);
return new ResponseEntity<>(list, HttpStatus.OK);
}
@PostMapping("/searchInteractiveResult")
@ResponseBody
public ResponseEntity<ResultDTO> searchInteractiveResult(@RequestBody CampaignRequestDTO dto) throws Exception {
......@@ -154,4 +171,11 @@ public class CampaignController {
headers.setContentType(MediaType.parseMediaType("application/vnd.ms-excel"));
return new ResponseEntity<byte[]>(contentReturn, headers, HttpStatus.OK);
}
@PostMapping("/updateCampaign")
@ResponseBody
public ResponseEntity<?> updateCampaign(@RequestBody CampaignDTO dto) {
ResultDTO resultDTO = campaignService.updateCampaign(dto);
return new ResponseEntity<>(resultDTO, HttpStatus.OK);
}
}
......@@ -187,10 +187,11 @@ public class CustomerController {
}
@GetMapping(value = "/downloadFileTemplate")
public ResponseEntity<byte[]> downloadFileTemplate() {
public ResponseEntity<byte[]> downloadFileTemplate(@RequestParam("companySiteId") Long companySiteId) {
LOGGER.debug("--------DOWNLOAD FILE TEMPLATE---------");
try {
File file = ResourceUtils.getFile("classpath:templates/test_download.xlsx");
customerService.buildTemplate(companySiteId);
File file = ResourceUtils.getFile("classpath:templates/import_customer_template.xlsx");
byte[] content = Files.readAllBytes(file.toPath());
return ResponseEntity.ok()
.header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=" + file.getName())
......@@ -248,6 +249,12 @@ public class CustomerController {
@RequestParam("sort") String sort,
@RequestParam("campaignId") Long campaignId,
@RequestParam("companySiteId") Long companySiteId) {
return null;//customerService.searchCustomerListInfoFromCustomerList(page, pageSize, sort, campaignId, companySiteId);
return null;// customerService.searchCustomerListInfoFromCustomerList(page, pageSize, sort, campaignId, companySiteId);
}
@PostMapping("/getCustomizeField")
public ResponseEntity<?> getCustomizeField(@RequestBody Long customerId) {
List<CustomizeFieldDTO> data = customerService.getCustomizeField(customerId);
return new ResponseEntity<>(data, HttpStatus.OK);
}
}
package com.viettel.campaign.web.rest;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* @author anhvd_itsol
*/
@RestController
@RequestMapping("/ipcc/campaign")
@CrossOrigin
public class ScenarioController {
}
select CUSTOMIZE_FIELD_ID customizeFieldId,
SITE_ID companySiteId,
FUNCTION_CODE functionCode,
CREATE_BY createBy,
CREATE_DATE createDate,
UPDATE_BY updateBy,
UPDATE_DATE updateDate,
STATUS status,
TYPE type,
TITLE title,
PLACEHOLDER placeholder,
DESCRIPTION description,
POSITION position,
REQUIRED required,
FIELD_OPTIONS_ID fieldOptionsId,
REGEXP_FOR_VALIDATION regexpForValidation,
MAX_LENGTH maxLength,
MIN min,
MAX max,
MIN_LENGTH minLength,
ACTIVE active
from customize_fields
where function_code = 'CUSTOMER'
and site_id = :p_company_site_id
\ No newline at end of file
select CUSTOMIZE_FIELD_OBJECT_ID customizeFieldObjectId,
OBJECT_ID objectId,
CUSTOMIZE_FIELDS_ID customizeFieldId,
VALUE_TEXT valueText,
VALUE_NUMBER valueNumber,
VALUE_DATE valueDate,
VALUE_CHECKBOX valueCheckbox,
CREATE_BY createBy,
CREATE_DATE createDate,
UPDATE_BY updateBy,
UPDATE_DATE updateDate,
STATUS status,
FIELD_OPTION_VALUE_ID fieldOptionValueId,
TITLE title,
FUNCTION_CODE functionCode
from customize_field_object
where function_code = 'CUSTOMER' and object_id = :p_customer_id
\ No newline at end of file
......@@ -11,7 +11,8 @@ from customer_contact cc
where cc.contact_type = 2
and status = 1
), datas as (
select c.name,
select c.customer_id customerId,
c.name,
cP.phone,
cE.email,
c.customer_type cusType,
......
SELECT
CAMPAIGN_COMPLETE_CODE_ID campaignCompleteCodeId,
IS_RECALL isRecall ,
CAMPAIGN_ID campaignId,
COMPLETE_VALUE completeValue,
COMPLETE_NAME completeName,
COMPLETE_TYPE completeType,
CAMPAIGN_TYPE campaignType,
DESCRIPTION description,
STATUS status,
COMPANY_SITE_ID companySiteId,
UPDATE_BY updateBy ,
UPDATE_AT updateAt,
CREATE_BY createBy,
CREATE_AT createAt,
IS_FINISH isFinish,
IS_LOCK isLock,
DURATION_LOCK durationLock,
CHANEL chanel
FROM CAMPAIGN_COMPLETE_CODE
where 1 = 1
AND STATUS = 1
and COMPANY_SITE_ID = :p_company_site_id
SELECT CAMPAIGN_COMPLETE_CODE_ID campaignCompleteCodeId,
IS_RECALL isRecall ,
CAMPAIGN_ID campaignId,
COMPLETE_VALUE completeValue,
COMPLETE_NAME completeName,
COMPLETE_TYPE completeType,
CAMPAIGN_TYPE campaignType,
DESCRIPTION description,
STATUS status,
COMPANY_SITE_ID companySiteId,
UPDATE_BY updateBy ,
UPDATE_AT updateAt,
CREATE_BY createBy,
CREATE_AT createAt,
IS_FINISH isFinish,
IS_LOCK isLock,
DURATION_LOCK durationLock,
CHANEL chanel
from CAMPAIGN_COMPLETE_CODE WHERE CAMPAIGN_COMPLETE_CODE_ID=:p_campaignComleteCode
SELECT max(COMPLETE_VALUE) completeValue, COMPANY_SITE_ID companySiteId from CAMPAIGN_COMPLETE_CODE where COMPANY_SITE_ID = :p_site_id GROUP BY COMPANY_SITE_ID
SELECT max(to_number(COMPLETE_VALUE)) completeValue, COMPANY_SITE_ID companySiteId from CAMPAIGN_COMPLETE_CODE where COMPANY_SITE_ID = :p_site_id GROUP BY COMPANY_SITE_ID
......@@ -17,3 +17,4 @@ LEFT JOIN AP_PARAM c ON a.CAMPAIGN_TYPE = to_char(c.AP_PARAM_ID);
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