Browse Source

Merge remote-tracking branch 'origin/master'

littleblue55 1 month ago
parent
commit
5ddac9c69a

+ 2 - 0
enteprise-admin/src/main/java/com/enteprise/industry_run/mapper/EnterpriseBaseDataTotalMapper.java

@@ -2,6 +2,7 @@ package com.enteprise.industry_run.mapper;
 
 import java.util.List;
 import com.enteprise.industry_run.domain.EnterpriseBaseDataTotal;
+import org.apache.ibatis.annotations.Mapper;
 
 /**
  * industry_runMapper接口
@@ -9,6 +10,7 @@ import com.enteprise.industry_run.domain.EnterpriseBaseDataTotal;
  * @author ruoyi
  * @date 2024-11-13
  */
+@Mapper
 public interface EnterpriseBaseDataTotalMapper 
 {
     /**

+ 35 - 20
enteprise-admin/src/main/java/com/enteprise/matchAnalysis/service/impl/MatchServiceImpl.java

@@ -8,6 +8,8 @@ import com.enteprise.enterprise.domain.Enterprise;
 import com.enteprise.enterprise.dto.EnterpriseDto;
 import com.enteprise.enterprise.mapper.EnterpriseMapper;
 import com.enteprise.growthRate.domain.dto.GrowthRateDto;
+import com.enteprise.industry_run.domain.EnterpriseBaseDataTotal;
+import com.enteprise.industry_run.mapper.EnterpriseBaseDataTotalMapper;
 import com.enteprise.matchAnalysis.domain.MatchAna;
 import com.enteprise.matchAnalysis.domain.dto.MatchDto;
 import com.enteprise.matchAnalysis.service.IMatchService;
@@ -32,6 +34,9 @@ public class MatchServiceImpl implements IMatchService {
     private EnterpriseBaseDataSeasonMapper enterpriseBaseDataSeasonMapper;
     @Autowired
     private EnterpriseBaseDataYearMapper enterpriseBaseDataYearMapper;
+    @Autowired
+    private EnterpriseBaseDataTotalMapper enterpriseBaseDataTotalMapper;
+
     @Override
     public List<MatchDto> matchAnalysisList(MatchAna matchAna) {
         ArrayList<MatchDto> list = new ArrayList<>();
@@ -82,9 +87,7 @@ public class MatchServiceImpl implements IMatchService {
                     }
                 }
                 //计算同比增速:(今年-去年)/去年
-                double powerRate = (powerConsume - oldPowerConsume) / oldPowerConsume;
-                double industrialRate = (totalIndustrial - oldTotalIndustrial) / oldTotalIndustrial;
-                double trueThreshold =powerRate - industrialRate;
+                double trueThreshold = trueThreshold(powerConsume, oldPowerConsume, totalIndustrial, oldTotalIndustrial);
                 if (trueThreshold !=0 && trueThreshold < threshold) {
                     //初始化返回实体类并添加到list
                     MatchDto dto = new MatchDto(enterpriseName, trueThreshold, enterpriseDto.getLocation(), enterpriseDto.getCode(), enterpriseDto.getTypeNum(), enterpriseDto.getTypeName());
@@ -97,7 +100,7 @@ public class MatchServiceImpl implements IMatchService {
             //用人逻辑,季度指标
             List<Integer> seasonRange = getRange(manStartSeason, manEndSeason);
             for (EnterpriseDto enterpriseDto : enterpriseDtos){
-                EnterpriseBaseDataSeason dataSeason = new EnterpriseBaseDataSeason();
+                EnterpriseBaseDataTotal dataSeason = new EnterpriseBaseDataTotal();
                 double employeeNumber = 0;
                 double oldEmployeeNumber = 0;
                 double totalIndustrial = 0;
@@ -108,23 +111,25 @@ public class MatchServiceImpl implements IMatchService {
                     dataSeason.setSeason(String.valueOf(nowSeason));
                     dataSeason.setYear(String.valueOf(year));
                     //季度指标获取
-                    List<EnterpriseBaseDataSeason> dataSeasons = enterpriseBaseDataSeasonMapper.selectEnterpriseBaseDataSeasonList(dataSeason);
+                    List<EnterpriseBaseDataTotal> dataSeasons = enterpriseBaseDataTotalMapper.selectEnterpriseBaseDataTotalList(dataSeason);
                     dataSeason.setYear(String.valueOf(year - 1));
-                    List<EnterpriseBaseDataSeason> oldDataSeasons = enterpriseBaseDataSeasonMapper.selectEnterpriseBaseDataSeasonList(dataSeason);
-                    if (!dataSeasons.isEmpty() && !oldDataSeasons.isEmpty()) {
-                        EnterpriseBaseDataSeason dataSeason1 = dataSeasons.get(0);
-                        employeeNumber += dataSeason1.getEmployeeNumber();
-                        totalIndustrial += dataSeason1.getTotalIndustrialValue();
-                        EnterpriseBaseDataSeason dataSeason2 = oldDataSeasons.get(0);
-                        oldEmployeeNumber += dataSeason2.getEmployeeNumber();
-                        oldTotalIndustrial += dataSeason2.getTotalIndustrialValue();
+                    List<EnterpriseBaseDataTotal> oldDataSeasons = enterpriseBaseDataTotalMapper.selectEnterpriseBaseDataTotalList(dataSeason);
+                    if (!dataSeasons.isEmpty()) {
+                        for (EnterpriseBaseDataTotal item : dataSeasons){
+                            employeeNumber += item.getEmployeeNumber();
+                            totalIndustrial += item.getTotalIndustrialValue();
+                        }
+                    }
+                    if (!oldDataSeasons.isEmpty()){
+                        for (EnterpriseBaseDataTotal item : oldDataSeasons){
+                            oldEmployeeNumber += item.getEmployeeNumber();
+                            oldTotalIndustrial += item.getTotalIndustrialValue();
+                        }
                     }
                 }
                 //计算同比增速:(今年-去年)/去年
-                double employeeRate = (employeeNumber - oldEmployeeNumber) / oldEmployeeNumber;
-                double industrialRate = (totalIndustrial - oldTotalIndustrial) / oldTotalIndustrial;
-                double trueThreshold = employeeRate - industrialRate;
-                if (trueThreshold !=0 && trueThreshold < threshold) {
+                double trueThreshold =  trueThreshold(employeeNumber, oldEmployeeNumber, totalIndustrial, oldTotalIndustrial);
+                if (trueThreshold !=0 && trueThreshold < threshold ) {
                     //初始化返回实体类并添加到list
                     MatchDto dto = new MatchDto(enterpriseName, trueThreshold, enterpriseDto.getLocation(), enterpriseDto.getCode(), enterpriseDto.getTypeNum(), enterpriseDto.getTypeName());
                     list.add(dto);
@@ -156,9 +161,7 @@ public class MatchServiceImpl implements IMatchService {
                     oldTotalIndustrial = dataYear2.getTotalIndustrialValue();
                 }
                 //计算同比增速:(今年-去年)/去年
-                double employeeRate = (energyConsume - oldEnergyConsume) / oldEnergyConsume;
-                double industrialRate = (totalIndustrial - oldTotalIndustrial) / oldTotalIndustrial;
-                double trueThreshold = employeeRate - industrialRate;
+                double trueThreshold =  trueThreshold(energyConsume, oldEnergyConsume, totalIndustrial, oldTotalIndustrial);
                 if (trueThreshold !=0 && trueThreshold < threshold) {
                     //初始化返回实体类并添加到list
                     MatchDto dto = new MatchDto(enterpriseName, trueThreshold, enterpriseDto.getLocation(), enterpriseDto.getCode(), enterpriseDto.getTypeNum(), enterpriseDto.getTypeName());
@@ -169,4 +172,16 @@ public class MatchServiceImpl implements IMatchService {
         }
         return list;
     }
+
+    private double trueThreshold(double newValue, double oldValue,double newValue1, double oldValue1){
+        double employeeRate = 0;
+        double industrialRate = 0;
+        if (oldValue != 0) {
+            employeeRate = (newValue - oldValue) / oldValue;
+        }
+        if (oldValue1 != 0) {
+            industrialRate = (newValue1 - oldValue1) / oldValue1;
+        }
+        return  employeeRate - industrialRate;
+    }
 }