Commit 01f97d3a authored by ='s avatar =

Merge remote-tracking branch 'origin/master'

# Conflicts:
#	src/main/java/com/viettel/campaign/web/rest/CampaignController.java
parents fcd4f077 efc567f0
File mode changed from 100755 to 100644
...@@ -42,69 +42,69 @@ public class CampaignJob { ...@@ -42,69 +42,69 @@ public class CampaignJob {
// @Scheduled(fixedRate = 5000) // @Scheduled(fixedRate = 5000)
// @Transactional( propagation = Propagation.REQUIRED) // @Transactional( propagation = Propagation.REQUIRED)
public void process() { public void process() {
log.info(Thread.currentThread().getName() + " The Task executed at " + dateFormat.format(new Date())); // log.info(Thread.currentThread().getName() + " The Task executed at " + dateFormat.format(new Date()));
List<ProcessConfig> list = processConfigService.findAll(); // List<ProcessConfig> list = processConfigService.findAll();
//
list.parallelStream().forEach(p -> { // list.parallelStream().forEach(p -> {
boolean isExecute = DateTimeUtil.isRun(p.getConfigValue(), p.getLastProcess()); // boolean isExecute = DateTimeUtil.isRun(p.getConfigValue(), p.getLastProcess());
switch (p.getConfigCode()){ // switch (p.getConfigCode()){
case CUSTOMER_INACTIVE_DUARATION: // case CUSTOMER_INACTIVE_DUARATION:
if(isExecute){ // if(isExecute){
List<Customer> customers = customerService.findAllByCondition(p.getSiteId(), new Date()); // List<Customer> customers = customerService.findAllByCondition(p.getSiteId(), new Date());
updateCustomer(customers); // updateCustomer(customers);
updateCustomerTime(customers); // updateCustomerTime(customers);
log.info("Cap nhat thoi gian thuc hien tien trinh cho siteId ... #{}", p.getSiteId()); // log.info("Cap nhat thoi gian thuc hien tien trinh cho siteId ... #{}", p.getSiteId());
p.setLastProcess(new Date()); // p.setLastProcess(new Date());
processConfigService.update(p); // processConfigService.update(p);
} // }
break; // break;
case CRON_EXPRESSION_CHECK_START: // case CRON_EXPRESSION_CHECK_START:
// process // // process
if(isExecute){ // if(isExecute){
List<Long> status = new ArrayList<>(); // List<Long> status = new ArrayList<>();
status.add(1L); // status.add(1L);
status.add(1L); // status.add(1L);
List<Campaign> campaigns = campaignService.findCampaignByCompanySiteIdAndStartTimeIsLessThanEqualAndStatusIn(p.getSiteId(), new Date(), status); // List<Campaign> campaigns = campaignService.findCampaignByCompanySiteIdAndStartTimeIsLessThanEqualAndStatusIn(p.getSiteId(), new Date(), status);
campaigns.parallelStream().forEach(campaign -> { // campaigns.parallelStream().forEach(campaign -> {
log.info("Chuyen trang thai chien dich ... #{} ... tu Du thao sang Trien khai", campaign.getCampaignId()); // log.info("Chuyen trang thai chien dich ... #{} ... tu Du thao sang Trien khai", campaign.getCampaignId());
campaign.setProcessStatus(1); // campaign.setProcessStatus(1);
campaign.setStatus(2L); // campaign.setStatus(2L);
campaign.setCampaignStart(new Date()); // campaign.setCampaignStart(new Date());
campaignService.updateProcess(campaign); // campaignService.updateProcess(campaign);
//write log // //write log
saveLog(campaign, 1); // saveLog(campaign, 1);
}); // });
//
log.info("Cap nhat thoi gian thuc hien tien trinh cho siteId ... #{}", p.getSiteId()); // log.info("Cap nhat thoi gian thuc hien tien trinh cho siteId ... #{}", p.getSiteId());
p.setLastProcess(new Date()); // p.setLastProcess(new Date());
processConfigService.update(p); // processConfigService.update(p);
} // }
break; // break;
case CRON_EXPRESSION_CHECK_END: // case CRON_EXPRESSION_CHECK_END:
// process // // process
if(isExecute){ // if(isExecute){
List<Long> status = new ArrayList<>(); // List<Long> status = new ArrayList<>();
status.add(2L); // status.add(2L);
status.add(3L); // status.add(3L);
List<Campaign> campaigns = campaignService.findCampaignByCompanySiteIdAndEndTimeIsLessThanEqualAndStatusIn(p.getSiteId(), new Date(), status); // List<Campaign> campaigns = campaignService.findCampaignByCompanySiteIdAndEndTimeIsLessThanEqualAndStatusIn(p.getSiteId(), new Date(), status);
campaigns.parallelStream().forEach(campaign -> { // campaigns.parallelStream().forEach(campaign -> {
log.info("Chuyen trang thai chien dich ... #{} ... sang Ket thuc", campaign.getCampaignId()); // log.info("Chuyen trang thai chien dich ... #{} ... sang Ket thuc", campaign.getCampaignId());
campaign.setStatus(4L); // campaign.setStatus(4L);
campaign.setCampaignEnd(new Date()); // campaign.setCampaignEnd(new Date());
campaignService.updateProcess(campaign); // campaignService.updateProcess(campaign);
//write log // //write log
saveLog(campaign, 2); // saveLog(campaign, 2);
}); // });
//
log.info("Cap nhat thoi gian thuc hien tien trinh cho siteId ... #{}", p.getSiteId()); // log.info("Cap nhat thoi gian thuc hien tien trinh cho siteId ... #{}", p.getSiteId());
p.setLastProcess(new Date()); // p.setLastProcess(new Date());
processConfigService.update(p); // processConfigService.update(p);
} // }
break; // break;
default: // default:
// update last check time // // update last check time
} // }
}); // });
} }
......
...@@ -17,5 +17,5 @@ public interface AgentsRepository extends JpaRepository<Agents, String> { ...@@ -17,5 +17,5 @@ public interface AgentsRepository extends JpaRepository<Agents, String> {
@Modifying @Modifying
@Query(value = "UPDATE Agents SET campaignSystemStatus = :campaignSystemStatus WHERE agentId = :agentId") @Query(value = "UPDATE Agents SET campaignSystemStatus = :campaignSystemStatus WHERE agentId = :agentId")
void updateAgentLogoutFromCampaign(@Param("agentId") Long agentId, @Param("campaignSystemStatus") String campaignSystemStatus); void updateAgentLogoutFromCampaign(@Param("agentId") String agentId, @Param("campaignSystemStatus") String campaignSystemStatus);
} }
...@@ -92,7 +92,7 @@ public class CampaignRepositoryImpl implements CampaignRepositoryCustom { ...@@ -92,7 +92,7 @@ public class CampaignRepositoryImpl implements CampaignRepositoryCustom {
sb.append(" FROM CAMPAIGN a"); sb.append(" FROM CAMPAIGN a");
sb.append(" LEFT JOIN (SELECT campaign_id, COUNT (*) AS SLKHThamgiaCD"); sb.append(" LEFT JOIN (SELECT campaign_id, COUNT (*) AS SLKHThamgiaCD");
sb.append(" FROM campaign_customer cc INNER JOIN CUSTOMER cus ON cc.CUSTOMER_ID = cus.CUSTOMER_ID"); sb.append(" FROM campaign_customer cc INNER JOIN CUSTOMER cus ON cc.CUSTOMER_ID = cus.CUSTOMER_ID");
sb.append(" WHERE 1 = 1 AND cc.IN_CAMPAIGN_STATUS = 1 AND cus.STATUS = 1"); sb.append(" WHERE 1 = 1 AND cus.STATUS = 1");
sb.append(" group by campaign_id) b"); sb.append(" group by campaign_id) b");
sb.append(" ON a.CAMPAIGN_ID = b.CAMPAIGN_ID"); sb.append(" ON a.CAMPAIGN_ID = b.CAMPAIGN_ID");
sb.append(" LEFT JOIN (SELECT campaign_id, COUNT (*) AS SLKHChuaTuongTac"); sb.append(" LEFT JOIN (SELECT campaign_id, COUNT (*) AS SLKHChuaTuongTac");
......
...@@ -28,7 +28,9 @@ public interface CampaignExecuteService { ...@@ -28,7 +28,9 @@ public interface CampaignExecuteService {
ResultDTO getExecuteCampaign(CampaignRequestDTO requestDto); ResultDTO getExecuteCampaign(CampaignRequestDTO requestDto);
ResultDTO getCall(CampaignCustomerDTO dto); ResultDTO getCustomer(CampaignCustomerDTO dto);
ResultDTO getCustomerComplete(ReceiveCustLogDTO dto);
ResultDTO getCallLog(ReceiveCustLogDTO dto); ResultDTO getCallLog(ReceiveCustLogDTO dto);
......
...@@ -4,6 +4,7 @@ import com.viettel.campaign.config.DataSourceQualify; ...@@ -4,6 +4,7 @@ import com.viettel.campaign.config.DataSourceQualify;
import com.viettel.campaign.model.acd_full.Agents; import com.viettel.campaign.model.acd_full.Agents;
import com.viettel.campaign.model.ccms_full.CampaignCustomer; import com.viettel.campaign.model.ccms_full.CampaignCustomer;
import com.viettel.campaign.model.ccms_full.ContactCustResult; import com.viettel.campaign.model.ccms_full.ContactCustResult;
import com.viettel.campaign.model.ccms_full.ReceiveCustLog;
import com.viettel.campaign.repository.acd_full.AgentsRepository; import com.viettel.campaign.repository.acd_full.AgentsRepository;
import com.viettel.campaign.repository.ccms_full.*; import com.viettel.campaign.repository.ccms_full.*;
import com.viettel.campaign.service.CampaignExecuteService; import com.viettel.campaign.service.CampaignExecuteService;
...@@ -245,9 +246,7 @@ public class CampaignExecuteServiceImp implements CampaignExecuteService { ...@@ -245,9 +246,7 @@ public class CampaignExecuteServiceImp implements CampaignExecuteService {
//TimeRangeDialMode rangeDialMode = rangeDialModeRepository.findDialModeAtCurrent(Long.parseLong(requestDto.getCampaignId()), Long.parseLong(requestDto.getCompanySiteId())); //TimeRangeDialMode rangeDialMode = rangeDialModeRepository.findDialModeAtCurrent(Long.parseLong(requestDto.getCampaignId()), Long.parseLong(requestDto.getCompanySiteId()));
if (agents.getUserStatus() != null && agents.getCampaignSystemStatus() != null) { if (agents.getUserStatus() != null && agents.getCampaignSystemStatus() != null) {
// tạm thời bỏ qua điều kiện này vì DB ACD không thực thi update được if (agents.getUserStatus().equalsIgnoreCase("CALLOUT") && agents.getCampaignSystemStatus().equalsIgnoreCase("AVAILABLE")) {
// if (agents.getUserStatus().equalsIgnoreCase("CALLOUT") && agents.getCampaignSystemStatus().equalsIgnoreCase("AVAILABLE")) {
if (agents.getCampaignSystemStatus().equalsIgnoreCase("AVAILABLE")) {
//if (zoneDialMode != null && zoneDialMode.getDialMode().equals(0) || rangeDialMode != null && rangeDialMode.getDialMode().equals(0)) //if (zoneDialMode != null && zoneDialMode.getDialMode().equals(0) || rangeDialMode != null && rangeDialMode.getDialMode().equals(0))
data.put("dialModeManual", "1"); data.put("dialModeManual", "1");
} }
...@@ -269,9 +268,7 @@ public class CampaignExecuteServiceImp implements CampaignExecuteService { ...@@ -269,9 +268,7 @@ public class CampaignExecuteServiceImp implements CampaignExecuteService {
Agents agents = agentsRepository.findByAgentId(requestDto.getAgentId()); Agents agents = agentsRepository.findByAgentId(requestDto.getAgentId());
//TimeZoneDialMode zoneDialMode = zoneDialModeRepository.findDialModeAtCurrent(Long.parseLong(requestDto.getCampaignId()), Long.parseLong(requestDto.getCompanySiteId())); //TimeZoneDialMode zoneDialMode = zoneDialModeRepository.findDialModeAtCurrent(Long.parseLong(requestDto.getCampaignId()), Long.parseLong(requestDto.getCompanySiteId()));
//TimeRangeDialMode rangeDialMode = rangeDialModeRepository.findDialModeAtCurrent(Long.parseLong(requestDto.getCampaignId()), Long.parseLong(requestDto.getCompanySiteId())); //TimeRangeDialMode rangeDialMode = rangeDialModeRepository.findDialModeAtCurrent(Long.parseLong(requestDto.getCampaignId()), Long.parseLong(requestDto.getCompanySiteId()));
// tạm thời bỏ qua điều kiện này vì DB ACD không thực thi update được if (agents.getUserStatus().equalsIgnoreCase("CALLOUT") && agents.getCampaignSystemStatus().equalsIgnoreCase("LOGOUT")) {
// if (agents.getUserStatus().equalsIgnoreCase("CALLOUT") && agents.getCampaignSystemStatus().equalsIgnoreCase("LOGOUT")) {
if (agents.getCampaignSystemStatus().equalsIgnoreCase("LOGOUT")) {
//if (zoneDialMode != null && zoneDialMode.getDialMode().equals(0) || rangeDialMode != null && rangeDialMode.getDialMode().equals(0)) //if (zoneDialMode != null && zoneDialMode.getDialMode().equals(0) || rangeDialMode != null && rangeDialMode.getDialMode().equals(0))
// update acd_full.agents table // update acd_full.agents table
Agents a = new Agents(); Agents a = new Agents();
...@@ -292,7 +289,7 @@ public class CampaignExecuteServiceImp implements CampaignExecuteService { ...@@ -292,7 +289,7 @@ public class CampaignExecuteServiceImp implements CampaignExecuteService {
} }
@Override @Override
public ResultDTO getCall(CampaignCustomerDTO dto) { public ResultDTO getCustomer(CampaignCustomerDTO dto) {
ResultDTO result = new ResultDTO(); ResultDTO result = new ResultDTO();
//Agents agents = agentsRepository.findByAgentId(dto.getAgentId()); //Agents agents = agentsRepository.findByAgentId(dto.getAgentId());
...@@ -442,6 +439,26 @@ public class CampaignExecuteServiceImp implements CampaignExecuteService { ...@@ -442,6 +439,26 @@ public class CampaignExecuteServiceImp implements CampaignExecuteService {
return result; return result;
} }
@Override
public ResultDTO getCustomerComplete(ReceiveCustLogDTO dto) {
ResultDTO result = new ResultDTO();
try {
ReceiveCustLog rclResult = custLogRepository.save(modelMapper.map(dto, ReceiveCustLog.class));
agentsRepository.updateAgentLogoutFromCampaign(dto.getAgentId().toString(), "NOT AVAILABLE");
result.setErrorCode(Constants.ApiErrorCode.SUCCESS);
result.setDescription(Constants.ApiErrorDesc.SUCCESS);
result.setData(rclResult);
} catch (Exception e) {
e.printStackTrace();
result.setErrorCode(Constants.ApiErrorCode.ERROR);
result.setDescription(Constants.ApiErrorDesc.ERROR);
}
return result;
}
@Override @Override
public ResultDTO getCallLog(ReceiveCustLogDTO dto) { public ResultDTO getCallLog(ReceiveCustLogDTO dto) {
ResultDTO result = new ResultDTO(); ResultDTO result = new ResultDTO();
...@@ -467,7 +484,7 @@ public class CampaignExecuteServiceImp implements CampaignExecuteService { ...@@ -467,7 +484,7 @@ public class CampaignExecuteServiceImp implements CampaignExecuteService {
ResultDTO result = new ResultDTO(); ResultDTO result = new ResultDTO();
try { try {
agentsRepository.updateAgentLogoutFromCampaign(Long.parseLong(dto.getAgentId()), "LOGOUT"); agentsRepository.updateAgentLogoutFromCampaign(dto.getAgentId(), "LOGOUT");
campaignAgentRepository.updateCampaignAgentSetStatus(Long.parseLong(dto.getAgentId()), Long.parseLong(dto.getCampaignId()), 0); campaignAgentRepository.updateCampaignAgentSetStatus(Long.parseLong(dto.getAgentId()), Long.parseLong(dto.getCampaignId()), 0);
result.setErrorCode(Constants.ApiErrorCode.SUCCESS); result.setErrorCode(Constants.ApiErrorCode.SUCCESS);
......
...@@ -126,6 +126,7 @@ public class ScenarioServiceImpl implements ScenarioService { ...@@ -126,6 +126,7 @@ public class ScenarioServiceImpl implements ScenarioService {
} }
return null; return null;
} }
public ResultDTO saveContacQuestResult(ContactQuestResultDTO dto) { public ResultDTO saveContacQuestResult(ContactQuestResultDTO dto) {
ResultDTO resultDTO = new ResultDTO(); ResultDTO resultDTO = new ResultDTO();
......
...@@ -10,7 +10,7 @@ import java.util.Date; ...@@ -10,7 +10,7 @@ import java.util.Date;
@Getter @Getter
@Setter @Setter
@NoArgsConstructor @NoArgsConstructor
public class ContactCustResultDTO extends BaseDTO{ public class ContactCustResultDTO extends BaseDTO {
private Long contactCustResultId; private Long contactCustResultId;
private Long companySiteId; private Long companySiteId;
private Short callStatus; private Short callStatus;
......
...@@ -4,8 +4,13 @@ import com.viettel.campaign.model.ccms_full.TimeRangeDialMode; ...@@ -4,8 +4,13 @@ import com.viettel.campaign.model.ccms_full.TimeRangeDialMode;
import com.viettel.campaign.model.ccms_full.TimeZoneDialMode; import com.viettel.campaign.model.ccms_full.TimeZoneDialMode;
import com.viettel.campaign.service.CampaignExecuteService; import com.viettel.campaign.service.CampaignExecuteService;
import com.viettel.campaign.service.CampaignService; import com.viettel.campaign.service.CampaignService;
import com.viettel.campaign.utils.BundleUtils;
import com.viettel.campaign.utils.Constants;
import com.viettel.campaign.utils.RedisUtil;
import com.viettel.campaign.web.dto.*; import com.viettel.campaign.web.dto.*;
import com.viettel.campaign.web.dto.request_dto.CampaignRequestDTO; import com.viettel.campaign.web.dto.request_dto.CampaignRequestDTO;
import com.viettel.econtact.filter.UserSession;
import org.apache.commons.io.FilenameUtils;
import org.apache.poi.xssf.usermodel.XSSFWorkbook; import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
...@@ -15,6 +20,7 @@ import org.springframework.http.HttpStatus; ...@@ -15,6 +20,7 @@ import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
...@@ -22,7 +28,8 @@ import java.io.ByteArrayOutputStream; ...@@ -22,7 +28,8 @@ import java.io.ByteArrayOutputStream;
import java.io.IOException; import java.io.IOException;
import java.io.OutputStream; import java.io.OutputStream;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Locale;
import java.util.Objects;
@RestController @RestController
@RequestMapping("/ipcc/campaign") @RequestMapping("/ipcc/campaign")
...@@ -52,10 +59,17 @@ public class CampaignController { ...@@ -52,10 +59,17 @@ public class CampaignController {
return new ResponseEntity<>(result, HttpStatus.OK); return new ResponseEntity<>(result, HttpStatus.OK);
} }
@PostMapping("/getCall") @PostMapping("/getCustomer")
@ResponseBody @ResponseBody
public ResponseEntity<ResultDTO> getCall(@RequestBody CampaignCustomerDTO requestDto) { public ResponseEntity<ResultDTO> getCustomer(@RequestBody CampaignCustomerDTO requestDto) {
ResultDTO result = campaignExecuteService.getCall(requestDto); ResultDTO result = campaignExecuteService.getCustomer(requestDto);
return new ResponseEntity<>(result, HttpStatus.OK);
}
@PostMapping("/getCustomerComplete")
@ResponseBody
public ResponseEntity<ResultDTO> getCustomerComplete(@RequestBody ReceiveCustLogDTO requestDto) {
ResultDTO result = campaignExecuteService.getCustomerComplete(requestDto);
return new ResponseEntity<>(result, HttpStatus.OK); return new ResponseEntity<>(result, HttpStatus.OK);
} }
...@@ -296,4 +310,33 @@ public class CampaignController { ...@@ -296,4 +310,33 @@ public class CampaignController {
ResultDTO result = campaignService.renewCampaign(campaignDTO); ResultDTO result = campaignService.renewCampaign(campaignDTO);
return new ResponseEntity<>(result, HttpStatus.OK); return new ResponseEntity<>(result, HttpStatus.OK);
} }
@RequestMapping(value = "/import-file", method = RequestMethod.POST)
public ResponseEntity<?> importFile(@RequestParam("file") MultipartFile file,
@RequestHeader("X-Auth-Token") String authToken) {
Locale locale = new Locale("vi", "VN");
try {
UserSession userSession = (UserSession) RedisUtil.getInstance().get(authToken);
if (file.isEmpty()) {
return new ResponseEntity<>(BundleUtils.getLangString("common.fileNotSelected"), HttpStatus.OK);
}
if (!Objects.equals(FilenameUtils.getExtension(file.getOriginalFilename()), Constants.FileType.xlsx)) {
return new ResponseEntity<>(BundleUtils.getLangString("common.fileInvalidFormat", locale), HttpStatus.OK);
}
//String path = saveUploadFile(file);
// List<CustomizeFields> dynamicHeaders = customerService.getDynamicHeader(userSession.getCompanySiteId());
// Map<String, Object> map = customerService.readAndValidateCustomer(path, dynamicHeaders, userSession, customerListId);
// File fileExport = (File) map.get("file");
// String message = (String) map.get("message");
// return ResponseEntity.ok()
// .header("Content-Type", Constants.MIME_TYPE.EXCEL_XLSX)
// .header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=template_import_customer.xlsx")
// .header("Message", message)
// .body(Files.readAllBytes(fileExport.toPath()));
return new ResponseEntity<>(null, HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getMessage(), e);
return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
}
}
} }
server: server:
port: 9999 port: 1111
spring: spring:
application: application:
name: campaign name: campaign
......
...@@ -103,3 +103,6 @@ customer.notLessThan = not less than ...@@ -103,3 +103,6 @@ customer.notLessThan = not less than
customer.importCustomer = IMPORT CUSTOMER customer.importCustomer = IMPORT CUSTOMER
customer.notice = Attention: A record is valid when Full Name is not null and one of three fields Main phone, secondary phone or email is not null customer.notice = Attention: A record is valid when Full Name is not null and one of three fields Main phone, secondary phone or email is not null
customer.fileNotSelected=Please select a file customer.fileNotSelected=Please select a file
common.fileNotSelected=Please select a file
common.fileInvalidFormat=File invalid
...@@ -105,3 +105,6 @@ customer.notLessThan = không được nhỏ hơn ...@@ -105,3 +105,6 @@ customer.notLessThan = không được nhỏ hơn
customer.importCustomer = IMPORT KHÁCH HÀNG customer.importCustomer = IMPORT KHÁCH HÀNG
customer.notice = Chú ý: 1 bản ghi được coi là hợp lệ bắt buộc phải có thông tin Họ và Tên và 1 trong 3 thông tin liên lạc (số điện thoại chính, số điện thoại phụ hoặc email) customer.notice = Chú ý: 1 bản ghi được coi là hợp lệ bắt buộc phải có thông tin Họ và Tên và 1 trong 3 thông tin liên lạc (số điện thoại chính, số điện thoại phụ hoặc email)
customer.fileNotSelected=Bạn chưa chọn file customer.fileNotSelected=Bạn chưa chọn file
common.fileNotSelected=Bạn chưa chọn file
common.fileInvalidFormat=File không hợp lệ
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