diff --git a/pom.xml b/pom.xml
index 7633ec2..797df84 100644
--- a/pom.xml
+++ b/pom.xml
@@ -217,6 +217,12 @@
${ruoyi.version}
+
+ cn.hutool
+ hutool-all
+ 5.8.33
+
+
diff --git a/ruoyi-dw/pom.xml b/ruoyi-dw/pom.xml
index b1bd088..b66fc91 100644
--- a/ruoyi-dw/pom.xml
+++ b/ruoyi-dw/pom.xml
@@ -19,6 +19,11 @@
ruoyi-system
+
+ cn.hutool
+ hutool-all
+
+
\ No newline at end of file
diff --git a/ruoyi-dw/src/main/java/com/ruoyi/dw/controller/XyCheckController.java b/ruoyi-dw/src/main/java/com/ruoyi/dw/controller/XyCheckController.java
index 097062b..d05bb68 100644
--- a/ruoyi-dw/src/main/java/com/ruoyi/dw/controller/XyCheckController.java
+++ b/ruoyi-dw/src/main/java/com/ruoyi/dw/controller/XyCheckController.java
@@ -26,8 +26,12 @@ import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.net.URLEncoder;
+import java.time.DayOfWeek;
import java.time.LocalDate;
+import java.time.LocalDateTime;
+import java.time.LocalTime;
import java.time.format.DateTimeFormatter;
+import java.time.temporal.TemporalAdjusters;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
@@ -106,10 +110,11 @@ public class XyCheckController extends BaseController {
@GetMapping("/zzt")
public AjaxResult studentCount(CheckQuery checkQuery) {
DataCheckStatus checkStatus = dataCheckMapper.getStatus();
- List dates = getPreviousTuesdayIntervals(checkStatus.getWeekCheck());
- Date date1 = DateUtils.parseDate(dates.get(2) + " " +checkStatus.getWeekTimeCheck());
- Date date2 = DateUtils.parseDate(dates.get(0) + " " +checkStatus.getWeekTimeCheck());
- List mondayAndSundays = xyCheckMapper.selectGxCount(date1, date2);
+ String[] dates = getWeekRange(checkStatus.getWeekCheck(), checkStatus.getWeekTimeCheck());
+ Date date1 = DateUtils.parseDate(dates[0]);
+ Date date2 = DateUtils.parseDate(dates[1]);
+ List bzs = xyCheckMapper.selectGxCount(date1, date2);
+ List bzyx = xyCheckMapper.selectYxCount(date1, date2);
Date beginDate = null;
Date endDate = null;
if (StringUtils.isNotEmpty(checkQuery.getBeginDate())) {
@@ -125,7 +130,7 @@ public class XyCheckController extends BaseController {
List alls = xyCheckMapper.selectAllCount();
List gxs = xyCheckMapper.selectGxCount(beginDate, endDate);
List yxs = xyCheckMapper.selectYxCount(beginDate, endDate);
- List checks = getChecks(alls,gxs,yxs,mondayAndSundays);
+ List checks = getChecks(alls,gxs,yxs,bzs,bzyx);
if (checkQuery.getSort().intValue() == 1){
checks = XyCheckSorter.sortList(checks, SortField.BZ_COUNT, SortOrder.DESC);
}else if (checkQuery.getSort().intValue() == 2){
@@ -134,6 +139,31 @@ public class XyCheckController extends BaseController {
return AjaxResult.success(checks);
}
+ public static String[] getWeekRange(int weekDay, String timeStr) {
+ DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
+ // 把周几转成 Java 的 DayOfWeek
+ DayOfWeek targetDay = DayOfWeek.of(weekDay);
+
+ LocalTime targetTime = LocalTime.parse(timeStr);
+ LocalDateTime now = LocalDateTime.now();
+
+ // 找到最近一次目标星期+时间(可能是本周,也可能是上周)
+ LocalDate targetDate = now.toLocalDate()
+ .with(TemporalAdjusters.previousOrSame(targetDay));
+
+ LocalDateTime startDateTime = LocalDateTime.of(targetDate, targetTime);
+
+ // 如果今天就是目标日但时间还没到,就回退一周
+ if (now.isBefore(startDateTime)) {
+ startDateTime = startDateTime.minusWeeks(1);
+ }
+
+ // 结束时间是起始时间 + 1 周
+ LocalDateTime endDateTime = startDateTime.plusWeeks(1);
+
+ return new String[]{formatter.format(startDateTime), formatter.format(endDateTime)};
+ }
+
/**
* 导出采集数量考核接口
* @param response
@@ -141,14 +171,15 @@ public class XyCheckController extends BaseController {
@PostMapping("/export/cj")
public void exportCj(HttpServletResponse response) throws IOException {
DataCheckStatus checkStatus = dataCheckMapper.getStatus();
- List dates = getPreviousTuesdayIntervals(checkStatus.getWeekCheck());
- Date date1 = DateUtils.parseDate(dates.get(2) + " " +checkStatus.getWeekTimeCheck());
- Date date2 = DateUtils.parseDate(dates.get(0) + " " +checkStatus.getWeekTimeCheck());
- List mondayAndSundays = xyCheckMapper.selectGxCount(date1, date2);
+ String[] dates = getWeekRange(checkStatus.getWeekCheck(), checkStatus.getWeekTimeCheck());
+ Date date1 = DateUtils.parseDate(dates[0]);
+ Date date2 = DateUtils.parseDate(dates[1]);
+ List bzs = xyCheckMapper.selectGxCount(date1, date2);
+ List bzyx = xyCheckMapper.selectYxCount(date1, date2);
List alls = xyCheckMapper.selectAllCount();
List gxs = xyCheckMapper.selectGxCount(checkStatus.getBeginDate(), checkStatus.getEndDate());
List yxs = xyCheckMapper.selectYxCount(checkStatus.getBeginDate(), checkStatus.getEndDate());
- List checks = getChecksExport(alls,gxs,yxs,mondayAndSundays);
+ List checks = getChecksExport(alls,gxs,yxs,bzs,bzyx);
String zipFileName = "进度统计-信息采集-" + DateUtils.dateTimeNow() + ".xlsx";
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
response.setHeader("Access-Control-Expose-Headers", "Content-Disposition");
@@ -195,11 +226,13 @@ public class XyCheckController extends BaseController {
* @param alls
* @param gxs
* @param yxs
- * @param mondayAndSundays
+ * @param bzs
+ * @param bzyx
* @return
*/
private static List getChecks(List alls,List gxs,
- List yxs,List mondayAndSundays){
+ List yxs,List bzs,
+ List bzyx){
List checks = new ArrayList<>();
for(int i=0;i getChecksExport(List alls,List gxs,
- List yxs,List mondayAndSundays){
+ List yxs,List bzs,List bzyx){
List checks = new ArrayList<>();
+ int sumAllCount = 0;
+ int sumGxCount = 0;
+ int sumYxCount = 0;
+ int sumWxCount = 0;
+ int sumBzCount = 0;
+ int sumBzYxCount = 0;
+ int sumBzWxCount = 0;
for(int i=0;i getThisWeekDates() {
- Calendar cal = Calendar.getInstance();
- // 设置周一为一周的第一天(中国习惯)
- cal.setFirstDayOfWeek(Calendar.MONDAY);
-
- // 设置时间为本周一
- cal.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);
- cal.set(Calendar.HOUR_OF_DAY, 0);
- cal.set(Calendar.MINUTE, 0);
- cal.set(Calendar.SECOND, 0);
- cal.set(Calendar.MILLISECOND, 0);
- List dates = new ArrayList<>();
- Date monday = cal.getTime();
- dates.add(monday);
- cal.add(Calendar.DAY_OF_MONTH, 6);
- cal.set(Calendar.HOUR_OF_DAY, 23);
- cal.set(Calendar.MINUTE, 59);
- cal.set(Calendar.SECOND, 59);
- cal.set(Calendar.MILLISECOND, 0);
- Date sunday = cal.getTime();
- dates.add(sunday);
- return dates;
- }
-
- /**
- * 获取当前日期区间和之前的日期区间(以周二为起点和终点)
- *
- * @return 包含两个区间的 List,格式为 [start1, end1, start2, end2]
- */
- public static List getPreviousTuesdayIntervals(int weekCheck) {
- LocalDate today = LocalDate.now();
- List result = new ArrayList<>();
-
- DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
-
- // 当前周的周二(本周二)
- LocalDate thisTuesday = calculateTuesday(today,weekCheck);
- // 当前周的结束周二(下一周的周二)
- LocalDate nextTuesday = thisTuesday.plusWeeks(1);
-
- // 上一周的周二(即当前周的起始周二 - 7 天)
- LocalDate lastTuesday = thisTuesday.minusWeeks(1);
-
- // 添加当前区间
- result.add(thisTuesday.format(formatter));
- result.add(nextTuesday.format(formatter));
- result.add(lastTuesday.format(formatter));
-
- return result;
- }
-
- /**
- * 计算某日期所在周的周二
- *
- * @param date 当前日期
- * @return 本周二的日期
- */
- private static LocalDate calculateTuesday(LocalDate date,int weekCheck) {
- int dayOfWeek = date.getDayOfWeek().getValue(); // 1=Monday, 2=Tuesday, ..., 7=Sunday
- int daysUntilTuesday = (weekCheck - dayOfWeek + 7) % 7;
- return date.plusDays(daysUntilTuesday);
- }
-
}
diff --git a/ruoyi-dw/src/main/java/com/ruoyi/dw/domain/vo/XyCheck.java b/ruoyi-dw/src/main/java/com/ruoyi/dw/domain/vo/XyCheck.java
index 41be239..5ebdb1c 100644
--- a/ruoyi-dw/src/main/java/com/ruoyi/dw/domain/vo/XyCheck.java
+++ b/ruoyi-dw/src/main/java/com/ruoyi/dw/domain/vo/XyCheck.java
@@ -32,6 +32,10 @@ public class XyCheck {
*/
private Integer bzCount;
+ private Integer bzYxCount;
+
+ private Integer bzWxCount;
+
public String getXy() {
return xy;
}
@@ -79,4 +83,20 @@ public class XyCheck {
public void setBzCount(Integer bzCount) {
this.bzCount = bzCount;
}
+
+ public Integer getBzYxCount() {
+ return bzYxCount;
+ }
+
+ public void setBzYxCount(Integer bzYxCount) {
+ this.bzYxCount = bzYxCount;
+ }
+
+ public Integer getBzWxCount() {
+ return bzWxCount;
+ }
+
+ public void setBzWxCount(Integer bzWxCount) {
+ this.bzWxCount = bzWxCount;
+ }
}
diff --git a/ruoyi-dw/src/main/java/com/ruoyi/dw/domain/vo/XyCheckExport.java b/ruoyi-dw/src/main/java/com/ruoyi/dw/domain/vo/XyCheckExport.java
index 89ed4b1..953af64 100644
--- a/ruoyi-dw/src/main/java/com/ruoyi/dw/domain/vo/XyCheckExport.java
+++ b/ruoyi-dw/src/main/java/com/ruoyi/dw/domain/vo/XyCheckExport.java
@@ -45,6 +45,11 @@ public class XyCheckExport {
@Excel(name = "本周更新数量")
private Integer bzCount;
+ @Excel(name = "本周有效数量")
+ private Integer bzYxCount;
+
+ @Excel(name = "本周无效数量")
+ private Integer bzWxCount;
/**
* 完成比例
*/
@@ -107,6 +112,22 @@ public class XyCheckExport {
this.bzCount = bzCount;
}
+ public Integer getBzYxCount() {
+ return bzYxCount;
+ }
+
+ public void setBzYxCount(Integer bzYxCount) {
+ this.bzYxCount = bzYxCount;
+ }
+
+ public Integer getBzWxCount() {
+ return bzWxCount;
+ }
+
+ public void setBzWxCount(Integer bzWxCount) {
+ this.bzWxCount = bzWxCount;
+ }
+
public String getBl() {
return bl;
}
diff --git a/ruoyi-dw/src/main/java/com/ruoyi/dw/service/impl/CjStudentServiceImpl.java b/ruoyi-dw/src/main/java/com/ruoyi/dw/service/impl/CjStudentServiceImpl.java
index 4413c4c..7111aee 100644
--- a/ruoyi-dw/src/main/java/com/ruoyi/dw/service/impl/CjStudentServiceImpl.java
+++ b/ruoyi-dw/src/main/java/com/ruoyi/dw/service/impl/CjStudentServiceImpl.java
@@ -1,22 +1,21 @@
package com.ruoyi.dw.service.impl;
+import cn.hutool.core.bean.BeanUtil;
+import com.ruoyi.common.core.redis.RedisCache;
+import com.ruoyi.dw.domain.CjStudent;
+import com.ruoyi.dw.mapper.CjStudentMapper;
+import com.ruoyi.dw.service.ICjStudentService;
+import org.apache.poi.ss.usermodel.*;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.web.multipart.MultipartFile;
+
+import javax.annotation.Resource;
import java.io.IOException;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-import com.ruoyi.common.core.redis.RedisCache;
-import com.ruoyi.common.utils.StringUtils;
-import org.apache.poi.ss.usermodel.*;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-import com.ruoyi.dw.mapper.CjStudentMapper;
-import com.ruoyi.dw.domain.CjStudent;
-import com.ruoyi.dw.service.ICjStudentService;
-import org.springframework.web.multipart.MultipartFile;
-
-import javax.annotation.Resource;
-
/**
* 采集学生信息Service业务层处理
*
@@ -223,6 +222,7 @@ public class CjStudentServiceImpl implements ICjStudentService
}
Cell xhCell = row.getCell(3);
CjStudent cjStudent = null;
+ CjStudent old = null;
boolean isInsert = false;
if (xhCell == null) {
cjStudent = new CjStudent();
@@ -235,6 +235,7 @@ public class CjStudentServiceImpl implements ICjStudentService
cjStudent = new CjStudent();
isInsert = true;
}
+ old = BeanUtil.copyProperties(cjStudent,CjStudent.class);
cjStudent.setXh(xh);
}
Cell xmCell = row.getCell(1);
@@ -338,11 +339,15 @@ public class CjStudentServiceImpl implements ICjStudentService
cjStudent.setYx(yxCell.getStringCellValue().trim());
}
cjStudent.setSfqr(1L);
- if (isInsert)
+ if (isInsert){
cjStudentMapper.insertCjStudent(cjStudent);
- else
- cjStudentMapper.updateCjStudent(cjStudent);
- j++;
+ j++;
+ }else {
+ if (!BeanUtil.isCommonFieldsEqual(cjStudent, old)) {
+ cjStudentMapper.updateCjStudent(cjStudent);
+ j++;
+ }
+ }
}
return j;
}catch (Exception e) {