需求变更
This commit is contained in:
6
pom.xml
6
pom.xml
@ -217,6 +217,12 @@
|
||||
<version>${ruoyi.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>cn.hutool</groupId>
|
||||
<artifactId>hutool-all</artifactId>
|
||||
<version>5.8.33</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
|
@ -19,6 +19,11 @@
|
||||
<artifactId>ruoyi-system</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>cn.hutool</groupId>
|
||||
<artifactId>hutool-all</artifactId>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
</project>
|
@ -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<String> dates = getPreviousTuesdayIntervals(checkStatus.getWeekCheck());
|
||||
Date date1 = DateUtils.parseDate(dates.get(2) + " " +checkStatus.getWeekTimeCheck());
|
||||
Date date2 = DateUtils.parseDate(dates.get(0) + " " +checkStatus.getWeekTimeCheck());
|
||||
List<XyDataCheck> 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<XyDataCheck> bzs = xyCheckMapper.selectGxCount(date1, date2);
|
||||
List<XyDataCheck> 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<XyDataCheck> alls = xyCheckMapper.selectAllCount();
|
||||
List<XyDataCheck> gxs = xyCheckMapper.selectGxCount(beginDate, endDate);
|
||||
List<XyDataCheck> yxs = xyCheckMapper.selectYxCount(beginDate, endDate);
|
||||
List<XyCheck> checks = getChecks(alls,gxs,yxs,mondayAndSundays);
|
||||
List<XyCheck> 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<String> dates = getPreviousTuesdayIntervals(checkStatus.getWeekCheck());
|
||||
Date date1 = DateUtils.parseDate(dates.get(2) + " " +checkStatus.getWeekTimeCheck());
|
||||
Date date2 = DateUtils.parseDate(dates.get(0) + " " +checkStatus.getWeekTimeCheck());
|
||||
List<XyDataCheck> 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<XyDataCheck> bzs = xyCheckMapper.selectGxCount(date1, date2);
|
||||
List<XyDataCheck> bzyx = xyCheckMapper.selectYxCount(date1, date2);
|
||||
List<XyDataCheck> alls = xyCheckMapper.selectAllCount();
|
||||
List<XyDataCheck> gxs = xyCheckMapper.selectGxCount(checkStatus.getBeginDate(), checkStatus.getEndDate());
|
||||
List<XyDataCheck> yxs = xyCheckMapper.selectYxCount(checkStatus.getBeginDate(), checkStatus.getEndDate());
|
||||
List<XyCheckExport> checks = getChecksExport(alls,gxs,yxs,mondayAndSundays);
|
||||
List<XyCheckExport> 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<XyCheck> getChecks(List<XyDataCheck> alls,List<XyDataCheck> gxs,
|
||||
List<XyDataCheck> yxs,List<XyDataCheck> mondayAndSundays){
|
||||
List<XyDataCheck> yxs,List<XyDataCheck> bzs,
|
||||
List<XyDataCheck> bzyx){
|
||||
List<XyCheck> checks = new ArrayList<>();
|
||||
for(int i=0;i<alls.size();i++){
|
||||
XyCheck check = new XyCheck();
|
||||
@ -208,28 +241,58 @@ public class XyCheckController extends BaseController {
|
||||
check.setGxCount(gxs.get(i).getDataCount());
|
||||
check.setYxCount(yxs.get(i).getDataCount());
|
||||
check.setWxCount(check.getGxCount() - check.getYxCount());
|
||||
check.setBzCount(mondayAndSundays.get(i).getDataCount());
|
||||
check.setBzCount(bzs.get(i).getDataCount());
|
||||
check.setBzYxCount(bzyx.get(i).getDataCount());
|
||||
check.setBzWxCount(check.getBzCount() - check.getYxCount());
|
||||
checks.add(check);
|
||||
}
|
||||
return checks;
|
||||
}
|
||||
|
||||
private static List<XyCheckExport> getChecksExport(List<XyDataCheck> alls,List<XyDataCheck> gxs,
|
||||
List<XyDataCheck> yxs,List<XyDataCheck> mondayAndSundays){
|
||||
List<XyDataCheck> yxs,List<XyDataCheck> bzs,List<XyDataCheck> bzyx){
|
||||
List<XyCheckExport> 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<alls.size();i++){
|
||||
XyCheckExport check = new XyCheckExport();
|
||||
check.setXy(gxs.get(i).getXy());
|
||||
check.setJc(alls.get(i).getXy());
|
||||
check.setAllCount(alls.get(i).getDataCount());
|
||||
sumAllCount += check.getAllCount();
|
||||
check.setGxCount(gxs.get(i).getDataCount());
|
||||
sumGxCount += check.getGxCount();
|
||||
check.setYxCount(yxs.get(i).getDataCount());
|
||||
sumYxCount += check.getYxCount();
|
||||
check.setWxCount(check.getGxCount() - check.getYxCount());
|
||||
check.setBzCount(mondayAndSundays.get(i).getDataCount());
|
||||
sumWxCount += check.getWxCount();
|
||||
check.setBzCount(bzs.get(i).getDataCount());
|
||||
sumBzCount += check.getBzCount();
|
||||
check.setBzYxCount(bzyx.get(i).getDataCount());
|
||||
sumBzYxCount += check.getBzYxCount();
|
||||
check.setBzWxCount(check.getBzCount() - check.getBzYxCount());
|
||||
sumBzWxCount += check.getBzWxCount();
|
||||
double result = (double) gxs.get(i).getDataCount().intValue() / alls.get(i).getDataCount().intValue() * 100;
|
||||
check.setBl(String.format("%.2f", result) + "%");
|
||||
checks.add(check);
|
||||
}
|
||||
XyCheckExport sumCheck = new XyCheckExport();
|
||||
sumCheck.setXy("合计");
|
||||
sumCheck.setAllCount(sumAllCount);
|
||||
sumCheck.setGxCount(sumGxCount);
|
||||
sumCheck.setYxCount(sumYxCount);
|
||||
sumCheck.setWxCount(sumWxCount);
|
||||
sumCheck.setBzCount(sumBzCount);
|
||||
sumCheck.setBzYxCount(sumBzYxCount);
|
||||
sumCheck.setBzWxCount(sumBzWxCount);
|
||||
double result = (double) sumGxCount / sumAllCount * 100;
|
||||
sumCheck.setBl(String.format("%.2f", result) + "%");
|
||||
checks.add(sumCheck);
|
||||
return checks;
|
||||
}
|
||||
|
||||
@ -251,73 +314,4 @@ public class XyCheckController extends BaseController {
|
||||
return bls;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 获取今天所在周的周一到周日的日期列表(按中国习惯:周一为第一天)
|
||||
* @return 包含7个日期的列表,索引0=周一,6=周日
|
||||
*/
|
||||
public static List<Date> 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<Date> 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<String> getPreviousTuesdayIntervals(int weekCheck) {
|
||||
LocalDate today = LocalDate.now();
|
||||
List<String> 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);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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) {
|
||||
|
Reference in New Issue
Block a user