Commit ebd8bd69 authored by Vu Duy Anh's avatar Vu Duy Anh

anhvd accept merge

parents 52dc2499 a6847133
......@@ -18,9 +18,7 @@ public interface CampaignAgentRepository extends JpaRepository<CampaignAgent, Lo
@Query(value = "SELECT campaign_agent_seq.nextval FROM DUAL", nativeQuery = true)
Long getNextSeqId();
@Modifying
@Query("UPDATE CampaignAgent SET status = :status WHERE agentId = :agentId AND campaignId = :campaignId")
void updateCampaignAgentSetStatus(@Param("agentId") Long agentId, @Param("campaignId") Long campaignId, @Param("status") Integer status);
List<CampaignAgent> findByCampaignIdAndAgentId(Long campaignId, Long agentId);
@Modifying
@Query("delete from CampaignAgent c where c.campaignAgentId in (:p_campaign_agent_id)")
......
......@@ -12,26 +12,25 @@ import org.springframework.stereotype.Repository;
import java.util.List;
@Repository
public interface CampaignCfgRepository extends JpaRepository<CampaignCfg, Long>{
public interface CampaignCfgRepository extends JpaRepository<CampaignCfg, Long> {
@Query("FROM CampaignCfg u WHERE u.status = 1 AND u.completeValue NOT IN (1,2,3,4)")
Page<CampaignCfg> findAll(Pageable pageable);
@Query("FROM CampaignCfg WHERE completeName LIKE concat('%', :name, '%') ")
List<CampaignCfg> findByName(@Param("name") String name, Pageable pageable);
List<CampaignCfg> findByCompleteNameContains(String name, Pageable pageable);
@Modifying
@Query("update CampaignCfg c set c.status = 0 where c.campaignCompleteCodeId in (:p_ids) and c.companySiteId=:p_company_site_id" )
@Query("update CampaignCfg 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);
List<CampaignCfg> findCampaignCompleteCodesByCompanySiteId(Long companySiteId);
@Query(value="SELECT max(completeValue) FROM CampaignCfg WHERE companySiteId = :companySiteId GROUP BY companySiteId")
@Query(value = "SELECT max(completeValue) FROM CampaignCfg WHERE companySiteId = :companySiteId GROUP BY companySiteId")
Short findByMaxCompanySiteId(Long companySiteId);
@Modifying
@Query("update CampaignCfg 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);
......@@ -39,6 +38,9 @@ public interface CampaignCfgRepository extends JpaRepository<CampaignCfg, Long>{
@Query(value = "FROM CampaignCfg WHERE status = 1 AND completeValue = :completeValue AND completeType = :completeType AND companySiteId = :companySiteId")
List<CampaignCfg> getCustomerStatus(@Param("completeValue") String completeValue, @Param("completeType") Short completeType, @Param("companySiteId") Long companySiteId);
@Query(value = "FROM CampaignCfg WHERE status = 1 AND completeType = :completeType AND companySiteId = :companySiteId")
List<CampaignCfg> getCustomerStatusByType(@Param("completeType") Short completeType, @Param("companySiteId") Long companySiteId);
@Query(value = "FROM CampaignCfg WHERE status = 1 AND completeValue <> :completeValue AND completeType = :completeType AND companySiteId = :companySiteId")
List<CampaignCfg> getCustomerStatusWithoutValue(@Param("completeValue") String completeValue, @Param("completeType") Short completeType, @Param("companySiteId") Long companySiteId);
......
......@@ -21,7 +21,4 @@ public interface CampaignExecuteRepository {
List<ContactCustResultDTO> getInteractiveResult(CampaignRequestDTO dto, Pageable pageable);
List<ContactCustResultDTO> getExcelInteractiveResult(CampaignRequestDTO dto);
List<ContactCustResultDTO> getContactCustById(CampaignRequestDTO dto);
//</editor-fold: hungtt>
}
package com.viettel.campaign.repository.ccms_full;
import com.viettel.campaign.config.DataSourceQualify;
import com.viettel.campaign.model.ccms_full.TimeRangeDialMode;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
......@@ -13,13 +15,21 @@ import java.util.List;
*/
@Repository
@Transactional(DataSourceQualify.CCMS_FULL)
public interface TimeRangeDialModeRepository extends JpaRepository<TimeRangeDialMode, Long> {
List<TimeRangeDialMode> findTimeRangeDialModeByCampaignIdAndCompanySiteId(Long campaignId, Long companySiteId);
@Query(value = "SELECT * FROM TIME_RANGE_DIAL_MODE r " +
"WHERE r.CAMPAIGN_ID = :campaignId AND r.COMPANY_SITE_ID = :companySiteId AND TO_CHAR(r.START_TIME,'HH24:MI:SS') <= TO_CHAR(SYSDATE,'HH24:MI:SS')", nativeQuery = true)
TimeRangeDialMode findDialModeAtCurrent(@Param("campaignId") Long campaignId, @Param("companySiteId") Long companySiteId);
@Query(value = "SELECT * " +
"FROM (SELECT Z.* " +
" FROM TIME_ZONE_DIAL_MODE Z INNER JOIN CAMPAIGN C ON Z.CAMPAIGN_ID = C.CAMPAIGN_ID " +
" WHERE Z.COMPANY_SITE_ID = :companySiteId " +
" AND Z.CAMPAIGN_ID = :campaignId " +
" AND TO_DATE(START_TIME, 'YYYY/MM/DD') <= TO_DATE(SYSDATE, 'YYYY/MM/DD') " +
" AND TO_DATE((to_char(SYSDATE, 'YYYY/MM/DD') || ' ' || Z.HOUR || ':' || Z.MINUTE || ':00'), 'YYYY/MM/DD HH24:MI:SS') <= SYSDATE " +
" ORDER BY TO_DATE((to_char(SYSDATE, 'YYYY/MM/DD') || ' ' || Z.HOUR || ':' || Z.MINUTE || ':00'), 'YYYY/MM/DD HH24:MI:SS') DESC " +
" ) WHERE ROWNUM = 1", nativeQuery = true)
TimeRangeDialMode findDialModeAtCurrent(@Param("companySiteId") Long companySiteId, @Param("campaignId") Long campaignId);
void deleteAllByCampaignIdAndCompanySiteId(Long campaignId, Long companySiteId);
}
package com.viettel.campaign.repository.ccms_full;
import com.viettel.campaign.config.DataSourceQualify;
import com.viettel.campaign.model.ccms_full.TimeZoneDialMode;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
......@@ -13,12 +15,19 @@ import java.util.List;
*/
@Repository
@Transactional(DataSourceQualify.CCMS_FULL)
public interface TimeZoneDialModeRepository extends JpaRepository<TimeZoneDialMode, Long> {
List<TimeZoneDialMode> findTimeZoneDialModeByCampaignIdAndCompanySiteId(Long campaignId, Long companySiteId);
@Query(value = "SELECT * FROM TIME_ZONE_DIAL_MODE z " +
"WHERE z.CAMPAIGN_ID = :campaignId AND z.COMPANY_SITE_ID = :companySiteId AND concat(z.HOUR, ':', z.MINUTE) <= TO_CHAR(SYSDATE,'HH24:MI')", nativeQuery = true)
@Query(value = "SELECT * " +
"FROM (SELECT R.* " +
" FROM TIME_RANGE_DIAL_MODE R " +
" WHERE R.CAMPAIGN_ID = 11 " +
" AND R.COMPANY_SITE_ID = 662691 " +
" AND TO_DATE(R.START_TIME, 'YYYY/MM/DD HH24:MI:SS') <= TO_DATE(SYSDATE, 'YYYY/MM/DD HH24:MI:SS') " +
" ORDER BY R.START_TIME DESC " +
" ) WHERE ROWNUM = 1", nativeQuery = true)
TimeZoneDialMode findDialModeAtCurrent(@Param("campaignId") Long campaignId, @Param("companySiteId") Long companySiteId);
void deleteAllByCampaignIdAndCompanySiteId(Long campaignId, Long companySiteId);
......
......@@ -443,11 +443,6 @@ public class CampaignExecuteRepositoryImp implements CampaignExecuteRepository {
return list;
}
@Override
public List<ContactCustResultDTO> getContactCustById(CampaignRequestDTO dto) {
return null;
}
private boolean isLower24Hour(Date createTime) {
Date currTime = new Date();
long diffMilSec = currTime.getTime() - createTime.getTime();
......
package com.viettel.campaign.service;
import com.viettel.campaign.model.ccms_full.ContactCustResult;
import com.viettel.campaign.web.dto.*;
import com.viettel.campaign.web.dto.request_dto.CampaignRequestDTO;
import com.viettel.econtact.filter.UserSession;
......@@ -20,9 +21,6 @@ public interface CampaignExecuteService {
XSSFWorkbook exportInteractiveResult(CampaignRequestDTO dto) throws IOException;
List<ContactCustResultDTO> getContactCustById(CampaignRequestDTO dto);
//</editor-fold>
ResultDTO searchCampaignExecute(CampaignRequestDTO requestDto, String xAuthToken);
ResultDTO getExecuteCampaign(CampaignRequestDTO requestDto);
......@@ -50,4 +48,8 @@ public interface CampaignExecuteService {
ResultDTO getCustomerRecall(Long campaignId, Long customerId);
ResultDTO getCustomerInfor(Long companySiteId, Long customerId, Long campaignId);
ResultDTO createListContacQuestResult(List<ContactQuestResultDTO> dtoList);
String getDialModeAtCurrent(Long campaignId, Long companySiteId);
}
......@@ -334,8 +334,13 @@ public class CampaignCfgServiceImpl implements CampaignCfgService {
@Transactional(DataSourceQualify.CCMS_FULL)
public ResultDTO getListStatus(String completeValue, Short completeType, Long companySiteId) {
ResultDTO resultDTO = new ResultDTO();
List<CampaignCfg> list = new ArrayList<>();
try {
List<CampaignCfg> list = completeCodeRepository.getCustomerStatus(completeValue, completeType, companySiteId);
if (completeValue == null || completeValue.equalsIgnoreCase("null"))
list = completeCodeRepository.getCustomerStatusByType(completeType, companySiteId);
else
list = completeCodeRepository.getCustomerStatus(completeValue, completeType, companySiteId);
resultDTO.setListData(list);
resultDTO.setErrorCode(Constants.ApiErrorCode.SUCCESS);
......
......@@ -2,9 +2,7 @@ package com.viettel.campaign.service.impl;
import com.viettel.campaign.config.DataSourceQualify;
import com.viettel.campaign.model.acd_full.Agents;
import com.viettel.campaign.model.ccms_full.CampaignCustomer;
import com.viettel.campaign.model.ccms_full.ContactCustResult;
import com.viettel.campaign.model.ccms_full.ReceiveCustLog;
import com.viettel.campaign.model.ccms_full.*;
import com.viettel.campaign.repository.acd_full.AgentsRepository;
import com.viettel.campaign.repository.ccms_full.*;
import com.viettel.campaign.service.CampaignExecuteService;
......@@ -20,7 +18,6 @@ import org.modelmapper.ModelMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
......@@ -71,6 +68,9 @@ public class CampaignExecuteServiceImp implements CampaignExecuteService {
@Autowired
CampaignCustomerListColumnRepository campaignCustomerListColumnRepository;
@Autowired
ContactQuestResultRepository contactQuestResultRepository;
public CampaignExecuteServiceImp() throws NoSuchAlgorithmException {
}
......@@ -235,12 +235,6 @@ public class CampaignExecuteServiceImp implements CampaignExecuteService {
return workbook;
}
@Override
@Transactional(DataSourceQualify.CCMS_FULL)
public List<ContactCustResultDTO> getContactCustById(CampaignRequestDTO dto) {
return campaignExecuteRepository.getContactCustById(dto);
}
private void writeCellContent(Row row, CellStyle rowStyle, int colNo, Object content) {
Cell cell = row.createCell(colNo);
if (content == null) {
......@@ -288,27 +282,30 @@ public class CampaignExecuteServiceImp implements CampaignExecuteService {
@Override
public ResultDTO getExecuteCampaign(CampaignRequestDTO requestDto) {
ResultDTO result = new ResultDTO();
String dialMode = getDialModeAtCurrent(Long.parseLong(requestDto.getCompanySiteId()), Long.parseLong(requestDto.getCampaignId()));
try {
Agents agents = agentsRepository.findByAgentId(requestDto.getAgentId());
//TimeZoneDialMode zoneDialMode = zoneDialModeRepository.findDialModeAtCurrent(Long.parseLong(requestDto.getCampaignId()), Long.parseLong(requestDto.getCompanySiteId()));
//TimeRangeDialMode rangeDialMode = rangeDialModeRepository.findDialModeAtCurrent(Long.parseLong(requestDto.getCampaignId()), Long.parseLong(requestDto.getCompanySiteId()));
if (agents.getUserStatus().equalsIgnoreCase("CALLOUT") && agents.getCampaignSystemStatus().equalsIgnoreCase("LOGOUT")) {
//if (zoneDialMode != null && zoneDialMode.getDialMode().equals(0) || rangeDialMode != null && rangeDialMode.getDialMode().equals(0))
// update acd_full.agents table
Agents a = new Agents();
a = agents;
a.setAgentId(requestDto.getAgentId());
a.setCampaignSystemStatus("AVAILABLE");
a.setCurrentCampaignId(Long.parseLong(requestDto.getCampaignId()));
a.setUpdateDate(new Date());
agentsRepository.save(a);
Agents agents = agentsRepository.findByAgentId(requestDto.getAgentId());
agents.setAgentId(requestDto.getAgentId());
agents.setCampaignSystemStatus("AVAILABLE");
agents.setCurrentCampaignId(Long.parseLong(requestDto.getCampaignId()));
agents.setUpdateDate(new Date());
Agents a1 = agentsRepository.save(agents);
// update ccms_full.campaign_agent table
campaignAgentRepository.updateCampaignAgentSetStatus(Long.parseLong(requestDto.getAgentId()), Long.parseLong(requestDto.getCampaignId()), 1);
List<CampaignAgent> ca = campaignAgentRepository.findByCampaignIdAndAgentId(Long.parseLong(requestDto.getCampaignId()), Long.parseLong(requestDto.getAgentId()));
for (CampaignAgent item : ca) {
item.setStatus(1);
}
List<CampaignAgent> ca1 = campaignAgentRepository.saveAll(ca);
result.setErrorCode(Constants.ApiErrorCode.SUCCESS);
result.setDescription(Constants.ApiErrorDesc.SUCCESS);
} catch (Exception e) {
e.printStackTrace();
result.setErrorCode(Constants.ApiErrorCode.ERROR);
result.setDescription(Constants.ApiErrorDesc.ERROR);
}
return result;
......@@ -317,6 +314,7 @@ public class CampaignExecuteServiceImp implements CampaignExecuteService {
@Override
public ResultDTO getCustomer(CampaignCustomerDTO dto) {
ResultDTO result = new ResultDTO();
String dialMode = getDialModeAtCurrent(dto.getCompanySiteId(), dto.getCampaignId());
//Agents agents = agentsRepository.findByAgentId(dto.getAgentId());
//TimeZoneDialMode zoneDialMode = zoneDialModeRepository.findDialModeAtCurrent(Long.parseLong(dto.getCampaignId()), Long.parseLong(dto.getCompanySiteId()));
......@@ -529,7 +527,12 @@ public class CampaignExecuteServiceImp implements CampaignExecuteService {
try {
agentsRepository.updateAgentLogoutFromCampaign(dto.getAgentId(), "LOGOUT");
campaignAgentRepository.updateCampaignAgentSetStatus(Long.parseLong(dto.getAgentId()), Long.parseLong(dto.getCampaignId()), 0);
// update ccms_full.campaign_agent table
List<CampaignAgent> ca = campaignAgentRepository.findByCampaignIdAndAgentId(Long.parseLong(dto.getCampaignId()), Long.parseLong(dto.getAgentId()));
for (CampaignAgent item : ca) {
item.setStatus(1);
}
List<CampaignAgent> ca1 = campaignAgentRepository.saveAll(ca);
result.setErrorCode(Constants.ApiErrorCode.SUCCESS);
result.setDescription(Constants.ApiErrorDesc.SUCCESS);
......@@ -685,4 +688,44 @@ public class CampaignExecuteServiceImp implements CampaignExecuteService {
}
return resultDTO;
}
@Override
public ResultDTO createListContacQuestResult(List<ContactQuestResultDTO> dtoList) {
ResultDTO resultDTO = new ResultDTO();
List<ContactQuestResult> lstContactQuestResult = new ArrayList<>();
for (ContactQuestResultDTO item : dtoList) {
lstContactQuestResult.add(modelMapper.map(item, ContactQuestResult.class));
}
try {
List<ContactQuestResult> dataReturn = contactQuestResultRepository.saveAll(lstContactQuestResult);
resultDTO.setErrorCode(Constants.ApiErrorCode.SUCCESS);
resultDTO.setDescription(Constants.ApiErrorDesc.SUCCESS);
resultDTO.setListData(dataReturn);
} catch (Exception e) {
resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR);
resultDTO.setDescription(Constants.ApiErrorDesc.ERROR);
}
return resultDTO;
}
@Override
public String getDialModeAtCurrent(Long campaignId, Long companySiteId) {
// 0: manual, 1- Preview, 2-Progressive, 3-Super Progressive, 4- Predictive
try {
TimeRangeDialMode lstTimeRange = rangeDialModeRepository.findDialModeAtCurrent(companySiteId, campaignId);
TimeZoneDialMode lstTimeZone = zoneDialModeRepository.findDialModeAtCurrent(companySiteId, campaignId);
if (lstTimeRange.getTimeRangeDialModeId() != null) {
return lstTimeRange.getDialMode().toString();
} else if (lstTimeZone.getTimeZoneDialModeId() != null) {
return lstTimeZone.getDialMode().toString();
}
} catch (Exception e) {
e.printStackTrace();
}
return "-1";
}
}
......@@ -243,6 +243,7 @@ public class DataUtil {
}
return sb.toString();
}
// public static void main(String[] args) {
//// Date rs = DataUtil.toDatefromStringFormat("20170702", "yyyyMMdd");
//// System.out.println(rs);
......@@ -263,5 +264,8 @@ public class DataUtil {
public static boolean isNullOrZero(Short value) {
return (value == null || value.equals(Short.parseShort("0")));
}
public static boolean isNullOrZero(Integer value) { return (value == null || value.equals(Integer.parseInt("0"))); }
public static boolean isNullOrZero(Integer value) {
return (value == null || value.equals(Integer.parseInt("0")));
}
}
package com.viettel.campaign.web.rest;
import com.viettel.campaign.model.ccms_full.ContactQuestResult;
import com.viettel.campaign.service.CampaignExecuteService;
import com.viettel.campaign.utils.RedisUtil;
import com.viettel.campaign.web.dto.*;
......@@ -20,6 +21,7 @@ import javax.servlet.http.HttpServletResponse;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.List;
@RestController
@RequestMapping("/ipcc/campaign/execute")
......@@ -163,4 +165,19 @@ public class CampaignExecuteController {
ResultDTO result = campaignExecuteService.getCustomerRecall(campaignId, customerId);
return new ResponseEntity<>(result, HttpStatus.OK);
}
@PostMapping("/createListContactQuestResult")
@ResponseBody
public ResponseEntity<ResultDTO> createListContactQuestResult(@RequestBody List<ContactQuestResultDTO> dtoList) {
ResultDTO result = null;
//ResultDTO result = campaignExecuteService.createListContacQuestResult(dtoList);
return new ResponseEntity<>(result, HttpStatus.OK);
}
@GetMapping("/getDialModeAtCurrent")
@ResponseBody
public ResponseEntity getDialModeAtCurrent(@RequestParam("companySiteId") Long companySiteId, @RequestParam("campaignId") Long campaignId) {
String result = campaignExecuteService.getDialModeAtCurrent(companySiteId, campaignId);
return new ResponseEntity<>(result, HttpStatus.OK);
}
}
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