|
@@ -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;
|
|
|
}
|