Browse Source

ljx:修改:1.招商辅助出现除数为0的情况

ljx 1 month ago
parent
commit
59679422ad

+ 12 - 12
enteprise-admin/src/main/java/com/enteprise/attract_inv/service/impl/AttractInvServiceImpl.java

@@ -46,28 +46,24 @@ public class AttractInvServiceImpl implements IAttractInvService {
                 taxSum += item.getPaidTax();
                 industrialSum += item.getTotalIndustrialValue();
             }
-            long a = taxSum / areaSum;
-            long b = industrialSum / areaSum;
-            if (a != 0 ){
-                aList.add(a);
-            }
-            if (b != 0){
-                bList.add(b);
+            if (areaSum != 0 && taxSum != 0 && industrialSum != 0){
+                aList.add(taxSum / areaSum);
+                bList.add(industrialSum / areaSum);
             }
         }
         if (!aList.isEmpty()){
             for (Long a : aList){
                 averageAnnualOutputValue += a;
             }
+            //基准值
+            attractInvReturnDto.setStandardA(averageAnnualOutputValue / aList.size() * 1.5);
         }
         if (!bList.isEmpty()){
             for (Long b : bList){
                 averageAnnualTaxPaid += b;
             }
+            attractInvReturnDto.setStandardB(averageAnnualTaxPaid / bList.size() * 1.5);
         }
-        //计算基准值
-        attractInvReturnDto.setStandardA(averageAnnualOutputValue / aList.size() * 1.5);
-        attractInvReturnDto.setStandardB(averageAnnualTaxPaid / bList.size() * 1.5);
 
 
         //筛选企业
@@ -107,8 +103,12 @@ public class AttractInvServiceImpl implements IAttractInvService {
                 }
             }
             //计算该企业近三年的用地、年均产值、年均实缴税金
-            attractInvDto.setAverageAnnualOutputValue(industrialSum/divisorB);
-            attractInvDto.setAverageAnnualTaxPaid(taxSum/divisorA);
+            if (divisorB !=0) {
+                attractInvDto.setAverageAnnualOutputValue(industrialSum / divisorB);
+            }
+            if (divisorA != 0) {
+                attractInvDto.setAverageAnnualTaxPaid(taxSum / divisorA);
+            }
             attractInvDto.setLandUsedInRecentThreeYears(areaSum);
             //添加到返回list
             attractInvDtos.add(attractInvDto);