Sfoglia il codice sorgente

智慧办公核心指标接口修改

ZhangManMan 2 anni fa
parent
commit
588a339803

+ 40 - 22
src/main/java/com/sky/ioc/service/carbon/impl/CarbonServiceImpl.java

@@ -11,8 +11,10 @@ import com.sky.ioc.tool.GeneralMethod;
 import com.sky.ioc.tool.ReturnMsg;
 import org.springframework.stereotype.Service;
 
+import java.text.DecimalFormat;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.concurrent.ThreadLocalRandom;
 
 /**
  * TODO  双碳
@@ -46,17 +48,25 @@ public class CarbonServiceImpl implements CarbonService {
     public ReturnMsg getPrintingCoreIndicators(IocDateParam iocDateParam) {
         Indeicator indeicator = new Indeicator();
         List<JSONObject> objects = indeicator.getList();
-        objects.get(0).put("value",10);
-        objects.get(0).put("compare",0.4);
-
-        objects.get(1).put("value",80);
-        objects.get(1).put("compare",0.4);
-
-        objects.get(2).put("value",80);
-        objects.get(2).put("compare",0.4);
-
-        objects.get(3).put("value",80);
-        objects.get(3).put("compare",0.4);
+        ThreadLocalRandom random = ThreadLocalRandom.current();
+        int personCost = random.nextInt(10, 100);
+        int personPaper = random.nextInt(10,20);
+        int personC = random.nextInt(15,100);
+        int personNum = random.nextInt(1,20);
+        float compare = (float) Math.random();
+        DecimalFormat decimalFormat = new DecimalFormat("#.0");
+        compare = Float.parseFloat(decimalFormat.format(compare));
+        objects.get(0).put("value",personCost);
+        objects.get(0).put("compare",compare);
+
+        objects.get(1).put("value",personPaper);
+        objects.get(1).put("compare",compare);
+
+        objects.get(2).put("value",personC);
+        objects.get(2).put("compare",compare);
+
+        objects.get(3).put("value",personNum);
+        objects.get(3).put("compare",compare);
         indeicator.setWorthAttention("今日人流高峰在9:00/17:00,记得提前做好应对喔");
         indeicator.setList(objects);
         return ReturnMsg.ok(indeicator);
@@ -82,17 +92,25 @@ public class CarbonServiceImpl implements CarbonService {
     public ReturnMsg getBusCoreIndicators(IocDateParam iocDateParam) {
         Indeicator indeicator = new Indeicator();
         List<JSONObject> objects = indeicator.getList();
-        objects.get(0).put("value",100);
-        objects.get(0).put("compare",0.4);
-
-        objects.get(1).put("value",80);
-        objects.get(1).put("compare",0.4);
-
-        objects.get(2).put("value",80);
-        objects.get(2).put("compare",0.4);
-
-        objects.get(3).put("value",80);
-        objects.get(3).put("compare",0.4);
+        ThreadLocalRandom random = ThreadLocalRandom.current();
+        int carCost = random.nextInt(10000, 1000000);
+        int carTimes = random.nextInt(10,80);
+        int carC = random.nextInt(150,500);
+        int carHours = random.nextInt(1,20);
+        float compare = (float) Math.random();
+        DecimalFormat decimalFormat = new DecimalFormat("#.0");
+        compare = Float.parseFloat(decimalFormat.format(compare));
+        objects.get(0).put("value",carCost);
+        objects.get(0).put("compare",compare);
+
+        objects.get(1).put("value",carTimes);
+        objects.get(1).put("compare",compare);
+
+        objects.get(2).put("value",carC);
+        objects.get(2).put("compare",compare);
+
+        objects.get(3).put("value",carHours);
+        objects.get(3).put("compare",compare);
         indeicator.setWorthAttention("增加20个公车数量");
         indeicator.setList(objects);
         return ReturnMsg.ok(indeicator);

+ 46 - 17
src/main/java/com/sky/ioc/service/space/impl/SpaceServiceImpl.java

@@ -11,7 +11,9 @@ import com.sky.ioc.tool.GeneralMethod;
 import com.sky.ioc.tool.ReturnMsg;
 import org.springframework.stereotype.Service;
 
+import java.text.DecimalFormat;
 import java.util.List;
+import java.util.concurrent.ThreadLocalRandom;
 
 /**
  * TODO  空间
@@ -43,14 +45,33 @@ public class SpaceServiceImpl implements SpaceService {
     public ReturnMsg getFloorCoreIndicators(IocDateParam iocDateParam) {
         Indeicator indeicator = new Indeicator();
         List<JSONObject> objects = indeicator.getList();
-        objects.get(0).put("value",90);
-        objects.get(1).put("value",500);
-        objects.get(2).put("value",380);
-        objects.get(3).put("value",80);
+        ThreadLocalRandom random = ThreadLocalRandom.current();
+        int totalSite = random.nextInt(100, 800);
+        int total = random.nextInt(500,2000);
+        while (totalSite>total){
+            totalSite = random.nextInt(100, 800);
+        }
+        int meetting = random.nextInt(150,500);
+        while (meetting>total){
+            meetting = random.nextInt(150,500);
+        }
+        int leader = random.nextInt(15,300);
+        while (leader>total){
+            leader = random.nextInt(15,300);
+        }
+        int other = random.nextInt(15,200);
+        while (other>total){
+            other = random.nextInt(15,200);
+        }
+        int percent = random.nextInt(30,100);
+        objects.get(0).put("value",percent);
+        objects.get(1).put("value",totalSite);
+        objects.get(2).put("value",total);
+        objects.get(3).put("value",meetting);
         objects.add(new JSONObject());
         objects.add(new JSONObject());
-        objects.get(4).put("value",40);
-        objects.get(5).put("value",20);
+        objects.get(4).put("value",leader);
+        objects.get(5).put("value",other);
         indeicator.setList(objects);
         return ReturnMsg.ok(indeicator);
     }
@@ -69,17 +90,25 @@ public class SpaceServiceImpl implements SpaceService {
     public ReturnMsg getMeetingCoreIndicators(IocDateParam iocDateParam) {
         Indeicator indeicator = new Indeicator();
         List<JSONObject> objects = indeicator.getList();
-        objects.get(0).put("value",95);
-        objects.get(0).put("compare",0.4);
-
-        objects.get(1).put("value",80);
-        objects.get(1).put("compare",0.4);
-
-        objects.get(2).put("value",80);
-        objects.get(2).put("compare",0.4);
-
-        objects.get(3).put("value",8);
-        objects.get(3).put("compare",0.4);
+        ThreadLocalRandom random = ThreadLocalRandom.current();
+        int monthMeeting = random.nextInt(10, 100);
+        int dayMeeting = random.nextInt(10,100);
+        int dayPrice = random.nextInt(15,500);
+        int personDayPrice = dayPrice/10;
+        float compare = (float) Math.random();
+        DecimalFormat decimalFormat = new DecimalFormat("#.0");
+        compare = Float.parseFloat(decimalFormat.format(compare));
+        objects.get(0).put("value",monthMeeting);
+        objects.get(0).put("compare",compare);
+
+        objects.get(1).put("value",dayMeeting);
+        objects.get(1).put("compare",compare);
+
+        objects.get(2).put("value",dayPrice);
+        objects.get(2).put("compare",compare);
+
+        objects.get(3).put("value",personDayPrice);
+        objects.get(3).put("compare",compare);
         indeicator.setWorthAttention("增加会议室");
         indeicator.setList(objects);
         return ReturnMsg.ok(indeicator);

+ 9 - 1
src/main/java/com/sky/ioc/service/supermarket/impl/SupermarketServiceImpl.java

@@ -10,6 +10,8 @@ import com.sky.ioc.tool.GeneralMethod;
 import com.sky.ioc.tool.ReturnMsg;
 import org.springframework.stereotype.Service;
 
+import java.math.BigDecimal;
+import java.math.RoundingMode;
 import java.text.DecimalFormat;
 import java.util.List;
 import java.util.concurrent.ThreadLocalRandom;
@@ -31,7 +33,13 @@ public class SupermarketServiceImpl implements SupermarketService {
         int orderCount = random.nextInt(100, 3000);
         int orderprice = random.nextInt(50,150);
         int price = random.nextInt(1,20);
-        int totalPrice = orderprice*orderCount/10000;
+
+        BigDecimal bigDecimal = new BigDecimal(orderprice*orderCount);
+        BigDecimal decimal = bigDecimal.divide(new BigDecimal("10000"));
+        DecimalFormat formater = new DecimalFormat("#.0");
+
+        // 格式化完成之后得出结果
+        double totalPrice = Double.parseDouble(formater.format(decimal));
         float compare = (float) Math.random();
         DecimalFormat decimalFormat = new DecimalFormat("#.0");
         compare = Float.parseFloat(decimalFormat.format(compare));