Commit a66d2070 authored by Tu Bach's avatar Tu Bach

tubn campaign execute update

parent 2f4944a3
...@@ -10,7 +10,7 @@ import java.util.Date; ...@@ -10,7 +10,7 @@ import java.util.Date;
import java.util.List; import java.util.List;
@Repository @Repository
public interface CampaignRepository extends JpaRepository<Campaign, Long> { public interface CampaignRepository extends JpaRepository<Campaign, Long>, CampaignRepositoryCustom {
List<Campaign> findAllByCompanySiteId(Long companyId); List<Campaign> findAllByCompanySiteId(Long companyId);
......
...@@ -252,8 +252,13 @@ public class CampaignExecuteRepositoryImp implements CampaignExecuteRepository { ...@@ -252,8 +252,13 @@ public class CampaignExecuteRepositoryImp implements CampaignExecuteRepository {
+ "%"); + "%");
} }
if (!DataUtil.isNullOrEmpty(dto.getCallTimeFrom())) {
query.setParameter("p_call_time_from", dto.getCallTimeFrom()); query.setParameter("p_call_time_from", dto.getCallTimeFrom());
}
if (!DataUtil.isNullOrEmpty(dto.getCallTimeTo())) {
query.setParameter("p_call_time_to", dto.getCallTimeTo()); query.setParameter("p_call_time_to", dto.getCallTimeTo());
}
// add data to parameter // add data to parameter
/*query.addScalar("contactCustResultId", new LongType()); /*query.addScalar("contactCustResultId", new LongType());
......
...@@ -388,7 +388,7 @@ public class CampaignCfgServiceImpl implements CampaignCfgService { ...@@ -388,7 +388,7 @@ public class CampaignCfgServiceImpl implements CampaignCfgService {
try { try {
if (completeValue == null || completeValue.equalsIgnoreCase("null")) if (completeValue == null || completeValue.equalsIgnoreCase("null"))
list = completeCodeRepository.getCustomerStatusByType(completeType, companySiteId); list = completeCodeRepository.getCustomerStatusByType(completeType, companySiteId);
else if (completeType == null) else if (completeType == -1)
cfg = completeCodeRepository.findByCompanySiteIdAndCompleteValue(companySiteId, completeValue); cfg = completeCodeRepository.findByCompanySiteIdAndCompleteValue(companySiteId, completeValue);
else else
list = completeCodeRepository.getCustomerStatus(completeValue, completeType, companySiteId); list = completeCodeRepository.getCustomerStatus(completeValue, completeType, companySiteId);
......
...@@ -44,7 +44,7 @@ public class CampaignExecuteServiceImp implements CampaignExecuteService { ...@@ -44,7 +44,7 @@ public class CampaignExecuteServiceImp implements CampaignExecuteService {
ReceiveCustLogRepository custLogRepository; ReceiveCustLogRepository custLogRepository;
@Autowired @Autowired
CampaignRepositoryCustom campaignRepositoryCustom; CampaignRepository campaignRepository;
@Autowired @Autowired
CampaignExecuteRepository campaignExecuteRepository; CampaignExecuteRepository campaignExecuteRepository;
...@@ -960,12 +960,15 @@ public class CampaignExecuteServiceImp implements CampaignExecuteService { ...@@ -960,12 +960,15 @@ public class CampaignExecuteServiceImp implements CampaignExecuteService {
try { try {
ContactCustResult ccr = ccResultRepository.findByContactCustResultId(contactCustResultId); ContactCustResult ccr = ccResultRepository.findByContactCustResultId(contactCustResultId);
ContactCustResultDTO dtoCCR = modelMapper.map(ccr, ContactCustResultDTO.class); ContactCustResultDTO dtoCCR = modelMapper.map(ccr, ContactCustResultDTO.class);
// if (dtoCCR.getCreateTime().) Calendar createTimeAfter24h = Calendar.getInstance();
// dtoCCR.setCheckUpdate(true); createTimeAfter24h.setTime(dtoCCR.getCreateTime());
createTimeAfter24h.add(Calendar.HOUR_OF_DAY, 4);
if (new Date().after(dtoCCR.getCreateTime()) && new Date().before(createTimeAfter24h.getTime()))
dtoCCR.setCheckUpdate(true);
resultDTO.setErrorCode(Constants.ApiErrorCode.SUCCESS); resultDTO.setErrorCode(Constants.ApiErrorCode.SUCCESS);
resultDTO.setDescription(Constants.ApiErrorDesc.SUCCESS); resultDTO.setDescription(Constants.ApiErrorDesc.SUCCESS);
resultDTO.setData(ccr); resultDTO.setData(dtoCCR);
} catch (Exception e) { } catch (Exception e) {
logger.error(e.getMessage()); logger.error(e.getMessage());
resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR); resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR);
...@@ -979,16 +982,27 @@ public class CampaignExecuteServiceImp implements CampaignExecuteService { ...@@ -979,16 +982,27 @@ public class CampaignExecuteServiceImp implements CampaignExecuteService {
public ResultDTO updateCampaignCustomer(CampaignCustomerDTO dto) { public ResultDTO updateCampaignCustomer(CampaignCustomerDTO dto) {
ResultDTO resultDTO = new ResultDTO(); ResultDTO resultDTO = new ResultDTO();
TimeZone tzClient = TimeZoneUtils.getZoneMinutes(dto.getTimezone()); TimeZone tzClient = TimeZoneUtils.getZoneMinutes(dto.getTimezone());
Campaign c = new Campaign();
CampaignCustomer cc = new CampaignCustomer();
try { try {
CampaignCustomer cc = campaignCustomerRepository.findCampaignCustomersByCampaignIdAndCustomerId(dto.getCampaignId(), dto.getCustomerId()); cc = campaignCustomerRepository.findCampaignCustomersByCampaignIdAndCustomerId(dto.getCampaignId(), dto.getCustomerId());
cc.setStatus(dto.getStatus()); if (dto.getContactStatus().equals(1)) {
cc.setAgentId(dto.getAgentId()); cc.setStatus(dto.getCallStatus().shortValue());
} else if (dto.getContactStatus().equals(2)) {
c = campaignRepository.findByCampaignId(dto.getCampaignId());
if (cc.getRecallCount().equals(c.getMaxRecall())) {
cc.setStatus((short) 4);
} else {
cc.setStatus(dto.getContactStatus());
}
}
if (dto.getRecallTime() != null) { if (dto.getRecallTime() != null) {
cc.setRecallTime(dto.getRecallTime() == null ? null : TimeZoneUtils.changeTimeZone(dto.getRecallTime(), 0L)); cc.setRecallTime(dto.getRecallTime() == null ? null : TimeZoneUtils.changeTimeZone(dto.getRecallTime(), 0L));
cc.setRecallCount(cc.getRecallCount() + 1); cc.setRecallCount(cc.getRecallCount() + 1);
} }
cc.setCallTime(dto.getCallTimeL() == null ? null : TimeZoneUtils.changeTimeZone(new Date(dto.getCallTimeL() * 1000), 0L)); cc.setCallTime(dto.getCallTimeL() == null ? null : TimeZoneUtils.changeTimeZone(new Date(dto.getCallTimeL() * 1000), 0L));
cc.setAgentId(dto.getAgentId());
resultDTO.setErrorCode(Constants.ApiErrorCode.SUCCESS); resultDTO.setErrorCode(Constants.ApiErrorCode.SUCCESS);
resultDTO.setDescription(Constants.ApiErrorDesc.SUCCESS); resultDTO.setDescription(Constants.ApiErrorDesc.SUCCESS);
......
...@@ -36,9 +36,6 @@ public class CampaignServiceImpl implements CampaignService { ...@@ -36,9 +36,6 @@ public class CampaignServiceImpl implements CampaignService {
@Autowired @Autowired
CampaignRepository campaignRepository; CampaignRepository campaignRepository;
@Autowired
CampaignRepositoryCustom campaignRepositoryCustom;
@Autowired @Autowired
TimeZoneDialModeRepository timeZoneDialModeRepository; TimeZoneDialModeRepository timeZoneDialModeRepository;
...@@ -72,13 +69,13 @@ public class CampaignServiceImpl implements CampaignService { ...@@ -72,13 +69,13 @@ public class CampaignServiceImpl implements CampaignService {
@Override @Override
@Transactional(DataSourceQualify.CCMS_FULL) @Transactional(DataSourceQualify.CCMS_FULL)
public ResultDTO search(CampaignRequestDTO requestDto) { public ResultDTO search(CampaignRequestDTO requestDto) {
return campaignRepositoryCustom.search(requestDto); return campaignRepository.search(requestDto);
} }
@Override @Override
@Transactional(DataSourceQualify.CCMS_FULL) @Transactional(DataSourceQualify.CCMS_FULL)
public ResultDTO findByCampaignCode(CampaignRequestDTO requestDTO) { public ResultDTO findByCampaignCode(CampaignRequestDTO requestDTO) {
return campaignRepositoryCustom.findByCampaignCode(requestDTO); return campaignRepository.findByCampaignCode(requestDTO);
} }
@Override @Override
...@@ -255,14 +252,14 @@ public class CampaignServiceImpl implements CampaignService { ...@@ -255,14 +252,14 @@ public class CampaignServiceImpl implements CampaignService {
@Override @Override
@Transactional(DataSourceQualify.CCMS_FULL) @Transactional(DataSourceQualify.CCMS_FULL)
public ResultDTO checkAllowStatusToPrepare(Long campaignId) { public ResultDTO checkAllowStatusToPrepare(Long campaignId) {
return campaignRepositoryCustom.checkAllowStatusToPrepare(campaignId); return campaignRepository.checkAllowStatusToPrepare(campaignId);
} }
@Override @Override
@Transactional(DataSourceQualify.CCMS_FULL) @Transactional(DataSourceQualify.CCMS_FULL)
public XSSFWorkbook exportCampaigns(CampaignRequestDTO dto) { public XSSFWorkbook exportCampaigns(CampaignRequestDTO dto) {
Locale locale = Locale.forLanguageTag("vi"); Locale locale = Locale.forLanguageTag("vi");
ResultDTO resultDTO = campaignRepositoryCustom.search(dto); ResultDTO resultDTO = campaignRepository.search(dto);
List<CampaignDTO> listData = (List<CampaignDTO>) resultDTO.getData(); List<CampaignDTO> listData = (List<CampaignDTO>) resultDTO.getData();
List<ApParam> lstType = apParamRepository.findParamByParType(CAMPAIGN_TYPE); List<ApParam> lstType = apParamRepository.findParamByParType(CAMPAIGN_TYPE);
...@@ -449,14 +446,14 @@ public class CampaignServiceImpl implements CampaignService { ...@@ -449,14 +446,14 @@ public class CampaignServiceImpl implements CampaignService {
@Override @Override
@Transactional(DataSourceQualify.CCMS_FULL) @Transactional(DataSourceQualify.CCMS_FULL)
public ResultDTO findCustomerListReallocation(CampaignRequestDTO dto) { public ResultDTO findCustomerListReallocation(CampaignRequestDTO dto) {
return campaignRepositoryCustom.findCustomerListReallocation(dto); return campaignRepository.findCustomerListReallocation(dto);
} }
// hungtt // hungtt
@Override @Override
@Transactional(DataSourceQualify.CCMS_FULL) @Transactional(DataSourceQualify.CCMS_FULL)
public ResultDTO reallocationCustomer(CampaignRequestDTO dto) { public ResultDTO reallocationCustomer(CampaignRequestDTO dto) {
return campaignRepositoryCustom.reallocationCustomer(dto); return campaignRepository.reallocationCustomer(dto);
} }
// hungtt // hungtt
...@@ -466,7 +463,7 @@ public class CampaignServiceImpl implements CampaignService { ...@@ -466,7 +463,7 @@ public class CampaignServiceImpl implements CampaignService {
Locale locale = Locale.forLanguageTag("vi"); Locale locale = Locale.forLanguageTag("vi");
Map<String, String> mapColumn = new HashMap<>(); Map<String, String> mapColumn = new HashMap<>();
mapColumn = setMapData(mapColumn, locale); mapColumn = setMapData(mapColumn, locale);
ResultDTO resultDTO = campaignRepositoryCustom.getListFieldsNotShow(dto); ResultDTO resultDTO = campaignRepository.getListFieldsNotShow(dto);
List<FieldsToShowDTO> list = (List<FieldsToShowDTO>)resultDTO.getListData(); List<FieldsToShowDTO> list = (List<FieldsToShowDTO>)resultDTO.getListData();
for (FieldsToShowDTO fieldsToShowDTO : list) { for (FieldsToShowDTO fieldsToShowDTO : list) {
if (fieldsToShowDTO.getIsFix()) { if (fieldsToShowDTO.getIsFix()) {
...@@ -487,7 +484,7 @@ public class CampaignServiceImpl implements CampaignService { ...@@ -487,7 +484,7 @@ public class CampaignServiceImpl implements CampaignService {
Locale locale = Locale.forLanguageTag("vi"); Locale locale = Locale.forLanguageTag("vi");
Map<String, String> mapColumn = new HashMap<>(); Map<String, String> mapColumn = new HashMap<>();
mapColumn = setMapData(mapColumn, locale); mapColumn = setMapData(mapColumn, locale);
ResultDTO resultDTO = campaignRepositoryCustom.getListFieldsToShow(dto); ResultDTO resultDTO = campaignRepository.getListFieldsToShow(dto);
List<FieldsToShowDTO> list = (List<FieldsToShowDTO>)resultDTO.getListData(); List<FieldsToShowDTO> list = (List<FieldsToShowDTO>)resultDTO.getListData();
for (FieldsToShowDTO fieldsToShowDTO : list) { for (FieldsToShowDTO fieldsToShowDTO : list) {
if (fieldsToShowDTO.getIsFix()) { if (fieldsToShowDTO.getIsFix()) {
...@@ -503,19 +500,19 @@ public class CampaignServiceImpl implements CampaignService { ...@@ -503,19 +500,19 @@ public class CampaignServiceImpl implements CampaignService {
@Override @Override
@Transactional(DataSourceQualify.CCMS_FULL) @Transactional(DataSourceQualify.CCMS_FULL)
public ResultDTO getCampaignCustomerList(CampaignRequestDTO dto) { public ResultDTO getCampaignCustomerList(CampaignRequestDTO dto) {
return campaignRepositoryCustom.getCampaignCustomerList(dto); return campaignRepository.getCampaignCustomerList(dto);
} }
@Override @Override
@Transactional(DataSourceQualify.CCMS_FULL) @Transactional(DataSourceQualify.CCMS_FULL)
public ResultDTO getCustomerList(CampaignRequestDTO dto) { public ResultDTO getCustomerList(CampaignRequestDTO dto) {
return campaignRepositoryCustom.getCustomerList(dto); return campaignRepository.getCustomerList(dto);
} }
@Override @Override
@Transactional(DataSourceQualify.CCMS_FULL) @Transactional(DataSourceQualify.CCMS_FULL)
public ResultDTO getCustomerChoosenList(CampaignRequestDTO dto) { public ResultDTO getCustomerChoosenList(CampaignRequestDTO dto) {
return campaignRepositoryCustom.getCustomerChoosenList(dto); return campaignRepository.getCustomerChoosenList(dto);
} }
@Override @Override
...@@ -626,19 +623,19 @@ public class CampaignServiceImpl implements CampaignService { ...@@ -626,19 +623,19 @@ public class CampaignServiceImpl implements CampaignService {
@Override @Override
@Transactional(DataSourceQualify.CCMS_FULL) @Transactional(DataSourceQualify.CCMS_FULL)
public ResultDTO getCampaignCustomerInformation(CampaignRequestDTO dto) { public ResultDTO getCampaignCustomerInformation(CampaignRequestDTO dto) {
return campaignRepositoryCustom.getCampaignCustomerInformation(dto); return campaignRepository.getCampaignCustomerInformation(dto);
} }
@Override @Override
@Transactional(DataSourceQualify.CCMS_FULL) @Transactional(DataSourceQualify.CCMS_FULL)
public ResultDTO getCustomerListInformation(CampaignRequestDTO dto) { public ResultDTO getCustomerListInformation(CampaignRequestDTO dto) {
return campaignRepositoryCustom.getCustomerListInformation(dto); return campaignRepository.getCustomerListInformation(dto);
} }
@Override @Override
@Transactional(DataSourceQualify.CCMS_FULL) @Transactional(DataSourceQualify.CCMS_FULL)
public ResultDTO getCountIndividualOnList(CampaignRequestDTO dto) { public ResultDTO getCountIndividualOnList(CampaignRequestDTO dto) {
return campaignRepositoryCustom.getCountIndividualOnList(dto); return campaignRepository.getCountIndividualOnList(dto);
} }
@Override @Override
...@@ -706,7 +703,7 @@ public class CampaignServiceImpl implements CampaignService { ...@@ -706,7 +703,7 @@ public class CampaignServiceImpl implements CampaignService {
public ResultDTO getConnectStatus(Long companySiteId) { public ResultDTO getConnectStatus(Long companySiteId) {
ResultDTO resultDTO = new ResultDTO(); ResultDTO resultDTO = new ResultDTO();
try { try {
List<ApParamDTO> list = campaignRepositoryCustom.getConnectStatus(companySiteId); List<ApParamDTO> list = campaignRepository.getConnectStatus(companySiteId);
resultDTO.setListData(list); resultDTO.setListData(list);
resultDTO.setErrorCode(Constants.ApiErrorCode.SUCCESS); resultDTO.setErrorCode(Constants.ApiErrorCode.SUCCESS);
resultDTO.setDescription(Constants.ApiErrorDesc.SUCCESS); resultDTO.setDescription(Constants.ApiErrorDesc.SUCCESS);
...@@ -750,7 +747,7 @@ public class CampaignServiceImpl implements CampaignService { ...@@ -750,7 +747,7 @@ public class CampaignServiceImpl implements CampaignService {
} }
private String generateCampaignCode(String campaignType, Short chanel) { private String generateCampaignCode(String campaignType, Short chanel) {
int year = Calendar.getInstance().get(Calendar.YEAR); int year = Calendar.getInstance().get(Calendar.YEAR);
String maxIndexStr = campaignRepositoryCustom.getMaxCampaignIndex(); String maxIndexStr = campaignRepository.getMaxCampaignIndex();
if (maxIndexStr != null) { if (maxIndexStr != null) {
Long maxIndex = Long.valueOf(maxIndexStr) + 1; Long maxIndex = Long.valueOf(maxIndexStr) + 1;
String result = campaignType + "_" + chanel + "_" + year + "_" + maxIndex.toString(); String result = campaignType + "_" + chanel + "_" + year + "_" + maxIndex.toString();
......
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