From 924d018e6e6f15effbd272cead5dff67cd3b93a5 Mon Sep 17 00:00:00 2001
From: XiaoRuby <3114200645@qq.com>
Date: 星期三, 23 八月 2023 16:22:06 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'
---
inspection-server/src/main/java/com/yuanchu/limslaboratory/service/impl/HomeServiceImpl.java | 249 +++++++++++++++++++++++++++++++++++++++++++++++--
1 files changed, 239 insertions(+), 10 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 e08a03e..ef21304 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
@@ -1,14 +1,25 @@
package com.yuanchu.limslaboratory.service.impl;
-import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.yuanchu.limslaboratory.mapper.InspectionMapper;
import com.yuanchu.limslaboratory.mapper.InspectionProductMapper;
-import com.yuanchu.limslaboratory.pojo.Inspection;
-import com.yuanchu.limslaboratory.pojo.ProjectNum;
+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;
@Service
@@ -23,16 +34,234 @@
//璁$畻妫�楠屼笌鏈楠岀殑鍗曞瓙涓庨」鐩殑鏁伴噺鎺ュ彛
@Override
- public ProjectNum checkProjectNum() {
- ProjectNum projectNum = new ProjectNum();
+ public ProjectNumVo checkProjectNum() {
+ ProjectNumVo projectNumVo = new ProjectNumVo();
//宸叉楠岀殑妫�楠屽崟鏁伴噺
- projectNum.setInsNum(inspectionMapper.seleCountIns());
+ projectNumVo.setInsNum(inspectionMapper.seleCountIns());
//鏈楠岀殑妫�楠屽崟鏁伴噺
- projectNum.setInsUnNum(inspectionMapper.seleCountUnIns());
+ projectNumVo.setInsUnNum(inspectionMapper.seleCountUnIns());
//宸叉楠岀殑妫�楠岄」鐩暟閲�
- projectNum.setInsproNum(inspectionProductMapper.seleCountInspro());
+ projectNumVo.setInsproNum(inspectionProductMapper.seleCountInspro());
//鏈楠岀殑妫�楠岄」鐩暟閲�
- projectNum.setInsproUnNum(inspectionProductMapper.seleCountUnInspro());
- return projectNum;
+ projectNumVo.setInsproUnNum(inspectionProductMapper.seleCountUnInspro());
+ return projectNumVo;
}
+
+ //宸叉楠宼op3
+ @Override
+ public List<Map<String, Object>> checktop3() {
+ //鑾峰彇妫�楠屽崟鎬绘暟
+ Integer allIns = inspectionMapper.getcount();
+ //妫�楠岀粨璁�,妫�楠屾暟閲�
+ List<Map<String, Object>> mapList = inspectionMapper.getResultNum();
+ for (Map<String, Object> map : mapList) {
+ //閬嶅巻鑾峰彇鏁伴噺
+ Long num = (Long) map.get("num");
+ //璁$畻鐧惧垎姣斿苟瀛樺叆map涓�
+ map.put("chact", getRadio(allIns, num));
+ }
+ return mapList;
+ }
+
+ //鏈楠宼po4
+ @Override
+ public List<Map<String, Object>> unchecktop4() {
+ //妫�楠岄」鐩�,璁惧,妫�楠屽紑濮嬫椂闂�,鎵ц浜�,妫�楠岀粨鏉熸椂闂�
+ List<Map<String, Object>> mapList = inspectionProductMapper.getResultNum();
+ 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);
+ //鏌ヨ璇ユ棩鏈熺殑鍘熸潗鏂欏悎鏍肩巼
+ Long okMaterByDay = inspectionMapper.getOkMaterByDay(dayofWeek);
+ list3.add(getRadio(allMaterByDay, okMaterByDay));
+ //鏌ヨ璇ユ棩鏈熺殑鎴愬搧鍚堟牸鐜�
+ Long okFinByDay = inspectionMapper.getOkFinByDay(dayofWeek);
+ list4.add(getRadio(allFinByDay, okFinByDay));
+ }
+ break;
+ /*鏈湀*/
+ case 2:
+ List<String> dayofMonths = getDayofMonth();
+ lineChartVO.setXAxis(dayofMonths);
+ for (String dayofMonth : dayofMonths) {
+ //鏌ヨ璇ユ棩鏈熺殑鍘熸潗鏂欐楠屾暟閲�
+ Integer allMaterByDay = inspectionMapper.getMaterByDay(dayofMonth);
+ list1.add(allMaterByDay);
+ //鏌ヨ璇ユ棩鏈熺殑鎴愬搧妫�楠屾暟閲�
+ Integer allFinByDay = inspectionMapper.getFinByDay(dayofMonth);
+ list2.add(allFinByDay);
+ //鏌ヨ璇ユ棩鏈熺殑鍘熸潗鏂欏悎鏍肩巼
+ Long okMaterByDay = inspectionMapper.getOkMaterByDay(dayofMonth);
+ list3.add(getRadio(allMaterByDay, okMaterByDay));
+ //鏌ヨ璇ユ棩鏈熺殑鎴愬搧鍚堟牸鐜�
+ Long okFinByDay = inspectionMapper.getOkFinByDay(dayofMonth);
+ list4.add(getRadio(allFinByDay, okFinByDay));
+ }
+ break;
+ /*鏈勾*/
+ case 3:
+ List<String> monthofYears = getMonthofYear();
+ lineChartVO.setXAxis(monthofYears);
+ for (String monthofYear : monthofYears) {
+ //鏌ヨ璇ユ棩鏈熻寖鍥村唴鐨勫師鏉愭枡妫�楠屾暟閲�
+ Integer allMaterByDay = inspectionMapper.getMaterByMonth(monthofYear);
+ list1.add(allMaterByDay);
+ //鏌ヨ璇ユ棩鏈熺殑鎴愬搧妫�楠屾暟閲�
+ Integer allFinByDay = inspectionMapper.getFinByMonth(monthofYear);
+ list2.add(allFinByDay);
+ //鏌ヨ璇ユ棩鏈熺殑鍘熸潗鏂欏悎鏍肩巼
+ Long okMaterByDay = inspectionMapper.getOkMaterByMonth(monthofYear);
+ list3.add(getRadio(allMaterByDay, okMaterByDay));
+ //鏌ヨ璇ユ棩鏈熺殑鎴愬搧鍚堟牸鐜�
+ Long okFinByDay = inspectionMapper.getOkFinByMonth(monthofYear);
+ list4.add(getRadio(allFinByDay, okFinByDay));
+ }
+ break;
+ }
+ lineSeriesVO1.setData(list1);
+ lineSeriesVO2.setData(list2);
+ lineSeriesVO3.setData(list3);
+ lineSeriesVO4.setData(list4);
+ 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) {
+ return new BigDecimal(0);
+ }
+ BigDecimal numBigDecimal = new BigDecimal(num);
+ BigDecimal allBigDecimal = new BigDecimal(all);
+ 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