Browse Source

Merge branch 'master' of http://bgfh7wa.nat.ipyingshe.com/ztpt-dev/data-service

chenminghao 1 year ago
parent
commit
a89e32e0a8

+ 2 - 0
video/src/main/java/cn/com/taiji/video/cotroller/VideoUrlController.java

@@ -10,6 +10,7 @@ import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
+import java.math.BigDecimal;
 import java.time.LocalDate;
 import java.util.List;
 
@@ -47,4 +48,5 @@ public class VideoUrlController {
     public List<VideoAnalysisLineDTO> queryLineRecord(Integer type) {
         return urlService.queryLineRecord(type);
     }
+
 }

+ 3 - 3
video/src/main/java/cn/com/taiji/video/model/VideoAnalysisLineDTO.java

@@ -14,10 +14,10 @@ public class VideoAnalysisLineDTO {
 
     private String time;
 
-    private Integer face;
+    private Double face;
 
-    private Integer car;
+    private Double car;
 
-    private Integer body;
+    private Double body;
 
 }

+ 3 - 3
video/src/main/java/cn/com/taiji/video/model/VideoAnalysisPieDTO.java

@@ -14,11 +14,11 @@ public class VideoAnalysisPieDTO {
 
     private Integer total;
 
-    private Integer face;
+    private Double face;
 
-    private Integer car;
+    private Double car;
 
-    private Integer body;
+    private Double body;
 
     // private List<AnalysisDTO> analysis;
 

+ 17 - 7
video/src/main/java/cn/com/taiji/video/service/impl/VideoUrlServiceImpl.java

@@ -20,6 +20,8 @@ import org.springframework.util.LinkedMultiValueMap;
 import org.springframework.util.MultiValueMap;
 import org.springframework.web.client.RestTemplate;
 
+import java.math.BigDecimal;
+import java.text.NumberFormat;
 import java.time.*;
 import java.time.format.DateTimeFormatter;
 import java.util.HashMap;
@@ -183,10 +185,10 @@ public class VideoUrlServiceImpl implements IVideoUrlService {
         }
         VideoAnalysisPieDTO videoAnalysisPieDTO = new VideoAnalysisPieDTO();
         // videoAnalysisPieDTO.setAnalysis(analysisDTO);
-        Integer total = 0;
-        Integer face = 0;
-        Integer car = 0;
-        Integer body = 0;
+        int total = 0;
+        int face = 0;
+        int car = 0;
+        int body = 0;
         if (null != analysisDTO && analysisDTO.size() > 0) {
             for (AnalysisDTO dto: analysisDTO) {
                 total += dto.getCount();
@@ -202,9 +204,17 @@ public class VideoUrlServiceImpl implements IVideoUrlService {
             }
         }
         videoAnalysisPieDTO.setTotal(total);
-        videoAnalysisPieDTO.setFace(face);
-        videoAnalysisPieDTO.setCar(car);
-        videoAnalysisPieDTO.setBody(body);
+        if (total != 0) {
+            log.info(String.valueOf(face));
+            log.info(String.valueOf(car));
+            videoAnalysisPieDTO.setFace((new BigDecimal((float)face/total).setScale(4,BigDecimal.ROUND_HALF_UP).doubleValue())*100);
+            videoAnalysisPieDTO.setCar((new BigDecimal((float)car/total).setScale(4,BigDecimal.ROUND_HALF_UP).doubleValue())*100);
+            videoAnalysisPieDTO.setBody((new BigDecimal((float)body/total).setScale(4,BigDecimal.ROUND_HALF_UP).doubleValue())*100);
+        } else {
+            videoAnalysisPieDTO.setFace(0.00);
+            videoAnalysisPieDTO.setCar(0.00);
+            videoAnalysisPieDTO.setBody(0.00);
+        }
 
         return videoAnalysisPieDTO;
     }

+ 7 - 7
video/src/main/resources/mapper/HtDpVideoAnalysisMapper.xml

@@ -5,7 +5,7 @@
 <mapper namespace="cn.com.taiji.video.mapper.HtDpVideoAnalysisMapper">
 
     <select id="selectFilter" resultType="AnalysisDTO">
-        SELECT type,sum(pic_filter_count) AS count FROM `ht_dp_video_analysis`
+        SELECT type,sum(pic_analysis_total) AS count FROM `ht_dp_video_analysis`
         <where>
         <if test="year != null and year != ''">
             and `year` = #{year}
@@ -20,15 +20,15 @@
         SELECT
         <if test="year != null and year != ''">
             t.`year_month` as time,
-            (select sum(pic_filter_count) from `ht_dp_video_analysis` t1 where t1.`year_month` = t.`year_month` and t1.type = 1) as face,
-            (select sum(pic_filter_count) from `ht_dp_video_analysis` t1 where t1.`year_month` = t.`year_month` and t1.type = 2) as car,
-            (select sum(pic_filter_count) from `ht_dp_video_analysis` t1 where t1.`year_month` = t.`year_month` and t1.type = 3) as body
+            (select sum(pic_analysis_total) / 10000 from `ht_dp_video_analysis` t1 where t1.`year_month` = t.`year_month` and t1.type = 1) as face,
+            (select sum(pic_analysis_total) / 10000 from `ht_dp_video_analysis` t1 where t1.`year_month` = t.`year_month` and t1.type = 2) as car,
+            (select sum(pic_analysis_total) / 10000 from `ht_dp_video_analysis` t1 where t1.`year_month` = t.`year_month` and t1.type = 3) as body
         </if>
         <if test="yearMonth != null and yearMonth != ''">
             t.stat_date as time,
-            (select sum(pic_filter_count) from `ht_dp_video_analysis` t1 where t1.stat_date = t.stat_date and t1.type = 1) as face,
-            (select sum(pic_filter_count) from `ht_dp_video_analysis` t1 where t1.stat_date = t.stat_date and t1.type = 2) as car,
-            (select sum(pic_filter_count) from `ht_dp_video_analysis` t1 where t1.stat_date = t.stat_date and t1.type = 3) as body
+            (select sum(pic_analysis_total) / 10000 from `ht_dp_video_analysis` t1 where t1.stat_date = t.stat_date and t1.type = 1) as face,
+            (select sum(pic_analysis_total) / 10000 from `ht_dp_video_analysis` t1 where t1.stat_date = t.stat_date and t1.type = 2) as car,
+            (select sum(pic_analysis_total) / 10000 from `ht_dp_video_analysis` t1 where t1.stat_date = t.stat_date and t1.type = 3) as body
         </if>
         FROM `ht_dp_video_analysis` t
         where