From 8c37d903a2fe25d5857c4555c791d552bec60cb8 Mon Sep 17 00:00:00 2001 From: zss <zss@example.com> Date: 星期二, 22 八月 2023 17:48:44 +0800 Subject: [PATCH] 改动6.0 --- inspection-server/src/main/java/com/yuanchu/limslaboratory/service/impl/HomeServiceImpl.java | 120 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 120 insertions(+), 0 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 79fb8cc..7370328 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,6 +2,8 @@ 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; @@ -10,6 +12,12 @@ 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; @@ -95,6 +103,61 @@ 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) { @@ -105,4 +168,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