报表加入企业区分

master
wujingtao 3 years ago
parent 050d5d6309
commit f7d46eb233

@ -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<Object> 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<Object> reportTaskReport(Long id) {
return reportService.reportSingleTaskReport(id);
return reportService.reportSingleTaskReport(id);
}
@PostMapping("/report/organize")
@ApiOperation("按组的统计信息")
public CommonResponse<Object> 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);
}

@ -24,4 +24,8 @@ public class StatisticalReportDTO {
private Integer type;
private List<Long> ids;
private Long companyId;
private Long userId;
}

@ -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<Object> getReportByAll() {
List<CallClueInfo> all = callClueRepository.selectByDay(DateTimeUtil.getBeginTimeByDay(DateUtil.today()), DateTimeUtil.getEndTimeByDay(DateUtil.today()));
Long companyId = SecurityUtils.getCompanyId();
List<CallClueInfo> 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<CallClueInfo> callClueInfos = callClueRepository.selectAllByTimeAndTeamId(beginTime, endTime, s.getIds());
List<CallClueInfo> callClueInfos = callClueRepository.selectAllByTimeAndTeamId(beginTime, endTime, s.getIds(), s.getCompanyId());
Map<Long, List<CallClueInfo>> 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<CallClueInfo> callClueInfos = callClueRepository.selectAllByTimeAndTeamId(beginTime, endTime, s.getIds());
List<CallClueInfo> callClueInfos = callClueRepository.selectAllByTimeAndTeamId(beginTime, endTime, s.getIds(), s.getCompanyId());
//按人分组
Map<Long, List<CallClueInfo>> mapByMember = new HashMap<>(16);
@ -412,7 +418,9 @@ public class ReportServiceImpl implements ReportService {
List<Long> 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<Long> ids) {
List<Task> allByIsAndIsDistribution = taskRepository.findAllByIsAndIsDistributionAndId(DefaultNumberConstants.ONE_NUMBER, ids);
private void getTaskId(List<Long> ids, Long userId) {
List<Task> 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<HashMap<String, Object>> getMapByTask(StatisticalReportDTO s, Map<Long, List<CallClueInfo>> mapByTask) {
List<HashMap<String, Object>> listMap = new ArrayList<>();
List<Task> tasks = taskRepository.findAllByIsAndIsDistributionAndId(DefaultNumberConstants.ONE_NUMBER, s.getIds());
List<Task> tasks = taskRepository.findAllByIsAndIsDistributionAndId(DefaultNumberConstants.ONE_NUMBER, s.getIds(), s.getUserId());
//按id分组
Map<Long, Task> taskInfos = new HashMap<>(8);
for (Task info : tasks) {
@ -592,7 +600,7 @@ public class ReportServiceImpl implements ReportService {
*/
private List<UploadTaskDTO> getMapByTaskUpload(StatisticalReportDTO s, Map<Long, List<CallClueInfo>> mapByTask) {
List<UploadTaskDTO> list = new ArrayList<>();
List<Task> tasks = taskRepository.findAllByIsAndIsDistributionAndId(DefaultNumberConstants.ONE_NUMBER, s.getIds());
List<Task> tasks = taskRepository.findAllByIsAndIsDistributionAndId(DefaultNumberConstants.ONE_NUMBER, s.getIds(), s.getUserId());
//按id分组
Map<Long, Task> taskInfos = new HashMap<>(8);
for (Task info : tasks) {

@ -27,8 +27,8 @@ public interface TaskRepository extends JpaRepository<Task, Long>, 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<Task> findAllByIsAndIsDistributionAndId(Integer isDistribution, List<Long> 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<Task> findAllByIsAndIsDistributionAndId(Integer isDistribution, List<Long> ids, Long userId);
/**
*

@ -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("未配置呼叫");
}

@ -23,8 +23,8 @@ public interface CallClueRepository extends JpaRepository<CallClueInfo, Long>, J
* @param endTime
* @return
*/
@Query(value = "select * from tb_call_clue d where (d.create_time between ?1 and ?2)", nativeQuery = true)
List<CallClueInfo> 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<CallClueInfo> selectByDay(String beginTime, String endTime, Long companyId);
/**
@ -46,8 +46,8 @@ public interface CallClueRepository extends JpaRepository<CallClueInfo, Long>, 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<CallClueInfo> selectAllByTimeAndTeamId(String beginTime, String endTime, List<Long> 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<CallClueInfo> selectAllByTimeAndTeamId(String beginTime, String endTime, List<Long> id, Long companyId);
/**
* id

@ -14,7 +14,7 @@ public interface TelephoneCallService {
* @param telephoneCallReqDTO
* @return
*/
CommonResponse<String> doubleCallReq(TelephoneCallReqDTO telephoneCallReqDTO);
CommonResponse<String> doubleCallReq(TelephoneCallReqDTO telephoneCallReqDTO,Long companyId);
/**
*
@ -53,7 +53,7 @@ public interface TelephoneCallService {
* @param telephoneCallReqDTO
* @return
*/
CommonResponse<String> axbDialNumber(TelephoneCallReqDTO telephoneCallReqDTO);
CommonResponse<String> axbDialNumber(TelephoneCallReqDTO telephoneCallReqDTO,Long companyId);
/**
*
@ -61,7 +61,7 @@ public interface TelephoneCallService {
* @param telephoneCallReqDTO
* @return
*/
CommonResponse<String> rollCallReq(TelephoneCallReqDTO telephoneCallReqDTO);
CommonResponse<String> rollCallReq(TelephoneCallReqDTO telephoneCallReqDTO,Long companyId);
/**
*
*

@ -59,7 +59,7 @@ public class TelephoneCallServiceImpl implements TelephoneCallService {
private ExtensionNumberRepository extensionNumberRepository;
@Override
public CommonResponse<String> doubleCallReq(TelephoneCallReqDTO doubleCallReq) {
public CommonResponse<String> 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<String> axbDialNumber(TelephoneCallReqDTO doubleCallReq) {
public CommonResponse<String> axbDialNumber(TelephoneCallReqDTO doubleCallReq, Long companyId) {
long originalNumber = Long.parseLong(doubleCallReq.getUserData());
ResponseEntity<Clue> 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<String> rollCallReq(TelephoneCallReqDTO telephoneCallReqDTO) {
public CommonResponse<String> 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 {

Loading…
Cancel
Save