|
|
@@ -1,5 +1,6 @@
|
|
|
package com.ydtech.modules.admin.service.impl;
|
|
|
|
|
|
+import cn.hutool.core.bean.BeanUtil;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
@@ -19,6 +20,7 @@ import com.ydtech.modules.admin.model.SysUser;
|
|
|
import com.ydtech.modules.admin.model.dto.*;
|
|
|
import com.ydtech.modules.admin.model.vo.BusinessAgentData;
|
|
|
import com.ydtech.modules.admin.model.vo.BusinessOrderData;
|
|
|
+import com.ydtech.modules.admin.model.vo.SysUserPartner;
|
|
|
import com.ydtech.modules.admin.model.vo.TaskStatisticsVo;
|
|
|
import com.ydtech.modules.admin.service.SysDeptService;
|
|
|
import com.ydtech.modules.admin.service.TaskStatisticsService;
|
|
|
@@ -30,9 +32,11 @@ import com.ydtech.modules.order.dao.InsAreaCompanyMapper;
|
|
|
import com.ydtech.modules.order.dao.InsOrdersMapper;
|
|
|
import org.apache.commons.lang3.ObjectUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
import java.io.File;
|
|
|
import java.io.IOException;
|
|
|
@@ -1220,6 +1224,154 @@ public class TaskStatisticsServiceImpl implements TaskStatisticsService {
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public HttpResult getBusinessDataExcel(TaskStatisticsVo taskStatisticsVo) {
|
|
|
+ if (StringUtils.isNotEmpty(taskStatisticsVo.getDays())) {
|
|
|
+ if ("7".equals(taskStatisticsVo.getDays())) {
|
|
|
+ taskStatisticsVo.setDateType("2");
|
|
|
+ } else if ("30".equals(taskStatisticsVo.getDays())) {
|
|
|
+ taskStatisticsVo.setDateType("3");
|
|
|
+ } else if ("1".equals(taskStatisticsVo.getDays())) {
|
|
|
+ taskStatisticsVo.setDateType("1");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (com.ydtech.utils.StringUtils.isNotEmpty(taskStatisticsVo.getParterProvinceId())) {
|
|
|
+ String provinceId = this.removeTrailingZeros(taskStatisticsVo.getParterProvinceId());
|
|
|
+ taskStatisticsVo.setParterProvinceId(provinceId);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (com.ydtech.utils.StringUtils.isNotEmpty(taskStatisticsVo.getParterCityId())) {
|
|
|
+ String cityId = this.removeTrailingZeros(taskStatisticsVo.getParterCityId());
|
|
|
+ taskStatisticsVo.setParterCityId(cityId);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (com.ydtech.utils.StringUtils.isNotEmpty(taskStatisticsVo.getParterCountyId())) {
|
|
|
+ String countyId = this.removeTrailingZeros(taskStatisticsVo.getParterCountyId());
|
|
|
+ taskStatisticsVo.setParterCountyId(countyId);
|
|
|
+ }
|
|
|
+
|
|
|
+ HashMap<String, String> dateMapByType = getDateMapByTypeNew(taskStatisticsVo.getDateType(), taskStatisticsVo.getCreatetimeStart(), taskStatisticsVo.getCreatetimeEnd());
|
|
|
+ taskStatisticsVo.setCreatetimeStart(dateMapByType.get("startDate"));
|
|
|
+ taskStatisticsVo.setCreatetimeEnd(dateMapByType.get("endDate"));
|
|
|
+
|
|
|
+ List<TaskStatisticsDto> list = this.insAreaCompanyMapper.getBusinessDataList(taskStatisticsVo);
|
|
|
+ List<BusinessCompanyExcel> sysUserPartners = BeanUtil.copyToList(list, BusinessCompanyExcel.class);
|
|
|
+ String uploadPath = this.uploadPath + "/excel/";
|
|
|
+ Path path = Paths.get(uploadPath);
|
|
|
+ if (!Files.exists(path)) {
|
|
|
+ try {
|
|
|
+ Files.createDirectories(path);
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ String fileName = EasyExcelUtils.downExcel(uploadPath, "业务数据保险公司导出", BusinessCompanyExcel.class, sysUserPartners);
|
|
|
+ return HttpResult.ok("", uploadUrl + "excel/" + fileName);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @description: 控制台 - 业务数据 - 代理人导出
|
|
|
+ * @author: whp
|
|
|
+ * @date: 2024/12/13
|
|
|
+ **/
|
|
|
+ @Override
|
|
|
+ public HttpResult getBusinessAgentExcel(TaskStatisticsVo taskStatisticsVo) {
|
|
|
+ if(StringUtils.isNotEmpty(taskStatisticsVo.getTreeType()) ){
|
|
|
+ if((StringUtils.isNotEmpty(taskStatisticsVo.getTreeUserId()) && "2".equals(taskStatisticsVo.getTreeType()))){
|
|
|
+ List<String> userIds=this.getNextLevel(taskStatisticsVo.getTreeUserId());
|
|
|
+ if(!userIds.isEmpty() && userIds.get(0)!=null){
|
|
|
+ taskStatisticsVo.setUserIds(userIds);
|
|
|
+ }else {
|
|
|
+ taskStatisticsVo.setUserId(taskStatisticsVo.getTreeUserId());
|
|
|
+ }
|
|
|
+ }else if (StringUtils.isNotEmpty(taskStatisticsVo.getTreeUserId()) && "1".equals(taskStatisticsVo.getTreeType())){
|
|
|
+ taskStatisticsVo.setDeptId(taskStatisticsVo.getTreeUserId());
|
|
|
+ taskStatisticsVo.setTreeUserId(null);
|
|
|
+ taskStatisticsVo.setUserIds(new ArrayList<>());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ HashMap<String, String> dateMapByType = getDateMapByTypeNew(taskStatisticsVo.getDateType(), taskStatisticsVo.getCreatetimeStart(), taskStatisticsVo.getCreatetimeEnd());
|
|
|
+ taskStatisticsVo.setCreatetimeStart(dateMapByType.get("startDate"));
|
|
|
+ taskStatisticsVo.setCreatetimeEnd(dateMapByType.get("endDate"));
|
|
|
+ getDateByType(taskStatisticsVo.getDateType(), taskStatisticsVo);
|
|
|
+ List<BusinessAgentData> list = this.taskStatisticsMapper.getBusinessAgentDataExcel(taskStatisticsVo);
|
|
|
+ for (BusinessAgentData record : list) {
|
|
|
+ this.appendName(record);
|
|
|
+ if (record.getDistributionAmountRate() == null) {
|
|
|
+ record.setDistributionAmountRate(new BigDecimal("0.0000"));
|
|
|
+ }
|
|
|
+ if(record.getManagementSource().equals("2")){
|
|
|
+ record.setManagementSource("代理人");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ List<BusinessAgentExcel> sysUserPartners = BeanUtil.copyToList(list, BusinessAgentExcel.class);
|
|
|
+
|
|
|
+ String uploadPath = this.uploadPath + "/excel/";
|
|
|
+ Path path = Paths.get(uploadPath);
|
|
|
+ if (!Files.exists(path)) {
|
|
|
+ try {
|
|
|
+ Files.createDirectories(path);
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ String fileName = EasyExcelUtils.downExcel(uploadPath, "业务数据代理人导出", BusinessAgentExcel.class, sysUserPartners);
|
|
|
+ return HttpResult.ok("", uploadUrl + "excel/" + fileName);
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * @description: 控制台 - 业务数据 -渠道导出
|
|
|
+ * @author: whp
|
|
|
+ * @date: 2024/12/13
|
|
|
+ **/
|
|
|
+ @Override
|
|
|
+ public HttpResult getChannelExcel(TaskStatisticsVo taskStatisticsVo) {
|
|
|
+ if(StringUtils.isNotEmpty(taskStatisticsVo.getTreeType()) ){
|
|
|
+ if((StringUtils.isNotEmpty(taskStatisticsVo.getTreeUserId()) && "2".equals(taskStatisticsVo.getTreeType()))){
|
|
|
+ List<String> userIds=this.getNextLevel(taskStatisticsVo.getTreeUserId());
|
|
|
+ if(!userIds.isEmpty() && userIds.get(0)!=null){
|
|
|
+ taskStatisticsVo.setUserIds(userIds);
|
|
|
+ }else {
|
|
|
+ taskStatisticsVo.setUserId(taskStatisticsVo.getTreeUserId());
|
|
|
+ }
|
|
|
+ }else if (StringUtils.isNotEmpty(taskStatisticsVo.getTreeUserId()) && "1".equals(taskStatisticsVo.getTreeType())){
|
|
|
+ taskStatisticsVo.setDeptId(taskStatisticsVo.getTreeUserId());
|
|
|
+ taskStatisticsVo.setTreeUserId(null);
|
|
|
+ taskStatisticsVo.setUserIds(new ArrayList<>());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ HashMap<String, String> dateMapByType = getDateMapByTypeNew(taskStatisticsVo.getDateType(), taskStatisticsVo.getCreatetimeStart(), taskStatisticsVo.getCreatetimeEnd());
|
|
|
+ taskStatisticsVo.setCreatetimeStart(dateMapByType.get("startDate"));
|
|
|
+ taskStatisticsVo.setCreatetimeEnd(dateMapByType.get("endDate"));
|
|
|
+ getDateByType(taskStatisticsVo.getDateType(), taskStatisticsVo);
|
|
|
+ List<BusinessAgentData> list = this.taskStatisticsMapper.getBusinessAgentDataExcel(taskStatisticsVo);
|
|
|
+ for (BusinessAgentData record : list) {
|
|
|
+ this.appendName(record);
|
|
|
+ if (record.getDistributionAmountRate() == null) {
|
|
|
+ record.setDistributionAmountRate(new BigDecimal("0.0000"));
|
|
|
+ }
|
|
|
+ if(record.getManagementSource().equals("1")){
|
|
|
+ record.setManagementSource("渠道");
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ List<GetChannelExcel> sysUserPartners = BeanUtil.copyToList(list, GetChannelExcel.class);
|
|
|
+
|
|
|
+ String uploadPath = this.uploadPath + "/excel/";
|
|
|
+ Path path = Paths.get(uploadPath);
|
|
|
+ if (!Files.exists(path)) {
|
|
|
+ try {
|
|
|
+ Files.createDirectories(path);
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ String fileName = EasyExcelUtils.downExcel(uploadPath, "业务数据渠道导出", GetChannelExcel.class, sysUserPartners);
|
|
|
+ return HttpResult.ok("", uploadUrl + "excel/" + fileName);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* @version
|
|
|
* @author: hh
|