Browse Source

(大屏)新建重要指标的读取功能:优化百分比数据。

zhuoning 3 years ago
parent
commit
d662807fe0

+ 35 - 5
huimv-farm-produce/src/main/java/com/huimv/produce/produce/service/impl/ImportantDynamicServiceImpl.java

@@ -38,7 +38,9 @@ public class ImportantDynamicServiceImpl implements IImportantDynamicService {
     public Result getImportantDynamicForIndex(Integer farmId) {
     public Result getImportantDynamicForIndex(Integer farmId) {
         //以月为时间单位,进行统计。
         //以月为时间单位,进行统计。
         String year = dateUtil.getThisYear();
         String year = dateUtil.getThisYear();
-//        String month = dateUtil.getThisMonth();
+        //正式月份
+        // String month = dateUtil.getThisMonth();
+        //演示月份
         String month = "2";
         String month = "2";
         System.out.println("year>>" + year);
         System.out.println("year>>" + year);
         System.out.println("month>>" + month);
         System.out.println("month>>" + month);
@@ -49,6 +51,19 @@ public class ImportantDynamicServiceImpl implements IImportantDynamicService {
         //查询一周数据
         //查询一周数据
         JSONArray importantJa = getOneWeekImportant(farmId,year,month);
         JSONArray importantJa = getOneWeekImportant(farmId,year,month);
         System.out.println("11 importantJa.size>>" + importantJa.size());
         System.out.println("11 importantJa.size>>" + importantJa.size());
+//        for(int a=0;a<importantJa.size();a++){
+//            JSONObject importantJo = importantJa.getJSONObject(a);
+//            System.out.println("importantJo>>"+importantJo);
+//            if(importantJo.getString("titleNum").indexOf("%") != -1){
+//                importantJo.put("titleNum",importantJo.getString("titleNum").replace("%",""));
+//                importantJo.put("subtitleNum",importantJo.getString("subtitleNum").replace("%",""));
+//                JSONObject dataJo = importantJo.getJSONObject("data");
+//                dataJo.
+//
+//            }
+//            importantJo.getString("");
+//
+//        }
 
 
         JSONObject outJo = new JSONObject();
         JSONObject outJo = new JSONObject();
         outJo.put("count", dynamicEntityList);
         outJo.put("count", dynamicEntityList);
@@ -60,6 +75,7 @@ public class ImportantDynamicServiceImpl implements IImportantDynamicService {
     //查询重要指标一周统计
     //查询重要指标一周统计
     private JSONArray getOneWeekImportant(Integer farmId,String year,String month) {
     private JSONArray getOneWeekImportant(Integer farmId,String year,String month) {
         JSONArray outJa = new JSONArray();
         JSONArray outJa = new JSONArray();
+        //
         JSONArray titleJa = getTitle();
         JSONArray titleJa = getTitle();
 
 
         //查询重要指标详细数据
         //查询重要指标详细数据
@@ -72,20 +88,29 @@ public class ImportantDynamicServiceImpl implements IImportantDynamicService {
             outJa.add(newJo);
             outJa.add(newJo);
             newJo.put("title",titleJo.getString("title"));
             newJo.put("title",titleJo.getString("title"));
             newJo.put("subtitle",titleJo.getString("subtitle"));
             newJo.put("subtitle",titleJo.getString("subtitle"));
+            newJo.put("percent",titleJo.getBoolean("percent"));
             for (ProdImportantIndicatorEntity importantEntity : importantList) {
             for (ProdImportantIndicatorEntity importantEntity : importantList) {
                 if (titleJo.getString("type").trim().equalsIgnoreCase(importantEntity.getStockType())) {
                 if (titleJo.getString("type").trim().equalsIgnoreCase(importantEntity.getStockType())) {
                     if (importantEntity.getYear() == Integer.parseInt(year) && importantEntity.getMonth() == Integer.parseInt(month)) {
                     if (importantEntity.getYear() == Integer.parseInt(year) && importantEntity.getMonth() == Integer.parseInt(month)) {
-                        newJo.put("titleNum", importantEntity.getStockQuantity());
+                        newJo.put("titleNum", importantEntity.getStockQuantity().replace("%",""));
                         if (importantEntity.getRiseFall() > 0) {
                         if (importantEntity.getRiseFall() > 0) {
                             newJo.put("ifPositive", true);
                             newJo.put("ifPositive", true);
-                            newJo.put("subtitleNum", "+"+importantEntity.getRange1());
+                            newJo.put("subtitleNum", "+"+importantEntity.getRange1().replace("%",""));
+                            System.out.println(">0");
                         } else {
                         } else {
                             newJo.put("ifPositive", false);
                             newJo.put("ifPositive", false);
-                            newJo.put("subtitleNum", "-"+importantEntity.getRange1());
+                            newJo.put("subtitleNum", "-"+importantEntity.getRange1().replace("%",""));
+                            System.out.println("<0");
                         }
                         }
+                    }else{
+                        newJo.put("titleNum", importantEntity.getStockQuantity().replace("%",""));
+                        newJo.put("ifPositive", true);
+                        newJo.put("subtitleNum", "+" + importantEntity.getRange1().replace("%",""));
                     }
                     }
                     timeList.add(importantEntity.getMonth());
                     timeList.add(importantEntity.getMonth());
-                    dataList.add(importantEntity.getStockQuantity());
+                    dataList.add(importantEntity.getStockQuantity().replace("%",""));
+                }else{
+//                    !titleJo.getString("type").trim().equalsIgnoreCase(importantEntity.getStockType())
                 }
                 }
             }
             }
             JSONObject dataJo = new JSONObject();
             JSONObject dataJo = new JSONObject();
@@ -103,24 +128,29 @@ public class ImportantDynamicServiceImpl implements IImportantDynamicService {
         psyJo.put("title", "PSY");
         psyJo.put("title", "PSY");
         psyJo.put("type", "psy");
         psyJo.put("type", "psy");
         psyJo.put("subtitle", "衡量母猪群繁殖性能力指标,一头母猪一年提供的成活仔猪数");
         psyJo.put("subtitle", "衡量母猪群繁殖性能力指标,一头母猪一年提供的成活仔猪数");
+        psyJo.put("percent", false);
 
 
         JSONObject avgFarrow1Jo = new JSONObject();
         JSONObject avgFarrow1Jo = new JSONObject();
         titleJa.add(avgFarrow1Jo);
         titleJa.add(avgFarrow1Jo);
         avgFarrow1Jo.put("title", "平均窝产仔猪");
         avgFarrow1Jo.put("title", "平均窝产仔猪");
         avgFarrow1Jo.put("type", "avg_farrow_1");
         avgFarrow1Jo.put("type", "avg_farrow_1");
         avgFarrow1Jo.put("subtitle", "母猪每一台生产的仔猪数量");
         avgFarrow1Jo.put("subtitle", "母猪每一台生产的仔猪数量");
+        avgFarrow1Jo.put("percent", false);
 
 
         JSONObject griceRateJo = new JSONObject();
         JSONObject griceRateJo = new JSONObject();
         titleJa.add(griceRateJo);
         titleJa.add(griceRateJo);
         griceRateJo.put("title", "产房成活率");
         griceRateJo.put("title", "产房成活率");
         griceRateJo.put("type", "grice_rate");
         griceRateJo.put("type", "grice_rate");
         griceRateJo.put("subtitle", "每一窝仔猪断奶前平均存活数量");
         griceRateJo.put("subtitle", "每一窝仔猪断奶前平均存活数量");
+        griceRateJo.put("percent", true);
 
 
         JSONObject pigletRateJo = new JSONObject();
         JSONObject pigletRateJo = new JSONObject();
         titleJa.add(pigletRateJo);
         titleJa.add(pigletRateJo);
         pigletRateJo.put("title", "保育成活率");
         pigletRateJo.put("title", "保育成活率");
         pigletRateJo.put("type", "piglet_rate");
         pigletRateJo.put("type", "piglet_rate");
         pigletRateJo.put("subtitle", "保育阶段的猪只存活率");
         pigletRateJo.put("subtitle", "保育阶段的猪只存活率");
+        pigletRateJo.put("percent", true);
+
         return titleJa;
         return titleJa;
     }
     }