fix:Date冲突

This commit is contained in:
nieziyan 2023-06-21 14:48:47 +08:00
parent 66640852ca
commit e8d369c46c
4 changed files with 53 additions and 8 deletions

View File

@ -16,6 +16,12 @@
</properties>
<dependencies>
<!-- jeecg-system-cloud-api -->
<dependency>
<groupId>org.jeecgframework.boot</groupId>
<artifactId>jeecg-system-cloud-api</artifactId>
</dependency>
<dependency>
<groupId>org.jeecgframework.boot</groupId>
<artifactId>jeecg-boot-base-core</artifactId>

View File

@ -2,19 +2,29 @@ package org.jeecg.modules.controller;
import io.swagger.annotations.ApiOperation;
import org.jeecg.common.api.QueryRequest;
import org.jeecg.common.api.dto.message.MessageDTO;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.constant.enums.MessageTypeEnum;
import org.jeecg.common.system.api.ISysBaseAPI;
import org.jeecg.modules.entity.AlarmLog;
import org.jeecg.modules.service.IAlarmLogService;
import org.jeecg.modules.vo.AlarmVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.HashMap;
import java.util.Map;
@RestController
@RequestMapping("alarmLog")
public class AlarmLogController {
@Autowired
private IAlarmLogService alarmLogService;
@Autowired
private ISysBaseAPI sysBaseAPI;
@ApiOperation("报警日志量总览-柱状图")
@PostMapping("viewAll")
public Result viewAll(@RequestBody AlarmVo alarmVo){ return alarmLogService.viewAll(alarmVo); }
@ -57,4 +67,19 @@ public class AlarmLogController {
public Result deleteById(String id){
return alarmLogService.deleteById(id);
}
@GetMapping("test")
public void test(){
MessageDTO message = new MessageDTO();
message.setFromUser("admin");
message.setToUser("nieziyan");
message.setTitle("测试消息");
message.setType(MessageTypeEnum.XT.getType());
message.setTemplateCode("SYS001");
Map<String,Object> data = new HashMap<>();
data.put("userName","聂子炎");
data.put("taskName","请假申请");
message.setData(data);
sysBaseAPI.sendTemplateMessage(message);
}
}

View File

@ -17,6 +17,7 @@ import org.springframework.web.bind.annotation.RestController;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.stream.Collectors;
@ -100,9 +101,18 @@ public class SysEmailLogController {
String todayEnd = today + " 23:59:59";
wrapper.between(SysEmailLog::getReceiveTime,todayStart,todayEnd);
List<SysEmailLog> emailLogs = sysEmailLogService.list(wrapper);
List<LocalDateTime> allTime = emailLogs.stream()
// 将Date转换为LocalDateTime
List<Date> allDate = emailLogs.stream()
.map(SysEmailLog::getReceiveTime)
.collect(Collectors.toList());
List<LocalDateTime> allTime = allDate.stream()
.map(item -> {
ZoneId zoneId = ZoneId.systemDefault();
return item.toInstant()
.atZone(zoneId)
.toLocalDateTime();
})
.collect(Collectors.toList());
// 按照小时分组
Map<String,Integer> statistic = new TreeMap<>();
Map<Integer, List<LocalDateTime>> groupTime = allTime.stream()
@ -136,8 +146,17 @@ public class SysEmailLogController {
Collection<Integer> yData = new ArrayList<>();
Map<String,Integer> statistic = new TreeMap<>();
Map<String,Object> result = new HashMap<>();
List<LocalDateTime> allDate = sysEmailLogService.listObjs(wrapper,
List<Date> allDate = sysEmailLogService.listObjs(wrapper,
emailLog -> ((SysEmailLog) emailLog).getReceiveTime());
// 将Date转换为LocalDateTime
List<LocalDateTime> allTime = allDate.stream()
.map(item -> {
ZoneId zoneId = ZoneId.systemDefault();
return item.toInstant()
.atZone(zoneId)
.toLocalDateTime();
})
.collect(Collectors.toList());
if (CollUtil.isEmpty(allDate)){
result.put("xData",xData);
result.put("yData",yData);
@ -147,7 +166,7 @@ public class SysEmailLogController {
/* 支持跨年跨月选择 */
// 通过年月日进行分组 :2023-06-06
DateTimeFormatter formatter = DateTimeFormatter.ISO_LOCAL_DATE;
Map<String, List<LocalDateTime>> group = allDate.stream()
Map<String, List<LocalDateTime>> group = allTime.stream()
.collect(Collectors.groupingBy(datetime -> datetime.format(formatter)));
// 列举出startDate-endDate中所有日期(包括闰年)

View File

@ -12,11 +12,6 @@
<artifactId>jeecg-abnormal-alarm-start</artifactId>
<dependencies>
<!-- jeecg-system-cloud-api -->
<dependency>
<groupId>org.jeecgframework.boot</groupId>
<artifactId>jeecg-system-cloud-api</artifactId>
</dependency>
<!-- jeecg-module-abnormal-alarm模块 -->
<dependency>
<groupId>org.jeecgframework.boot</groupId>