From 35bf80accf4117e3de030fdd7e3962f16a5fcfd9 Mon Sep 17 00:00:00 2001
From: zss <zss@example.com>
Date: 星期三, 23 八月 2023 09:05:41 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'

---
 inspection-server/src/main/java/com/yuanchu/limslaboratory/service/impl/HomeServiceImpl.java |  158 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 157 insertions(+), 1 deletions(-)

diff --git a/inspection-server/src/main/java/com/yuanchu/limslaboratory/service/impl/HomeServiceImpl.java b/inspection-server/src/main/java/com/yuanchu/limslaboratory/service/impl/HomeServiceImpl.java
index 3d0f258..0cde463 100644
--- a/inspection-server/src/main/java/com/yuanchu/limslaboratory/service/impl/HomeServiceImpl.java
+++ b/inspection-server/src/main/java/com/yuanchu/limslaboratory/service/impl/HomeServiceImpl.java
@@ -2,12 +2,22 @@
 
 import com.yuanchu.limslaboratory.mapper.InspectionMapper;
 import com.yuanchu.limslaboratory.mapper.InspectionProductMapper;
+import com.yuanchu.limslaboratory.pojo.vo.LineChartVO;
+import com.yuanchu.limslaboratory.pojo.vo.LineSeriesVO;
 import com.yuanchu.limslaboratory.pojo.vo.ProjectNumVo;
+import com.yuanchu.limslaboratory.pojo.vo.StatisticsDataVo;
 import com.yuanchu.limslaboratory.service.HomeService;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 
 import javax.annotation.Resource;
 import java.math.BigDecimal;
+import java.time.DayOfWeek;
+import java.time.LocalDate;
+import java.time.YearMonth;
+import java.time.format.DateTimeFormatter;
+import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.List;
 import java.util.Map;
 
@@ -48,7 +58,7 @@
             //閬嶅巻鑾峰彇鏁伴噺
             Long num = (Long) map.get("num");
             //璁$畻鐧惧垎姣斿苟瀛樺叆map涓�
-            map.put("chact",getRadio(allIns,num));
+            map.put("chact", getRadio(allIns, num));
         }
         return mapList;
     }
@@ -61,6 +71,95 @@
         return mapList;
     }
 
