bug修改
This commit is contained in:
parent
05a0b927b4
commit
72af5999d5
@ -119,27 +119,31 @@
|
|||||||
</select>
|
</select>
|
||||||
<select id="getProjectInspectRecordCount" resultType="java.util.Map">
|
<select id="getProjectInspectRecordCount" resultType="java.util.Map">
|
||||||
select tp.*,
|
select tp.*,
|
||||||
round(IFNULL(TRUNCATE(IFNULL(rectifyCompleteNum, 0) / IFNULL(inspectNum, 0), 4), 0) * 100,
|
round(IFNULL(TRUNCATE(IFNULL(rectifyCompleteNum, 0) / IFNULL(inspectNum, 0), 4), 0) * 100,
|
||||||
2) completeRatio,
|
2) completeRatio, <!--及时整改率-->
|
||||||
round(IFNULL(TRUNCATE(IFNULL(closeNum, 0) / IFNULL(totalNum, 0), 4), 0) * 100, 2) closeRatio
|
round(IFNULL(TRUNCATE(IFNULL(closeNum, 0) / IFNULL(totalNum, 0), 4), 0) * 100, 2) closeRatio,
|
||||||
|
tp.totalNum-tp.weekInspectNum-tp.monthInspectNum AS otherInspectNum <!--其他数量,就是除了月、周的检查数量-->
|
||||||
from (
|
from (
|
||||||
SELECT count(1) totalNum,
|
SELECT count(1) totalNum,
|
||||||
IFNULL(SUM((CASE WHEN a.record_type = 2 THEN 1 ELSE 0 END)), 0) investigateNum,
|
IFNULL(SUM((CASE WHEN a.record_type = 2 THEN 1 ELSE 0 END)), 0) investigateNum,
|
||||||
IFNULL(SUM((CASE WHEN a.record_type = 1 THEN 1 ELSE 0 END)), 0) inspectNum,
|
IFNULL(SUM((CASE WHEN a.record_type = 1 THEN 1 ELSE 0 END)), 0) inspectNum,
|
||||||
IFNULL(SUM((CASE WHEN a.status = 1 or a.status = 4 THEN 1 ELSE 0 END)), 0) closeNum,
|
IFNULL(SUM((CASE WHEN a.status = 1 or a.status = 4 THEN 1 ELSE 0 END)), 0) closeNum,
|
||||||
IFNULL(SUM((CASE WHEN a.status = 4 THEN 1 ELSE 0 END)), 0) rectifyCompleteNum,
|
IFNULL(SUM((CASE WHEN a.status = 4 THEN 1 ELSE 0 END)), 0) rectifyCompleteNum, <!--合格,就是已整改-->
|
||||||
IFNULL(SUM((CASE WHEN a.status = 2 OR a.status = 3 THEN 1 ELSE 0 END)), 0) notCloseNum,
|
IFNULL(SUM((CASE WHEN a.status = 2 OR a.status = 3 THEN 1 ELSE 0 END)), 0) notCloseNum, <!--未整改-->
|
||||||
IFNULL(SUM((CASE
|
IFNULL(SUM((CASE
|
||||||
WHEN (a.status = 2 OR a.status = 3)
|
WHEN (a.status = 2 OR a.status = 3)
|
||||||
AND DATE_FORMAT(now(), "%Y-%m-%d") > a.change_limit_time THEN 1
|
AND DATE_FORMAT(now(), "%Y-%m-%d") > a.change_limit_time THEN 1
|
||||||
ELSE 0 END)), 0) overdueNotCloseNum,
|
ELSE 0 END)), 0) overdueNotCloseNum,
|
||||||
IFNULL(SUM((CASE
|
IFNULL(SUM((CASE
|
||||||
WHEN a.status = 2 AND DATE_FORMAT(now(), "%Y-%m-%d") > a.change_limit_time THEN 1
|
WHEN a.status = 2 AND DATE_FORMAT(now(), "%Y-%m-%d") > a.change_limit_time THEN 1
|
||||||
ELSE 0 END)),
|
ELSE 0 END)),
|
||||||
0) overdueRectificationNum,
|
0) overdueRectificationNum,
|
||||||
IFNULL(SUM((CASE WHEN a.status = 2 THEN 1 ELSE 0 END)), 0) rectificationNum,
|
IFNULL(SUM((CASE WHEN a.status = 2 THEN 1 ELSE 0 END)), 0) rectificationNum,
|
||||||
IFNULL(SUM((CASE WHEN a.status = 3 THEN 1 ELSE 0 END)), 0) reviewNum
|
IFNULL(SUM((CASE WHEN a.status = 3 THEN 1 ELSE 0 END)), 0) reviewNum, <!--待复查,待审核-->
|
||||||
|
IFNULL(SUM((CASE WHEN tr.frequency_type = 3 THEN 1 ELSE 0 END)), 0) weekInspectNum, <!--周检查数量-->
|
||||||
|
IFNULL(SUM((CASE WHEN tr.frequency_type = 4 THEN 1 ELSE 0 END)), 0) monthInspectNum <!--月检查数量-->
|
||||||
from hidden_danger_inspection_record a
|
from hidden_danger_inspection_record a
|
||||||
|
left join inspect_task_record tr on tr.id=a.task_id
|
||||||
WHERE a.project_sn = #{projectSn}
|
WHERE a.project_sn = #{projectSn}
|
||||||
<if test="createUser != null and createUser != ''">
|
<if test="createUser != null and createUser != ''">
|
||||||
and a.create_user = #{createUser}
|
and a.create_user = #{createUser}
|
||||||
|
|||||||
@ -743,12 +743,12 @@ public class EnvironmentAlarmServiceImpl extends ServiceImpl<EnvironmentAlarmMap
|
|||||||
Map<String,Object> map=companyService.getCompanyType(param);
|
Map<String,Object> map=companyService.getCompanyType(param);
|
||||||
Integer dateType=MapUtils.getInteger(param,"dateType");
|
Integer dateType=MapUtils.getInteger(param,"dateType");
|
||||||
List<String> dayList=new ArrayList<>();
|
List<String> dayList=new ArrayList<>();
|
||||||
if(dateType==2){
|
if (dateType == 2) {
|
||||||
//查询本月所有天数
|
//查询近一月所有天数
|
||||||
dayList=DateUtil.getNowMonthAllDayList();
|
dayList = DateUtil.getDaysBetweenLastMonth();
|
||||||
}else{
|
} else {
|
||||||
//查询本周所有天数
|
//查询近一周所有天数
|
||||||
dayList=DateUtil.getNowWeekAllDayList();
|
dayList = DateUtil.getDaysBetweenLastWeek();
|
||||||
}
|
}
|
||||||
List<Map<String,Object>> list=companyService.selectComapnyOrProjectList(map);
|
List<Map<String,Object>> list=companyService.selectComapnyOrProjectList(map);
|
||||||
if(list!=null&&list.size()>0){
|
if(list!=null&&list.size()>0){
|
||||||
|
|||||||
@ -36,7 +36,8 @@ public class GtMaterialDepartmentTeam implements Serializable {
|
|||||||
*/
|
*/
|
||||||
@Excel(name = "作业单位id", width = 15)
|
@Excel(name = "作业单位id", width = 15)
|
||||||
@ApiModelProperty(value = "作业单位id")
|
@ApiModelProperty(value = "作业单位id")
|
||||||
private String unitName;
|
private Long gtMaterialOperatingUnitId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 班组
|
* 班组
|
||||||
*/
|
*/
|
||||||
@ -84,4 +85,13 @@ public class GtMaterialDepartmentTeam implements Serializable {
|
|||||||
@ApiModelProperty(value = "更新时间")
|
@ApiModelProperty(value = "更新时间")
|
||||||
private java.util.Date updateTime;
|
private java.util.Date updateTime;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 单位名称
|
||||||
|
*/
|
||||||
|
@Excel(name = "单位名称", width = 15)
|
||||||
|
@ApiModelProperty(value = "单位名称")
|
||||||
|
@TableField(exist = false)
|
||||||
|
private String unitName;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,8 +2,9 @@
|
|||||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
<mapper namespace="com.zhgd.xmgl.modules.gt.mapper.GtMaterialDepartmentTeamMapper">
|
<mapper namespace="com.zhgd.xmgl.modules.gt.mapper.GtMaterialDepartmentTeamMapper">
|
||||||
<select id="queryPageList" resultType="com.zhgd.xmgl.modules.gt.entity.GtMaterialDepartmentTeam">
|
<select id="queryPageList" resultType="com.zhgd.xmgl.modules.gt.entity.GtMaterialDepartmentTeam">
|
||||||
select dt.*
|
select dt.*,ou.unit_name,ou.id as gt_material_operating_unit_id
|
||||||
from gt_material_department_team dt
|
from gt_material_department_team dt
|
||||||
|
join gt_material_operating_unit ou on ou.id=dt.gt_material_operating_unit_id
|
||||||
${ew.customSqlSegment}
|
${ew.customSqlSegment}
|
||||||
</select>
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
package com.zhgd.xmgl.modules.worker.controller;
|
package com.zhgd.xmgl.modules.worker.controller;
|
||||||
|
|
||||||
import cn.hutool.core.bean.BeanUtil;
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
|
import cn.hutool.core.date.DateUtil;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.zhgd.annotation.OperLog;
|
import com.zhgd.annotation.OperLog;
|
||||||
import com.zhgd.jeecg.common.api.vo.Result;
|
import com.zhgd.jeecg.common.api.vo.Result;
|
||||||
@ -19,10 +20,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.*;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -1,12 +1,18 @@
|
|||||||
package com.zhgd.xmgl.util;
|
package com.zhgd.xmgl.util;
|
||||||
|
|
||||||
|
import cn.hutool.core.date.DateTime;
|
||||||
|
|
||||||
import java.text.ParseException;
|
import java.text.ParseException;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.time.DayOfWeek;
|
import java.time.DayOfWeek;
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.time.temporal.TemporalAdjusters;
|
import java.time.temporal.TemporalAdjusters;
|
||||||
import java.util.*;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Calendar;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @program: wisdomSite
|
* @program: wisdomSite
|
||||||
@ -19,6 +25,7 @@ public class DateUtil {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 时间格式化
|
* 时间格式化
|
||||||
|
*
|
||||||
* @param oldDate
|
* @param oldDate
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@ -28,7 +35,7 @@ public class DateUtil {
|
|||||||
try {
|
try {
|
||||||
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
|
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
|
||||||
Date date = df.parse(oldDate);
|
Date date = df.parse(oldDate);
|
||||||
Calendar beijingcal=Calendar.getInstance();
|
Calendar beijingcal = Calendar.getInstance();
|
||||||
beijingcal.setTime(date);
|
beijingcal.setTime(date);
|
||||||
//SimpleDateFormat df1 = new SimpleDateFormat ("EEE MMM dd HH:mm:ss Z yyyy", Locale.UK);
|
//SimpleDateFormat df1 = new SimpleDateFormat ("EEE MMM dd HH:mm:ss Z yyyy", Locale.UK);
|
||||||
//date1 = df1.parse(date.toString());
|
//date1 = df1.parse(date.toString());
|
||||||
@ -59,7 +66,7 @@ public class DateUtil {
|
|||||||
String formatStr2 = null;
|
String formatStr2 = null;
|
||||||
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");//注意格式化的表达式
|
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");//注意格式化的表达式
|
||||||
try {
|
try {
|
||||||
Date time = format.parse(createTime );
|
Date time = format.parse(createTime);
|
||||||
String date = time.toString();
|
String date = time.toString();
|
||||||
//将西方形式的日期字符串转换成java.util.Date对象
|
//将西方形式的日期字符串转换成java.util.Date对象
|
||||||
SimpleDateFormat sdf = new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy", java.util.Locale.US);
|
SimpleDateFormat sdf = new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy", java.util.Locale.US);
|
||||||
@ -74,9 +81,10 @@ public class DateUtil {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询本周所有天数
|
* 查询本周所有天数
|
||||||
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static List<String> getNowWeekAllDayList(){
|
public static List<String> getNowWeekAllDayList() {
|
||||||
Calendar cal = Calendar.getInstance();
|
Calendar cal = Calendar.getInstance();
|
||||||
// 判断要计算的日期是否是周日,如果是则减一天计算周六的,否则会出问题,计算到下一周去了
|
// 判断要计算的日期是否是周日,如果是则减一天计算周六的,否则会出问题,计算到下一周去了
|
||||||
// 获得当前日期是一个星期的第几天
|
// 获得当前日期是一个星期的第几天
|
||||||
@ -91,46 +99,99 @@ public class DateUtil {
|
|||||||
int day = cal.get(Calendar.DAY_OF_WEEK);
|
int day = cal.get(Calendar.DAY_OF_WEEK);
|
||||||
// 根据日历的规则,给当前日期减去星期几与一个星期第一天的差值
|
// 根据日历的规则,给当前日期减去星期几与一个星期第一天的差值
|
||||||
cal.add(Calendar.DATE, cal.getFirstDayOfWeek() - day);
|
cal.add(Calendar.DATE, cal.getFirstDayOfWeek() - day);
|
||||||
return findDates(cal.getTime(),new Date());
|
return findDates(cal.getTime(), new Date());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询本月所有天数Fix,如:2023-06-01到2023-06-30
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static List<String> getNowMonthAllDayListFix() {
|
||||||
|
ArrayList<String> rtList = new ArrayList<>();
|
||||||
|
Date now = new Date();
|
||||||
|
DateTime beginDate = cn.hutool.core.date.DateUtil.beginOfMonth(now);
|
||||||
|
DateTime endDate = cn.hutool.core.date.DateUtil.endOfMonth(now);
|
||||||
|
long offset = cn.hutool.core.date.DateUtil.betweenDay(beginDate, endDate, true);
|
||||||
|
for (int i = 0; i < offset + 1; i++) {
|
||||||
|
rtList.add(cn.hutool.core.date.DateUtil.formatDate(cn.hutool.core.date.DateUtil.offsetDay(beginDate, i)));
|
||||||
|
}
|
||||||
|
return rtList;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询一个月前内所有天数,如:2023-06-10到2023-07-10
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static List<String> getDaysBetweenLastMonth() {
|
||||||
|
ArrayList<String> rtList = new ArrayList<>();
|
||||||
|
DateTime beginDate = cn.hutool.core.date.DateUtil.lastMonth();
|
||||||
|
DateTime endDate = DateTime.now();
|
||||||
|
long offset = cn.hutool.core.date.DateUtil.betweenDay(beginDate, endDate, true);
|
||||||
|
for (int i = 0; i < offset + 1; i++) {
|
||||||
|
rtList.add(cn.hutool.core.date.DateUtil.formatDate(cn.hutool.core.date.DateUtil.offsetDay(beginDate, i)));
|
||||||
|
}
|
||||||
|
return rtList;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询一个周前内所有天数,如:2023-06-10到2023-07-10
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static List<String> getDaysBetweenLastWeek() {
|
||||||
|
ArrayList<String> rtList = new ArrayList<>();
|
||||||
|
DateTime beginDate = cn.hutool.core.date.DateUtil.lastWeek();
|
||||||
|
DateTime endDate = DateTime.now();
|
||||||
|
long offset = cn.hutool.core.date.DateUtil.betweenDay(beginDate, endDate, true);
|
||||||
|
for (int i = 0; i < offset + 1; i++) {
|
||||||
|
rtList.add(cn.hutool.core.date.DateUtil.formatDate(cn.hutool.core.date.DateUtil.offsetDay(beginDate, i)));
|
||||||
|
}
|
||||||
|
return rtList;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询现在时间几天前到现在之间的所有日期
|
* 查询现在时间几天前到现在之间的所有日期
|
||||||
|
*
|
||||||
* @param days
|
* @param days
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static List<String> getOtherDayAllDayList(int days){
|
public static List<String> getOtherDayAllDayList(int days) {
|
||||||
Calendar cal = Calendar.getInstance();
|
Calendar cal = Calendar.getInstance();
|
||||||
cal.add(Calendar.DATE,-days);
|
cal.add(Calendar.DATE, -days);
|
||||||
return findDates(cal.getTime(),new Date());
|
return findDates(cal.getTime(), new Date());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询本月所有天数
|
* 查询本月所有天数
|
||||||
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static List<String> getNowMonthAllDayList(){
|
public static List<String> getNowMonthAllDayList() {
|
||||||
Calendar cal = Calendar.getInstance();
|
Calendar cal = Calendar.getInstance();
|
||||||
cal.set(Calendar.DAY_OF_MONTH, 1);
|
cal.set(Calendar.DAY_OF_MONTH, 1);
|
||||||
return findDates(cal.getTime(),new Date());
|
return findDates(cal.getTime(), new Date());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取两个时间段所有天数
|
* 获取两个时间段所有天数
|
||||||
|
*
|
||||||
* @param beginTime
|
* @param beginTime
|
||||||
* @param endTime
|
* @param endTime
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static List<String> getDiffTimeDayList(String beginTime,String endTime){
|
public static List<String> getDiffTimeDayList(String beginTime, String endTime) {
|
||||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||||
try {
|
try {
|
||||||
return findDates(sdf.parse(beginTime),sdf.parse(endTime));
|
return findDates(sdf.parse(beginTime), sdf.parse(endTime));
|
||||||
} catch (ParseException e) {
|
} catch (ParseException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<String> findDates(Date dBegin, Date dEnd){
|
public static List<String> findDates(Date dBegin, Date dEnd) {
|
||||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||||
List lDate = new ArrayList();
|
List lDate = new ArrayList();
|
||||||
lDate.add(sdf.format(dBegin));
|
lDate.add(sdf.format(dBegin));
|
||||||
@ -141,10 +202,10 @@ public class DateUtil {
|
|||||||
// 使用给定的 Date 设置此 Calendar 的时间
|
// 使用给定的 Date 设置此 Calendar 的时间
|
||||||
calEnd.setTime(dEnd);
|
calEnd.setTime(dEnd);
|
||||||
// 测试此日期是否在指定日期之后
|
// 测试此日期是否在指定日期之后
|
||||||
while (dEnd.after(calBegin.getTime())){
|
while (dEnd.after(calBegin.getTime())) {
|
||||||
// 根据日历的规则,为给定的日历字段添加或减去指定的时间量
|
// 根据日历的规则,为给定的日历字段添加或减去指定的时间量
|
||||||
calBegin.add(Calendar.DAY_OF_MONTH, 1);
|
calBegin.add(Calendar.DAY_OF_MONTH, 1);
|
||||||
if(calBegin.getTimeInMillis()<=dEnd.getTime()) {
|
if (calBegin.getTimeInMillis() <= dEnd.getTime()) {
|
||||||
lDate.add(sdf.format(calBegin.getTime()));
|
lDate.add(sdf.format(calBegin.getTime()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -153,36 +214,37 @@ public class DateUtil {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取指定年份所有天数
|
* 获取指定年份所有天数
|
||||||
|
*
|
||||||
* @param yearMonth
|
* @param yearMonth
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static List<String> getYearAllMonthList(String yearMonth) {
|
public static List<String> getYearAllMonthList(String yearMonth) {
|
||||||
String year=yearMonth.substring(0,4);
|
String year = yearMonth.substring(0, 4);
|
||||||
List<String> list=new ArrayList<>();
|
List<String> list = new ArrayList<>();
|
||||||
for (int i = 1; i <=12 ; i++) {
|
for (int i = 1; i <= 12; i++) {
|
||||||
if(i<10){
|
if (i < 10) {
|
||||||
list.add(year+"0"+i);
|
list.add(year + "0" + i);
|
||||||
}else{
|
} else {
|
||||||
list.add(year+i);
|
list.add(year + i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* @param yearMonth 月份格式yyyy-MM
|
||||||
* @param yearMonth 月份格式yyyy-MM
|
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static List<String> getMonthDayList(String yearMonth) {
|
public static List<String> getMonthDayList(String yearMonth) {
|
||||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");
|
||||||
//判断是否是当月
|
//判断是否是当月
|
||||||
if(yearMonth.equals(sdf.format(new Date()))){
|
if (yearMonth.equals(sdf.format(new Date()))) {
|
||||||
return getNowMonthAllDayList();
|
return getNowMonthAllDayList();
|
||||||
}else{
|
} else {
|
||||||
return getDayListOfMonth(yearMonth);
|
return getDayListOfMonth(yearMonth);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<String> getDayListOfMonth(String yearMonth) {
|
public static List<String> getDayListOfMonth(String yearMonth) {
|
||||||
int year = Integer.parseInt(yearMonth.split("-")[0]); //年
|
int year = Integer.parseInt(yearMonth.split("-")[0]); //年
|
||||||
int month = Integer.parseInt(yearMonth.split("-")[1]); //月
|
int month = Integer.parseInt(yearMonth.split("-")[1]); //月
|
||||||
@ -205,14 +267,15 @@ public class DateUtil {
|
|||||||
int firstDay = startCal.getActualMinimum(Calendar.DAY_OF_MONTH);
|
int firstDay = startCal.getActualMinimum(Calendar.DAY_OF_MONTH);
|
||||||
//设置日历中月份的最小天数
|
//设置日历中月份的最小天数
|
||||||
startCal.set(Calendar.DAY_OF_MONTH, firstDay);
|
startCal.set(Calendar.DAY_OF_MONTH, firstDay);
|
||||||
return findDates(startCal.getTime(),endCal.getTime());
|
return findDates(startCal.getTime(), endCal.getTime());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取当前周第一天日期
|
* 获取当前周第一天日期
|
||||||
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static String getNowWeekStartTime(){
|
public static String getNowWeekStartTime() {
|
||||||
Calendar cal = Calendar.getInstance();
|
Calendar cal = Calendar.getInstance();
|
||||||
// 判断要计算的日期是否是周日,如果是则减一天计算周六的,否则会出问题,计算到下一周去了
|
// 判断要计算的日期是否是周日,如果是则减一天计算周六的,否则会出问题,计算到下一周去了
|
||||||
// 获得当前日期是一个星期的第几天
|
// 获得当前日期是一个星期的第几天
|
||||||
@ -230,16 +293,18 @@ public class DateUtil {
|
|||||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||||
return sdf.format(cal.getTime());
|
return sdf.format(cal.getTime());
|
||||||
}
|
}
|
||||||
public static List<String> getDiffTimeYearList(String beginTime,String endTime){
|
|
||||||
|
public static List<String> getDiffTimeYearList(String beginTime, String endTime) {
|
||||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||||
try {
|
try {
|
||||||
return findYear(sdf.parse(beginTime),sdf.parse(endTime));
|
return findYear(sdf.parse(beginTime), sdf.parse(endTime));
|
||||||
} catch (ParseException e) {
|
} catch (ParseException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
public static List<String> findYear(Date dBegin, Date dEnd){
|
|
||||||
|
public static List<String> findYear(Date dBegin, Date dEnd) {
|
||||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy");
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy");
|
||||||
List lDate = new ArrayList();
|
List lDate = new ArrayList();
|
||||||
lDate.add(sdf.format(dBegin));
|
lDate.add(sdf.format(dBegin));
|
||||||
@ -250,25 +315,27 @@ public class DateUtil {
|
|||||||
// 使用给定的 Date 设置此 Calendar 的时间
|
// 使用给定的 Date 设置此 Calendar 的时间
|
||||||
calEnd.setTime(dEnd);
|
calEnd.setTime(dEnd);
|
||||||
// 测试此日期是否在指定日期之后
|
// 测试此日期是否在指定日期之后
|
||||||
while (dEnd.after(calBegin.getTime())){
|
while (dEnd.after(calBegin.getTime())) {
|
||||||
// 根据日历的规则,为给定的日历字段添加或减去指定的时间量
|
// 根据日历的规则,为给定的日历字段添加或减去指定的时间量
|
||||||
calBegin.add(Calendar.YEAR, 1);
|
calBegin.add(Calendar.YEAR, 1);
|
||||||
if(calBegin.getTimeInMillis()<=dEnd.getTime()) {
|
if (calBegin.getTimeInMillis() <= dEnd.getTime()) {
|
||||||
lDate.add(sdf.format(calBegin.getTime()));
|
lDate.add(sdf.format(calBegin.getTime()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return lDate;
|
return lDate;
|
||||||
}
|
}
|
||||||
public static List<String> getDiffTimeMonthList(String beginTime,String endTime){
|
|
||||||
|
public static List<String> getDiffTimeMonthList(String beginTime, String endTime) {
|
||||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||||
try {
|
try {
|
||||||
return findMonth(sdf.parse(beginTime),sdf.parse(endTime));
|
return findMonth(sdf.parse(beginTime), sdf.parse(endTime));
|
||||||
} catch (ParseException e) {
|
} catch (ParseException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
public static List<String> findMonth(Date dBegin, Date dEnd){
|
|
||||||
|
public static List<String> findMonth(Date dBegin, Date dEnd) {
|
||||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");
|
||||||
List lDate = new ArrayList();
|
List lDate = new ArrayList();
|
||||||
lDate.add(sdf.format(dBegin));
|
lDate.add(sdf.format(dBegin));
|
||||||
@ -279,10 +346,10 @@ public class DateUtil {
|
|||||||
// 使用给定的 Date 设置此 Calendar 的时间
|
// 使用给定的 Date 设置此 Calendar 的时间
|
||||||
calEnd.setTime(dEnd);
|
calEnd.setTime(dEnd);
|
||||||
// 测试此日期是否在指定日期之后
|
// 测试此日期是否在指定日期之后
|
||||||
while (dEnd.after(calBegin.getTime())){
|
while (dEnd.after(calBegin.getTime())) {
|
||||||
// 根据日历的规则,为给定的日历字段添加或减去指定的时间量
|
// 根据日历的规则,为给定的日历字段添加或减去指定的时间量
|
||||||
calBegin.add(Calendar.MONTH, 1);
|
calBegin.add(Calendar.MONTH, 1);
|
||||||
if(calBegin.getTimeInMillis()<=dEnd.getTime()) {
|
if (calBegin.getTimeInMillis() <= dEnd.getTime()) {
|
||||||
lDate.add(sdf.format(calBegin.getTime()));
|
lDate.add(sdf.format(calBegin.getTime()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -290,16 +357,16 @@ public class DateUtil {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<String> getDiffTimeWeekList(String beginTime,String endTime){
|
public static List<String> getDiffTimeWeekList(String beginTime, String endTime) {
|
||||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
||||||
LocalDate startDate = LocalDate.parse(beginTime,formatter);
|
LocalDate startDate = LocalDate.parse(beginTime, formatter);
|
||||||
LocalDate endDate = LocalDate.parse(endTime,formatter);
|
LocalDate endDate = LocalDate.parse(endTime, formatter);
|
||||||
List<String> lDate = new ArrayList();
|
List<String> lDate = new ArrayList();
|
||||||
while (endDate.isAfter(startDate)){
|
while (endDate.isAfter(startDate)) {
|
||||||
String start=startDate.format(formatter);
|
String start = startDate.format(formatter);
|
||||||
if(startDate.getDayOfWeek()==DayOfWeek.SUNDAY) {
|
if (startDate.getDayOfWeek() == DayOfWeek.SUNDAY) {
|
||||||
lDate.add(start + "/" + start);
|
lDate.add(start + "/" + start);
|
||||||
}else{
|
} else {
|
||||||
LocalDate sunday = startDate.with(TemporalAdjusters.next(DayOfWeek.SUNDAY));
|
LocalDate sunday = startDate.with(TemporalAdjusters.next(DayOfWeek.SUNDAY));
|
||||||
if (sunday.isAfter(endDate)) {
|
if (sunday.isAfter(endDate)) {
|
||||||
lDate.add(start + "/" + endDate.format(formatter));
|
lDate.add(start + "/" + endDate.format(formatter));
|
||||||
@ -307,7 +374,7 @@ public class DateUtil {
|
|||||||
lDate.add(start + "/" + sunday.format(formatter));
|
lDate.add(start + "/" + sunday.format(formatter));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
startDate=startDate.with(TemporalAdjusters.next(DayOfWeek.SUNDAY)).plusDays(1);
|
startDate = startDate.with(TemporalAdjusters.next(DayOfWeek.SUNDAY)).plusDays(1);
|
||||||
|
|
||||||
}
|
}
|
||||||
return lDate;
|
return lDate;
|
||||||
@ -315,15 +382,16 @@ public class DateUtil {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取当前时间和当天时间几天前之间的所有天数
|
* 获取当前时间和当天时间几天前之间的所有天数
|
||||||
* @param dayNum 当天时间以前具体几天
|
*
|
||||||
|
* @param dayNum 当天时间以前具体几天
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static List<String> getNowFewDaysAgoList(int dayNum){
|
public static List<String> getNowFewDaysAgoList(int dayNum) {
|
||||||
try {
|
try {
|
||||||
Calendar calendar = Calendar.getInstance();
|
Calendar calendar = Calendar.getInstance();
|
||||||
calendar.add(Calendar.DATE, -dayNum);
|
calendar.add(Calendar.DATE, -dayNum);
|
||||||
Date date = calendar.getTime();
|
Date date = calendar.getTime();
|
||||||
return findDates(date,new Date());
|
return findDates(date, new Date());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
@ -331,22 +399,20 @@ public class DateUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @param type 1 今日24 小时,2本周所有天,3本月所有天
|
* @param type 1 今日24 小时,2本周所有天,3本月所有天
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static List<String> getDayList(Integer type) {
|
public static List<String> getDayList(Integer type) {
|
||||||
if(type==1){
|
if (type == 1) {
|
||||||
List<String> list=new ArrayList<>();
|
List<String> list = new ArrayList<>();
|
||||||
for(int i=0;i<=23;i++){
|
for (int i = 0; i <= 23; i++) {
|
||||||
list.add(i+"");
|
list.add(i + "");
|
||||||
}
|
}
|
||||||
return list;
|
return list;
|
||||||
}else if(type==2){
|
} else if (type == 2) {
|
||||||
return getNowWeekAllDayList();
|
return getDaysBetweenLastWeek();
|
||||||
}else if(type==3){
|
} else if (type == 3) {
|
||||||
return getNowMonthAllDayList();
|
return getNowMonthAllDayList();
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
@ -354,42 +420,44 @@ public class DateUtil {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 比较两个日期大小
|
* 比较两个日期大小
|
||||||
|
*
|
||||||
* @param time1
|
* @param time1
|
||||||
* @param time2
|
* @param time2
|
||||||
* @return
|
* @return
|
||||||
* @throws ParseException
|
* @throws ParseException
|
||||||
*/
|
*/
|
||||||
public static boolean compareTime(String time1,String time2){
|
public static boolean compareTime(String time1, String time2) {
|
||||||
try {
|
try {
|
||||||
//如果想比较日期则写成"yyyy-MM-dd"就可以了
|
//如果想比较日期则写成"yyyy-MM-dd"就可以了
|
||||||
SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||||
//将字符串形式的时间转化为Date类型的时间
|
//将字符串形式的时间转化为Date类型的时间
|
||||||
Date a=sdf.parse(time1);
|
Date a = sdf.parse(time1);
|
||||||
Date b=sdf.parse(time2);
|
Date b = sdf.parse(time2);
|
||||||
//Date类的一个方法,如果a早于b返回true,否则返回false
|
//Date类的一个方法,如果a早于b返回true,否则返回false
|
||||||
//a时间下雨b时间返回true,否正返回false
|
//a时间下雨b时间返回true,否正返回false
|
||||||
if(a.before(b)) {
|
if (a.before(b)) {
|
||||||
return true;
|
return true;
|
||||||
}else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}catch (Exception e){
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询当前时间指定天数之前的日期
|
* 查询当前时间指定天数之前的日期
|
||||||
* @Title: getBeginDayTime
|
*
|
||||||
* @Description: TODO(这里用一句话描述这个方法的作用)
|
* @param @param days
|
||||||
* @param @param days
|
* @param @return 参数
|
||||||
* @param @return 参数
|
|
||||||
* @return String 返回类型
|
* @return String 返回类型
|
||||||
* @throws
|
* @throws
|
||||||
|
* @Title: getBeginDayTime
|
||||||
*/
|
*/
|
||||||
public static String getBeginDayTime(int days){
|
public static String getBeginDayTime(int days) {
|
||||||
Calendar cal = Calendar.getInstance();
|
Calendar cal = Calendar.getInstance();
|
||||||
cal.add(Calendar.DATE,-days);
|
cal.add(Calendar.DATE, -days);
|
||||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||||
return sdf.format(cal.getTime());
|
return sdf.format(cal.getTime());
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user