考核周期更新

This commit is contained in:
2025-08-08 09:57:16 +08:00
parent f0353d5ba1
commit 39eddb496d
6 changed files with 258 additions and 16 deletions

View File

@ -1,13 +1,17 @@
package com.ruoyi.dw.controller;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.dw.domain.CheckQuery;
import com.ruoyi.dw.domain.DataCheckStatus;
import com.ruoyi.dw.domain.vo.XyCheck;
import com.ruoyi.dw.domain.vo.XyCheckBl;
import com.ruoyi.dw.domain.vo.XyCheckExport;
import com.ruoyi.dw.domain.vo.XyDataCheck;
import com.ruoyi.dw.mapper.DataCheckMapper;
import com.ruoyi.dw.mapper.XyCheckMapper;
@ -15,10 +19,13 @@ import com.ruoyi.dw.util.SortField;
import com.ruoyi.dw.util.SortOrder;
import com.ruoyi.dw.util.XyBlSorter;
import com.ruoyi.dw.util.XyCheckSorter;
import org.apache.poi.ss.usermodel.Workbook;
import org.springframework.http.HttpHeaders;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.time.DayOfWeek;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
@ -65,7 +72,7 @@ public class XyCheckController extends BaseController {
endTime.set(Calendar.SECOND, 59);
endTime.set(Calendar.MILLISECOND, 0);
Date endDate = endTime.getTime();
dataCheckMapper.updateCheck(startDate, endDate);
dataCheckMapper.updateCheck(startDate, endDate,checkStatus.getWeekCheck(),checkStatus.getWeekTimeCheck());
return AjaxResult.success("设置成功");
}
@ -100,9 +107,11 @@ public class XyCheckController extends BaseController {
*/
@GetMapping("/zzt")
public AjaxResult studentCount(CheckQuery checkQuery) {
List<Date> mondayAndSunday = getThisWeekDates();
List<XyDataCheck> mondayAndSundays = xyCheckMapper.selectGxCount(mondayAndSunday.get(0), mondayAndSunday.get(1));
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);
Date beginDate = null;
Date endDate = null;
if (StringUtils.isNotEmpty(checkQuery.getBeginDate())) {
@ -127,6 +136,34 @@ public class XyCheckController extends BaseController {
return AjaxResult.success(checks);
}
/**
* 导出采集数量考核接口
* @param response
*/
@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);
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);
String zipFileName = "进度统计-信息采集-" + DateUtils.dateTimeNow() + ".xlsx";
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheetzip");
response.setHeader("Access-Control-Expose-Headers", "Content-Disposition");
response.setHeader(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=" + zipFileName);
ExcelUtil<XyCheckExport> excelUtil = new ExcelUtil<>(XyCheckExport.class);
excelUtil.init(checks, "数据", StringUtils.EMPTY, Excel.Type.EXPORT);
excelUtil.writeSheet();
Workbook workbook = excelUtil.getWb();
workbook.write(response.getOutputStream());
}
/**
* 获取采集数据更新
* @param checkQuery
@ -181,6 +218,25 @@ public class XyCheckController extends BaseController {
return checks;
}
private static List<XyCheckExport> getChecksExport(List<XyDataCheck> alls,List<XyDataCheck> gxs,
List<XyDataCheck> yxs,List<XyDataCheck> mondayAndSundays){
List<XyCheckExport> checks = new ArrayList<>();
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());
check.setGxCount(gxs.get(i).getDataCount());
check.setYxCount(yxs.get(i).getDataCount());
check.setWxCount(check.getGxCount() - check.getYxCount());
check.setBzCount(mondayAndSundays.get(i).getDataCount());
double result = (double) gxs.get(i).getDataCount().intValue() / alls.get(i).getDataCount().intValue() * 100;
check.setBl(String.format("%.2f", result) + "%");
checks.add(check);
}
return checks;
}
/**
* 拼装数据
* @param alls
@ -193,12 +249,14 @@ public class XyCheckController extends BaseController {
XyCheckBl bl = new XyCheckBl();
bl.setXy(alls.get(i).getXy());
double result = (double) gxs.get(i).getDataCount().intValue() / alls.get(i).getDataCount().intValue();
bl.setBl(String.format("%.2f", result));
bl.setBl(String.format("%.4f", result));
bls.add(bl);
}
return bls;
}
/**
* 获取今天所在周的周一到周日的日期列表(按中国习惯:周一为第一天)
* @return 包含7个日期的列表索引0=周一6=周日
@ -227,4 +285,43 @@ public class XyCheckController extends BaseController {
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);
}
}

View File

@ -19,6 +19,10 @@ public class DataCheckStatus {
@JsonFormat(pattern = "yyyy-MM-dd")
private Date endDate;
private int weekCheck;
private String weekTimeCheck;
public Integer getId() {
return id;
}
@ -50,4 +54,20 @@ public class DataCheckStatus {
public void setEndDate(Date endDate) {
this.endDate = endDate;
}
public int getWeekCheck() {
return weekCheck;
}
public void setWeekCheck(int weekCheck) {
this.weekCheck = weekCheck;
}
public String getWeekTimeCheck() {
return weekTimeCheck;
}
public void setWeekTimeCheck(String weekTimeCheck) {
this.weekTimeCheck = weekTimeCheck;
}
}

View File

@ -0,0 +1,117 @@
package com.ruoyi.dw.domain.vo;
import com.ruoyi.common.annotation.Excel;
public class XyCheckExport {
/**
* 学院名称
*/
@Excel(name = "学院名称")
private String xy;
/**
* 简称
*/
@Excel(name = "简称")
private String jc;
/**
* 总数量
*/
@Excel(name = "总数量")
private Integer allCount;
/**
* 更新数量
*/
@Excel(name = "更新数量")
private Integer gxCount;
/**
* 有效数量
*/
@Excel(name = "有效数量")
private Integer yxCount;
/**
* 无效数量
*/
@Excel(name = "无效数量")
private Integer wxCount;
/**
* 本周更新数量
*/
@Excel(name = "本周更新数量")
private Integer bzCount;
/**
* 完成比例
*/
@Excel(name = "完成比例")
private String bl;
public String getXy() {
return xy;
}
public void setXy(String xy) {
this.xy = xy;
}
public String getJc() {
return jc;
}
public void setJc(String jc) {
this.jc = jc;
}
public Integer getAllCount() {
return allCount;
}
public void setAllCount(Integer allCount) {
this.allCount = allCount;
}
public Integer getGxCount() {
return gxCount;
}
public void setGxCount(Integer gxCount) {
this.gxCount = gxCount;
}
public Integer getYxCount() {
return yxCount;
}
public void setYxCount(Integer yxCount) {
this.yxCount = yxCount;
}
public Integer getWxCount() {
return wxCount;
}
public void setWxCount(Integer wxCount) {
this.wxCount = wxCount;
}
public Integer getBzCount() {
return bzCount;
}
public void setBzCount(Integer bzCount) {
this.bzCount = bzCount;
}
public String getBl() {
return bl;
}
public void setBl(String bl) {
this.bl = bl;
}
}

