|
|
@@ -0,0 +1,305 @@
|
|
|
+package com.ydtech.modules.admin.service.impl;
|
|
|
+
|
|
|
+
|
|
|
+import com.ydtech.core.page.HttpResult;
|
|
|
+import com.ydtech.modules.admin.dao.SysUserAccountHistoryMapper;
|
|
|
+import com.ydtech.modules.admin.model.dto.*;
|
|
|
+import com.ydtech.modules.admin.model.vo.ReportQueryVo;
|
|
|
+import com.ydtech.modules.admin.service.AppReportService;
|
|
|
+import com.ydtech.modules.admin.utils.SliceUpDateUtil;
|
|
|
+import com.ydtech.modules.esm.dao.EsmUserReferrerMapper;
|
|
|
+import com.ydtech.modules.order.dao.InsAreaCompanyMapper;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+import java.math.BigDecimal;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.LinkedHashMap;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @version
|
|
|
+ * @author: hxl
|
|
|
+ * @Date: 2024/6/5 15:25
|
|
|
+ * @Description: 报表统计页面
|
|
|
+ */
|
|
|
+@Service
|
|
|
+public class AppReportServiceImpl implements AppReportService {
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private InsAreaCompanyMapper insAreaCompanyMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private EsmUserReferrerMapper esmUserReferrerMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private SysUserAccountHistoryMapper sysUserAccountHistoryMapper;
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @version
|
|
|
+ * @author: hxl
|
|
|
+ * @Date: 2024/6/5 16:05
|
|
|
+ * @Description: 保费报表统计
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public HttpResult<PremiumReportAllDto> premiumReport(ReportQueryVo reportQueryVo) {
|
|
|
+ //年分查询当年12月的数据
|
|
|
+ if("1".equals(reportQueryVo.getSearchType())){
|
|
|
+ List<PremiumReportDto> allList= insAreaCompanyMapper.premiumReportYear(getDateMap(reportQueryVo));
|
|
|
+ return HttpResult.ok(getPremiumReportAllDto(allList, getDateStrings(reportQueryVo),reportQueryVo.getSearchYear()));
|
|
|
+ }
|
|
|
+ //月分查询当月的数据
|
|
|
+ if("2".equals(reportQueryVo.getSearchType())){
|
|
|
+ reportQueryVo.setSearchMonth(reportQueryVo.getSearchYear()+"-"+reportQueryVo.getSearchMonth());
|
|
|
+ List<PremiumReportDto> allList= insAreaCompanyMapper.premiumReportMonth(getDateMap(reportQueryVo));
|
|
|
+ return HttpResult.ok(getPremiumReportAllDto(allList, getDateStrings(reportQueryVo),reportQueryVo.getSearchMonth()));
|
|
|
+ }
|
|
|
+ //日查询当日的前20条数据
|
|
|
+ if("3".equals(reportQueryVo.getSearchType())){
|
|
|
+ reportQueryVo.setSearchDay(reportQueryVo.getSearchYear()+"-"+reportQueryVo.getSearchMonth()+"-"+reportQueryVo.getSearchDay());
|
|
|
+ List<PremiumReportDto> allList= insAreaCompanyMapper.premiumReportDay(getDateMap(reportQueryVo));
|
|
|
+ return HttpResult.ok(getPremiumReportAllDto(allList, getDateStrings(reportQueryVo),reportQueryVo.getSearchDay()));
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * @version
|
|
|
+ * @author: hxl
|
|
|
+ * @Date: 2024/6/6 9:07
|
|
|
+ * @Description: 处理日期返回对应的数据
|
|
|
+ */
|
|
|
+ private static List<String> getDateStrings(ReportQueryVo reportQueryVo) {
|
|
|
+ //获取所有的月分
|
|
|
+ if("1".equals(reportQueryVo.getSearchType())){
|
|
|
+ return SliceUpDateUtil.sliceUpDateRange(SliceUpDateUtil.getFirstDayStringByYear(Integer.parseInt(reportQueryVo.getSearchYear())),
|
|
|
+ SliceUpDateUtil.getLastDayStringByYear(Integer.parseInt(reportQueryVo.getSearchYear())), 2);
|
|
|
+ }
|
|
|
+ //获取所有的日
|
|
|
+ if("2".equals(reportQueryVo.getSearchType())){
|
|
|
+ int year = Integer.parseInt(reportQueryVo.getSearchMonth().split("-")[0]);
|
|
|
+ int month = Integer.parseInt(reportQueryVo.getSearchMonth().split("-")[1].replaceAll("^0+", ""));
|
|
|
+ return SliceUpDateUtil.sliceUpDateRange(SliceUpDateUtil.getFirstDayStringByMonth(year,month),
|
|
|
+ SliceUpDateUtil.getLastDayStringByMonth(year,month), 3);
|
|
|
+ }
|
|
|
+ //获取所有的时
|
|
|
+ if("3".equals(reportQueryVo.getSearchType())){
|
|
|
+ return SliceUpDateUtil.sliceUpDateRange(reportQueryVo.getSearchDay()+" 00",
|
|
|
+ reportQueryVo.getSearchDay()+" 23", 4);
|
|
|
+ }
|
|
|
+ return new ArrayList<String>();
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * @version
|
|
|
+ * @author: hxl
|
|
|
+ * @Date: 2024/6/6 15:05
|
|
|
+ * @Description: 获取开始和结束时间
|
|
|
+ */
|
|
|
+ private static HashMap<String,String> getDateMap(ReportQueryVo reportQueryVo) {
|
|
|
+ HashMap<String,String> map=new HashMap<String,String>();
|
|
|
+ String beginTime="";
|
|
|
+ String endTime="";
|
|
|
+ //获取所有的月分
|
|
|
+ if("1".equals(reportQueryVo.getSearchType())){
|
|
|
+ beginTime = SliceUpDateUtil.getFirstDayStringByYear(Integer.parseInt(reportQueryVo.getSearchYear()))+" 00:00:00";
|
|
|
+ endTime = SliceUpDateUtil.getLastDayStringByYear(Integer.parseInt(reportQueryVo.getSearchYear()))+" 23:59:59";
|
|
|
+ }
|
|
|
+ //获取所有的日
|
|
|
+ if("2".equals(reportQueryVo.getSearchType())){
|
|
|
+ int year = Integer.parseInt(reportQueryVo.getSearchMonth().split("-")[0]);
|
|
|
+ int month = Integer.parseInt(reportQueryVo.getSearchMonth().split("-")[1].replaceAll("^0+", ""));
|
|
|
+ beginTime = SliceUpDateUtil.getFirstDayStringByMonth(year,month)+" 00:00:00";
|
|
|
+ endTime = SliceUpDateUtil.getLastDayStringByMonth(year,month)+" 23:59:59";
|
|
|
+ }
|
|
|
+ //获取所有的时
|
|
|
+ if("3".equals(reportQueryVo.getSearchType())){
|
|
|
+ beginTime = reportQueryVo.getSearchDay()+" 00:00:00";
|
|
|
+ endTime = reportQueryVo.getSearchDay()+" 23:59:59";
|
|
|
+ }
|
|
|
+ map.put("beginTime",beginTime);
|
|
|
+ map.put("endTime",endTime);
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @version
|
|
|
+ * @author: hxl
|
|
|
+ * @Date: 2024/6/6 9:02
|
|
|
+ * @Description: 处理保费的数据
|
|
|
+ */
|
|
|
+ private static PremiumReportAllDto getPremiumReportAllDto(List<PremiumReportDto> allList, List<String> dateStrs, String dateStr) {
|
|
|
+ List<PremiumReportDto> list =new ArrayList<>();
|
|
|
+ BigDecimal jqPremium =BigDecimal.ZERO;
|
|
|
+ BigDecimal syPremium=BigDecimal.ZERO;
|
|
|
+ BigDecimal sumPremium=BigDecimal.ZERO;
|
|
|
+ List<BigDecimal> jqPremiumList =new ArrayList<>();
|
|
|
+ List<BigDecimal> syPremiumList =new ArrayList<>();
|
|
|
+ List<BigDecimal> sumPremiumList =new ArrayList<>();
|
|
|
+ LinkedHashMap<String,PremiumReportDto> map=new LinkedHashMap<String,PremiumReportDto>();
|
|
|
+ if(allList !=null && allList.size()>0){
|
|
|
+ for(PremiumReportDto premiumReportDto: allList){
|
|
|
+ map.put(premiumReportDto.getReportDate(),premiumReportDto);
|
|
|
+ }
|
|
|
+ for(String str: dateStrs){
|
|
|
+ if(map.get(str)==null){
|
|
|
+ jqPremiumList.add(BigDecimal.ZERO);
|
|
|
+ syPremiumList.add(BigDecimal.ZERO);
|
|
|
+ sumPremiumList.add(BigDecimal.ZERO);
|
|
|
+ list.add(new PremiumReportDto(str,BigDecimal.ZERO,BigDecimal.ZERO,BigDecimal.ZERO));
|
|
|
+ }else{
|
|
|
+ jqPremium=jqPremium.add(map.get(str).getJqPremium());
|
|
|
+ syPremium=syPremium.add(map.get(str).getSyPremium());
|
|
|
+ sumPremium=sumPremium.add(map.get(str).getSumPremium());
|
|
|
+ jqPremiumList.add(map.get(str).getJqPremium());
|
|
|
+ syPremiumList.add(map.get(str).getSyPremium());
|
|
|
+ sumPremiumList.add(map.get(str).getSumPremium());
|
|
|
+ list.add(map.get(str));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ for (String str : dateStrs) {
|
|
|
+ jqPremiumList.add(BigDecimal.ZERO);
|
|
|
+ syPremiumList.add(BigDecimal.ZERO);
|
|
|
+ sumPremiumList.add(BigDecimal.ZERO);
|
|
|
+ list.add(new PremiumReportDto(str, BigDecimal.ZERO, BigDecimal.ZERO, BigDecimal.ZERO));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return new PremiumReportAllDto(dateStr,jqPremium,syPremium,sumPremium,dateStrs,jqPremiumList,syPremiumList,sumPremiumList);
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * @version
|
|
|
+ * @author: hxl
|
|
|
+ * @Date: 2024/6/6 9:02
|
|
|
+ * @Description: 处理增员的数据
|
|
|
+ */
|
|
|
+ private static EmployeeIncreaseReportAllDto getEmployeeIncreaseReportAllDto(List<EmployeeIncreaseReportDto> allList, List<String> dateStrs, String dateStr) {
|
|
|
+ List<EmployeeIncreaseReportDto> list =new ArrayList<>();
|
|
|
+ LinkedHashMap<String,EmployeeIncreaseReportDto> map=new LinkedHashMap<String,EmployeeIncreaseReportDto>();
|
|
|
+ int employeeIncreaseCount=0;
|
|
|
+ List<Integer> employeeIncreaseList =new ArrayList<>();
|
|
|
+ if(allList !=null && allList.size()>0){
|
|
|
+ for(EmployeeIncreaseReportDto employeeIncreaseReportDto: allList){
|
|
|
+ map.put(employeeIncreaseReportDto.getReportDate(),employeeIncreaseReportDto);
|
|
|
+ }
|
|
|
+ for(String str: dateStrs){
|
|
|
+ if(map.get(str)==null){
|
|
|
+ employeeIncreaseList.add(0);
|
|
|
+ list.add(new EmployeeIncreaseReportDto(str,0));
|
|
|
+ }else{
|
|
|
+ employeeIncreaseCount+=(map.get(str).getEmployeeIncreaseCount());
|
|
|
+ employeeIncreaseList.add(map.get(str).getEmployeeIncreaseCount());
|
|
|
+ list.add(map.get(str));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ for(String str: dateStrs){
|
|
|
+ employeeIncreaseList.add(0);
|
|
|
+ list.add(new EmployeeIncreaseReportDto(str,0));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return new EmployeeIncreaseReportAllDto(dateStr,employeeIncreaseCount,dateStrs,employeeIncreaseList);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @version
|
|
|
+ * @author: hxl
|
|
|
+ * @Date: 2024/6/6 9:02
|
|
|
+ * @Description: 处理收入报表的数据
|
|
|
+ */
|
|
|
+ private static RevenueReportAllDto getRevenueReportAllDto(List<RevenueReportDto> allList, List<String> dateStrs,String dateStr) {
|
|
|
+ List<RevenueReportDto> list =new ArrayList<RevenueReportDto>();
|
|
|
+ BigDecimal haldingAmount =BigDecimal.ZERO;
|
|
|
+ BigDecimal documentaryAmount=BigDecimal.ZERO;
|
|
|
+ BigDecimal promotionAmount=BigDecimal.ZERO;
|
|
|
+ List<BigDecimal> haldingAmountList =new ArrayList<>();
|
|
|
+ List<BigDecimal> documentaryAmountList =new ArrayList<>();
|
|
|
+ List<BigDecimal> promotionAmountList =new ArrayList<>();
|
|
|
+ LinkedHashMap<String,RevenueReportDto> map=new LinkedHashMap<String,RevenueReportDto>();
|
|
|
+ if(allList !=null && allList.size()>0){
|
|
|
+ for(RevenueReportDto revenueReportDto: allList){
|
|
|
+ map.put(revenueReportDto.getReportDate(),revenueReportDto);
|
|
|
+ }
|
|
|
+ for(String str: dateStrs){
|
|
|
+ if(map.get(str)==null){
|
|
|
+ haldingAmountList.add(BigDecimal.ZERO);
|
|
|
+ documentaryAmountList.add(BigDecimal.ZERO);
|
|
|
+ promotionAmountList.add(BigDecimal.ZERO);
|
|
|
+ list.add(new RevenueReportDto(str,BigDecimal.ZERO,BigDecimal.ZERO,BigDecimal.ZERO));
|
|
|
+ }else{
|
|
|
+ haldingAmount=haldingAmount.add(map.get(str).getHaldingAmount());
|
|
|
+ documentaryAmount=documentaryAmount.add(map.get(str).getDocumentaryAmount());
|
|
|
+ promotionAmount=promotionAmount.add(map.get(str).getPromotionAmount());
|
|
|
+ haldingAmountList.add(map.get(str).getHaldingAmount());
|
|
|
+ documentaryAmountList.add(map.get(str).getDocumentaryAmount());
|
|
|
+ promotionAmountList.add(map.get(str).getPromotionAmount());
|
|
|
+ list.add(map.get(str));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ for (String str : dateStrs) {
|
|
|
+ haldingAmountList.add(BigDecimal.ZERO);
|
|
|
+ documentaryAmountList.add(BigDecimal.ZERO);
|
|
|
+ promotionAmountList.add(BigDecimal.ZERO);
|
|
|
+ list.add(new RevenueReportDto(str,BigDecimal.ZERO,BigDecimal.ZERO,BigDecimal.ZERO));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return new RevenueReportAllDto(dateStr,haldingAmount,documentaryAmount,promotionAmount,dateStrs,haldingAmountList,documentaryAmountList,promotionAmountList);
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * @version
|
|
|
+ * @author: hxl
|
|
|
+ * @Date: 2024/6/5 16:05
|
|
|
+ * @Description: 增援报表统计
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public HttpResult<EmployeeIncreaseReportAllDto> employeeIncreaseReport(ReportQueryVo reportQueryVo) {
|
|
|
+ //年分查询当年12月的数据
|
|
|
+ if("1".equals(reportQueryVo.getSearchType())){
|
|
|
+ List<EmployeeIncreaseReportDto> allList= esmUserReferrerMapper.employeeIncreaseReportYear(getDateMap(reportQueryVo));
|
|
|
+ return HttpResult.ok(getEmployeeIncreaseReportAllDto(allList, getDateStrings(reportQueryVo),reportQueryVo.getSearchYear()));
|
|
|
+ }
|
|
|
+ //月分查询当月的数据
|
|
|
+ if("2".equals(reportQueryVo.getSearchType())){
|
|
|
+ reportQueryVo.setSearchMonth(reportQueryVo.getSearchYear()+"-"+reportQueryVo.getSearchMonth());
|
|
|
+ List<EmployeeIncreaseReportDto> allList= esmUserReferrerMapper.employeeIncreaseReportMonth(getDateMap(reportQueryVo));
|
|
|
+ return HttpResult.ok(getEmployeeIncreaseReportAllDto(allList, getDateStrings(reportQueryVo),reportQueryVo.getSearchMonth()));
|
|
|
+ }
|
|
|
+ //日查询当日的前20条数据
|
|
|
+ if("3".equals(reportQueryVo.getSearchType())){
|
|
|
+ reportQueryVo.setSearchDay(reportQueryVo.getSearchYear()+"-"+reportQueryVo.getSearchMonth()+"-"+reportQueryVo.getSearchDay());
|
|
|
+ List<EmployeeIncreaseReportDto> allList= esmUserReferrerMapper.employeeIncreaseReportDay(getDateMap(reportQueryVo));
|
|
|
+ return HttpResult.ok(getEmployeeIncreaseReportAllDto(allList, getDateStrings(reportQueryVo),reportQueryVo.getSearchDay()));
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * @version
|
|
|
+ * @author: hxl
|
|
|
+ * @Date: 2024/6/5 16:05
|
|
|
+ * @Description: 收入报表统计
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public HttpResult<RevenueReportAllDto> revenueReport(ReportQueryVo reportQueryVo) {
|
|
|
+ //年分查询当年12月的数据
|
|
|
+ if("1".equals(reportQueryVo.getSearchType())){
|
|
|
+ List<RevenueReportDto> allList= sysUserAccountHistoryMapper.revenueReportYear(getDateMap(reportQueryVo));
|
|
|
+ return HttpResult.ok(getRevenueReportAllDto(allList, getDateStrings(reportQueryVo),reportQueryVo.getSearchYear()));
|
|
|
+ }
|
|
|
+ //月分查询当月的数据
|
|
|
+ if("2".equals(reportQueryVo.getSearchType())){
|
|
|
+ reportQueryVo.setSearchMonth(reportQueryVo.getSearchYear()+"-"+reportQueryVo.getSearchMonth());
|
|
|
+ List<RevenueReportDto> allList= sysUserAccountHistoryMapper.revenueReportMonth(getDateMap(reportQueryVo));
|
|
|
+ return HttpResult.ok(getRevenueReportAllDto(allList, getDateStrings(reportQueryVo),reportQueryVo.getSearchMonth()));
|
|
|
+ }
|
|
|
+ //日查询当日的前20条数据
|
|
|
+ if("3".equals(reportQueryVo.getSearchType())){
|
|
|
+ reportQueryVo.setSearchDay(reportQueryVo.getSearchYear()+"-"+reportQueryVo.getSearchMonth()+"-"+reportQueryVo.getSearchDay());
|
|
|
+ List<RevenueReportDto> allList= sysUserAccountHistoryMapper.revenueReportDay(getDateMap(reportQueryVo));
|
|
|
+ return HttpResult.ok(getRevenueReportAllDto(allList, getDateStrings(reportQueryVo),reportQueryVo.getSearchDay()));
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+}
|