oyq28 1 год назад
Родитель
Сommit
8cb087190b

+ 17 - 8
src/main/java/com/imcs/admin/business/service/impl/BigScreenDetailServiceImpl.java

@@ -63,6 +63,7 @@ public class BigScreenDetailServiceImpl implements BigScreenDetailService {
         List<Object> createDateList = items1.stream()
                 .map(map -> map.get("createDate")) // 获取 device_rate 字段
                 .collect(Collectors.toList());
+        //主轴利用率
         json.put("dateList",createDateList);
         json.put("deviceRates",deviceRates);
 
@@ -70,6 +71,7 @@ public class BigScreenDetailServiceImpl implements BigScreenDetailService {
 
         Optional<Map<String, Object>> createDate = items1.stream().filter(vo -> vo.get("createDate").equals(currentDateAsString)).findFirst();
         if(createDate.isPresent()){
+            //当天设备实时数据
             json.put("detailInfo", JSONArray.parseArray(createDate.get().get("detailInfo").toString()));
             json.put("deviceRate",createDate.get().get("deviceRate"));
             json.put("todayPowerOnTime",createDate.get().get("todayPowerOnTime"));
@@ -84,11 +86,16 @@ public class BigScreenDetailServiceImpl implements BigScreenDetailService {
         return json;
     }
 
-
+    /**
+     * 本月设备主轴利用率
+     * @param ip
+     * @param jsonObject
+     * @param pageParam
+     */
     public void getleftBox(String ip,JSONObject jsonObject,PageParam pageParam){
-        StringBuffer str=new StringBuffer("SELECT ROUND(AVG(device_rate),2) as avg_device_rate,ROUND(100 - AVG(device_rate), 2) AS dif_avg_device_rate\n" +
+        StringBuffer str=new StringBuffer("SELECT ROUND((sum(today_power_on_time)/60)/(16 * count(*)),2) as avg_device_rate, ROUND(100-(sum(today_power_on_time)/60)/(16 * count(*)),2) as dif_avg_device_rate\n" +
                 "FROM device_collection_detail\n" +
-                "WHERE MONTH(create_date) = ? and device_ip= ? ");
+                "WHERE DATE_FORMAT(create_date, '%Y-%m') = ? and device_ip= ? ");
         List<Object> detailArgs = new ArrayList<>();
         detailArgs.add(StrUtil.format("{}",DateUtils.getCurrentMonth()));
         detailArgs.add(StrUtil.format("{}",ip));
@@ -97,10 +104,14 @@ public class BigScreenDetailServiceImpl implements BigScreenDetailService {
         if(!CollectionUtil.isEmpty(items)){
             jsonObject.putAll(items.get(0));
         }
-
-
     }
 
+    /**
+     * 近一年主轴利用率
+     * @param ip
+     * @param jsonObject
+     * @param pageParam
+     */
     public void getEchart3(String ip,JSONObject jsonObject,PageParam pageParam){
 
         List<String> pastDaysDates = DateUtils.getLastYearMonths();
@@ -108,7 +119,7 @@ public class BigScreenDetailServiceImpl implements BigScreenDetailService {
                 .map(date -> "'" + date + "'")
                 .collect(Collectors.joining(", "));
         StringBuffer str=new StringBuffer("SELECT CONCAT(YEAR(create_date), '-', LPAD(MONTH(create_date), 2, '0')) AS year_month_str,\n" +
-                "       ROUND(AVG(device_rate),2) AS average_value\n" +
+                "       ROUND((sum(today_power_on_time)/60)/(16 * count(*)),2) AS average_value\n" +
                 "FROM device_collection_detail\n" +
                 "where DATE_FORMAT(create_date, '%Y-%m') in ("+collect+") and device_ip = ? " +
                 "GROUP BY CONCAT(YEAR(create_date), '-', LPAD(MONTH(create_date), 2, '0')) order by CONCAT(YEAR(create_date), '-', LPAD(MONTH(create_date), 2, '0')) asc ");
@@ -121,8 +132,6 @@ public class BigScreenDetailServiceImpl implements BigScreenDetailService {
             List<BigDecimal> avgYearMonth = items.stream().map(vo -> new BigDecimal(vo.get("averageValue").toString())).collect(Collectors.toList());
             jsonObject.put("yearMonthList",yearMonthStr);
             jsonObject.put("avgYearMonth",avgYearMonth);
-        }else{
-
         }
     }
 }

+ 7 - 3
src/main/java/com/imcs/admin/util/DateUtils.java

@@ -2,6 +2,7 @@ package com.imcs.admin.util;
 
 import java.text.SimpleDateFormat;
 import java.time.LocalDateTime;
+import java.time.YearMonth;
 import java.time.format.DateTimeFormatter;
 import java.util.ArrayList;
 import java.util.Calendar;
@@ -37,9 +38,12 @@ public class DateUtils {
         return dateFormat.format(new Date());
     }
 
-    public static int getCurrentMonth() {
-        Calendar calendar = Calendar.getInstance();
-        return calendar.get(Calendar.MONTH) + 1; // 注意月份是从 0 开始的,所以需要加 1
+    public static String  getCurrentMonth() {
+        YearMonth currentYearMonth = YearMonth.now();
+
+        // 将年份和月份格式化为字符串,例如 "yyyy-MM"
+        String formattedYearMonth = currentYearMonth.format(DateTimeFormatter.ofPattern("yyyy-MM"));
+        return formattedYearMonth;
     }
 
     /**

+ 1 - 1
src/main/resources/static/admin/bigScreenDetail/css/index.css

@@ -257,7 +257,7 @@ a{
     position: absolute;
     left: 55%;
     top: 8%;
-    width: 1rem;
+    width: 2rem;
 }
 .t_b_h h3 span{
     font-size: 0.2rem;