diff --git a/ruoyi-bussiness/src/main/java/com/ruoyi/cms/mapper/ThemeProfessionalTrainMapper.java b/ruoyi-bussiness/src/main/java/com/ruoyi/cms/mapper/ThemeProfessionalTrainMapper.java index 905c6e7..2cb098a 100644 --- a/ruoyi-bussiness/src/main/java/com/ruoyi/cms/mapper/ThemeProfessionalTrainMapper.java +++ b/ruoyi-bussiness/src/main/java/com/ruoyi/cms/mapper/ThemeProfessionalTrainMapper.java @@ -13,6 +13,14 @@ import java.util.List; */ public interface ThemeProfessionalTrainMapper { + /** + * 查询数量 + * + * @param dto 查询参数 + * @return 结果 + */ + Long queryCount(QueryParamDto dto); + /** * 通过技能等级查询 * diff --git a/ruoyi-bussiness/src/main/java/com/ruoyi/cms/service/impl/AnalysisSectorTalentServiceImpl.java b/ruoyi-bussiness/src/main/java/com/ruoyi/cms/service/impl/AnalysisSectorTalentServiceImpl.java index 4a14080..0e23c9d 100644 --- a/ruoyi-bussiness/src/main/java/com/ruoyi/cms/service/impl/AnalysisSectorTalentServiceImpl.java +++ b/ruoyi-bussiness/src/main/java/com/ruoyi/cms/service/impl/AnalysisSectorTalentServiceImpl.java @@ -33,6 +33,7 @@ import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Objects; import java.util.Optional; import java.util.Set; @@ -60,8 +61,15 @@ public class AnalysisSectorTalentServiceImpl implements AnalysisSectorTalentServ // 计算当前时间数据 ParamUtil.dealParam(dto); BigDecimal sectorAmount = themeSectorDevelopMapper.querySectorAmount(dto); + if (Objects.nonNull(sectorAmount)) { + sectorAmount = MathUtil.divide(new BigDecimal("100000000"), sectorAmount); + } BigDecimal companyNewInvestmentAmount = themeSectorDevelopMapper.queryCompanyNewInvestmentAmount(dto); + if (Objects.nonNull(companyNewInvestmentAmount)) { + companyNewInvestmentAmount = MathUtil.divide(new BigDecimal("100000000"), + companyNewInvestmentAmount); + } Long talentDemandCount = Optional.ofNullable(themeRecruitmentJobMapper.queryDemandCount(dto)) .orElse(0L); @@ -75,6 +83,8 @@ public class AnalysisSectorTalentServiceImpl implements AnalysisSectorTalentServ Long startupCompanyCount = themeSectorDevelopMapper.queryStartupCompanyCount(dto); + Long skillTrainCount = themeProfessionalTrainMapper.queryCount(dto); + // 计算上一时间段数据 QueryParamDto lastDto = new QueryParamDto(); BeanUtils.copyProperties(dto, lastDto); @@ -97,6 +107,8 @@ public class AnalysisSectorTalentServiceImpl implements AnalysisSectorTalentServ Long lastStartupCompanyCount = themeSectorDevelopMapper.queryStartupCompanyCount(lastDto); + Long lastSkillTrainCount = themeProfessionalTrainMapper.queryCount(lastDto); + return SectorTalentOverviewVo.builder() .sectorAmount(sectorAmount) .sectorAmountMom(MathUtil.calculatePercentageGrowthRate(lastSectorAmount, sectorAmount)) @@ -117,6 +129,8 @@ public class AnalysisSectorTalentServiceImpl implements AnalysisSectorTalentServ .startupCompanyCount(startupCompanyCount) .startupCompanyCountMom( MathUtil.calculatePercentageGrowthRate(lastStartupCompanyCount, startupCompanyCount)) + .skillTrainCount(skillTrainCount) + .skillTrainCountMom(MathUtil.calculatePercentageGrowthRate(lastSkillTrainCount, skillTrainCount)) .build(); } @@ -231,17 +245,32 @@ public class AnalysisSectorTalentServiceImpl implements AnalysisSectorTalentServ .orElse(SectorTalentTreadVo.builder().build()); } + BigDecimal sectorInvestmentAmount = vo.getSectorInvestmentAmount(); + if (Objects.nonNull(sectorInvestmentAmount)) { + sectorInvestmentAmount = MathUtil.divide(new BigDecimal("100000000"), + sectorInvestmentAmount); + } + + BigDecimal lastSectorIncreaseValue = lastSector.getSectorIncreaseValue(); + if (Objects.nonNull(lastSectorIncreaseValue)) { + lastSectorIncreaseValue = MathUtil.divide(new BigDecimal("100000000"), + lastSectorIncreaseValue); + } + BigDecimal sectorIncreaseValue = Optional.ofNullable(vo.getSectorIncreaseValue()) .orElse(BigDecimal.ZERO) .subtract(Optional.ofNullable(lastSector.getSectorIncreaseValue()).orElse(BigDecimal.ZERO)); + sectorInvestmentAmount = MathUtil.divide(new BigDecimal("100000000"), + sectorInvestmentAmount); + list.add(SectorTalentTreadVo.builder() .code(vo.getCode()) .desc(vo.getDesc()) .jobDemandCount(lobarDemand.getLaborDemandCount()) - .sectorInvestmentAmount(vo.getSectorInvestmentAmount()) + .sectorInvestmentAmount(sectorInvestmentAmount) .sectorIncreaseValue(sectorIncreaseValue) - .growthRate(MathUtil.calculatePercentage(lastSector.getSectorIncreaseValue(), sectorIncreaseValue)) + .growthRate(MathUtil.calculatePercentage(lastSectorIncreaseValue, sectorIncreaseValue)) .build() ); } @@ -323,23 +352,12 @@ public class AnalysisSectorTalentServiceImpl implements AnalysisSectorTalentServ @Override public List heatmap(QueryParamDto dto) { - List list = new ArrayList<>(); - for (Tuple2 area : CommonConstant.AREA_LIST) { - list.add(HeatmapVo.builder() - .areaCode(area.getT1()) - .areaName(area.getT2()) - .count((long) Math.floor(Math.random() * 10000) + 1) - .build()); - } - long totalCount = list.stream().mapToLong(HeatmapVo::getCount).sum(); - for (HeatmapVo vo : list) { - if (totalCount > 0) { - vo.setPercentage(new BigDecimal(vo.getCount()) - .divide(BigDecimal.valueOf(totalCount), 4, RoundingMode.HALF_UP) - .multiply(BigDecimal.valueOf(100)) - .setScale(2, RoundingMode.HALF_UP)); - } - } + + ParamUtil.dealParam(dto); + List list = themeRecruitmentJobMapper.heatmap(dto); + // 计算占比 + MathUtil.calculatePercentageHeatmap(list); + return list; } } \ No newline at end of file diff --git a/ruoyi-bussiness/src/main/java/com/ruoyi/cms/util/MathUtil.java b/ruoyi-bussiness/src/main/java/com/ruoyi/cms/util/MathUtil.java index 1020197..737d369 100644 --- a/ruoyi-bussiness/src/main/java/com/ruoyi/cms/util/MathUtil.java +++ b/ruoyi-bussiness/src/main/java/com/ruoyi/cms/util/MathUtil.java @@ -5,8 +5,6 @@ import com.ruoyi.cms.constant.enums.QueryTimeTypeEnum; import com.ruoyi.cms.domain.vo.HeatmapVo; import com.ruoyi.cms.domain.vo.QueryResultVo; import com.ruoyi.cms.domain.vo.TreadVo; -import com.ruoyi.common.exception.ServiceException; -import com.ruoyi.common.utils.StringUtils; import org.apache.commons.collections4.CollectionUtils; import java.math.BigDecimal; @@ -57,6 +55,24 @@ public class MathUtil { return new BigDecimal(plainString); } + /** + * 计算比率 + * + * @param divisor 除数(分母) + * @param dividend 被除数(分子) + * @return 比率 + */ + public static BigDecimal divide(BigDecimal divisor, BigDecimal dividend) { + + if (Objects.isNull(divisor) || Objects.isNull(dividend)) { + return null; + } + + String plainString = dividend.divide(divisor, 2, RoundingMode.HALF_UP) + .stripTrailingZeros().toPlainString(); + return new BigDecimal(plainString); + } + /** * 计算比率 @@ -99,7 +115,7 @@ public class MathUtil { /** * 计算占比 * - * @param list 数据 + * @param list 数据 */ public static void calculatePercentage(List list) { if (CollectionUtils.isEmpty(list)) { diff --git a/ruoyi-bussiness/src/main/resources/mapper/ThemeProfessionalTrainMapper.xml b/ruoyi-bussiness/src/main/resources/mapper/ThemeProfessionalTrainMapper.xml index 8ee6b3d..844e19a 100644 --- a/ruoyi-bussiness/src/main/resources/mapper/ThemeProfessionalTrainMapper.xml +++ b/ruoyi-bussiness/src/main/resources/mapper/ThemeProfessionalTrainMapper.xml @@ -10,6 +10,17 @@ + +