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 {
// @Scheduled(fixedRate = 5000)
// @Transactional( propagation = Propagation.REQUIRED)
public void process() {
log.info(Thread.currentThread().getName() + " The Task executed at " + dateFormat.format(new Date()));
List<ProcessConfig> list = processConfigService.findAll();
list.parallelStream().forEach(p -> {
boolean isExecute = DateTimeUtil.isRun(p.getConfigValue(), p.getLastProcess());
switch (p.getConfigCode()){
case CUSTOMER_INACTIVE_DUARATION:
if(isExecute){
List<Customer> customers = customerService.findAllByCondition(p.getSiteId(), new Date());
updateCustomer(customers);
updateCustomerTime(customers);
log.info("Cap nhat thoi gian thuc hien tien trinh cho siteId ... #{}", p.getSiteId());
p.setLastProcess(new Date());
processConfigService.update(p);
}
break;
case CRON_EXPRESSION_CHECK_START:
// process
if(isExecute){
List<Long> status = new ArrayList<>();
status.add(1L);
status.add(1L);
List<Campaign> campaigns = campaignService.findCampaignByCompanySiteIdAndStartTimeIsLessThanEqualAndStatusIn(p.getSiteId(), new Date(), status);
campaigns.parallelStream().forEach(campaign -> {
log.info("Chuyen trang thai chien dich ... #{} ... tu Du thao sang Trien khai", campaign.getCampaignId());
campaign.setProcessStatus(1);
campaign.setStatus(2L);
campaign.setCampaignStart(new Date());
campaignService.updateProcess(campaign);
//write log
saveLog(campaign, 1);
});
log.info("Cap nhat thoi gian thuc hien tien trinh cho siteId ... #{}", p.getSiteId());
p.setLastProcess(new Date());
processConfigService.update(p);
}
break;
case CRON_EXPRESSION_CHECK_END:
// process
if(isExecute){
List<Long> status = new ArrayList<>();
status.add(2L);
status.add(3L);
List<Campaign> campaigns = campaignService.findCampaignByCompanySiteIdAndEndTimeIsLessThanEqualAndStatusIn(p.getSiteId(), new Date(), status);
campaigns.parallelStream().forEach(campaign -> {
log.info("Chuyen trang thai chien dich ... #{} ... sang Ket thuc", campaign.getCampaignId());
campaign.setStatus(4L);
campaign.setCampaignEnd(new Date());
campaignService.updateProcess(campaign);
//write log
saveLog(campaign, 2);
});
log.info("Cap nhat thoi gian thuc hien tien trinh cho siteId ... #{}", p.getSiteId());
p.setLastProcess(new Date());
processConfigService.update(p);
}
break;
default:
// update last check time
}
});
// log.info(Thread.currentThread().getName() + " The Task executed at " + dateFormat.format(new Date()));
// List<ProcessConfig> list = processConfigService.findAll();
//
// list.parallelStream().forEach(p -> {
// boolean isExecute = DateTimeUtil.isRun(p.getConfigValue(), p.getLastProcess());
// switch (p.getConfigCode()){
// case CUSTOMER_INACTIVE_DUARATION:
// if(isExecute){
// List<Customer> customers = customerService.findAllByCondition(p.getSiteId(), new Date());
// updateCustomer(customers);
// updateCustomerTime(customers);
// log.info("Cap nhat thoi gian thuc hien tien trinh cho siteId ... #{}", p.getSiteId());
// p.setLastProcess(new Date());
// processConfigService.update(p);
// }
// break;
// case CRON_EXPRESSION_CHECK_START:
// // process
// if(isExecute){
// List<Long> status = new ArrayList<>();
// status.add(1L);
// status.add(1L);
// List<Campaign> campaigns = campaignService.findCampaignByCompanySiteIdAndStartTimeIsLessThanEqualAndStatusIn(p.getSiteId(), new Date(), status);
// campaigns.parallelStream().forEach(campaign -> {
// log.info("Chuyen trang thai chien dich ... #{} ... tu Du thao sang Trien khai", campaign.getCampaignId());
// campaign.setProcessStatus(1);
// campaign.setStatus(2L);
// campaign.setCampaignStart(new Date());
// campaignService.updateProcess(campaign);
// //write log
// saveLog(campaign, 1);
// });
//
// log.info("Cap nhat thoi gian thuc hien tien trinh cho siteId ... #{}", p.getSiteId());
// p.setLastProcess(new Date());
// processConfigService.update(p);
// }
// break;
// case CRON_EXPRESSION_CHECK_END:
// // process
// if(isExecute){
// List<Long> status = new ArrayList<>();
// status.add(2L);
// status.add(3L);
// List<Campaign> campaigns = campaignService.findCampaignByCompanySiteIdAndEndTimeIsLessThanEqualAndStatusIn(p.getSiteId(), new Date(), status);
// campaigns.parallelStream().forEach(campaign -> {
// log.info("Chuyen trang thai chien dich ... #{} ... sang Ket thuc", campaign.getCampaignId());
// campaign.setStatus(4L);
// campaign.setCampaignEnd(new Date());
// campaignService.updateProcess(campaign);
// //write log
// saveLog(campaign, 2);
// });
//
// log.info("Cap nhat thoi gian thuc hien tien trinh cho siteId ... #{}", p.getSiteId());
// p.setLastProcess(new Date());
// processConfigService.update(p);
// }
// break;
// default:
// // update last check time
// }
// });
}
......
......@@ -17,5 +17,5 @@ public interface AgentsRepository extends JpaRepository<Agents, String> {
@Modifying
@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 {
sb.append(" FROM CAMPAIGN a");
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(" 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(" ON a.CAMPAIGN_ID = b.CAMPAIGN_ID");
sb.append(" LEFT JOIN (SELECT campaign_id, COUNT (*) AS SLKHChuaTuongTac");
......
......@@ -28,7 +28,9 @@ public interface CampaignExecuteService {
ResultDTO getExecuteCampaign(CampaignRequestDTO requestDto);
ResultDTO getCall(CampaignCustomerDTO dto);
ResultDTO getCustomer(CampaignCustomerDTO dto);
ResultDTO getCustomerComplete(ReceiveCustLogDTO dto);
ResultDTO getCallLog(ReceiveCustLogDTO dto);
......
......@@ -4,6 +4,7 @@ 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.repository.acd_full.AgentsRepository;
import com.viettel.campaign.repository.ccms_full.*;
import com.viettel.campaign.service.CampaignExecuteService;
......@@ -245,9 +246,7 @@ public class CampaignExecuteServiceImp implements CampaignExecuteService {
//TimeRangeDialMode rangeDialMode = rangeDialModeRepository.findDialModeAtCurrent(Long.parseLong(requestDto.getCampaignId()), Long.parseLong(requestDto.getCompanySiteId()));
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.getCampaignSystemStatus().equalsIgnoreCase("AVAILABLE")) {
if (agents.getUserStatus().equalsIgnoreCase("CALLOUT") && agents.getCampaignSystemStatus().equalsIgnoreCase("AVAILABLE")) {
//if (zoneDialMode != null && zoneDialMode.getDialMode().equals(0) || rangeDialMode != null && rangeDialMode.getDialMode().equals(0))
data.put("dialModeManual", "1");
}
......@@ -269,9 +268,7 @@ public class CampaignExecuteServiceImp implements CampaignExecuteService {
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()));
// 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.getCampaignSystemStatus().equalsIgnoreCase("LOGOUT")) {
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();
......@@ -292,7 +289,7 @@ public class CampaignExecuteServiceImp implements CampaignExecuteService {
}
@Override
public ResultDTO getCall(CampaignCustomerDTO dto) {
public ResultDTO getCustomer(CampaignCustomerDTO dto) {
ResultDTO result = new ResultDTO();
//Agents agents = agentsRepository.findByAgentId(dto.getAgentId());
......@@ -442,6 +439,26 @@ public class CampaignExecuteServiceImp implements CampaignExecuteService {
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
public ResultDTO getCallLog(ReceiveCustLogDTO dto) {
ResultDTO result = new ResultDTO();
......@@ -467,7 +484,7 @@ public class CampaignExecuteServiceImp implements CampaignExecuteService {
ResultDTO result = new ResultDTO();
try {
agentsRepository.updateAgentLogoutFromCampaign(Long.parseLong(dto.getAgentId()), "LOGOUT");
agentsRepository.updateAgentLogoutFromCampaign(dto.getAgentId(), "LOGOUT");
campaignAgentRepository.updateCampaignAgentSetStatus(Long.parseLong(dto.getAgentId()), Long.parseLong(dto.getCampaignId()), 0);
result.setErrorCode(Constants.ApiErrorCode.SUCCESS);
......
......@@ -126,6 +126,7 @@ public class ScenarioServiceImpl implements ScenarioService {
}
return null;
}
public ResultDTO saveContacQuestResult(ContactQuestResultDTO dto) {
ResultDTO resultDTO = new ResultDTO();
......
......@@ -10,7 +10,7 @@ import java.util.Date;
@Getter
@Setter
@NoArgsConstructor
public class ContactCustResultDTO extends BaseDTO{
public class ContactCustResultDTO extends BaseDTO {
private Long contactCustResultId;
private Long companySiteId;
private Short callStatus;
......
......@@ -4,8 +4,13 @@ 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.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.request_dto.CampaignRequestDTO;
import com.viettel.econtact.filter.UserSession;
import org.apache.commons.io.FilenameUtils;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -15,6 +20,7 @@ import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
......@@ -22,7 +28,8 @@ import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.List;
import java.util.Map;
import java.util.Locale;
import java.util.Objects;
@RestController
@RequestMapping("/ipcc/campaign")
......@@ -52,10 +59,17 @@ public class CampaignController {
return new ResponseEntity<>(result, HttpStatus.OK);
}
@PostMapping("/getCall")
@PostMapping("/getCustomer")
@ResponseBody
public ResponseEntity<ResultDTO> getCall(@RequestBody CampaignCustomerDTO requestDto) {
ResultDTO result = campaignExecuteService.getCall(requestDto);
public ResponseEntity<ResultDTO> getCustomer(@RequestBody CampaignCustomerDTO 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);
}
......@@ -296,4 +310,33 @@ public class CampaignController {
ResultDTO result = campaignService.renewCampaign(campaignDTO);
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:
port: 9999
port: 1111
spring:
application:
name: campaign
......
......@@ -103,3 +103,6 @@ customer.notLessThan = not less than
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.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
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.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