|
@@ -3,18 +3,25 @@ package com.ydtech.modules.admin.service.impl;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.ydtech.modules.admin.dao.SysDeptInternalAgentMapper;
|
|
import com.ydtech.modules.admin.dao.SysDeptInternalAgentMapper;
|
|
|
import com.ydtech.modules.admin.dao.SysUserLinkAreaMapper;
|
|
import com.ydtech.modules.admin.dao.SysUserLinkAreaMapper;
|
|
|
|
|
+import com.ydtech.modules.admin.model.SysArea;
|
|
|
import com.ydtech.modules.admin.model.SysUser;
|
|
import com.ydtech.modules.admin.model.SysUser;
|
|
|
import com.ydtech.modules.admin.model.report.opetationData.*;
|
|
import com.ydtech.modules.admin.model.report.opetationData.*;
|
|
|
|
|
+import com.ydtech.modules.admin.model.vo.SysAreaVo;
|
|
|
import com.ydtech.modules.admin.service.OperationDataReportService;
|
|
import com.ydtech.modules.admin.service.OperationDataReportService;
|
|
|
|
|
+import com.ydtech.modules.admin.service.SysAreaService;
|
|
|
import com.ydtech.modules.admin.service.SysUserLinkDeptInternalAgentService;
|
|
import com.ydtech.modules.admin.service.SysUserLinkDeptInternalAgentService;
|
|
|
import com.ydtech.modules.admin.service.SysUserService;
|
|
import com.ydtech.modules.admin.service.SysUserService;
|
|
|
import com.ydtech.modules.order.dao.InsAreaCompanyMapper;
|
|
import com.ydtech.modules.order.dao.InsAreaCompanyMapper;
|
|
|
import com.ydtech.modules.order.entity.BasePageResult;
|
|
import com.ydtech.modules.order.entity.BasePageResult;
|
|
|
|
|
+import lombok.Data;
|
|
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
|
|
|
+import java.util.HashMap;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
|
+import java.util.Map;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* @version
|
|
* @version
|
|
@@ -41,8 +48,9 @@ public class OperationDataReportServiceImpl implements OperationDataReportServic
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private InsAreaCompanyMapper insAreaCompanyMapper;
|
|
private InsAreaCompanyMapper insAreaCompanyMapper;
|
|
|
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private SysAreaService sysAreaService;
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* @version
|
|
* @version
|
|
|
* @author: hxl
|
|
* @author: hxl
|
|
@@ -51,15 +59,17 @@ public class OperationDataReportServiceImpl implements OperationDataReportServic
|
|
|
*/
|
|
*/
|
|
|
@Override
|
|
@Override
|
|
|
public BasePageResult<BusinessDataDto> queryBusinessDataPage(BusinessDataQueryDto businessDataQueryDto) {
|
|
public BasePageResult<BusinessDataDto> queryBusinessDataPage(BusinessDataQueryDto businessDataQueryDto) {
|
|
|
- // if(StringUtils.isBlank(businessDataQueryDto.getDeptId())){
|
|
|
|
|
- // throw new SystemException("机构id不能为空");
|
|
|
|
|
- // }
|
|
|
|
|
|
|
+ if(StringUtils.isBlank(businessDataQueryDto.getDeptId())){
|
|
|
|
|
+ // throw new SystemException("机构id不能为空");
|
|
|
|
|
+ businessDataQueryDto.setDeptId("00");
|
|
|
|
|
+ businessDataQueryDto.setDeptType("1");
|
|
|
|
|
+ }
|
|
|
Result resultData = new Result().getRestData(businessDataQueryDto.getDeptId(), businessDataQueryDto.getDeptType());
|
|
Result resultData = new Result().getRestData(businessDataQueryDto.getDeptId(), businessDataQueryDto.getDeptType());
|
|
|
if(resultData.userIds ==null || resultData.userIds.size()==0){
|
|
if(resultData.userIds ==null || resultData.userIds.size()==0){
|
|
|
return new BasePageResult<BusinessDataDto>();
|
|
return new BasePageResult<BusinessDataDto>();
|
|
|
}else{
|
|
}else{
|
|
|
Page<BusinessDataDto> page = new Page<>(businessDataQueryDto.getPageNum(), businessDataQueryDto.getPageSize());
|
|
Page<BusinessDataDto> page = new Page<>(businessDataQueryDto.getPageNum(), businessDataQueryDto.getPageSize());
|
|
|
- Page<BusinessDataDto> result = insAreaCompanyMapper.queryBusinessDataPage(businessDataQueryDto, page, null, resultData.flag);
|
|
|
|
|
|
|
+ Page<BusinessDataDto> result = insAreaCompanyMapper.queryBusinessDataPage(businessDataQueryDto, page, resultData.getUserIds(), resultData.getFlag());
|
|
|
return new BasePageResult<>(businessDataQueryDto.getPageNum(), page.getSize(), result.getTotal(), page.getPages(),
|
|
return new BasePageResult<>(businessDataQueryDto.getPageNum(), page.getSize(), result.getTotal(), page.getPages(),
|
|
|
result.getRecords());
|
|
result.getRecords());
|
|
|
}
|
|
}
|
|
@@ -70,6 +80,7 @@ public class OperationDataReportServiceImpl implements OperationDataReportServic
|
|
|
* @Date: 2024/7/3 11:27
|
|
* @Date: 2024/7/3 11:27
|
|
|
* @Description: 参数数据封装
|
|
* @Description: 参数数据封装
|
|
|
*/
|
|
*/
|
|
|
|
|
+ @Data
|
|
|
private class Result {
|
|
private class Result {
|
|
|
private List<String> userIds;
|
|
private List<String> userIds;
|
|
|
private String flag;
|
|
private String flag;
|
|
@@ -118,19 +129,21 @@ public class OperationDataReportServiceImpl implements OperationDataReportServic
|
|
|
*/
|
|
*/
|
|
|
@Override
|
|
@Override
|
|
|
public BasePageResult<QuotationCountDataDto> queryQuotationCountDataPage(QuotationCountQueryDto quotationCountQueryDto) {
|
|
public BasePageResult<QuotationCountDataDto> queryQuotationCountDataPage(QuotationCountQueryDto quotationCountQueryDto) {
|
|
|
- //if(StringUtils.isBlank(quotationCountQueryDto.getDeptId())){
|
|
|
|
|
- // throw new SystemException("机构id不能为空");
|
|
|
|
|
- //}
|
|
|
|
|
|
|
+ if(StringUtils.isBlank(quotationCountQueryDto.getDeptId())){
|
|
|
|
|
+ // throw new SystemException("机构id不能为空");
|
|
|
|
|
+ quotationCountQueryDto.setDeptId("00");
|
|
|
|
|
+ quotationCountQueryDto.setDeptType("1");
|
|
|
|
|
+ }
|
|
|
Result resultData = new Result().getRestData(quotationCountQueryDto.getDeptId(),quotationCountQueryDto.getDeptType());
|
|
Result resultData = new Result().getRestData(quotationCountQueryDto.getDeptId(),quotationCountQueryDto.getDeptType());
|
|
|
if(resultData.userIds ==null || resultData.userIds.size()==0){
|
|
if(resultData.userIds ==null || resultData.userIds.size()==0){
|
|
|
return new BasePageResult<QuotationCountDataDto>();
|
|
return new BasePageResult<QuotationCountDataDto>();
|
|
|
}else{
|
|
}else{
|
|
|
Page<QuotationCountDataDto> page = new Page<>(quotationCountQueryDto.getPageNum(), quotationCountQueryDto.getPageSize());
|
|
Page<QuotationCountDataDto> page = new Page<>(quotationCountQueryDto.getPageNum(), quotationCountQueryDto.getPageSize());
|
|
|
- Page<QuotationCountDataDto> resultInsOrder = insAreaCompanyMapper.queryQuotationOrderCountDataPage(quotationCountQueryDto, page, null, resultData.flag);
|
|
|
|
|
|
|
+ // Page<QuotationCountDataDto> resultInsOrder = insAreaCompanyMapper.queryQuotationOrderCountDataPage(quotationCountQueryDto, page, resultData.getUserIds(), resultData.getFlag());
|
|
|
//合并到一起
|
|
//合并到一起
|
|
|
- Page<QuotationCountDataDto> resultSubOrder = insAreaCompanyMapper.queryQuotationSubOrderCountDataPage(quotationCountQueryDto, page, null, resultData.flag);
|
|
|
|
|
- return new BasePageResult<>(quotationCountQueryDto.getPageNum(), page.getSize(), resultInsOrder.getTotal(), page.getPages(),
|
|
|
|
|
- resultInsOrder.getRecords());
|
|
|
|
|
|
|
+ Page<QuotationCountDataDto> resultSubOrder = insAreaCompanyMapper.queryQuotationSubOrderCountDataPage(quotationCountQueryDto, page, resultData.getUserIds(), resultData.getFlag());
|
|
|
|
|
+ return new BasePageResult<>(quotationCountQueryDto.getPageNum(), page.getSize(), resultSubOrder.getTotal(), page.getPages(),
|
|
|
|
|
+ resultSubOrder.getRecords());
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -145,37 +158,67 @@ public class OperationDataReportServiceImpl implements OperationDataReportServic
|
|
|
//if(StringUtils.isBlank(quotationCountQueryDto.getDeptId())){
|
|
//if(StringUtils.isBlank(quotationCountQueryDto.getDeptId())){
|
|
|
// throw new SystemException("机构id不能为空");
|
|
// throw new SystemException("机构id不能为空");
|
|
|
//}
|
|
//}
|
|
|
|
|
+ if(StringUtils.isBlank(quotationCountQueryDto.getDeptId())){
|
|
|
|
|
+ // throw new SystemException("机构id不能为空");
|
|
|
|
|
+ quotationCountQueryDto.setDeptId("00");
|
|
|
|
|
+ quotationCountQueryDto.setDeptType("1");
|
|
|
|
|
+ }
|
|
|
|
|
+ Page<QuotationCountDataDto> page = new Page<>(quotationCountQueryDto.getPageNum(), quotationCountQueryDto.getPageSize());
|
|
|
List<String> userIds= sysUserLinkDeptInternalAgentService.getUserIdListByDeptId(quotationCountQueryDto.getDeptId());
|
|
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);
|
|
|
|
|
|
|
+ List<OperationsPersonnelDataDto> list =new ArrayList<>();
|
|
|
|
|
+ List<SysAreaVo> sysAreaVos = sysAreaService.querySysArea();
|
|
|
|
|
+ Map<String, String> map=new HashMap<String,String>();
|
|
|
|
|
+ if(sysAreaVos!=null && sysAreaVos.size()>0){
|
|
|
|
|
+ for (SysArea sysArea : sysAreaVos) {
|
|
|
|
|
+ map.put(sysArea.getAreaCode(),sysArea.getAreaCname());
|
|
|
}
|
|
}
|
|
|
- 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(userIds!=null && userIds.size()>0){
|
|
|
|
|
+ List<SysUser> userList = sysUserService.getByIds(userIds);
|
|
|
|
|
+ for(SysUser user :userList){
|
|
|
|
|
+ OperationsPersonnelDataDto vo=new OperationsPersonnelDataDto();
|
|
|
|
|
+ vo.setUserId(user.getId());
|
|
|
|
|
+ vo.setUserName(user.getName());
|
|
|
|
|
+ String areaStr="";
|
|
|
|
|
+ if(user.getId().length()==4){
|
|
|
|
|
+ areaStr=user.getId().substring(2,3)+"0000";
|
|
|
|
|
+ }else if(user.getId().length()==6){
|
|
|
|
|
+ areaStr=user.getId().substring(2,3)+user.getId().substring(4,5)+"00";
|
|
|
|
|
+ }else if(user.getId().length()>8){
|
|
|
|
|
+ areaStr=user.getId().substring(2,3)+user.getId().substring(4,5)+user.getId().substring(6,7);
|
|
|
|
|
+ }
|
|
|
|
|
+ String areaName = map.get(areaStr) == null ? "" : map.get(areaStr);
|
|
|
|
|
+ vo.setAreaCode(areaName);
|
|
|
|
|
+ vo.setSumCount(userIds.size());
|
|
|
|
|
+ list.add(vo);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ List<OperationsPersonnelDataDto> subList= new ArrayList<>();
|
|
|
|
|
+ int totalcount = list==null?0:list.size();
|
|
|
|
|
+ int currentPage = quotationCountQueryDto.getPageNum();
|
|
|
|
|
+ int pagecount = 0;
|
|
|
|
|
+ int pageSize = quotationCountQueryDto.getPageSize();
|
|
|
|
|
+ int m = totalcount % pageSize;
|
|
|
|
|
+ if(list!=null && list.size()>0){
|
|
|
|
|
+ if (m > 0) {
|
|
|
|
|
+ pagecount = totalcount / pageSize + 1;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ pagecount = totalcount / pageSize;
|
|
|
}
|
|
}
|
|
|
- if(allUserIds!=null && allUserIds.size()>0){
|
|
|
|
|
- dLUserList = sysUserService.getByIds(allUserIds);
|
|
|
|
|
|
|
+ if (m == 0) {
|
|
|
|
|
+ subList = list.subList((pageSize - 1) * pageSize, pageSize * (currentPage));
|
|
|
|
|
+ } else {
|
|
|
|
|
+ if (currentPage == pagecount) {
|
|
|
|
|
+ subList = list.subList((currentPage - 1) * pageSize, totalcount);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ subList = list.subList((currentPage - 1) * pageSize, pageSize * (currentPage));
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- return null;
|
|
|
|
|
|
|
+ return new BasePageResult<>(quotationCountQueryDto.getPageNum(), page.getSize(), totalcount, page.getPages(),
|
|
|
|
|
+ subList);
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* @version
|
|
* @version
|
|
|
* @author: hxl
|
|
* @author: hxl
|