|
|
@@ -6,23 +6,35 @@ import com.github.pagehelper.PageHelper;
|
|
|
import com.github.pagehelper.PageInfo;
|
|
|
import com.ydtech.core.page.HttpResult;
|
|
|
import com.ydtech.core.page.PageRequest;
|
|
|
+import com.ydtech.exception.SystemException;
|
|
|
import com.ydtech.modules.admin.dao.SysAmountAuditingMapper;
|
|
|
+import com.ydtech.modules.admin.dao.TaskStatisticsMapper;
|
|
|
import com.ydtech.modules.admin.model.SysDept;
|
|
|
+import com.ydtech.modules.admin.model.dto.InsuranceCompanyExcel;
|
|
|
import com.ydtech.modules.admin.model.dto.TaskStatisticsDto;
|
|
|
+import com.ydtech.modules.admin.model.dto.TaskStatisticsExcel;
|
|
|
+import com.ydtech.modules.admin.model.vo.BusinessAgentData;
|
|
|
import com.ydtech.modules.admin.model.vo.TaskStatisticsVo;
|
|
|
import com.ydtech.modules.admin.service.SysDeptService;
|
|
|
import com.ydtech.modules.admin.service.TaskStatisticsService;
|
|
|
+import com.ydtech.modules.admin.utils.SliceUpDateUtil;
|
|
|
import com.ydtech.modules.base.model.vo.PageVo;
|
|
|
-import com.ydtech.modules.fnc.entity.InsPlyIncome;
|
|
|
+import com.ydtech.modules.inv.utils.EasyExcelUtils;
|
|
|
import com.ydtech.modules.order.dao.InsAreaCompanyMapper;
|
|
|
import com.ydtech.modules.order.dao.InsOrdersMapper;
|
|
|
-import com.ydtech.modules.order.entity.BasePageResult;
|
|
|
-import com.ydtech.modules.order.entity.InsAreaCompany;
|
|
|
import org.apache.commons.lang3.ObjectUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import java.io.File;
|
|
|
+import java.io.IOException;
|
|
|
+import java.math.BigDecimal;
|
|
|
+import java.math.RoundingMode;
|
|
|
+import java.nio.file.Files;
|
|
|
+import java.nio.file.Path;
|
|
|
+import java.nio.file.Paths;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Date;
|
|
|
import java.util.HashMap;
|
|
|
@@ -44,10 +56,20 @@ public class TaskStatisticsServiceImpl implements TaskStatisticsService {
|
|
|
@Autowired
|
|
|
private InsOrdersMapper insOrdersMapper;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private TaskStatisticsMapper taskStatisticsMapper;
|
|
|
+
|
|
|
@Autowired
|
|
|
private SysDeptService sysDeptService;
|
|
|
|
|
|
|
|
|
+ @Value("${upload.file.path}")
|
|
|
+ private String uploadPath;
|
|
|
+
|
|
|
+ @Value("${upload.file.url}")
|
|
|
+ private String uploadUrl;
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* @description: 渠道任务统计查询
|
|
|
* @author: whp
|
|
|
@@ -129,17 +151,18 @@ public class TaskStatisticsServiceImpl implements TaskStatisticsService {
|
|
|
if (StringUtils.isNotEmpty(deptId)) {
|
|
|
int length = deptId.length();
|
|
|
if (length > 0) {
|
|
|
- if (length > 10) {
|
|
|
- String substring = deptId.substring(0, 6);
|
|
|
- String substring1 = deptId.substring(0, 8);
|
|
|
- SysDept cityName = sysDeptService.getById(substring);
|
|
|
- SysDept districtName = sysDeptService.getById(substring1);
|
|
|
- record.setCityName(cityName.getName());
|
|
|
- record.setDistrictName(districtName.getName());
|
|
|
- } else if (length > 6) {
|
|
|
- String substring = deptId.substring(0, 6);
|
|
|
- SysDept cityName = sysDeptService.getById(substring);
|
|
|
- record.setCityName(cityName.getName());
|
|
|
+ if (length > 0) {
|
|
|
+ if (length > 10) {
|
|
|
+ String substring = deptId.substring(0, 6);
|
|
|
+ String substring1 = deptId.substring(0, 8);
|
|
|
+ String province = deptId.substring(0, 4);
|
|
|
+ SysDept cityName = sysDeptService.getById(substring);
|
|
|
+ SysDept districtName = sysDeptService.getById(substring1);
|
|
|
+ SysDept provinceName = sysDeptService.getById(province);
|
|
|
+ record.setCityName(cityName.getName());
|
|
|
+ record.setDistrictName(districtName.getName());
|
|
|
+ record.setProvinceName(provinceName.getName());
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -210,4 +233,169 @@ public class TaskStatisticsServiceImpl implements TaskStatisticsService {
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * @description: 任务统计-渠道导出
|
|
|
+ * @author: whp
|
|
|
+ * @date: 2024/09/09
|
|
|
+ **/
|
|
|
+ @Override
|
|
|
+ public HttpResult channelExcel(TaskStatisticsVo taskStatisticsVo) {
|
|
|
+ taskStatisticsVo.setManagementSource("1");
|
|
|
+ return getHttpResult(taskStatisticsVo);
|
|
|
+ }
|
|
|
+
|
|
|
+ private HttpResult getHttpResult(TaskStatisticsVo taskStatisticsVo) {
|
|
|
+ List<TaskStatisticsExcel> list = this.insAreaCompanyMapper.channelExcel(taskStatisticsVo);
|
|
|
+ if (list != null && !list.isEmpty()) {
|
|
|
+ for (TaskStatisticsExcel record : list) {
|
|
|
+ String deptId = record.getDeptId();
|
|
|
+ if (StringUtils.isNotEmpty(deptId)) {
|
|
|
+ int length = deptId.length();
|
|
|
+ if (length > 0) {
|
|
|
+ if (length > 0) {
|
|
|
+ if (length > 10) {
|
|
|
+ String substring = deptId.substring(0, 6);
|
|
|
+ String substring1 = deptId.substring(0, 8);
|
|
|
+ String province = deptId.substring(0, 4);
|
|
|
+ SysDept cityName = sysDeptService.getById(substring);
|
|
|
+ SysDept districtName = sysDeptService.getById(substring1);
|
|
|
+ SysDept provinceName = sysDeptService.getById(province);
|
|
|
+ record.setCityName(cityName.getName());
|
|
|
+ record.setDistrictName(districtName.getName());
|
|
|
+ record.setProvinceName(provinceName.getName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ 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, taskStatisticsVo.getManagementSource() .equals("1") ? "渠道导出":"代理人导出", TaskStatisticsExcel.class, list);
|
|
|
+ return HttpResult.ok("", uploadUrl + "excel/" + fileName);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @description: 任控制台-业务数据-代理人
|
|
|
+ * @author: whp
|
|
|
+ * @date: 2024/09/09
|
|
|
+ **/
|
|
|
+ @Override
|
|
|
+ public IPage<BusinessAgentData> getBusinessAgentData(TaskStatisticsVo taskStatisticsVo) {
|
|
|
+ PageVo<TaskStatisticsVo> pageVo = new PageVo<>();
|
|
|
+ Page page = new Page(taskStatisticsVo.getPageNum(), taskStatisticsVo.getPageSize());
|
|
|
+ page.setSearchCount(false).setOptimizeCountSql(false);//关闭count查询
|
|
|
+ pageVo.setPageNum(taskStatisticsVo.getPageNum());
|
|
|
+ pageVo.setPageSize(taskStatisticsVo.getPageSize());
|
|
|
+
|
|
|
+
|
|
|
+ HashMap<String, String> dateMapByType = getDateMapByType(taskStatisticsVo.getDateType(), taskStatisticsVo.getCreatetimeStart(), taskStatisticsVo.getCreatetimeEnd());
|
|
|
+ taskStatisticsVo.setCreatetimeStart(dateMapByType.get("startDate"));
|
|
|
+ taskStatisticsVo.setCreatetimeEnd(dateMapByType.get("endDate"));
|
|
|
+
|
|
|
+ IPage<BusinessAgentData> list = this.taskStatisticsMapper.getBusinessAgentData(page,taskStatisticsVo);
|
|
|
+ Long total = this.taskStatisticsMapper.getBusinessAgentDataTotal(taskStatisticsVo);
|
|
|
+ list.setTotal(total);
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @version
|
|
|
+ * @author: hxl
|
|
|
+ * @Date: 2024/6/19 11:57
|
|
|
+ * @Description: 通过时间类型判断
|
|
|
+ */
|
|
|
+ private static HashMap<String,String> getDateMapByType(String type, String startDate, String endDate) {
|
|
|
+ HashMap<String,String> map =new HashMap<>();
|
|
|
+ String startDateStr="";
|
|
|
+ String endDateStr="";
|
|
|
+ if(StringUtils.isNotBlank(startDate) && StringUtils.isNotBlank(endDate)){
|
|
|
+ startDateStr= StringUtils.isNotBlank(startDate)?startDate+" 00:00:00":null;
|
|
|
+ endDateStr= StringUtils.isNotBlank(endDate)?endDate+" 23:59:59":null;
|
|
|
+ }else{
|
|
|
+ if("1".equals(type)){
|
|
|
+ // 一月内
|
|
|
+ startDateStr= SliceUpDateUtil.getBeforeDay(new Date(),2)+" 00:00:00";
|
|
|
+ endDateStr=SliceUpDateUtil.getBeforeDay(new Date(),0)+" 23:59:59";
|
|
|
+ }else if("2".equals(type)){
|
|
|
+ // 三月内
|
|
|
+ startDateStr=SliceUpDateUtil.getBeforeDay(new Date(),3)+" 00:00:00";
|
|
|
+ endDateStr=SliceUpDateUtil.getBeforeDay(new Date(),0)+" 23:59:59";
|
|
|
+ }else if("3".equals(type)){
|
|
|
+ // 近半年
|
|
|
+ startDateStr=SliceUpDateUtil.getBeforeDay(new Date(),4)+" 00:00:00";
|
|
|
+ endDateStr=SliceUpDateUtil.getBeforeDay(new Date(),0)+" 23:59:59";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ map.put("startDate",startDateStr);
|
|
|
+ map.put("endDate",endDateStr);
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @description: 任控制台-业务数据-代理人-合计
|
|
|
+ * @author: whp
|
|
|
+ * @date: 2024/09/09
|
|
|
+ **/
|
|
|
+ @Override
|
|
|
+ public BusinessAgentData getBusinessAgentDataTotal(TaskStatisticsVo taskStatisticsVo) {
|
|
|
+ HashMap<String, String> dateMapByType = getDateMapByType(taskStatisticsVo.getDateType(), taskStatisticsVo.getCreatetimeStart(), taskStatisticsVo.getCreatetimeEnd());
|
|
|
+ taskStatisticsVo.setCreatetimeStart(dateMapByType.get("startDate"));
|
|
|
+ taskStatisticsVo.setCreatetimeEnd(dateMapByType.get("endDate"));
|
|
|
+
|
|
|
+ BusinessAgentData result = this.taskStatisticsMapper.getBusinessAgentDataTotalAdd(taskStatisticsVo);
|
|
|
+
|
|
|
+ BusinessAgentData allsumPremium = this.taskStatisticsMapper.getAllsumPremium(taskStatisticsVo);
|
|
|
+
|
|
|
+ if (ObjectUtils.isNotEmpty(allsumPremium) && ObjectUtils.isNotEmpty(result)) {
|
|
|
+ BigDecimal sumPremium = allsumPremium.getSumPremium().compareTo(BigDecimal.ZERO) > 0 ? allsumPremium.getSumPremium() : BigDecimal.ZERO;
|
|
|
+ BigDecimal resultSumPremium = result.getSumPremium().compareTo(BigDecimal.ZERO) > 0 ? result.getSumPremium() : BigDecimal.ZERO;
|
|
|
+ if (!sumPremium.equals(BigDecimal.ZERO)) {
|
|
|
+ result.setSumPremiumProportion(resultSumPremium.divide(sumPremium).setScale(2, RoundingMode.DOWN).multiply(new BigDecimal("100")));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * @description: 任务统计-代理人导出
|
|
|
+ * @author: whp
|
|
|
+ * @date: 2024/9/9
|
|
|
+ **/
|
|
|
+ @Override
|
|
|
+ public HttpResult agentExcel(TaskStatisticsVo taskStatisticsVo) {
|
|
|
+ taskStatisticsVo.setManagementSource("2");
|
|
|
+ return getHttpResult(taskStatisticsVo);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @description: 任务统计-保险公司-导出
|
|
|
+ * @author: whp
|
|
|
+ * @date: 2024/9/9
|
|
|
+ **/
|
|
|
+ @Override
|
|
|
+ public HttpResult insuranceCompanyExcel(TaskStatisticsVo taskStatisticsVo) {
|
|
|
+ List<InsuranceCompanyExcel> list = this.insAreaCompanyMapper.insuranceCompanyExcel(taskStatisticsVo);
|
|
|
+ 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, "保险公司导出", InsuranceCompanyExcel.class, list);
|
|
|
+ return HttpResult.ok("", uploadUrl + "excel/" + fileName);
|
|
|
+ }
|
|
|
+
|
|
|
}
|