用户采集数据考核
This commit is contained in:
@ -2,12 +2,29 @@ package com.ruoyi.dw.controller;
|
||||
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.utils.DateUtils;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
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.XyDataCheck;
|
||||
import com.ruoyi.dw.mapper.DataCheckMapper;
|
||||
import com.ruoyi.dw.mapper.XyCheckMapper;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
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.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.time.DayOfWeek;
|
||||
import java.time.LocalDate;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/xy/check")
|
||||
@ -16,14 +33,198 @@ public class XyCheckController extends BaseController {
|
||||
@Resource
|
||||
private XyCheckMapper xyCheckMapper;
|
||||
|
||||
@Resource
|
||||
private DataCheckMapper dataCheckMapper;
|
||||
|
||||
/**
|
||||
* 获取当前考核状态
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/status")
|
||||
public AjaxResult getStatus() {
|
||||
return AjaxResult.success(dataCheckMapper.getStatus());
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改考核状态
|
||||
* @return
|
||||
*/
|
||||
@PutMapping("/status")
|
||||
public AjaxResult updateStatus(DataCheckStatus checkStatus) {
|
||||
Calendar startTime = Calendar.getInstance();
|
||||
startTime.setTime(checkStatus.getBeginDate());
|
||||
startTime.set(Calendar.HOUR_OF_DAY, 0);
|
||||
startTime.set(Calendar.MINUTE, 0);
|
||||
startTime.set(Calendar.SECOND, 0);
|
||||
startTime.set(Calendar.MILLISECOND, 0);
|
||||
Date startDate = startTime.getTime();
|
||||
Calendar endTime = Calendar.getInstance();
|
||||
endTime.setTime(checkStatus.getEndDate());
|
||||
endTime.set(Calendar.HOUR_OF_DAY, 23);
|
||||
endTime.set(Calendar.MINUTE, 59);
|
||||
endTime.set(Calendar.SECOND, 59);
|
||||
endTime.set(Calendar.MILLISECOND, 0);
|
||||
Date endDate = endTime.getTime();
|
||||
dataCheckMapper.updateCheck(startDate, endDate);
|
||||
return AjaxResult.success("设置成功");
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 根据专业关联表统计各个学院的调查问卷数量
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/dwCount")
|
||||
public AjaxResult dwCount() {
|
||||
return AjaxResult.success(xyCheckMapper.selectXyCheckDw());
|
||||
public AjaxResult dwCount(CheckQuery checkQuery) {
|
||||
DataCheckStatus checkStatus = dataCheckMapper.getStatus();
|
||||
Date beginDate = null;
|
||||
Date endDate = null;
|
||||
if (StringUtils.isNotEmpty(checkQuery.getBeginDate())) {
|
||||
beginDate = DateUtils.dateTime(DateUtils.YYYY_MM_DD_HH_MM_SS, checkQuery.getBeginDate() + " 00:00:00");
|
||||
}else {
|
||||
beginDate = checkStatus.getBeginDate();
|
||||
}
|
||||
if (StringUtils.isNotEmpty(checkQuery.getEndDate())) {
|
||||
endDate = DateUtils.dateTime(DateUtils.YYYY_MM_DD_HH_MM_SS, checkQuery.getEndDate() + " 23:59:59");
|
||||
}else {
|
||||
endDate = checkStatus.getEndDate();
|
||||
}
|
||||
return AjaxResult.success(xyCheckMapper.selectXyCheckDw(beginDate, endDate));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取采集数据更新
|
||||
* @param checkQuery
|
||||
* @return
|
||||
*/
|
||||
@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();
|
||||
Date beginDate = null;
|
||||
Date endDate = null;
|
||||
if (StringUtils.isNotEmpty(checkQuery.getBeginDate())) {
|
||||
beginDate = DateUtils.dateTime(DateUtils.YYYY_MM_DD_HH_MM_SS, checkQuery.getBeginDate() + " 00:00:00");
|
||||
}else {
|
||||
beginDate = checkStatus.getBeginDate();
|
||||
}
|
||||
if (StringUtils.isNotEmpty(checkQuery.getEndDate())) {
|
||||
endDate = DateUtils.dateTime(DateUtils.YYYY_MM_DD_HH_MM_SS, checkQuery.getEndDate() + " 23:59:59");
|
||||
}else {
|
||||
endDate = checkStatus.getEndDate();
|
||||
}
|
||||
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);
|
||||
if (checkQuery.getSort().intValue() == 1){
|
||||
checks = XyCheckSorter.sortList(checks, SortField.BZ_COUNT, SortOrder.DESC);
|
||||
}else if (checkQuery.getSort().intValue() == 2){
|
||||
checks = XyCheckSorter.sortList(checks, SortField.GX_COUNT, SortOrder.DESC);
|
||||
}
|
||||
return AjaxResult.success(checks);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取采集数据更新
|
||||
* @param checkQuery
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/zxt")
|
||||
public AjaxResult studentCount2(CheckQuery checkQuery) {
|
||||
DataCheckStatus checkStatus = dataCheckMapper.getStatus();
|
||||
Date beginDate = null;
|
||||
Date endDate = null;
|
||||
if (StringUtils.isNotEmpty(checkQuery.getBeginDate())) {
|
||||
beginDate = DateUtils.dateTime(DateUtils.YYYY_MM_DD_HH_MM_SS, checkQuery.getBeginDate() + " 00:00:00");
|
||||
}else {
|
||||
beginDate = checkStatus.getBeginDate();
|
||||
}
|
||||
if (StringUtils.isNotEmpty(checkQuery.getEndDate())) {
|
||||
endDate = DateUtils.dateTime(DateUtils.YYYY_MM_DD_HH_MM_SS, checkQuery.getEndDate() + " 23:59:59");
|
||||
}else {
|
||||
endDate = checkStatus.getEndDate();
|
||||
}
|
||||
List<XyDataCheck> alls = xyCheckMapper.selectAllCount();
|
||||
List<XyDataCheck> gxs = xyCheckMapper.selectGxCount(beginDate, endDate);
|
||||
List<XyCheckBl> bls = getChecks2(alls,gxs);
|
||||
if (checkQuery.getSort().intValue() == 1){
|
||||
bls = XyBlSorter.sortList(bls);
|
||||
}
|
||||
return AjaxResult.success(bls);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 拼装数据
|
||||
* @param alls
|
||||
* @param gxs
|
||||
* @param yxs
|
||||
* @param mondayAndSundays
|
||||
* @return
|
||||
*/
|
||||
private static List<XyCheck> getChecks(List<XyDataCheck> alls,List<XyDataCheck> gxs,
|
||||
List<XyDataCheck> yxs,List<XyDataCheck> mondayAndSundays){
|
||||
List<XyCheck> checks = new ArrayList<>();
|
||||
for(int i=0;i<alls.size();i++){
|
||||
XyCheck check = new XyCheck();
|
||||
check.setXy(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());
|
||||
checks.add(check);
|
||||
}
|
||||
return checks;
|
||||
}
|
||||
|
||||
/**
|
||||
* 拼装数据
|
||||
* @param alls
|
||||
* @param gxs
|
||||
* @return
|
||||
*/
|
||||
private static List<XyCheckBl> getChecks2(List<XyDataCheck> alls, List<XyDataCheck> gxs){
|
||||
List<XyCheckBl> bls = new ArrayList<>();
|
||||
for(int i=0;i<alls.size();i++){
|
||||
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));
|
||||
bls.add(bl);
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
|
34
ruoyi-dw/src/main/java/com/ruoyi/dw/domain/CheckQuery.java
Normal file
34
ruoyi-dw/src/main/java/com/ruoyi/dw/domain/CheckQuery.java
Normal file
@ -0,0 +1,34 @@
|
||||
package com.ruoyi.dw.domain;
|
||||
|
||||
public class CheckQuery {
|
||||
|
||||
private Integer sort;
|
||||
|
||||
private String beginDate;
|
||||
|
||||
private String endDate;
|
||||
|
||||
public Integer getSort() {
|
||||
return sort;
|
||||
}
|
||||
|
||||
public void setSort(Integer sort) {
|
||||
this.sort = sort;
|
||||
}
|
||||
|
||||
public String getBeginDate() {
|
||||
return beginDate;
|
||||
}
|
||||
|
||||
public void setBeginDate(String beginDate) {
|
||||
this.beginDate = beginDate;
|
||||
}
|
||||
|
||||
public String getEndDate() {
|
||||
return endDate;
|
||||
}
|
||||
|
||||
public void setEndDate(String endDate) {
|
||||
this.endDate = endDate;
|
||||
}
|
||||
}
|
@ -0,0 +1,53 @@
|
||||
package com.ruoyi.dw.domain;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 数据验证周期
|
||||
*/
|
||||
public class DataCheckStatus {
|
||||
|
||||
private Integer id;
|
||||
|
||||
private Integer checkStatus;
|
||||
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
private Date beginDate;
|
||||
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
private Date endDate;
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Integer getCheckStatus() {
|
||||
return checkStatus;
|
||||
}
|
||||
|
||||
public void setCheckStatus(Integer checkStatus) {
|
||||
this.checkStatus = checkStatus;
|
||||
}
|
||||
|
||||
public Date getBeginDate() {
|
||||
return beginDate;
|
||||
}
|
||||
|
||||
public void setBeginDate(Date beginDate) {
|
||||
this.beginDate = beginDate;
|
||||
}
|
||||
|
||||
public Date getEndDate() {
|
||||
return endDate;
|
||||
}
|
||||
|
||||
public void setEndDate(Date endDate) {
|
||||
this.endDate = endDate;
|
||||
}
|
||||
}
|
82
ruoyi-dw/src/main/java/com/ruoyi/dw/domain/vo/XyCheck.java
Normal file
82
ruoyi-dw/src/main/java/com/ruoyi/dw/domain/vo/XyCheck.java
Normal file
@ -0,0 +1,82 @@
|
||||
package com.ruoyi.dw.domain.vo;
|
||||
|
||||
public class XyCheck {
|
||||
|
||||
/**
|
||||
* 学院名称
|
||||
*/
|
||||
private String xy;
|
||||
|
||||
/**
|
||||
* 总数量
|
||||
*/
|
||||
private Integer allCount;
|
||||
|
||||
/**
|
||||
* 更新数量
|
||||
*/
|
||||
private Integer gxCount;
|
||||
|
||||
/**
|
||||
* 有效数量
|
||||
*/
|
||||
private Integer yxCount;
|
||||
|
||||
/**
|
||||
* 无效数量
|
||||
*/
|
||||
private Integer wxCount;
|
||||
|
||||
/**
|
||||
* 本周更新数量
|
||||
*/
|
||||
private Integer bzCount;
|
||||
|
||||
public String getXy() {
|
||||
return xy;
|
||||
}
|
||||
|
||||
public void setXy(String xy) {
|
||||
this.xy = xy;
|
||||
}
|
||||
|
||||
public Integer getAllCount() {
|
||||
return allCount;
|
||||
}
|
||||
|
||||
public Integer getGxCount() {
|
||||
return gxCount;
|
||||
}
|
||||
|
||||
public void setGxCount(Integer gxCount) {
|
||||
this.gxCount = gxCount;
|
||||
}
|
||||
|
||||
public void setAllCount(Integer allCount) {
|
||||
this.allCount = allCount;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
24
ruoyi-dw/src/main/java/com/ruoyi/dw/domain/vo/XyCheckBl.java
Normal file
24
ruoyi-dw/src/main/java/com/ruoyi/dw/domain/vo/XyCheckBl.java
Normal file
@ -0,0 +1,24 @@
|
||||
package com.ruoyi.dw.domain.vo;
|
||||
|
||||
public class XyCheckBl {
|
||||
|
||||
private String xy;
|
||||
|
||||
private String bl;
|
||||
|
||||
public String getXy() {
|
||||
return xy;
|
||||
}
|
||||
|
||||
public void setXy(String xy) {
|
||||
this.xy = xy;
|
||||
}
|
||||
|
||||
public String getBl() {
|
||||
return bl;
|
||||
}
|
||||
|
||||
public void setBl(String bl) {
|
||||
this.bl = bl;
|
||||
}
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
package com.ruoyi.dw.domain.vo;
|
||||
|
||||
public class XyDataCheck {
|
||||
|
||||
private String xy;
|
||||
|
||||
private Integer dataCount;
|
||||
|
||||
public String getXy() {
|
||||
return xy;
|
||||
}
|
||||
|
||||
public void setXy(String xy) {
|
||||
this.xy = xy;
|
||||
}
|
||||
|
||||
public Integer getDataCount() {
|
||||
return dataCount;
|
||||
}
|
||||
|
||||
public void setDataCount(Integer dataCount) {
|
||||
this.dataCount = dataCount;
|
||||
}
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
package com.ruoyi.dw.mapper;
|
||||
|
||||
import com.ruoyi.dw.domain.DataCheckStatus;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
public interface DataCheckMapper {
|
||||
|
||||
public DataCheckStatus getStatus();
|
||||
|
||||
public int startCheck(@Param("checkDate") Date checkDate);
|
||||
|
||||
public int endCheck(@Param("checkDate") Date checkDate);
|
||||
|
||||
public int updateCheck(@Param("startCheckDate") Date startCheckDate, @Param("endCheckDate") Date endCheckDate);
|
||||
}
|
@ -1,10 +1,20 @@
|
||||
package com.ruoyi.dw.mapper;
|
||||
|
||||
import com.ruoyi.dw.domain.vo.XyCheckDw;
|
||||
import com.ruoyi.dw.domain.vo.XyDataCheck;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
public interface XyCheckMapper {
|
||||
|
||||
public List<XyCheckDw> selectXyCheckDw();
|
||||
public List<XyCheckDw> selectXyCheckDw(@Param("startDate") Date startDate, @Param("endDate") Date endDate);
|
||||
|
||||
public List<XyDataCheck> selectAllCount();
|
||||
|
||||
public List<XyDataCheck> selectGxCount(@Param("startDate") Date startDate, @Param("endDate") Date endDate);
|
||||
|
||||
public List<XyDataCheck> selectYxCount(@Param("startDate") Date startDate, @Param("endDate") Date endDate);
|
||||
|
||||
}
|
||||
|
@ -216,7 +216,12 @@ public class CjStudentServiceImpl implements ICjStudentService
|
||||
int rows = sheet.getLastRowNum();
|
||||
for (int i = 2; i <= rows; i++) {
|
||||
Row row = sheet.getRow(i);
|
||||
String xh = row.getCell(3).getStringCellValue().trim();
|
||||
if (row == null) {
|
||||
break;
|
||||
}
|
||||
Cell xhCell = row.getCell(3);
|
||||
xhCell.setCellType(CellType.STRING);
|
||||
String xh = xhCell.getStringCellValue().trim();
|
||||
boolean isInsert = false;
|
||||
CjStudent cjStudent = cjStudentMapper.selectCjStudentByXh(xh);
|
||||
if (cjStudent == null){
|
||||
@ -241,7 +246,12 @@ public class CjStudentServiceImpl implements ICjStudentService
|
||||
cjStudent.setBj(bjCell.getStringCellValue().trim());
|
||||
Cell bybfCell = row.getCell(7);
|
||||
bybfCell.setCellType(CellType.STRING);
|
||||
cjStudent.setBynf(Integer.valueOf(bybfCell.getStringCellValue()));
|
||||
try {
|
||||
Integer bynf = Integer.valueOf(bybfCell.getStringCellValue());
|
||||
cjStudent.setBynf(bynf);
|
||||
}catch (Exception e){
|
||||
cjStudent.setBynf(null);
|
||||
}
|
||||
Cell zgxlCell = row.getCell(8);
|
||||
zgxlCell.setCellType(CellType.STRING);
|
||||
cjStudent.setZgyl(zgxlCell.getStringCellValue().trim());
|
||||
@ -292,42 +302,88 @@ public class CjStudentServiceImpl implements ICjStudentService
|
||||
cjStudentMapper.updateCjStudent(cjStudent);
|
||||
}
|
||||
return rows-2;
|
||||
}catch (IOException e) {
|
||||
}catch (Exception e) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
private static final Set<String> MUNICIPALITIES = new HashSet<>(Arrays.asList("北京", "上海", "天津", "重庆"));
|
||||
|
||||
/**
|
||||
* 根据常驻地获取省市
|
||||
* @param address
|
||||
* @return
|
||||
* 提取省名和市名,支持普通省、自治区、直辖市
|
||||
*
|
||||
* @param address 地址字符串
|
||||
* @return Map 包含 province 和 city,未找到返回 null
|
||||
*/
|
||||
private static Map<String, String> extractProvinceAndCity(String address) {
|
||||
if (address == null || address.length() < 2) {
|
||||
public static Map<String, String> extractProvinceAndCity(String address) {
|
||||
if (address == null || address.trim().length() < 2) {
|
||||
return null;
|
||||
}
|
||||
|
||||
int provinceIndex = address.indexOf("省");
|
||||
int cityIndex = -1;
|
||||
|
||||
// 必须有"省",且"省"不能是最后一个字符
|
||||
if (provinceIndex == -1 || provinceIndex == address.length() - 1) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// 在"省"之后找"市"
|
||||
cityIndex = address.indexOf("市", provinceIndex + 1);
|
||||
if (cityIndex == -1) {
|
||||
return null;
|
||||
}
|
||||
|
||||
String province = address.substring(0, provinceIndex ); // 不包含"省"
|
||||
String city = address.substring(provinceIndex + 1, cityIndex); // 从省后到"市"结束
|
||||
|
||||
address = address.trim();
|
||||
Map<String, String> result = new HashMap<>();
|
||||
result.put("province", province);
|
||||
result.put("city", city);
|
||||
return result;
|
||||
|
||||
// 1. 查找“省”
|
||||
int provinceEnd = address.indexOf("省");
|
||||
if (provinceEnd != -1) {
|
||||
String province = address.substring(0, provinceEnd); // 不包含“省”
|
||||
result.put("province", province);
|
||||
|
||||
// 查找“市”在“省”之后
|
||||
int cityStart = provinceEnd + 1;
|
||||
int cityEnd = address.indexOf("市", cityStart);
|
||||
if (cityEnd != -1 && cityEnd > cityStart) {
|
||||
String city = address.substring(cityStart, cityEnd);
|
||||
result.put("city", city);
|
||||
} else {
|
||||
result.put("city", null);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
// 2. 查找“自治区”
|
||||
int autonomousEnd = address.indexOf("自治区");
|
||||
if (autonomousEnd != -1) {
|
||||
String province = address.substring(0, autonomousEnd); // 不包含“自治区”是3个字
|
||||
result.put("province", province);
|
||||
|
||||
int cityStart = autonomousEnd + 3;
|
||||
int cityEnd = address.indexOf("市", cityStart);
|
||||
if (cityEnd != -1 && cityEnd > cityStart) {
|
||||
String city = address.substring(cityStart, cityEnd);
|
||||
result.put("city", city);
|
||||
} else {
|
||||
result.put("city", null);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
// 3. 处理直辖市:如“北京市...”
|
||||
for (String city : MUNICIPALITIES) {
|
||||
if (address.startsWith(city)) {
|
||||
result.put("province", city);
|
||||
// 直辖市的“市”就是省,也可以把“市”设为市名,或提取区名
|
||||
// 这里我们设市名为“北京市”
|
||||
result.put("city", city);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
// 4. 兜底:尝试找“市”作为省名(如“上海市浦东新区”)
|
||||
int firstCityIndex = address.indexOf("市");
|
||||
if (firstCityIndex != -1 && firstCityIndex <= 3) { // 一般前3个字内出现“市”可能是直辖市
|
||||
String possibleCity = address.substring(0, firstCityIndex);
|
||||
for (String m : MUNICIPALITIES) {
|
||||
if (possibleCity.equals(m)) {
|
||||
result.put("province", possibleCity);
|
||||
result.put("city", possibleCity);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 无法识别
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
9
ruoyi-dw/src/main/java/com/ruoyi/dw/util/SortField.java
Normal file
9
ruoyi-dw/src/main/java/com/ruoyi/dw/util/SortField.java
Normal file
@ -0,0 +1,9 @@
|
||||
package com.ruoyi.dw.util;
|
||||
|
||||
public enum SortField {
|
||||
ALL_COUNT,
|
||||
GX_COUNT,
|
||||
YX_COUNT,
|
||||
WX_COUNT,
|
||||
BZ_COUNT
|
||||
}
|
6
ruoyi-dw/src/main/java/com/ruoyi/dw/util/SortOrder.java
Normal file
6
ruoyi-dw/src/main/java/com/ruoyi/dw/util/SortOrder.java
Normal file
@ -0,0 +1,6 @@
|
||||
package com.ruoyi.dw.util;
|
||||
|
||||
public enum SortOrder {
|
||||
ASC,
|
||||
DESC
|
||||
}
|
29
ruoyi-dw/src/main/java/com/ruoyi/dw/util/XyBlSorter.java
Normal file
29
ruoyi-dw/src/main/java/com/ruoyi/dw/util/XyBlSorter.java
Normal file
@ -0,0 +1,29 @@
|
||||
package com.ruoyi.dw.util;
|
||||
|
||||
import com.ruoyi.dw.domain.vo.XyCheck;
|
||||
import com.ruoyi.dw.domain.vo.XyCheckBl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
public class XyBlSorter {
|
||||
|
||||
/**
|
||||
* 根据指定字段和排序方式对 XyCheck 列表进行排序
|
||||
*
|
||||
* @param list 原始列表
|
||||
* @return 排序后的列表(新列表,不影响原始数据)
|
||||
*/
|
||||
public static List<XyCheckBl> sortList(List<XyCheckBl> list) {
|
||||
if (list == null || list.isEmpty()) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
Comparator<XyCheckBl> comparator = Comparator.comparing(XyCheckBl::getBl);;
|
||||
comparator = comparator.reversed();
|
||||
List<XyCheckBl> sortedList = new ArrayList<>(list);
|
||||
sortedList.sort(comparator);
|
||||
return sortedList;
|
||||
}
|
||||
}
|
54
ruoyi-dw/src/main/java/com/ruoyi/dw/util/XyCheckSorter.java
Normal file
54
ruoyi-dw/src/main/java/com/ruoyi/dw/util/XyCheckSorter.java
Normal file
@ -0,0 +1,54 @@
|
||||
package com.ruoyi.dw.util;
|
||||
|
||||
import com.ruoyi.dw.domain.vo.XyCheck;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
public class XyCheckSorter{
|
||||
|
||||
/**
|
||||
* 根据指定字段和排序方式对 XyCheck 列表进行排序
|
||||
*
|
||||
* @param list 原始列表
|
||||
* @param sortField 排序字段(ALL_COUNT、GX_COUNT、YX_COUNT、WX_COUNT)
|
||||
* @param sortOrder 排序方式(ASC 升序 / DESC 降序)
|
||||
* @return 排序后的列表(新列表,不影响原始数据)
|
||||
*/
|
||||
public static List<XyCheck> sortList(List<XyCheck> list, SortField sortField, SortOrder sortOrder) {
|
||||
if (list == null || list.isEmpty()) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
Comparator<XyCheck> comparator = null;
|
||||
|
||||
switch (sortField) {
|
||||
case ALL_COUNT:
|
||||
comparator = Comparator.comparing(XyCheck::getAllCount);
|
||||
break;
|
||||
case GX_COUNT:
|
||||
comparator = Comparator.comparing(XyCheck::getGxCount);
|
||||
break;
|
||||
case YX_COUNT:
|
||||
comparator = Comparator.comparing(XyCheck::getYxCount);
|
||||
break;
|
||||
case WX_COUNT:
|
||||
comparator = Comparator.comparing(XyCheck::getWxCount);
|
||||
break;
|
||||
case BZ_COUNT:
|
||||
comparator = Comparator.comparing(XyCheck::getBzCount);
|
||||
break;
|
||||
default:
|
||||
throw new IllegalArgumentException("无效的排序字段: " + sortField);
|
||||
}
|
||||
|
||||
if (sortOrder == SortOrder.DESC) {
|
||||
comparator = comparator.reversed();
|
||||
}
|
||||
|
||||
List<XyCheck> sortedList = new ArrayList<>(list);
|
||||
sortedList.sort(comparator);
|
||||
return sortedList;
|
||||
}
|
||||
}
|
@ -90,7 +90,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
ELSE xm -- 可选:处理 rysfzs 不是 0 或 1 的情况
|
||||
END AS xm,xh, xb,bj, zy,xy,sydsh, sydshi, bynf, zgyl, gzdw, dwxz, dwdz, zwjb, shjz, dbry, rysfzs,sj, yx, qt, sfqr from cj_student
|
||||
<where>
|
||||
dbry is not null and dbry != '' and dbry != '无'
|
||||
dbry is not null and dbry != '' and dbry != '无' and dbry != '暂无'
|
||||
</where>
|
||||
</select>
|
||||
|
||||
|
30
ruoyi-dw/src/main/resources/mapper/dw/DataCheckMapper.xml
Normal file
30
ruoyi-dw/src/main/resources/mapper/dw/DataCheckMapper.xml
Normal file
@ -0,0 +1,30 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.ruoyi.dw.mapper.DataCheckMapper">
|
||||
|
||||
<resultMap type="DataCheckStatus" id="dataCheckStatus">
|
||||
<result property="id" column="id" />
|
||||
<result property="checkStatus" column="check_status" />
|
||||
<result property="beginDate" column="begin_date" />
|
||||
<result property="endDate" column="end_date" />
|
||||
</resultMap>
|
||||
|
||||
<select id="getStatus" resultMap="dataCheckStatus">
|
||||
select id,check_status,begin_date,end_date from data_check_status where id = 1
|
||||
</select>
|
||||
|
||||
<update id="startCheck" parameterType="date">
|
||||
update data_check_status set check_status = 1,begin_date = #{checkDate},end_date = null
|
||||
</update>
|
||||
|
||||
<update id="endCheck" parameterType="date">
|
||||
update data_check_status set check_status = 2,end_date = #{checkDate}
|
||||
</update>
|
||||
|
||||
<update id="updateCheck" parameterType="date">
|
||||
update data_check_status set begin_date = #{startCheckDate},end_date = #{endCheckDate}
|
||||
</update>
|
||||
|
||||
</mapper>
|
@ -104,32 +104,39 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<select id="selectBynf" resultMap="bynfVo" parameterType="int">
|
||||
select bynf,count(0) as bynf_count
|
||||
from cj_student
|
||||
where sfqr = 1
|
||||
where sfqr = 1 and bynf is not null
|
||||
and cast(bynf as unsigned)
|
||||
between YEAR(CURRENT_DATE) - #{year} and YEAR(CURRENT_DATE)
|
||||
group by bynf order by bynf desc
|
||||
</select>
|
||||
|
||||
<select id="selectSyd" resultMap="sydVo" parameterType="int">
|
||||
SELECT
|
||||
select sc.city_name as city,ifnull(rc.student_count, 0) as student_count from sd_citys sc left join (SELECT
|
||||
CASE
|
||||
WHEN sydsh = '山东' THEN sydshi
|
||||
ELSE '省外'
|
||||
END AS city,
|
||||
COUNT(*) AS student_count
|
||||
FROM cj_student
|
||||
where sfqr = 1 and sydsh is not null
|
||||
where sfqr = 1 and sydsh is not null and bynf is not null
|
||||
and cast(bynf as unsigned)
|
||||
between YEAR(CURRENT_DATE) - #{year} and YEAR(CURRENT_DATE)
|
||||
GROUP BY
|
||||
CASE
|
||||
WHEN sydsh = '山东' THEN sydshi
|
||||
ELSE '省外'
|
||||
END
|
||||
END) as rc on sc.city_name = rc.city order by sc.id asc
|
||||
</select>
|
||||
|
||||
<select id="selectDwxz" resultMap="dwxzVo">
|
||||
select dwxz,count(0) as dwxz_count from cj_student where sfqr = 1 and dwxz is not null group by dwxz
|
||||
SELECT
|
||||
dz.dwxz,
|
||||
ifnull( dw.dwxz_count, 0 ) AS dwxz_count
|
||||
FROM
|
||||
dwxz dz
|
||||
LEFT JOIN ( SELECT dwxz, count( 0 ) AS dwxz_count FROM cj_student WHERE sfqr = 1 AND dwxz IS NOT NULL GROUP BY dwxz ) AS dw ON dz.dwxz = dw.dwxz
|
||||
ORDER BY
|
||||
dz.id ASC
|
||||
</select>
|
||||
|
||||
</mapper>
|
@ -9,6 +9,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<result property="dwCount" column="dw_count" />
|
||||
</resultMap>
|
||||
|
||||
<resultMap type="XyDataCheck" id="xyDataCheck">
|
||||
<result property="xy" column="xy" />
|
||||
<result property="dataCount" column="data_count" />
|
||||
</resultMap>
|
||||
|
||||
|
||||
<select id="selectXyCheckDw" resultMap="xyCheckDw">
|
||||
SELECT
|
||||
re.xy,re.order_index,
|
||||
@ -20,10 +26,55 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
IFNULL( dw.dw_count, 0 ) AS dw_count
|
||||
FROM
|
||||
xy_zy xz
|
||||
LEFT JOIN ( SELECT answer, count( 0 ) AS dw_count FROM dw_answer WHERE question_id IN ( 3, 43, 71 ) GROUP BY answer ) AS dw ON dw.answer = xz.zy
|
||||
LEFT JOIN ( SELECT answer, count( 0 ) AS dw_count FROM dw_answer
|
||||
WHERE question_id IN ( 3, 43, 71 )
|
||||
<if test="startDate != null"> and create_time >= #{startDate}</if>
|
||||
<if test="endDate != null"> and create_time <= #{endDate} </if>
|
||||
GROUP BY answer ) AS dw ON dw.answer = xz.zy
|
||||
) AS re
|
||||
GROUP BY re.xy,re.order_index
|
||||
order by re.order_index
|
||||
</select>
|
||||
|
||||
<select id="selectAllCount" resultMap="xyDataCheck">
|
||||
SELECT
|
||||
x.xy,
|
||||
IFNULL( re.data_count, 0 ) AS data_count
|
||||
FROM
|
||||
xy x
|
||||
LEFT JOIN ( SELECT xy, count( 0 ) AS data_count FROM cj_student WHERE sfqr = 1 GROUP BY xy ) AS re ON x.xy = re.xy
|
||||
ORDER BY
|
||||
x.id ASC
|
||||
</select>
|
||||
|
||||
<select id="selectGxCount" resultMap="xyDataCheck">
|
||||
SELECT
|
||||
x.xy,
|
||||
IFNULL( re.data_count, 0 ) AS data_count
|
||||
FROM
|
||||
xy x
|
||||
LEFT JOIN ( SELECT xy, count( 0 ) AS data_count FROM cj_student
|
||||
WHERE sfqr = 1
|
||||
<if test="startDate != null"> and update_time > #{startDate}</if>
|
||||
<if test="endDate != null"> and update_time < #{endDate} </if> GROUP BY xy ) AS re ON x.xy = re.xy
|
||||
ORDER BY x.id ASC
|
||||
</select>
|
||||
|
||||
<select id="selectYxCount" resultMap="xyDataCheck">
|
||||
SELECT
|
||||
x.xy,
|
||||
IFNULL( re.data_count, 0 ) AS data_count
|
||||
FROM
|
||||
xy x
|
||||
LEFT JOIN ( SELECT xy, count( 0 ) AS data_count FROM cj_student
|
||||
WHERE sfqr = 1
|
||||
<if test="startDate != null"> and update_time > #{startDate}</if>
|
||||
<if test="endDate != null"> and update_time < #{endDate} </if>
|
||||
and sydshi is not null and dwxz in (SELECT dwxz from dwxz) and xy in (SELECT xy from xy) and bynf is not null
|
||||
GROUP BY xy ) AS re ON x.xy = re.xy
|
||||
ORDER BY x.id ASC
|
||||
</select>
|
||||
|
||||
|
||||
|
||||
</mapper>
|
Reference in New Issue
Block a user