bug修复

This commit is contained in:
guo 2023-12-04 10:13:15 +08:00
parent 0a74952cdd
commit 6fbb77235c
12 changed files with 82 additions and 142 deletions

View File

@ -149,7 +149,7 @@ public class AmmeterRecordDetailServiceImpl extends ServiceImpl<AmmeterRecordDet
//近7天
map.put("addTime_begin", DateUtil.formatDate(DateUtil.offsetDay(new Date(), -10)));
List<AmmeterRecordDetail> ammeterRecordDetails = baseMapper.queryUseRecord(map);
List<String> days = DateUtils.getDaysBetweenLastWeek();
List<String> days = DateUtils.getDateStrList(60, "yyyy-MM-dd");
List<TrendVo> list = ammeterRecordDetails.stream().map(detail -> {
TrendVo vo = new TrendVo();
vo.setY(detail.getDegree() + "");

View File

@ -67,7 +67,7 @@ public class GantryCraneWorkCycleServiceImpl extends ServiceImpl<GantryCraneWork
List<TrendVo> trendVos = gantryCraneWorkCycleMapper.countGantryCraneWorkCycleNumEveryday(map);
List<String> days;
if (Objects.equals(MapUtils.getInteger(map, "type"), 1)) {
days = DateUtils.getDaysBetweenLastHalfMonth();
days = DateUtils.getDateStrList(72, "yyyy-MM-dd");
} else if (Objects.equals(MapUtils.getInteger(map, "type"), 2)) {
days = DateUtils.getDaysBefore(50);
} else {

View File

@ -386,7 +386,7 @@ public class CarPassRecordServiceImpl extends ServiceImpl<CarPassRecordMapper, C
private void fillDataCarPassRecordInOutCount(List<TodayOutInNumber> todayOutInNumbers) {
Map<String, TodayOutInNumber> map = todayOutInNumbers.stream().collect(Collectors.toMap(TodayOutInNumber::getPassTime, Function.identity()));
todayOutInNumbers.clear();
for (String h : DateUtils.getAllHourInDay()) {
for (String h : DateUtils.getDateStrList(100, "HH:mm")) {
TodayOutInNumber toi = map.get(h);
if (toi == null) {
toi = new TodayOutInNumber();

View File

@ -527,7 +527,7 @@ public class HiddenDangerInspectRecordServiceImpl extends ServiceImpl<HiddenDang
private List<DangerInspectionPassMonthStaticsVo> fillData(List<DangerInspectionPassMonthStaticsVo> monthStatics) {
List<DangerInspectionPassMonthStaticsVo> rtVos = new ArrayList<>();
Map<String, DangerInspectionPassMonthStaticsVo> map = monthStatics.stream().collect(Collectors.toMap(e -> e.getDay(), e -> e, (o, o2) -> o));
for (String orderDay : DateUtils.getDaysBetweenLastMonth()) {
for (String orderDay : DateUtils.getDateStrList(80, "yyyy-MM-dd")) {
DangerInspectionPassMonthStaticsVo vo = map.get(orderDay);
if (vo == null) {
vo = new DangerInspectionPassMonthStaticsVo();

View File

@ -100,7 +100,7 @@ public class ElectricalDataServiceImpl extends ServiceImpl<ElectricalDataMapper,
private void fillData(List<ElectricalData> electricalDataList) {
Map<String, ElectricalData> dataMap = electricalDataList.stream().collect(Collectors.toMap(ElectricalData::getTime, Function.identity()));
electricalDataList.clear();
for (String hour : DateUtils.getHoursListLastDay()) {
for (String hour : DateUtils.getDateStrList(20, "HH:00")) {
ElectricalData ed = dataMap.get(hour);
if (ed == null) {
ed = new ElectricalData();

View File

@ -205,7 +205,7 @@ public class DustNoiseDataServiceImpl extends ServiceImpl<DustNoiseDataMapper, D
private void fillData(List<DustNoiseData> dustNoiseDatas) {
Map<String, DustNoiseData> dataMap = dustNoiseDatas.stream().collect(Collectors.toMap(DustNoiseData::getTime, Function.identity()));
dustNoiseDatas.clear();
for (String hour : DateUtils.getAllHourInDay()) {
for (String hour : DateUtils.getDateStrList(100, "HH:mm")) {
DustNoiseData dnd = dataMap.get(hour);
if (dnd == null) {
dnd = new DustNoiseData();

View File

@ -759,10 +759,10 @@ public class EnvironmentAlarmServiceImpl extends ServiceImpl<EnvironmentAlarmMap
List<String> dayList = new ArrayList<>();
if (dateType == 2) {
//查询近一月所有天数
dayList = DateUtils.getDaysBetweenLastMonth();
dayList = DateUtils.getDateStrList(80, "yyyy-MM-dd");
} else {
//查询近一周所有天数
dayList = DateUtils.getDaysBetweenLastWeek();
dayList = DateUtils.getDateStrList(60, "yyyy-MM-dd");
}
List<Map<String, Object>> list = companyService.selectComapnyOrProjectList(map);
if (list != null && list.size() > 0) {

View File

@ -40,7 +40,7 @@ public class LocationTagLowVoltageAlarmServiceImpl extends ServiceImpl<LocationT
@Override
public List<TrendVo> countLocationTagLowVoltageAlarmEveryDay(HashMap<String, Object> paramMap) {
List<TrendVo> list = baseMapper.countLocationTagLowVoltageAlarmEveryDay(paramMap);
List<String> days = DateUtils.getDaysBetweenLastWeek();
List<String> days = DateUtils.getDateStrList(60, "yyyy-MM-dd");
List<TrendVo> trendVos = TrendVo.fillTrendVos(list, days, "MM-dd");
return trendVos;
}

View File

@ -140,9 +140,9 @@ public class AiAnalyseHardWareAlarmRecordServiceImpl extends ServiceImpl<AiAnaly
} else if ("2".equals(MapUtils.getString(map, "selectType"))) {
dayList = DateUtils.getNowFewDaysAgoList(29);
} else if ("3".equals(MapUtils.getString(map, "selectType"))) {
dayList = DateUtils.getAllHourInDay();
dayList = DateUtils.getDateStrList(100, "HH:mm");
} else {
dayList = DateUtils.getHoursListLastDay();
dayList = DateUtils.getDateStrList(20, "HH:00");
}
List<Map<String, Object>> dataList = new ArrayList<>();
Map<String, Object> data = aiAnalyseHardWareAlarmRecordMapper.selectAiAnalyseHardWareAlarmTrendList(map);

View File

@ -98,7 +98,7 @@ public class WaterMeterMonthRecordServiceImpl extends ServiceImpl<WaterMeterMont
private void fillMonthAlarmList(List<WaterMeterStatisticsVo.Alarm> alarmList) {
Map<String, WaterMeterStatisticsVo.Alarm> map = alarmList.stream().collect(Collectors.toMap(e -> e.getTitleTime(), Function.identity()));
alarmList.clear();
for (String date : DateUtils.getDaysBetweenLastMonth()) {
for (String date : DateUtils.getDateStrList(80, "yyyy-MM-dd")) {
WaterMeterStatisticsVo.Alarm alarm = map.get(date);
if (alarm == null) {
alarm = new WaterMeterStatisticsVo.Alarm();

View File

@ -999,7 +999,7 @@ status 状态码 String 1表示成功其余表示失败
return workerAttendance;
}).collect(Collectors.groupingBy(WorkerAttendance::getCreateTimeHour));
ArrayList<NumberTimeTableVo> rtList = new ArrayList<>();
List<String> allHourInDay = DateUtils.getAllHourInDay();
List<String> allHourInDay = DateUtils.getDateStrList(100, "HH:mm");
int lastNum = 0;
for (String hour : allHourInDay) {
List<WorkerAttendance> workerAttendances = timeDateListMap.get(hour);

View File

@ -23,12 +23,6 @@ import java.util.*;
**/
public class DateUtils {
/**
* 时间格式化
*
* @param oldDate
* @return
*/
public static String dealDateFormat(String oldDate) {
Date date1 = null;
SimpleDateFormat df2 = null;
@ -37,8 +31,6 @@ public class DateUtils {
Date date = df.parse(oldDate);
Calendar beijingcal = Calendar.getInstance();
beijingcal.setTime(date);
//SimpleDateFormat df1 = new SimpleDateFormat ("EEE MMM dd HH:mm:ss Z yyyy", Locale.UK);
//date1 = df1.parse(date.toString());
beijingcal.set(Calendar.HOUR, beijingcal.get(Calendar.HOUR) + 8);
date1 = beijingcal.getTime();
df2 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
@ -62,11 +54,6 @@ public class DateUtils {
return df2.format(date);
}
/**
* 查询本周所有天数
*
* @return
*/
public static List<String> getNowWeekAllDayList() {
Calendar cal = Calendar.getInstance();
// 判断要计算的日期是否是周日如果是则减一天计算周六的否则会出问题计算到下一周去了
@ -98,11 +85,6 @@ public class DateUtils {
return findDates(cal.getTime(), new Date());
}
/**
* 查询本月所有天数
*
* @return
*/
public static List<String> getNowMonthAllDayList() {
Calendar cal = Calendar.getInstance();
cal.set(Calendar.DAY_OF_MONTH, 1);
@ -346,7 +328,7 @@ public class DateUtils {
}
return list;
} else if (type == 2) {
return getDaysBetweenLastWeek();
return getDateStrList(60, "yyyy-MM-dd");
} else if (type == 3) {
return getNowMonthAllDayList();
}
@ -397,14 +379,6 @@ public class DateUtils {
return sdf.format(cal.getTime());
}
/**
* 获取一天内的小时列表
*
* @return
*/
public static List<String> getAllHourInDay() {
return Arrays.asList("00:00", "01:00", "02:00", "03:00", "04:00", "05:00", "06:00", "07:00", "08:00", "09:00", "10:00", "11:00", "12:00", "13:00", "14:00", "15:00", "16:00", "17:00", "18:00", "19:00", "20:00", "21:00", "22:00", "23:00");
}
/**
* 转成GMT时间
@ -418,70 +392,6 @@ public class DateUtils {
}
/**
* 查询本月所有天数Fix2023-06-01到2023-06-30
*
* @return
*/
public static List<String> getCurrentMonthAllDayList() {
ArrayList<String> rtList = new ArrayList<>();
Date now = new Date();
DateTime beginDate = DateUtil.beginOfMonth(now);
DateTime endDate = DateUtil.endOfMonth(now);
long offset = DateUtil.betweenDay(beginDate, endDate, true);
for (int i = 0; i < offset + 1; i++) {
rtList.add(DateUtil.formatDate(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 = DateUtil.lastMonth();
DateTime endDate = DateTime.now();
long offset = DateUtil.betweenDay(beginDate, endDate, true);
for (int i = 0; i < offset + 1; i++) {
rtList.add(DateUtil.formatDate(DateUtil.offsetDay(beginDate, i)));
}
return rtList;
}
/**
* 查询一个周前内所有天数2023-06-10到2023-06-17
*
* @return
*/
public static List<String> getDaysBetweenLastWeek() {
ArrayList<String> rtList = new ArrayList<>();
DateTime beginDate = DateUtil.lastWeek();
DateTime endDate = DateTime.now();
long offset = DateUtil.betweenDay(beginDate, endDate, true);
for (int i = 0; i < offset + 1; i++) {
rtList.add(DateUtil.formatDate(DateUtil.offsetDay(beginDate, i)));
}
return rtList;
}
/**
* 查询15天前的所有天数2023-06-10到2023-06-15
*
* @return
*/
public static List<String> getDaysBetweenLastHalfMonth() {
ArrayList<String> rtList = new ArrayList<>();
DateTime dateTime = DateUtil.parseDate(DateUtil.today());
for (int i = 0; i < 15; i++) {
rtList.add(DateUtil.formatDate(DateUtil.offsetDay(dateTime, i * (-1))));
}
Collections.reverse(rtList);
return rtList;
}
/**
* 查询N天前的所有天数2023-06-10到2023-06-15
*
@ -515,38 +425,6 @@ public class DateUtils {
return rtList;
}
/**
* 查询一个周前内所有天数06-10到06-17
*
* @return
*/
public static List<String> getDaysBetweenLastWeekWithoutYear() {
ArrayList<String> rtList = new ArrayList<>();
DateTime beginDate = DateUtil.lastWeek();
DateTime endDate = DateTime.now();
long offset = DateUtil.betweenDay(beginDate, endDate, true);
for (int i = 0; i < offset + 1; i++) {
rtList.add(DateUtil.format(DateUtil.offsetDay(beginDate, i), "MM-dd"));
}
return rtList;
}
/**
* 查询一天前内所有小时
*
* @return
*/
public static List<String> getHoursListLastDay() {
ArrayList<String> rtList = new ArrayList<>();
DateTime beginDate = DateUtil.yesterday();
DateTime endDate = DateTime.now();
long offset = DateUtil.between(beginDate, endDate, DateUnit.HOUR);
for (int i = 1; i < offset + 1; i++) {
rtList.add(DateUtil.format(DateUtil.offsetHour(beginDate, i), "HH:00"));
}
return rtList;
}
/**
* 偏移日期str传入2023-11-02返回2023-11-02传入2023-11-02 00:00:00返回2023-11-02 00:00:00
*
@ -566,15 +444,53 @@ public class DateUtils {
* 获取所有日期列表
*
* @param type 类型
* 10.近12小时,20.近24小时,30.近半天,40.近一天,50.近两天,60.近一周,70.近两周,80.近一个月,90.近半年,93.近一年
* 100.今天,200.昨天,300.本周,400.本月,500.本年每月,600.去年
* 10.近12小时,20.近24小时每小时,30.近半天,40.近一天,50.近两天,60.近一周每天,70.近两周,72.近15天每天,80.近一个月每天,90.近半年每月,93.近一年每月
* 100.今天每小时,200.昨天,300.本周,400.本月每天,500.本年每月,600.去年
* @param pattern 格式 yyyy-MM-dd HH:mm:ss
* @return
*/
public static List<String> getDateStrList(int type, String pattern) {
if (type == 1) {
if (type == 20) {
//近24小时每小时egHH:00
ArrayList<String> rtList = new ArrayList<>();
DateTime beginDate = DateUtil.yesterday();
DateTime endDate = DateTime.now();
long offset = DateUtil.between(beginDate, endDate, DateUnit.HOUR);
for (int i = 1; i < offset + 1; i++) {
rtList.add(DateUtil.format(DateUtil.offsetHour(beginDate, i), pattern));
}
return rtList;
} else if (type == 60) {
//近一周每天
ArrayList<String> rtList = new ArrayList<>();
DateTime beginDate = DateUtil.lastWeek();
DateTime endDate = DateTime.now();
long offset = DateUtil.betweenDay(beginDate, endDate, true);
for (int i = 0; i < offset + 1; i++) {
rtList.add(DateUtil.format(DateUtil.offsetDay(beginDate, i), pattern));
}
return rtList;
} else if (type == 72) {
//近15天每天
ArrayList<String> rtList = new ArrayList<>();
DateTime dateTime = DateUtil.parseDate(DateUtil.today());
for (int i = 0; i < 15; i++) {
rtList.add(DateUtil.format(DateUtil.offsetDay(dateTime, i * (-1)), pattern));
}
Collections.reverse(rtList);
return rtList;
} else if (type == 80) {
//近一个月每天
ArrayList<String> rtList = new ArrayList<>();
DateTime beginDate = DateUtil.lastMonth();
DateTime endDate = DateTime.now();
long offset = DateUtil.betweenDay(beginDate, endDate, true);
for (int i = 0; i < offset + 1; i++) {
rtList.add(DateUtil.format(DateUtil.offsetDay(beginDate, i), pattern));
}
return rtList;
} else if (type == 90) {
//近半年每月
ArrayList<String> rtList = new ArrayList<>();
DateTime endDate = DateTime.now();
DateTime beginDate = DateUtil.offsetMonth(endDate, -6);
@ -584,6 +500,7 @@ public class DateUtils {
}
return rtList;
} else if (type == 93) {
//近一年每月
ArrayList<String> rtList = new ArrayList<>();
DateTime endDate = DateTime.now();
DateTime beginDate = DateUtil.offsetMonth(endDate, -12);
@ -592,7 +509,29 @@ public class DateUtils {
rtList.add(DateUtil.format(DateUtil.offsetMonth(beginDate, i), pattern));
}
return rtList;
} else if (type == 100) {
//100.今天每小时
ArrayList<String> rtList = new ArrayList<>();
DateTime beginDate = DateUtil.beginOfDay(DateTime.now());
DateTime endDate = DateUtil.endOfDay(DateTime.now());
long offset = DateUtil.between(beginDate, endDate, DateUnit.HOUR);
for (int i = 0; i < offset + 1; i++) {
rtList.add(DateUtil.format(DateUtil.offsetHour(beginDate, i), pattern));
}
return rtList;
} else if (type == 400) {
//本月每天
ArrayList<String> rtList = new ArrayList<>();
Date now = new Date();
DateTime beginDate = DateUtil.beginOfMonth(now);
DateTime endDate = DateUtil.endOfMonth(now);
long offset = DateUtil.betweenDay(beginDate, endDate, true);
for (int i = 0; i < offset + 1; i++) {
rtList.add(DateUtil.format(DateUtil.offsetDay(beginDate, i), pattern));
}
return rtList;
} else if (type == 500) {
//本年每月
ArrayList<String> rtList = new ArrayList<>();
DateTime beginDate = DateUtil.beginOfYear(DateTime.now());
DateTime endDate = DateUtil.endOfYear(DateTime.now());
@ -602,10 +541,11 @@ public class DateUtils {
}
return rtList;
}
return null;
return new ArrayList<>();
}
public static void main(String[] args) {
System.out.println(getDateStrList(500, "月份M"));
System.out.println(getNowWeekAllDayList());
System.out.println(getDateStrList(100, "HH:mm"));
}
}