|
|
@@ -0,0 +1,195 @@
|
|
|
+package com.ydtech.modules.admin.service.impl;
|
|
|
+
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import com.ydtech.exception.SystemException;
|
|
|
+import com.ydtech.modules.admin.dao.SysDeptInternalAgentMapper;
|
|
|
+import com.ydtech.modules.admin.dao.SysUserLinkAreaMapper;
|
|
|
+import com.ydtech.modules.admin.model.SysUser;
|
|
|
+import com.ydtech.modules.admin.model.report.opetationData.*;
|
|
|
+import com.ydtech.modules.admin.service.OperationDataReportService;
|
|
|
+import com.ydtech.modules.admin.service.SysUserLinkDeptInternalAgentService;
|
|
|
+import com.ydtech.modules.admin.service.SysUserService;
|
|
|
+import com.ydtech.modules.order.dao.InsAreaCompanyMapper;
|
|
|
+import com.ydtech.modules.order.entity.BasePageResult;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @version
|
|
|
+ * @author: hxl
|
|
|
+ * @Date: 2024/7/1 11:36
|
|
|
+ * @Description: 控制台-运营数据
|
|
|
+ */
|
|
|
+@Service
|
|
|
+public class OperationDataReportServiceImpl implements OperationDataReportService {
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private SysDeptInternalAgentMapper sysDeptInternalAgentMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private SysUserLinkDeptInternalAgentService sysUserLinkDeptInternalAgentService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private SysUserService sysUserService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private SysUserLinkAreaMapper sysUserLinkAreaMapper;
|
|
|
+ @Autowired
|
|
|
+ private InsAreaCompanyMapper insAreaCompanyMapper;
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @version
|
|
|
+ * @author: hxl
|
|
|
+ * @Date: 2024/7/3 8:52
|
|
|
+ * @Description: 查询控制台的运营数据 分 1. 机构 运营部 2. 运营组 3. 组长 4. 组员 5.渠道 6.代理人
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public BasePageResult<BusinessDataDto> queryBusinessDataPage(BusinessDataQueryDto businessDataQueryDto) {
|
|
|
+ if(StringUtils.isBlank(businessDataQueryDto.getDeptId())){
|
|
|
+ throw new SystemException("机构id不能为空");
|
|
|
+ }
|
|
|
+ Result resultData = new Result().getRestData(businessDataQueryDto.getDeptId(), businessDataQueryDto.getDeptType());
|
|
|
+ if(resultData.userIds ==null || resultData.userIds.size()==0){
|
|
|
+ return new BasePageResult<BusinessDataDto>();
|
|
|
+ }else{
|
|
|
+ Page<BusinessDataDto> page = new Page<>(businessDataQueryDto.getPageNum(), businessDataQueryDto.getPageSize());
|
|
|
+ Page<BusinessDataDto> result = insAreaCompanyMapper.queryBusinessDataPage(businessDataQueryDto, page, resultData.userIds, resultData.flag);
|
|
|
+ return new BasePageResult<>(businessDataQueryDto.getPageNum(), page.getSize(), result.getTotal(), page.getPages(),
|
|
|
+ result.getRecords());
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * @version
|
|
|
+ * @author: hxl
|
|
|
+ * @Date: 2024/7/3 11:27
|
|
|
+ * @Description: 参数数据封装
|
|
|
+ */
|
|
|
+ private class Result {
|
|
|
+ private List<String> userIds;
|
|
|
+ private String flag;
|
|
|
+
|
|
|
+ public Result() {
|
|
|
+ }
|
|
|
+
|
|
|
+ public Result(List<String> userIds, String flag) {
|
|
|
+ this.userIds = userIds;
|
|
|
+ this.flag = flag;
|
|
|
+ }
|
|
|
+
|
|
|
+ public Result getRestData(String deptId,String deptType){
|
|
|
+ List<String> userIds=new ArrayList<>();
|
|
|
+ //通过传过来的机构id查询数据类型
|
|
|
+ String flag=null;
|
|
|
+ if("1".equals(deptType) || "2".equals(deptType) || "3".equals(deptType) || "4".equals(deptType) ){
|
|
|
+ //机构parentIds查询下面管理的人
|
|
|
+ userIds= sysUserLinkDeptInternalAgentService.getUserIdListByDeptId(deptId);
|
|
|
+ if("3".equals(deptType) || "4".equals(deptType)){
|
|
|
+ flag="1";
|
|
|
+ }
|
|
|
+ }else if("5".equals(deptType) ){
|
|
|
+ //通过用户id查询管理的渠道
|
|
|
+ //渠道
|
|
|
+ userIds = sysUserService.getUserIdsByLeaderId(deptId);
|
|
|
+ flag="1";
|
|
|
+
|
|
|
+ }else if("6".equals(deptType)){
|
|
|
+ //通过用户id查询管理的代理人
|
|
|
+ List<String> areaCodes = sysUserLinkAreaMapper.findAreaCodeByUserId(deptId);
|
|
|
+ if(areaCodes!=null && !areaCodes.isEmpty()){
|
|
|
+ userIds =sysUserLinkAreaMapper.findAreaIdsByAgentUserId(deptId,areaCodes);
|
|
|
+ }
|
|
|
+ flag="1";
|
|
|
+ }
|
|
|
+ return new Result(userIds, flag);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @version
|
|
|
+ * @author: hxl
|
|
|
+ * @Date: 2024/7/3 11:19
|
|
|
+ * @Description: 查询报价次数数据
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public BasePageResult<QuotationCountDataDto> queryQuotationCountDataPage(QuotationCountQueryDto quotationCountQueryDto) {
|
|
|
+ if(StringUtils.isBlank(quotationCountQueryDto.getDeptId())){
|
|
|
+ throw new SystemException("机构id不能为空");
|
|
|
+ }
|
|
|
+ Result resultData = new Result().getRestData(quotationCountQueryDto.getDeptId(),quotationCountQueryDto.getDeptType());
|
|
|
+ if(resultData.userIds ==null || resultData.userIds.size()==0){
|
|
|
+ return new BasePageResult<QuotationCountDataDto>();
|
|
|
+ }else{
|
|
|
+ Page<QuotationCountDataDto> page = new Page<>(quotationCountQueryDto.getPageNum(), quotationCountQueryDto.getPageSize());
|
|
|
+ Page<QuotationCountDataDto> resultInsOrder = insAreaCompanyMapper.queryQuotationOrderCountDataPage(quotationCountQueryDto, page, resultData.userIds, resultData.flag);
|
|
|
+ //合并到一起
|
|
|
+ Page<QuotationCountDataDto> resultSubOrder = insAreaCompanyMapper.queryQuotationSubOrderCountDataPage(quotationCountQueryDto, page, resultData.userIds, resultData.flag);
|
|
|
+ return new BasePageResult<>(quotationCountQueryDto.getPageNum(), page.getSize(), resultInsOrder.getTotal(), page.getPages(),
|
|
|
+ resultInsOrder.getRecords());
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * @version
|
|
|
+ * @author: hxl
|
|
|
+ * @Date: 2024/7/3 11:59
|
|
|
+ * @Description: 查询代理人渠道数据
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public BasePageResult<OperationsPersonnelDataDto> queryOperationsPersonnelDataPage(QuotationCountQueryDto quotationCountQueryDto) {
|
|
|
+ if(StringUtils.isBlank(quotationCountQueryDto.getDeptId())){
|
|
|
+ throw new SystemException("机构id不能为空");
|
|
|
+ }
|
|
|
+ List<String> userIds= sysUserLinkDeptInternalAgentService.getUserIdListByDeptId(quotationCountQueryDto.getDeptId());
|
|
|
+ //渠道用户数据
|
|
|
+ List<SysUser> qdUserList=new ArrayList<SysUser>();
|
|
|
+ //代理人用户数据
|
|
|
+ List<SysUser> dLUserList=new ArrayList<SysUser>();
|
|
|
+ if(userIds!=null && userIds.size()==0){
|
|
|
+ List<String> allUserIds=new ArrayList<String>();
|
|
|
+ for(String userId :userIds){
|
|
|
+ List<String> userIds_qd = sysUserService.getUserIdsByLeaderId(userId);
|
|
|
+ allUserIds.addAll(userIds_qd);
|
|
|
+ }
|
|
|
+ if(allUserIds!=null && allUserIds.size()>0){
|
|
|
+ qdUserList = sysUserService.getByIds(allUserIds);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ if(userIds!=null && userIds.size()==0){
|
|
|
+ List<String> allUserIds=new ArrayList<String>();
|
|
|
+ for(String userId :userIds){
|
|
|
+ List<String> areaCodes = sysUserLinkAreaMapper.findAreaCodeByUserId(userId);
|
|
|
+ if(areaCodes!=null && !areaCodes.isEmpty()){
|
|
|
+ List<String> userIds_dl =sysUserLinkAreaMapper.findAreaIdsByAgentUserId(userId,areaCodes);
|
|
|
+ allUserIds.addAll(userIds_dl);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(allUserIds!=null && allUserIds.size()>0){
|
|
|
+ dLUserList = sysUserService.getByIds(allUserIds);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * @version
|
|
|
+ * @author: hxl
|
|
|
+ * @Date: 2024/7/3 11:59
|
|
|
+ * @Description: 查询电销数据
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public BasePageResult<TelemarketingDataDto> queryTelemarketingDataDtoCountDataPage(TelemarketingDataQueryDto telemarketingDataQueryDto) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|