Commit a66d2070 authored by Tu Bach's avatar Tu Bach

tubn campaign execute update

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