haungxing
8 months ago
21 changed files with 353 additions and 24 deletions
@ -0,0 +1,24 @@
|
||||
package com.hnac.hzims.safeproduct.vo; |
||||
|
||||
import io.swagger.annotations.ApiModel; |
||||
import io.swagger.annotations.ApiModelProperty; |
||||
import lombok.Data; |
||||
|
||||
/** |
||||
* @author liwen |
||||
* @date 2023-12-25 |
||||
*/ |
||||
@Data |
||||
@ApiModel(value = "考试成绩VO类") |
||||
public class TestScoreSumVO { |
||||
|
||||
@ApiModelProperty("应考人数") |
||||
private Integer peopleNum=0; |
||||
|
||||
@ApiModelProperty("实考人数") |
||||
private Integer actualPeopleNum=0; |
||||
|
||||
@ApiModelProperty("及格率") |
||||
private Double percentage=0.0; |
||||
|
||||
} |
@ -0,0 +1,195 @@
|
||||
package com.hnac.hzims.safeproduct.utils; |
||||
|
||||
import com.hnac.hzims.safeproduct.vo.ConferenceRecordDetailVO; |
||||
import org.springblade.core.tool.utils.DateUtil; |
||||
|
||||
import java.text.SimpleDateFormat; |
||||
import java.util.ArrayList; |
||||
import java.util.Calendar; |
||||
import java.util.Date; |
||||
import java.util.List; |
||||
|
||||
public class TimeUtils { |
||||
|
||||
private static int sheet1NowRow, sheet2NowRow; |
||||
|
||||
|
||||
/** |
||||
* 相差时数 |
||||
* |
||||
* @param endDate |
||||
* @param nowDate |
||||
* @return |
||||
* @author ty |
||||
*/ |
||||
public static Long getDifferTime(Date nowDate, Date endDate) { |
||||
long nh = 1000 * 60 * 60L; |
||||
// 获得两个时间的毫秒时间差异
|
||||
long diff = endDate.getTime() - nowDate.getTime(); |
||||
// 计算差多少小时
|
||||
long hour = diff / nh; |
||||
return hour; |
||||
} |
||||
|
||||
public static String getYear(Integer year) { |
||||
// 创建一个Calendar对象
|
||||
Calendar calendar = Calendar.getInstance(); |
||||
// 设置年份
|
||||
calendar.set(Calendar.YEAR, year); |
||||
// 设置月份为1(即一月)
|
||||
calendar.set(Calendar.MONTH, Calendar.JANUARY); |
||||
// 设置日期为1
|
||||
calendar.set(Calendar.DATE, 1); |
||||
// 设置时间为0点0分0秒
|
||||
calendar.set(Calendar.HOUR_OF_DAY, 0); |
||||
calendar.set(Calendar.MINUTE, 0); |
||||
calendar.set(Calendar.SECOND, 0); |
||||
String start = DateUtil.format(calendar.getTime(), DateUtil.PATTERN_DATE) + " 00:00:00"; |
||||
return start; |
||||
} |
||||
|
||||
public static String getYearEnd(Integer year) { |
||||
// 创建一个Calendar对象
|
||||
Calendar calendar = Calendar.getInstance(); |
||||
// 设置年份
|
||||
calendar.set(Calendar.YEAR, year); |
||||
// 设置月份为12(即十二月)
|
||||
calendar.set(Calendar.MONTH, Calendar.DECEMBER); |
||||
// 设置日期为31
|
||||
calendar.set(Calendar.DATE, 31); |
||||
String end = DateUtil.format(calendar.getTime(), DateUtil.PATTERN_DATE) + " 00:00:00"; |
||||
return end; |
||||
} |
||||
public static String getYearEndV2(Integer year) { |
||||
// 创建一个Calendar对象
|
||||
Calendar calendar = Calendar.getInstance(); |
||||
// 设置年份
|
||||
calendar.set(Calendar.YEAR, year); |
||||
// 设置月份为12(即十二月)
|
||||
calendar.set(Calendar.MONTH, Calendar.DECEMBER); |
||||
// 设置日期为31
|
||||
calendar.set(Calendar.DATE, 31); |
||||
String end = DateUtil.format(calendar.getTime(), DateUtil.PATTERN_DATE) + " 23:59:59"; |
||||
return end; |
||||
} |
||||
|
||||
public static String getMonthStart(Integer year, Integer mon) { |
||||
// 创建一个Calendar对象
|
||||
Calendar calendar = Calendar.getInstance(); |
||||
// 设置年份
|
||||
calendar.set(Calendar.YEAR, year); |
||||
// 设置月份
|
||||
calendar.set(Calendar.MONTH,mon-1); |
||||
// 设置日期为1
|
||||
calendar.set(Calendar.DATE, 1); |
||||
String start = DateUtil.format(calendar.getTime(), DateUtil.PATTERN_DATE) + " 00:00:00"; |
||||
return start; |
||||
} |
||||
|
||||
public static String getMonthEnd(Integer year, Integer mon) { |
||||
// 创建一个Calendar对象
|
||||
Calendar calendar = Calendar.getInstance(); |
||||
// 设置年份
|
||||
calendar.set(Calendar.YEAR, year); |
||||
// 设置月份为1(即一月)
|
||||
calendar.set(Calendar.MONTH, mon); |
||||
calendar.set(Calendar.DAY_OF_MONTH, 1); |
||||
// 将日期对象减去一天,即为当月的最后一天
|
||||
calendar.add(Calendar.DAY_OF_MONTH, -1); |
||||
String end = DateUtil.format(calendar.getTime(), DateUtil.PATTERN_DATE) + " 00:00:00"; |
||||
return end; |
||||
} |
||||
public static String getMonthEndV2(Integer year, Integer mon) { |
||||
// 创建一个Calendar对象
|
||||
Calendar calendar = Calendar.getInstance(); |
||||
// 设置年份
|
||||
calendar.set(Calendar.YEAR, year); |
||||
// 设置月份为1(即一月)
|
||||
calendar.set(Calendar.MONTH, mon); |
||||
calendar.set(Calendar.DAY_OF_MONTH, 1); |
||||
// 将日期对象减去一天,即为当月的最后一天
|
||||
calendar.add(Calendar.DAY_OF_MONTH, -1); |
||||
String end = DateUtil.format(calendar.getTime(), DateUtil.PATTERN_DATE) + " 23:59:59"; |
||||
return end; |
||||
} |
||||
public static List<String> getListByYear(Integer year) { |
||||
List<String> monthList=new ArrayList<>(); |
||||
for (int i = 0; i <12; i++) { |
||||
// 创建一个Calendar对象
|
||||
Calendar calendar = Calendar.getInstance(); |
||||
// 设置年份
|
||||
calendar.set(Calendar.YEAR, year); |
||||
// 设置月份为1(即一月)
|
||||
calendar.set(Calendar.MONTH, i); |
||||
calendar.set(Calendar.DAY_OF_MONTH, 1); |
||||
// 将日期对象减去一天,即为当月的最后一天
|
||||
String mon = DateUtil.format(calendar.getTime(), DateUtil.PATTERN_DATE); |
||||
|
||||
monthList.add(mon); |
||||
} |
||||
return monthList; |
||||
} |
||||
public static List<String> getListByYearMon(Integer year,Integer mon) { |
||||
List<String> monthList=new ArrayList<>(); |
||||
for (int i = 0; i <mon; i++) { |
||||
// 创建一个Calendar对象
|
||||
Calendar calendar = Calendar.getInstance(); |
||||
// 设置年份
|
||||
calendar.set(Calendar.YEAR, year); |
||||
// 设置月份为1(即一月)
|
||||
calendar.set(Calendar.MONTH, i); |
||||
calendar.set(Calendar.DAY_OF_MONTH, 1); |
||||
String monTime = DateUtil.format(calendar.getTime(), DateUtil.PATTERN_DATE); |
||||
monthList.add(monTime); |
||||
} |
||||
return monthList; |
||||
} |
||||
public static String getMon(Integer year,Integer month) { |
||||
// 创建一个Calendar对象
|
||||
Calendar calendar = Calendar.getInstance(); |
||||
// 设置年份
|
||||
calendar.set(Calendar.YEAR, year); |
||||
// 设置月份为1(即一月)
|
||||
calendar.set(Calendar.MONTH, month-1); |
||||
// 设置日期为1
|
||||
calendar.set(Calendar.DATE, 1); |
||||
// 设置时间为0点0分0秒
|
||||
calendar.set(Calendar.HOUR_OF_DAY, 0); |
||||
calendar.set(Calendar.MINUTE, 0); |
||||
calendar.set(Calendar.SECOND, 0); |
||||
String start = DateUtil.format(calendar.getTime(), DateUtil.PATTERN_DATE) ; |
||||
return start; |
||||
} |
||||
|
||||
|
||||
public static String getEarlyTime(Integer year, Integer month) { |
||||
// 创建一个Calendar对象
|
||||
Calendar calendar = Calendar.getInstance(); |
||||
// 设置年份
|
||||
calendar.set(Calendar.YEAR, year); |
||||
// 设置月份为1(即一月)
|
||||
calendar.set(Calendar.MONTH, month-1); |
||||
// 设置日期为1
|
||||
calendar.set(Calendar.DATE, 1); |
||||
// 设置时间为0点0分0秒
|
||||
calendar.set(Calendar.HOUR_OF_DAY, 0); |
||||
calendar.set(Calendar.MINUTE, 0); |
||||
calendar.set(Calendar.SECOND, 0); |
||||
calendar.add(Calendar.MONTH, -1); |
||||
String start = DateUtil.format(calendar.getTime(), DateUtil.PATTERN_DATE) ; |
||||
return start; |
||||
} |
||||
public static String format(String time) { |
||||
String formattedDateString=""; |
||||
SimpleDateFormat originalFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
||||
try { |
||||
Date date = originalFormat.parse(time); |
||||
SimpleDateFormat targetFormat = new SimpleDateFormat("yyyy年MM月dd日 HH时mm分"); |
||||
formattedDateString = targetFormat.format(date); |
||||
return formattedDateString; |
||||
} catch (Exception e) { |
||||
e.printStackTrace(); |
||||
return time; |
||||
} |
||||
} |
||||
} |
Binary file not shown.
Loading…
Reference in new issue