Pārlūkot izejas kodu

小数位处理

chenendian 3 mēneši atpakaļ
vecāks
revīzija
0af1423ca6

+ 5 - 5
siwei-modules/siwei-apply/src/main/java/com/siwei/apply/controller/cadastre/SupplyController.java

@@ -93,8 +93,8 @@ public class SupplyController extends BaseController {
                 supplyRate.setCompleteRate(78 + (int) (Math.random() * 10));
                 supplyRate.setPlanProjectCount(15 + (int) (Math.random() * 5));
                 supplyRate.setCompleteProjectCount(11 + (int) (Math.random() * 5));
-                supplyRate.setPlanArea(788.6f + (float) (Math.random() * 100));
-                supplyRate.setCompleteArea(548.2f + (float) (Math.random() * 100));
+                supplyRate.setPlanArea((float) (Math.round((788.6f + (float) (Math.random() * 100)) * 100) / 100.0));
+                supplyRate.setCompleteArea((float) (Math.round((548.2f + (float) (Math.random() * 100)) * 100) / 100.0));
                 supplyRate.setGdUnit("亩");
                 res.setSupplyRate(supplyRate);
 
@@ -114,17 +114,17 @@ public class SupplyController extends BaseController {
                 // --------------供应方式----------------------
 
                 ProjectSupplyRes projectSupply1 = new ProjectSupplyRes();
-                projectSupply1.setGdArea(263.12f + (float) (Math.random() * 100));
+                projectSupply1.setGdArea((float) (Math.round((263.12f + (float) (Math.random() * 100)) * 100) / 100.0));
                 projectSupply1.setGdType("出让");
                 projectSupply1.setGdUnit("亩");
 
                 ProjectSupplyRes projectSupply2 = new ProjectSupplyRes();
-                projectSupply2.setGdArea(220.12f + (float) (Math.random() * 100));
+                projectSupply2.setGdArea((float) (Math.round((220.12f + (float) (Math.random() * 100)) * 100) / 100.0));
                 projectSupply2.setGdType("划拨");
                 projectSupply2.setGdUnit("亩");
 
                 ProjectSupplyRes projectSupply3 = new ProjectSupplyRes();
-                projectSupply3.setGdArea(190.12f + (float) (Math.random() * 100));
+                projectSupply3.setGdArea((float) (Math.round((190.12f + (float) (Math.random() * 100)) * 100) / 100.0));
                 projectSupply3.setGdType("其它");
                 projectSupply3.setGdUnit("亩");