Ver código fonte

字段处理

oyq28 1 ano atrás
pai
commit
82def6211b

+ 21 - 6
src/main/java/com/imcs/admin/business/service/impl/BigScreenDetailServiceImpl.java

@@ -47,12 +47,8 @@ public class BigScreenDetailServiceImpl implements BigScreenDetailService {
         String deviceInfo = json.get("deviceInfo").toString();
         cn.hutool.json.JSONObject jsonObject=new cn.hutool.json.JSONObject(deviceInfo);
         json.putAll(jsonObject);
-        if(ObjectUtil.isNotEmpty(json.get("mainProg"))){
-            String mainProg = json.get("mainProg").toString();
-            int lastBackslashIndex = mainProg.lastIndexOf('\\');
-            String result = mainProg.substring(lastBackslashIndex + 1);
-            json.put("mainProg",result);
-        }
+        //处理字符串
+        subJsonStr(json);
         String ip = json.get("ip").toString();
         List<String> pastDaysDates = DateUtils.getPastDaysDates(new Date(), 5);
         String collect = pastDaysDates.stream()
@@ -141,4 +137,23 @@ public class BigScreenDetailServiceImpl implements BigScreenDetailService {
             jsonObject.put("avgYearMonth",avgYearMonth);
         }
     }
+
+    public void  subJsonStr(JSONObject json){
+        if(ObjectUtil.isNotEmpty(json.get("mainProg"))){
+            String mainProg = json.get("mainProg").toString();
+            int lastBackslashIndex = mainProg.lastIndexOf('\\');
+            String result = mainProg.substring(lastBackslashIndex + 1);
+            json.put("mainProg",result);
+        }
+        if(ObjectUtil.isNotEmpty(json.get("actFeed"))){
+            String actFeed = json.get("actFeed").toString();
+            String[] parts = actFeed.split("\\.");
+            json.put("actFeed",parts[0]);
+        }
+        if(ObjectUtil.isNotEmpty(json.get("actSpindle"))){
+            String actSpindle = json.get("actSpindle").toString();
+            String[] parts = actSpindle.split("\\.");
+            json.put("actSpindle",parts[0]);
+        }
+    }
 }

+ 3 - 3
src/main/resources/static/admin/bigScreenDetail/index.html

@@ -170,17 +170,17 @@
                         <div class="t_b_box">
                             <span>进给速度</span>
                             <i></i>
-                            <h2>${data.actFeed}</h2>
+                            <h2>${(data.actFeed !== null && data.actFeed !== undefined && data.actFeed !== 'NaN' && data.actFeed !== '') ? data.actFeed + '%' : '0'}</h2>
                         </div>
                         <div class="t_b_box1">
                             <span>主轴倍率</span>
                             <i></i>
-                            <h2>${data.spindleMagnification}%</h2>
+                            <h2>${(data.spindleMagnification !== null && data.spindleMagnification !== undefined && data.spindleMagnification !== 'NaN' && data.spindleMagnification !== '') ? data.spindleMagnification + '%' : '0'}</h2>
                         </div>
                         <div class="t_b_box2">
                             <span>主轴转速</span>
                             <i></i>
-                            <h2>${data.actSpindle}</h2>
+                            <h2>${(data.actSpindle !== null && data.actSpindle !== undefined && data.actSpindle !== 'NaN' && data.actSpindle !== '') ? data.actSpindle + '%' : '0'}</h2>
                         </div>
                         <div class="t_b_box3">
                             <span>当日开机时长</span>