+    //璁$畻鍘熸潗鏂欎笌鎴愬搧鐨勫悎鏍肩巼
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public StatisticsDataVo qualified() {
+        StatisticsDataVo statisticsDataVo = new StatisticsDataVo();
+        //鍘熸潗鏂欐楠屽崟鎬绘暟
+        Integer allmater = inspectionMapper.getallmater();
+        //鍘熸潗鏂欏悎鏍肩巼
+        Long mater = inspectionMapper.qualified(1);
+        statisticsDataVo.setMaterial(getRadio(allmater, mater));
+        //鍘熸潗鏂欎笉鍚堟牸鐜�
+        Long unmater = inspectionMapper.qualified(0);
+        statisticsDataVo.setUnmaterial(getRadio(allmater, unmater));
+        //鍘熸潗鏂欐湭妫�楠岀巼
+        Long notmater = inspectionMapper.qualified(null);
+        statisticsDataVo.setNotmaterial(getRadio(allmater, notmater));
+
+        //鎴愬搧妫�楠屽崟鎬绘暟
+        Integer allfin = inspectionMapper.getallfin();
+        //鎴愬搧鍚堟牸鐜�
+        Long finished = inspectionMapper.qualifiedfin(1);
+        statisticsDataVo.setFinished(getRadio(allfin, finished));
+        //鎴愬搧涓嶅悎鏍肩巼
+        Long unfinished = inspectionMapper.qualifiedfin(0);
+        statisticsDataVo.setUnfinished(getRadio(allfin, unfinished));
+        //鎴愬搧鏈楠岀巼
+        Long notfinished = inspectionMapper.qualifiedfin(null);
+        statisticsDataVo.setNotfinished(getRadio(allfin, notfinished));
+
+        return statisticsDataVo;
+    }
+
+    //缁熻
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public LineChartVO turno(Integer type) {
+        LineChartVO lineChartVO = new LineChartVO();
+        List<LineSeriesVO> series = new ArrayList<>();
+        //鏋勫缓绗竴涓猯ineSeriesVO1(鍘熸潗鏂欐楠屾暟閲�)
+        LineSeriesVO lineSeriesVO1 = new LineSeriesVO();
+        lineSeriesVO1.setName("鍘熸潗鏂欐楠屾暟閲�");
+        //鏋勫缓绗簩涓猯ineSeriesVO2(鎴愬搧妫�楠屾暟閲�)
+        LineSeriesVO lineSeriesVO2 = new LineSeriesVO();
+        lineSeriesVO2.setName("鎴愬搧妫�楠屾暟閲�");
+        //鏋勫缓绗笁涓猯ineSeriesVO3(鍘熸潗鏂欏悎鏍肩巼)
+        LineSeriesVO lineSeriesVO3 = new LineSeriesVO();
+        lineSeriesVO3.setName("鍘熸潗鏂欏悎鏍肩巼");
+        //鏋勫缓绗洓涓猯ineSeriesVO4(鎴愬搧鍚堟牸鐜�)
+        LineSeriesVO lineSeriesVO4 = new LineSeriesVO();
+        lineSeriesVO4.setName("鎴愬搧鍚堟牸鐜�");
+        List<Object> list1 = new ArrayList<>();
+        List<Object> list2 = new ArrayList<>();
+        List<Object> list3 = new ArrayList<>();
+        List<Object> list4 = new ArrayList<>();
+        switch (type) {
+            case 1:         /*鏈懆*/
+                List<String> dayofWeeks = getDayofWeeks();
+                lineChartVO.setXAxis(dayofWeeks);
+                for (String dayofWeek : dayofWeeks) {
+                    //鏌ヨ璇ユ棩鏈熺殑鍘熸潗鏂欐楠屾暟閲�
+                    Integer allMaterByDay = inspectionMapper.getMaterByDay(dayofWeek);
+                    list1.add(allMaterByDay);
+                    //鏌ヨ璇ユ棩鏈熺殑鎴愬搧妫�楠屾暟閲�
+                    Integer allFinByDay = inspectionMapper.getFinByDay(dayofWeek);
+                    list2.add(allFinByDay);
+                    //鏌ヨ璇ユ棩鏈熺殑鍘熸潗鏂欏悎鏍肩巼
+
+                    //鏌ヨ璇ユ棩鏈熺殑鎴愬搧鍚堟牸鐜�
+                }
+                lineSeriesVO1.setData(list1);
+
+                break;
+            case 2:         /*鏈湀*/
+                List<String> dayofMonths = getDayofMonth();
+                lineChartVO.setXAxis(dayofMonths);
+                break;
+            case 3:         /*鏈勾*/
+                List<String> monthofYears = getMonthofYear();
+                lineChartVO.setXAxis(monthofYears);
+                break;
+        }
+        series.add(lineSeriesVO1);
+        series.add(lineSeriesVO2);
+        series.add(lineSeriesVO3);
+        series.add(lineSeriesVO4);
+        lineChartVO.setSeries(series);
+        return lineChartVO;
+    }
+
     /*璁$畻鐧惧垎姣�*/
     private BigDecimal getRadio(Integer all, Long num) {
         if (all.intValue() == 0) {
@@ -71,4 +170,61 @@
         BigDecimal divide = numBigDecimal.divide(allBigDecimal, 4, BigDecimal.ROUND_HALF_UP);
         return divide.multiply(new BigDecimal(100));
     }
+
+    /*鑾峰彇鏈勾鏈堜唤list闆嗗悎*/
+    private List<String> getMonthofYear() {
+        // 鑾峰彇褰撳墠骞翠唤
+        int year = YearMonth.now().getYear();
+        // 鍒涘缓鏈堜唤鍒楄〃
+        List<String> months = new ArrayList<>();
+        // 娣诲姞鏈堜唤鍒板垪琛�
+        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM");
+        for (int i = 1; i <= 12; i++) {
+            YearMonth month = YearMonth.of(year, i);
+            String monthString = month.format(formatter);
+            months.add(monthString);
+        }
+        return months;
+    }
+
+    /*鑾峰彇鏈湀鏃ヤ唤list闆嗗悎*/
+    private List<String> getDayofMonth() {
+        // 鑾峰彇褰撳墠鏃ユ湡
+        LocalDate now = LocalDate.now();
+        // 鑾峰彇褰撳墠鏈堜唤
+        YearMonth currentMonth = YearMonth.from(now);
+        // 鑾峰彇璇ユ湀鐨勫ぉ鏁�
+        int daysInMonth = currentMonth.lengthOfMonth();
+        // 鍒涘缓鏃ユ湡鍒楄〃
+        List<String> dates = new ArrayList<>();
+        // 娣诲姞鏃ユ湡鍒板垪琛�
+        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
+        for (int i = 1; i <= daysInMonth; i++) {
+            LocalDate date = currentMonth.atDay(i);
+            String dateString = date.format(formatter);
+            dates.add(dateString);
+        }
+        return dates;
+    }
+
+    /*鑾峰彇鏈懆鏃ヤ唤list闆嗗悎*/
+    private List<String> getDayofWeeks() {
+        // 鑾峰彇褰撳墠鏃ユ湡
+        LocalDate now = LocalDate.now();
+        // 鑾峰彇鏈懆鐨勭涓�澶╁拰鏈�鍚庝竴澶�
+        LocalDate startOfWeek = now.with(DayOfWeek.MONDAY);
+        LocalDate endOfWeek = now.with(DayOfWeek.SUNDAY);
+        // 鍒涘缓鏃ユ湡鍒楄〃
+        List<String> dates = new ArrayList<>();
+        // 娣诲姞鏃ユ湡鍒板垪琛�
+        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
+        while (!startOfWeek.isAfter(endOfWeek)) {
+            String dateString = startOfWeek.format(formatter);
+            dates.add(dateString);
+            startOfWeek = startOfWeek.plusDays(1);
+        }
+        return dates;
+    }
+
+
 }

--
Gitblit v1.9.3