15143018065 1 年之前
父節點
當前提交
35e62d87a2

+ 2 - 0
okc/src/main/java/com/ruoyi/okc/service/IOkcVideoProService.java

@@ -75,6 +75,8 @@ public interface IOkcVideoProService
 
     public List<double[]> getRcValue(String id);
 
+    public List<double[]> getRcCurve(String id);
+
     public List<Arc> getArc(String id);
 
     public List<Fre> getFre(String id);

+ 78 - 10
okc/src/main/java/com/ruoyi/okc/service/impl/OkcVideoProServiceImpl.java

@@ -103,6 +103,25 @@ public class OkcVideoProServiceImpl implements IOkcVideoProService
         return res;
     }
 
+    public List<double[]> getRcCurve(String id) {
+        List<double[]> res = new ArrayList<>();
+        OkcVideoPro pro = okcVideoProMapper.selectOkcVideoProById(id);
+        if (ObjectUtils.isNotEmpty(pro)) {
+            OkcVideoRec recQuery = new OkcVideoRec();
+            recQuery.setVideoId(pro.getId());
+            List<OkcVideoRec> recList = okcVideoRecMapper.selectOkcVideoRecList(recQuery);
+            if (CollectionUtils.isEmpty(recList)) {
+                throw new ServiceException("暂无数据!");
+            }
+            try {
+                res = RCUtils.getRcCharts(recList);
+            } catch(Exception e) {
+                throw new ServiceException("暂无数据!");
+            }
+        }
+        return res;
+    }
+
     public List<Arc> getArc(String id) {
         List<Arc> res = new ArrayList<>();
         OkcVideoPro pro = okcVideoProMapper.selectOkcVideoProById(id);
@@ -859,16 +878,16 @@ public class OkcVideoProServiceImpl implements IOkcVideoProService
      */
     public Map<String, String> createChRt(OkcVideoPro okcVideoPro, List<OkcVideoRec> recList, ChartsStatus chartsStatus) {
         Map<String, String> res = new LinkedHashMap<>();
-        List<String> teacherCon = BehavierType.getTeacherCon();
-        List<String> mediaCon = MediaType.getTalkMedia();
-        long allCount = recList.size();
-        long teacherCount = recList.stream().filter(r -> teacherCon.contains(r.getBehavior())).count();
-        long talkCount = recList.stream().filter(r -> mediaCon.contains(r.getMedia())).count();
-        DecimalFormat df = new DecimalFormat("0.0");
-        String x = String.valueOf(df.format((float) teacherCount / allCount));
-        String y = String.valueOf(df.format((float) talkCount / allCount));
-        Map<String,String> dataMap = new LinkedHashMap<>();
-        dataMap.put(y, x);
+//        List<String> teacherCon = BehavierType.getTeacherCon();
+//        List<String> mediaCon = MediaType.getTalkMedia();
+//        long allCount = recList.size();
+//        long teacherCount = recList.stream().filter(r -> teacherCon.contains(r.getBehavior())).count();
+//        long talkCount = recList.stream().filter(r -> mediaCon.contains(r.getMedia())).count();
+//        DecimalFormat df = new DecimalFormat("0.0");
+//        String x = String.valueOf(df.format((float) teacherCount / allCount));
+//        String y = String.valueOf(df.format((float) talkCount / allCount));
+        Map<String,String> dataMap = getRtch(recList);
+//        dataMap.put(y, x);
         String filePath = RuoYiConfig.getProfile() + File.separator + okcVideoPro.getId() + File.separator +
                 chartsStatus.getFileName();
         String title = chartsStatus.getTitle();
@@ -879,6 +898,55 @@ public class OkcVideoProServiceImpl implements IOkcVideoProService
         return res;
     }
 
+    private Map<String, String> getRtch(List<OkcVideoRec> recList) {
+        Map<String, String> res = new LinkedHashMap<>();
+        List<Integer> stList = new ArrayList<>();
+        for (int i = 0; i < recList.size(); i++) {
+            int num = RCEnum.getCodeByKey(recList.get(i).getBehavior());
+            // ST-2按照3s来切割
+            double keeptime = (new Double(recList.get(i).getEndTime()) - new Double(recList.get(i).getStartTime()));
+            int count = (int) (keeptime / 3);
+            if (num < 10)
+            {
+                for (int j = 0; j < count; j++)
+                {
+                    stList.add(1);
+                }
+            }
+            else
+            {
+                for (int j = 0; j < count; j++)
+                {
+                    stList.add(0);
+                }
+            }
+        }
+        double T_num = 0;
+        double g_num = 0;
+        int last_num = -1;
+        for (int i = 0; i < stList.size(); i++)
+        {
+            if (stList.get(i) == 1)
+            {
+                T_num++;
+            }
+            if (stList.get(i) != last_num)
+            {
+                g_num++;
+            }
+            last_num = stList.get(i);
+        }
+        double rt = 0;
+        double ch = 0;
+        if (stList.size() != 0)
+        {
+            rt = T_num / stList.size();
+            ch = (g_num - 1) / stList.size();
+        }
+        res.put(String.valueOf(rt), String.valueOf(ch));
+        return res;
+    }
+
     private void mkdirs(String filePath) {
         File desc = new File(filePath);
         if (!desc.exists()) {

+ 7 - 1
ruoyi-admin/src/main/java/com/ruoyi/web/controller/okc/OkcVideoProController.java

@@ -106,7 +106,6 @@ public class OkcVideoProController extends BaseController
         return success(okcVideoProService.exportOkcAllPort(okcVideoPro.getId()));
     }
 
-
     /**
      * 获取视频项目信息详细信息
      */
@@ -157,6 +156,13 @@ public class OkcVideoProController extends BaseController
         return success(okcVideoProService.getRcValue(okcVideoPro.getId()));
     }
 
+    @PreAuthorize("@ss.hasPermi('okc:videoPro:export')")
+    @GetMapping(value = "/getRcCurve")
+    public AjaxResult getRcCurve(OkcVideoPro okcVideoPro)
+    {
+        return success(okcVideoProService.getRcCurve(okcVideoPro.getId()));
+    }
+
     @PreAuthorize("@ss.hasPermi('okc:videoPro:export')")
     @PostMapping(value = "/export/arc")
     public void exportArc(OkcVideoPro okcVideoPro, HttpServletResponse response)

+ 1 - 1
ruoyi-common/src/main/java/com/ruoyi/common/utils/ChartUtils.java

@@ -253,7 +253,7 @@ public class ChartUtils {
             XYSeriesCollection dataset = new XYSeriesCollection();
             datas.forEach((key, value) -> {
                 XYSeries ie = new XYSeries("结果");
-                ie.add(Double.parseDouble(value), Double.parseDouble(key));
+                ie.add(Double.parseDouble(key), Double.parseDouble(value));
                 dataset.addSeries(ie);
             });
             //创建折线图,折线图分水平显示和垂直显示两种