Просмотр исходного кода

调整除法无限小数的bug

liwh 1 год назад
Родитель
Сommit
a987ac091b

+ 4 - 4
tile-web/src/main/java/cn/com/taiji/web/service/impl/EnterpriseServiceImpl.java

@@ -114,7 +114,7 @@ public class EnterpriseServiceImpl implements IEnterpriseService {
 
         String wkt = "POINT ("+deviceVo.getLon()+" "+deviceVo.getLat()+")";
 
-        filterCql.append("(DWITHIN(location," + wkt + ", "+deviceVo.getRadius()+", kilometers))");
+        filterCql.append("(DWITHIN(location," + wkt + ", "+deviceVo.getRadius()/1000+", kilometers))");
 
 
 
@@ -190,14 +190,14 @@ public class EnterpriseServiceImpl implements IEnterpriseService {
 
         if(countVisitor.getCount()>0){
 
-            BigDecimal deviceRate = new BigDecimal(deviceCountVisitor.getCount()).divide(new BigDecimal(countVisitor.getCount())).multiply(new BigDecimal(100)).setScale(2, RoundingMode.HALF_UP);
+            BigDecimal deviceRate = new BigDecimal(deviceCountVisitor.getCount()).divide(new BigDecimal(countVisitor.getCount()),3,RoundingMode.HALF_UP).multiply(new BigDecimal(100)).setScale(2, RoundingMode.HALF_UP);
 
             staticsInfo.setDeviceRate(deviceRate.stripTrailingZeros());
 
-            BigDecimal materialRate = new BigDecimal(materialCountVisitor.getCount()).divide(new BigDecimal(countVisitor.getCount())).multiply(new BigDecimal(100)).setScale(2, RoundingMode.HALF_UP);
+            BigDecimal materialRate = new BigDecimal(materialCountVisitor.getCount()).divide(new BigDecimal(countVisitor.getCount()),3,RoundingMode.HALF_UP).multiply(new BigDecimal(100)).setScale(2, RoundingMode.HALF_UP);
             staticsInfo.setMaterialRate(materialRate.stripTrailingZeros());
 
-            BigDecimal noTaxRate = new BigDecimal(noTaxCountVisitor.getCount()).divide(new BigDecimal(countVisitor.getCount())).multiply(new BigDecimal(100)).setScale(2, RoundingMode.HALF_UP);
+            BigDecimal noTaxRate = new BigDecimal(noTaxCountVisitor.getCount()).divide(new BigDecimal(countVisitor.getCount()),3,RoundingMode.HALF_UP).multiply(new BigDecimal(100)).setScale(2, RoundingMode.HALF_UP);
 
             staticsInfo.setNoTaxRate(noTaxRate.stripTrailingZeros());