diff --git a/manage/ad-platform-management/src/main/java/com/baiye/modules/report/api/ReportController.java b/manage/ad-platform-management/src/main/java/com/baiye/modules/report/api/ReportController.java index 29d9ccde..6afca5b8 100644 --- a/manage/ad-platform-management/src/main/java/com/baiye/modules/report/api/ReportController.java +++ b/manage/ad-platform-management/src/main/java/com/baiye/modules/report/api/ReportController.java @@ -3,6 +3,7 @@ package com.baiye.modules.report.api; import com.baiye.http.CommonResponse; import com.baiye.modules.report.entity.dto.StatisticalReportDTO; import com.baiye.modules.report.service.ReportService; +import com.baiye.util.SecurityUtils; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.extern.slf4j.Slf4j; @@ -32,12 +33,16 @@ public class ReportController { @PostMapping("/report/task") @ApiOperation("按任务的统计信息") public CommonResponse getReportByTask(@RequestBody StatisticalReportDTO s) { + Long companyId = SecurityUtils.getCompanyId(); + s.setCompanyId(companyId); return reportService.getReportByTask(s); } @PostMapping("/download/task") @ApiOperation("导出任务统计信息") public void downloadTaskReport(HttpServletResponse response, @RequestBody StatisticalReportDTO statisticalReportDTO) { + Long companyId = SecurityUtils.getCompanyId(); + statisticalReportDTO.setCompanyId(companyId); reportService.downloadTaskReport(response, statisticalReportDTO); } @@ -50,18 +55,22 @@ public class ReportController { @GetMapping("/report/single/task") @ApiOperation("导出单个任务的线索统计信息") public CommonResponse reportTaskReport(Long id) { - return reportService.reportSingleTaskReport(id); + return reportService.reportSingleTaskReport(id); } @PostMapping("/report/organize") @ApiOperation("按组的统计信息") public CommonResponse getReportByOrganize(@RequestBody StatisticalReportDTO s) { + Long companyId = SecurityUtils.getCompanyId(); + s.setCompanyId(companyId); return reportService.getReportByOrganize(s); } @PostMapping("/download/organize") @ApiOperation("导出组成员统计信息") public void downloadOrganizeReport(HttpServletResponse response, @RequestBody StatisticalReportDTO s) { + Long companyId = SecurityUtils.getCompanyId(); + s.setCompanyId(companyId); reportService.downloadOrganizeReport(response, s); } diff --git a/manage/ad-platform-management/src/main/java/com/baiye/modules/report/entity/dto/StatisticalReportDTO.java b/manage/ad-platform-management/src/main/java/com/baiye/modules/report/entity/dto/StatisticalReportDTO.java index 28900713..e41ee412 100644 --- a/manage/ad-platform-management/src/main/java/com/baiye/modules/report/entity/dto/StatisticalReportDTO.java +++ b/manage/ad-platform-management/src/main/java/com/baiye/modules/report/entity/dto/StatisticalReportDTO.java @@ -24,4 +24,8 @@ public class StatisticalReportDTO { private Integer type; private List ids; + + private Long companyId; + + private Long userId; } diff --git a/manage/ad-platform-management/src/main/java/com/baiye/modules/report/service/impl/ReportServiceImpl.java b/manage/ad-platform-management/src/main/java/com/baiye/modules/report/service/impl/ReportServiceImpl.java index 32c755fd..0ff2b4dd 100644 --- a/manage/ad-platform-management/src/main/java/com/baiye/modules/report/service/impl/ReportServiceImpl.java +++ b/manage/ad-platform-management/src/main/java/com/baiye/modules/report/service/impl/ReportServiceImpl.java @@ -20,12 +20,14 @@ import com.baiye.modules.report.entity.dto.StatisticalReportDTO; import com.baiye.modules.report.entity.dto.UploadTaskDTO; import com.baiye.modules.report.entity.vo.MemberInfoVO; import com.baiye.modules.report.service.ReportService; +import com.baiye.modules.system.domain.Company; import com.baiye.modules.system.domain.Organize; import com.baiye.modules.system.domain.Task; import com.baiye.modules.system.domain.User; import com.baiye.modules.system.repository.OrganizeRepository; import com.baiye.modules.system.repository.TaskRepository; import com.baiye.modules.system.repository.UserRepository; +import com.baiye.modules.system.service.CompanyService; import com.baiye.modules.telemarkting.dao.AllCallInfoRepository; import com.baiye.modules.telemarkting.dao.CallClueRepository; import com.baiye.modules.telemarkting.entity.AllCallInfo; @@ -33,6 +35,7 @@ import com.baiye.modules.telemarkting.entity.CallClueInfo; import com.baiye.modules.telemarkting.entity.DoubleCallInfo; import com.baiye.util.DateTimeUtil; import com.baiye.util.ExportExcelUtil; +import com.baiye.util.SecurityUtils; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; import org.springframework.cache.annotation.Cacheable; @@ -63,10 +66,13 @@ public class ReportServiceImpl implements ReportService { private UserRepository userRepository; @Resource private SourceClueClient sourceClueClient; + @Resource + private CompanyService companyService; @Override public CommonResponse getReportByAll() { - List all = callClueRepository.selectByDay(DateTimeUtil.getBeginTimeByDay(DateUtil.today()), DateTimeUtil.getEndTimeByDay(DateUtil.today())); + Long companyId = SecurityUtils.getCompanyId(); + List all = callClueRepository.selectByDay(DateTimeUtil.getBeginTimeByDay(DateUtil.today()), DateTimeUtil.getEndTimeByDay(DateUtil.today()), companyId); MemberInfoVO messageInfo = getMessageInfo(DateTimeUtil.getBeginTimeByDay(DateUtil.today()), DateTimeUtil.getEndTimeByDay(DateUtil.today()), all); return CommonResponse.createBySuccess(messageInfo); } @@ -265,7 +271,7 @@ public class ReportServiceImpl implements ReportService { endTime = DateTimeUtil.getEndTimeByDay(endTime); } //按时间和组id查询拨打线索记录 - List callClueInfos = callClueRepository.selectAllByTimeAndTeamId(beginTime, endTime, s.getIds()); + List callClueInfos = callClueRepository.selectAllByTimeAndTeamId(beginTime, endTime, s.getIds(), s.getCompanyId()); Map> map = new HashMap<>(16); callClueInfos.stream().collect(Collectors.groupingBy(CallClueInfo::getTeamId, Collectors.toList())).forEach(map::put); @@ -300,7 +306,7 @@ public class ReportServiceImpl implements ReportService { endTime = DateTimeUtil.getEndTimeByDay(endTime); } //按时间和组id查询拨打线索记录 - List callClueInfos = callClueRepository.selectAllByTimeAndTeamId(beginTime, endTime, s.getIds()); + List callClueInfos = callClueRepository.selectAllByTimeAndTeamId(beginTime, endTime, s.getIds(), s.getCompanyId()); //按人分组 Map> mapByMember = new HashMap<>(16); @@ -412,7 +418,9 @@ public class ReportServiceImpl implements ReportService { List ids = s.getIds(); if (CollUtil.isEmpty(ids)) { ids = new ArrayList<>(); - getTaskId(ids); + Long userId = companyService.findById(s.getCompanyId()).getUserId(); + s.setUserId(userId); + getTaskId(ids, userId); s.setIds(ids); } String beginTime = s.getBeginTime(); @@ -526,8 +534,8 @@ public class ReportServiceImpl implements ReportService { /** * 当参数为空,默认查询5条任务 */ - private void getTaskId(List ids) { - List allByIsAndIsDistribution = taskRepository.findAllByIsAndIsDistributionAndId(DefaultNumberConstants.ONE_NUMBER, ids); + private void getTaskId(List ids, Long userId) { + List allByIsAndIsDistribution = taskRepository.findAllByIsAndIsDistributionAndId(DefaultNumberConstants.ONE_NUMBER, ids, userId); if (CollUtil.isNotEmpty(allByIsAndIsDistribution)) { int flag = 0; for (int i = allByIsAndIsDistribution.size() - 1; i >= 0; i--) { @@ -545,7 +553,7 @@ public class ReportServiceImpl implements ReportService { */ private List> getMapByTask(StatisticalReportDTO s, Map> mapByTask) { List> listMap = new ArrayList<>(); - List tasks = taskRepository.findAllByIsAndIsDistributionAndId(DefaultNumberConstants.ONE_NUMBER, s.getIds()); + List tasks = taskRepository.findAllByIsAndIsDistributionAndId(DefaultNumberConstants.ONE_NUMBER, s.getIds(), s.getUserId()); //按id分组 Map taskInfos = new HashMap<>(8); for (Task info : tasks) { @@ -592,7 +600,7 @@ public class ReportServiceImpl implements ReportService { */ private List getMapByTaskUpload(StatisticalReportDTO s, Map> mapByTask) { List list = new ArrayList<>(); - List tasks = taskRepository.findAllByIsAndIsDistributionAndId(DefaultNumberConstants.ONE_NUMBER, s.getIds()); + List tasks = taskRepository.findAllByIsAndIsDistributionAndId(DefaultNumberConstants.ONE_NUMBER, s.getIds(), s.getUserId()); //按id分组 Map taskInfos = new HashMap<>(8); for (Task info : tasks) { diff --git a/manage/ad-platform-management/src/main/java/com/baiye/modules/system/repository/TaskRepository.java b/manage/ad-platform-management/src/main/java/com/baiye/modules/system/repository/TaskRepository.java index 65432471..80760ab4 100644 --- a/manage/ad-platform-management/src/main/java/com/baiye/modules/system/repository/TaskRepository.java +++ b/manage/ad-platform-management/src/main/java/com/baiye/modules/system/repository/TaskRepository.java @@ -27,8 +27,8 @@ public interface TaskRepository extends JpaRepository, JpaSpecificat * @param ids * @return */ - @Query(value = "select * from tb_task t where t.is_distribution = ?1 and (coalesce (?2,null) is null or t.task_id in (?2))", nativeQuery = true) - List findAllByIsAndIsDistributionAndId(Integer isDistribution, List ids); + @Query(value = "select * from tb_task t where t.is_distribution = ?1 and (coalesce (?2,null) is null or t.task_id in (?2)) and t.create_by = ?3", nativeQuery = true) + List findAllByIsAndIsDistributionAndId(Integer isDistribution, List ids, Long userId); /** * 查询单个分配的任务 diff --git a/manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/api/TelephoneCallController.java b/manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/api/TelephoneCallController.java index 4e49fde3..d9139daf 100644 --- a/manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/api/TelephoneCallController.java +++ b/manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/api/TelephoneCallController.java @@ -51,20 +51,21 @@ public class TelephoneCallController { Organize organize = organizeService.findByOrganizeId(telephoneCallReqDTO.getTeamId()); Company byId = companyService.findById(SecurityUtils.getCompanyId()); if (organize != null && byId != null) { - telephoneCallReqDTO.setCompanyName(byId.getCompanyName()); + if (organize.getCallMode() != null) { switch (organize.getCallMode()) { case DefaultNumberConstants.ZERO_NUMBER: - return telephoneCallService.doubleCallReq(telephoneCallReqDTO); + telephoneCallReqDTO.setCompanyName(byId.getCompanyName()); + return telephoneCallService.doubleCallReq(telephoneCallReqDTO, companyId); case DefaultNumberConstants.TWO_NUMBER: if (StringUtils.isBlank(byId.getXGroup()) || StringUtils.isBlank(byId.getTelX())) { throw new BadRequestException(ResponseCode.AXB_CONFIGURATION_ERROR.getDesc()); } telephoneCallReqDTO.setTelX(byId.getTelX()); telephoneCallReqDTO.setXGroup(byId.getXGroup()); - return telephoneCallService.axbDialNumber(telephoneCallReqDTO); + return telephoneCallService.axbDialNumber(telephoneCallReqDTO, companyId); case DefaultNumberConstants.ONE_NUMBER: - return telephoneCallService.rollCallReq(telephoneCallReqDTO); + return telephoneCallService.rollCallReq(telephoneCallReqDTO,companyId); default: return CommonResponse.createByErrorMessage("未配置呼叫"); } diff --git a/manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/dao/CallClueRepository.java b/manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/dao/CallClueRepository.java index dbf10614..e1732dbe 100644 --- a/manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/dao/CallClueRepository.java +++ b/manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/dao/CallClueRepository.java @@ -23,8 +23,8 @@ public interface CallClueRepository extends JpaRepository, J * @param endTime * @return */ - @Query(value = "select * from tb_call_clue d where (d.create_time between ?1 and ?2)", nativeQuery = true) - List selectByDay(String beginTime, String endTime); + @Query(value = "select * from tb_call_clue d where (d.create_time between ?1 and ?2) AND d.company_id = ?3", nativeQuery = true) + List selectByDay(String beginTime, String endTime, Long companyId); /** @@ -46,8 +46,8 @@ public interface CallClueRepository extends JpaRepository, J * @param id * @return */ - @Query(value = "select * from tb_call_clue d where (d.create_time between ?1 and ?2) and (coalesce (?3,null) is null or d.team_id in (?3))", nativeQuery = true) - List selectAllByTimeAndTeamId(String beginTime, String endTime, List id); + @Query(value = "select * from tb_call_clue d where (d.create_time between ?1 and ?2) and (coalesce (?3,null) is null or d.team_id in (?3)) and d.company_id = ?4", nativeQuery = true) + List selectAllByTimeAndTeamId(String beginTime, String endTime, List id, Long companyId); /** * 通过时间和任务id查询记录 diff --git a/manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/service/TelephoneCallService.java b/manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/service/TelephoneCallService.java index 95fc4793..7fd1b9cb 100644 --- a/manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/service/TelephoneCallService.java +++ b/manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/service/TelephoneCallService.java @@ -14,7 +14,7 @@ public interface TelephoneCallService { * @param telephoneCallReqDTO * @return */ - CommonResponse doubleCallReq(TelephoneCallReqDTO telephoneCallReqDTO); + CommonResponse doubleCallReq(TelephoneCallReqDTO telephoneCallReqDTO,Long companyId); /** * 回调话单 @@ -53,7 +53,7 @@ public interface TelephoneCallService { * @param telephoneCallReqDTO * @return */ - CommonResponse axbDialNumber(TelephoneCallReqDTO telephoneCallReqDTO); + CommonResponse axbDialNumber(TelephoneCallReqDTO telephoneCallReqDTO,Long companyId); /** * 点呼请求 @@ -61,7 +61,7 @@ public interface TelephoneCallService { * @param telephoneCallReqDTO * @return */ - CommonResponse rollCallReq(TelephoneCallReqDTO telephoneCallReqDTO); + CommonResponse rollCallReq(TelephoneCallReqDTO telephoneCallReqDTO,Long companyId); /** * 点呼回调 * diff --git a/manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/service/impl/TelephoneCallServiceImpl.java b/manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/service/impl/TelephoneCallServiceImpl.java index 21772c92..ed566d3a 100644 --- a/manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/service/impl/TelephoneCallServiceImpl.java +++ b/manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/service/impl/TelephoneCallServiceImpl.java @@ -59,7 +59,7 @@ public class TelephoneCallServiceImpl implements TelephoneCallService { private ExtensionNumberRepository extensionNumberRepository; @Override - public CommonResponse doubleCallReq(TelephoneCallReqDTO doubleCallReq) { + public CommonResponse doubleCallReq(TelephoneCallReqDTO doubleCallReq, Long companyId) { String requestId = RandomUtil.randomString(10); doubleCallReq.setRequestId(requestId); Clue body = sourceClueClient.queryDetails(Long.parseLong(doubleCallReq.getUserData())).getBody(); @@ -85,7 +85,7 @@ public class TelephoneCallServiceImpl implements TelephoneCallService { clueInfo.setMemberId(doubleCallReq.getMemberId()); clueInfo.setStatus(DefaultNumberConstants.ONE_NUMBER); clueInfo.setTaskId(doubleCallReq.getTaskId()); - + clueInfo.setCompanyId(companyId); allCallInfoRepository.save(allCallInfo); callClueRepository.save(clueInfo); } else { @@ -147,7 +147,7 @@ public class TelephoneCallServiceImpl implements TelephoneCallService { } @Override - public CommonResponse axbDialNumber(TelephoneCallReqDTO doubleCallReq) { + public CommonResponse axbDialNumber(TelephoneCallReqDTO doubleCallReq, Long companyId) { long originalNumber = Long.parseLong(doubleCallReq.getUserData()); ResponseEntity body = sourceClueClient.queryDetails(originalNumber); if (ObjectUtil.isNotNull(body) && ObjectUtil.isNotNull(body.getBody())) { @@ -171,6 +171,7 @@ public class TelephoneCallServiceImpl implements TelephoneCallService { clueInfo.setMemberId(doubleCallReq.getMemberId()); clueInfo.setStatus(DefaultNumberConstants.ONE_NUMBER); clueInfo.setTaskId(doubleCallReq.getTaskId()); + clueInfo.setCompanyId(companyId); allCallInfoRepository.save(allCallInfo); callClueRepository.save(clueInfo); return CommonResponse.createBySuccess(sessionId); @@ -180,7 +181,7 @@ public class TelephoneCallServiceImpl implements TelephoneCallService { } @Override - public CommonResponse rollCallReq(TelephoneCallReqDTO telephoneCallReqDTO) { + public CommonResponse rollCallReq(TelephoneCallReqDTO telephoneCallReqDTO, Long companyId) { String requestId = RandomUtil.randomString(10); telephoneCallReqDTO.setRequestId(requestId); if (telephoneCallReqDTO.getDisplay() == null || telephoneCallReqDTO.getTelA() == null) { @@ -219,6 +220,7 @@ public class TelephoneCallServiceImpl implements TelephoneCallService { clueInfo.setMemberId(telephoneCallReqDTO.getMemberId()); clueInfo.setStatus(DefaultNumberConstants.ONE_NUMBER); clueInfo.setTaskId(telephoneCallReqDTO.getTaskId()); + clueInfo.setCompanyId(companyId); allCallInfoRepository.save(allCallInfo); callClueRepository.save(clueInfo); } else {