View File

@ -13,5 +13,8 @@ public interface DataCheckMapper {
public int endCheck(@Param("checkDate") Date checkDate);
public int updateCheck(@Param("startCheckDate") Date startCheckDate, @Param("endCheckDate") Date endCheckDate);
public int updateCheck(@Param("startCheckDate") Date startCheckDate,
@Param("endCheckDate") Date endCheckDate,
@Param("weekCheck") Integer weekCheck,
@Param("weekTimeCheck") String weekTimeCheck);
}

View File

@ -222,17 +222,21 @@ public class CjStudentServiceImpl implements ICjStudentService
break;
}
Cell xhCell = row.getCell(3);
CjStudent cjStudent = null;
boolean isInsert = false;
if (xhCell == null) {
cjStudent = new CjStudent();
isInsert = true;
}else {
xhCell.setCellType(CellType.STRING);
String xh = xhCell.getStringCellValue().trim();
if (!StringUtils.isNumeric(xh)){
continue;
}
boolean isInsert = false;
CjStudent cjStudent = cjStudentMapper.selectCjStudentByXh(xh);
cjStudent = cjStudentMapper.selectCjStudentByXh(xh);
if (cjStudent == null){
cjStudent = new CjStudent();
isInsert = true;
}
cjStudent.setXh(xh);
}
Cell xmCell = row.getCell(1);
if (xmCell != null) {
xmCell.setCellType(CellType.STRING);
@ -243,7 +247,6 @@ public class CjStudentServiceImpl implements ICjStudentService
xbCell.setCellType(CellType.STRING);
cjStudent.setXb(xbCell.getStringCellValue().trim());
}
cjStudent.setXh(xh);
Cell xyCell = row.getCell(4);
if (xyCell != null) {
xyCell.setCellType(CellType.STRING);

View File

@ -9,10 +9,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="checkStatus" column="check_status" />
<result property="beginDate" column="begin_date" />
<result property="endDate" column="end_date" />
<result property="weekCheck" column="week_check" />
<result property="weekTimeCheck" column="week_time_check" />
</resultMap>
<select id="getStatus" resultMap="dataCheckStatus">
select id,check_status,begin_date,end_date from data_check_status where id = 1
select id,check_status,begin_date,end_date,week_check,week_time_check from data_check_status where id = 1
</select>
<update id="startCheck" parameterType="date">
@ -24,7 +26,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</update>
<update id="updateCheck" parameterType="date">
update data_check_status set begin_date = #{startCheckDate},end_date = #{endCheckDate}
update data_check_status set begin_date = #{startCheckDate},end_date = #{endCheckDate},week_check = #{weekCheck},week_time_check = #{weekTimeCheck}
</update>
</mapper>