feat:后端接口
This commit is contained in:
parent
2bc6d4352b
commit
da69a39e95
|
@ -11,4 +11,6 @@ public interface DateConstant {
|
|||
String TIME_START = " 00:00:00";
|
||||
|
||||
String TIME_END = " 23:59:59";
|
||||
|
||||
String TIME_ZONE = "UTC+08:00";
|
||||
}
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
package org.jeecg.modules.base.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
import org.jeecg.common.constant.DateConstant;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDate;
|
||||
|
||||
@Data
|
||||
public class NuclideAvgDto implements Serializable {
|
||||
|
||||
/** 核素名称 */
|
||||
private String nuclide;
|
||||
|
||||
/** 核素浓度平均值 */
|
||||
private String val;
|
||||
|
||||
/** 统计周期 */
|
||||
private String cycle;
|
||||
|
||||
/** 数据源类型 */
|
||||
private String datasource;
|
||||
|
||||
// 计算时间
|
||||
@JsonFormat(pattern = DateConstant.DATE,timezone = DateConstant.TIME_ZONE)
|
||||
private LocalDate caclDate;
|
||||
}
|
|
@ -1,13 +1,17 @@
|
|||
package org.jeecg.modules.base.dto;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class TypeDto {
|
||||
// 1.资源类型 Server|Database|Email
|
||||
// 2.规则名
|
||||
private String name;
|
||||
// 1.报警量
|
||||
// 2.规则使用量
|
||||
private Integer value;
|
||||
private Long value;
|
||||
}
|
||||
|
|
|
@ -31,6 +31,8 @@ public class AlarmAnalysisLog implements Serializable{
|
|||
|
||||
private String ruleId;
|
||||
|
||||
private String stationId;
|
||||
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "UTC+8")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime alarmStartDate = LocalDateTime.now();
|
||||
|
@ -45,6 +47,8 @@ public class AlarmAnalysisLog implements Serializable{
|
|||
|
||||
private String nuclideInfo;
|
||||
|
||||
private String datasource;
|
||||
|
||||
@TableField(exist = false)
|
||||
private List<NuclideInfo> nuclideInfoList;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
package org.jeecg.modules.base.vo;
|
||||
|
||||
import lombok.Data;
|
||||
import org.jeecg.common.api.QueryRequest;
|
||||
|
||||
@Data
|
||||
public class NuclideAvgVo extends QueryRequest {
|
||||
|
||||
private String startDate;
|
||||
|
||||
private String endDate;
|
||||
|
||||
private int pageStart;
|
||||
}
|
|
@ -1,6 +1,7 @@
|
|||
package org.jeecg.modules.controller;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
|
@ -29,21 +30,45 @@ import java.util.List;
|
|||
@RequestMapping("alarmAnalysisLog")
|
||||
public class AlarmAnalysisLogController extends JeecgController<AlarmAnalysisLog, IAlarmAnalysisLogService> {
|
||||
|
||||
@Autowired
|
||||
private IAlarmAnalysisLogService alarmAnalysisLogService;
|
||||
|
||||
@ApiOperation(value="报警日志分页查询", notes="报警日志分页查询")
|
||||
@GetMapping(value = "findPage")
|
||||
public Result<?> findPage(AnalysisLogVo analysisLogVo) {
|
||||
return alarmAnalysisLogService.findPage(analysisLogVo);
|
||||
return service.findPage(analysisLogVo);
|
||||
}
|
||||
|
||||
@ApiOperation(value="添加报警日志", notes="添加报警日志")
|
||||
@PostMapping(value = "add")
|
||||
public Result<?> add(@RequestBody AlarmAnalysisLog alarmAnalysisLog) {
|
||||
boolean success = alarmAnalysisLogService.save(alarmAnalysisLog);
|
||||
boolean success = service.save(alarmAnalysisLog);
|
||||
if (success)
|
||||
return Result.OK(Prompt.ADD_SUCC);
|
||||
return Result.error(Prompt.ADD_ERR);
|
||||
}
|
||||
|
||||
@ApiOperation(value="按照时间统计报警量-柱状图", notes="按照时间统计报警量-柱状图")
|
||||
@GetMapping(value = "byTime")
|
||||
public Result<?> byTime(@RequestParam String startDate,
|
||||
@RequestParam String endDate) {
|
||||
if (StrUtil.isBlank(startDate) || StrUtil.isBlank(endDate))
|
||||
return Result.error(Prompt.PARAM_REQUIRED);
|
||||
return Result.OK(service.byTime(startDate, endDate));
|
||||
}
|
||||
|
||||
@ApiOperation(value="按照时间+台站统计报警量-柱状图", notes="按照时间+台站统计报警量-柱状图")
|
||||
@GetMapping(value = "byStatoin")
|
||||
public Result<?> byStatoin(@RequestParam String startDate,
|
||||
@RequestParam String endDate) {
|
||||
if (StrUtil.isBlank(startDate) || StrUtil.isBlank(endDate))
|
||||
return Result.error(Prompt.PARAM_REQUIRED);
|
||||
return Result.OK(service.byStatoin(startDate, endDate));
|
||||
}
|
||||
|
||||
@ApiOperation(value="按照时间+数据源统计报警总量-饼图", notes="按照时间+数据源统计报警总量-饼图")
|
||||
@GetMapping(value = "bySource")
|
||||
public Result<?> bySource(@RequestParam String startDate,
|
||||
@RequestParam String endDate) {
|
||||
if (StrUtil.isBlank(startDate) || StrUtil.isBlank(endDate))
|
||||
return Result.error(Prompt.PARAM_REQUIRED);
|
||||
return Result.OK(service.bySource(startDate, endDate));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,14 @@
|
|||
package org.jeecg.modules.controller;
|
||||
|
||||
import cn.hutool.core.util.PageUtil;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.PageDTO;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.modules.base.dto.NuclideAvgDto;
|
||||
import org.jeecg.modules.base.entity.postgre.AlarmAnalysisNuclideAvg;
|
||||
import org.jeecg.modules.base.enums.PageType;
|
||||
import org.jeecg.modules.base.vo.NuclideAvgVo;
|
||||
import org.jeecg.modules.service.IAlarmAnalysisNuclideAvgService;
|
||||
import org.jeecg.common.system.base.controller.JeecgController;
|
||||
|
||||
|
@ -13,7 +21,11 @@ import io.swagger.annotations.Api;
|
|||
@RequestMapping("nuclideAvg")
|
||||
public class AlarmAnalysisNuclideAvgController extends JeecgController<AlarmAnalysisNuclideAvg, IAlarmAnalysisNuclideAvgService> {
|
||||
|
||||
@Autowired
|
||||
private IAlarmAnalysisNuclideAvgService nuclideAvgService;
|
||||
@GetMapping("findPage")
|
||||
@ApiOperation(value = "核素浓度均值列表信息",notes = "核素浓度均值列表信息")
|
||||
public Result findPage(NuclideAvgVo nuclideAvgVo){
|
||||
Page<NuclideAvgDto> result = service.findPage(nuclideAvgVo);
|
||||
return Result.OK(result);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
package org.jeecg.modules.controller;
|
||||
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.common.constant.Prompt;
|
||||
import org.jeecg.modules.base.entity.postgre.AlarmAnalysisNuclideParam;
|
||||
import org.jeecg.modules.service.IAlarmAnalysisNuclideParamService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
@ -11,18 +13,29 @@ import org.springframework.web.bind.annotation.*;
|
|||
import io.swagger.annotations.Api;
|
||||
|
||||
@Slf4j
|
||||
@Api(value = "核素浓度均值计算参数管理", tags= "核素浓度均值计算参数管理")
|
||||
@Api(value = "核素浓度计算参数管理", tags = "核素浓度计算参数管理")
|
||||
@RestController
|
||||
@RequestMapping("nuclideParam")
|
||||
public class AlarmAnalysisNuclideParamController extends JeecgController<AlarmAnalysisNuclideParam, IAlarmAnalysisNuclideParamService> {
|
||||
|
||||
@Autowired
|
||||
private IAlarmAnalysisNuclideParamService nuclideParamService;
|
||||
|
||||
@GetMapping("refresh")
|
||||
@ApiOperation(value = "定时刷新核素计算参数信息",notes = "定时刷新核素计算参数信息")
|
||||
public void refreshParam(){
|
||||
nuclideParamService.refresh();
|
||||
service.refresh();
|
||||
}
|
||||
|
||||
@GetMapping("findInfo")
|
||||
@ApiOperation(value = "回显核素计算参数信息",notes = "回显核素计算参数信息")
|
||||
public Result findInfo(){
|
||||
return Result.OK(service.getLatest());
|
||||
}
|
||||
|
||||
@PutMapping("update")
|
||||
@ApiOperation(value = "修改核素计算参数信息",notes = "修改核素计算参数信息")
|
||||
public Result update(@RequestBody AlarmAnalysisNuclideParam nuclideParam){
|
||||
boolean success = service.update(nuclideParam);
|
||||
if (success)
|
||||
return Result.OK(Prompt.UPDATE_SUCC);
|
||||
return Result.error(Prompt.UPDATE_ERR);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -52,7 +52,7 @@ public class SysEmailLogController {
|
|||
@GetMapping("today")
|
||||
@ApiOperation("今日邮件接收量")
|
||||
public Result today(@RequestParam("emailId") String emailId){
|
||||
return sysEmailLogService.today(emailId);
|
||||
return sysEmailLogService.todayMin(emailId);
|
||||
}
|
||||
|
||||
@GetMapping("analysis")
|
||||
|
|
|
@ -9,6 +9,7 @@ import org.springframework.web.bind.annotation.GetMapping;
|
|||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
@ -31,4 +32,7 @@ public interface SystemClient {
|
|||
/* GardsStationsController下相关接口 */
|
||||
@GetMapping("/gardsStations/getCodes")
|
||||
List<String> stationCodes(@RequestParam String stationIds);
|
||||
@GetMapping("/gardsStations/getCodesMap")
|
||||
Map<String,String> stationCodesMap(@RequestParam Collection<String> stationIds);
|
||||
|
||||
}
|
||||
|
|
|
@ -1,8 +1,13 @@
|
|||
package org.jeecg.modules.mapper;
|
||||
|
||||
import org.jeecg.modules.base.dto.NuclideAvgDto;
|
||||
import org.jeecg.modules.base.entity.postgre.AlarmAnalysisNuclideAvg;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface AlarmAnalysisNuclideAvgMapper extends BaseMapper<AlarmAnalysisNuclideAvg> {
|
||||
|
||||
List<NuclideAvgDto> findPage(Map<String,Object> params);
|
||||
}
|
||||
|
|
|
@ -2,4 +2,31 @@
|
|||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="org.jeecg.modules.mapper.AlarmAnalysisNuclideAvgMapper">
|
||||
|
||||
<select id="findPage" resultType="org.jeecg.modules.base.dto.NuclideAvgDto">
|
||||
SELECT
|
||||
nuclide,
|
||||
val,
|
||||
cycle,
|
||||
CASE data_source_type
|
||||
WHEN '1' THEN 'ARMDARR'
|
||||
WHEN '2' THEN 'ARMDRRR'
|
||||
WHEN '3' THEN 'IDCARR'
|
||||
WHEN '4' THEN 'IDCRRR'
|
||||
END AS datasource,
|
||||
cacl_date
|
||||
FROM
|
||||
alarm_analysis_nuclide_avg
|
||||
<where>
|
||||
<if test="startDate != null and startDate != ''">
|
||||
cacl_date >= #{startDate}
|
||||
</if>
|
||||
<if test="endDate != null and endDate != ''">
|
||||
AND cacl_date <= #{endDate}
|
||||
</if>
|
||||
</where>
|
||||
ORDER BY cacl_date DESC
|
||||
<if test="pageFlag == null">
|
||||
LIMIT #{pageSize} OFFSET #{pageStart}
|
||||
</if>
|
||||
</select>
|
||||
</mapper>
|
|
@ -44,6 +44,7 @@
|
|||
LEFT JOIN alarm_log l ON r.ID = l.rule_id
|
||||
AND l.alarm_start_date BETWEEN #{startDate} AND #{endDate}
|
||||
GROUP BY e.ID, e.NAME, e.email_server_address
|
||||
ORDER BY e.enabled DESC,e.NAME ASC
|
||||
<if test="pageFlag == null">
|
||||
LIMIT #{pageSize} OFFSET #{pageStart}
|
||||
</if>
|
||||
|
|
|
@ -5,9 +5,17 @@ import org.jeecg.common.api.vo.Result;
|
|||
import org.jeecg.modules.base.entity.postgre.AlarmAnalysisLog;
|
||||
import org.jeecg.modules.base.vo.AnalysisLogVo;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public interface IAlarmAnalysisLogService extends IService<AlarmAnalysisLog> {
|
||||
|
||||
Result findPage(AnalysisLogVo analysisLogVo);
|
||||
|
||||
boolean saveLog(AlarmAnalysisLog analysisLog);
|
||||
|
||||
Map<String,Object> byTime(String startDate,String endDate);
|
||||
|
||||
Map<String,Object> byStatoin(String startDate,String endDate);
|
||||
|
||||
Map<String,Object> bySource(String startDate,String endDate);
|
||||
}
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
package org.jeecg.modules.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import org.jeecg.modules.base.dto.NuclideAvgDto;
|
||||
import org.jeecg.modules.base.entity.postgre.AlarmAnalysisNuclideAvg;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import org.jeecg.modules.base.vo.NuclideAvgVo;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
@ -9,4 +12,6 @@ import java.util.Set;
|
|||
public interface IAlarmAnalysisNuclideAvgService extends IService<AlarmAnalysisNuclideAvg> {
|
||||
|
||||
List<AlarmAnalysisNuclideAvg> list(Set<String> nuclideNames,String dataSourceType);
|
||||
|
||||
Page<NuclideAvgDto> findPage(NuclideAvgVo nuclideAvgVo);
|
||||
}
|
||||
|
|
|
@ -8,4 +8,6 @@ public interface IAlarmAnalysisNuclideParamService extends IService<AlarmAnalysi
|
|||
AlarmAnalysisNuclideParam getLatest();
|
||||
|
||||
boolean refresh();
|
||||
|
||||
boolean update(AlarmAnalysisNuclideParam nuclideParam);
|
||||
}
|
||||
|
|
|
@ -7,7 +7,9 @@ import org.jeecg.modules.base.entity.postgre.SysEmailLog;
|
|||
public interface ISysEmailLogService extends IService<SysEmailLog> {
|
||||
Result totalEmail(String emailId);
|
||||
|
||||
Result today(String emailId);
|
||||
Result todayHour(String emailId);
|
||||
|
||||
Result todayMin(String emailId);
|
||||
|
||||
Result analysis(String emailId, String startDate, String endDate);
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package org.jeecg.modules.service.impl;
|
|||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.collection.ListUtil;
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
|
@ -10,6 +11,7 @@ import com.fasterxml.jackson.core.JsonProcessingException;
|
|||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.common.constant.CommonConstant;
|
||||
import org.jeecg.common.constant.DateConstant;
|
||||
import org.jeecg.common.constant.DictConstant;
|
||||
import org.jeecg.common.constant.SymbolConstant;
|
||||
|
@ -17,6 +19,7 @@ import org.jeecg.common.system.vo.DictModel;
|
|||
import org.jeecg.modules.base.dto.AlarmAnalysisRuleDto;
|
||||
import org.jeecg.modules.base.dto.AnalysisLogDto;
|
||||
import org.jeecg.modules.base.dto.NuclideInfo;
|
||||
import org.jeecg.modules.base.dto.TypeDto;
|
||||
import org.jeecg.modules.base.entity.postgre.AlarmAnalysisLog;
|
||||
import org.jeecg.modules.base.vo.AnalysisLogVo;
|
||||
import org.jeecg.modules.feignclient.SystemClient;
|
||||
|
@ -28,9 +31,8 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|||
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
|
@ -40,7 +42,7 @@ public class AlarmAnalysisLogServiceImpl extends ServiceImpl<AlarmAnalysisLogMap
|
|||
private SystemClient systemClient;
|
||||
|
||||
@Override
|
||||
public Result findPage(AnalysisLogVo analysisLogVo) {
|
||||
public Result<?> findPage(AnalysisLogVo analysisLogVo) {
|
||||
String startDate = analysisLogVo.getStartDate();
|
||||
String endDate = analysisLogVo.getEndDate();
|
||||
if (StrUtil.isNotBlank(startDate))
|
||||
|
@ -132,6 +134,127 @@ public class AlarmAnalysisLogServiceImpl extends ServiceImpl<AlarmAnalysisLogMap
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> byTime(String startDate, String endDate) {
|
||||
List<AlarmAnalysisLog> analysisLogs = getLogs(startDate, endDate);
|
||||
// 定义返回结果
|
||||
Set<String> xData = new HashSet<>();
|
||||
Collection<Long> yData = new ArrayList<>();
|
||||
Map<String,Object> result = new HashMap<>();
|
||||
|
||||
List<LocalDateTime> allDate = analysisLogs.stream()
|
||||
.map(AlarmAnalysisLog::getAlarmStartDate)
|
||||
.collect(Collectors.toList());
|
||||
if (CollUtil.isEmpty(allDate)){
|
||||
result.put("xData",xData);
|
||||
result.put("yData",yData);
|
||||
return result;
|
||||
}
|
||||
// 所选日期为同一天
|
||||
if (StrUtil.equals(startDate,endDate)){
|
||||
Map<String, Long> statistic = allDate.stream()
|
||||
.collect(Collectors.groupingBy(dateTime -> String.format("%02d:00",dateTime.getHour()),
|
||||
TreeMap::new,Collectors.counting()));
|
||||
for (int hour = 0; hour < 24; hour++) {
|
||||
statistic.putIfAbsent(String.format("%02d:00",hour),0L);
|
||||
}
|
||||
// 返回x轴和y轴数据
|
||||
xData = statistic.keySet();
|
||||
yData = statistic.values();
|
||||
result.put("xData",xData);
|
||||
result.put("yData",yData);
|
||||
return result;
|
||||
}
|
||||
// 所选日期不为同一天
|
||||
else {
|
||||
// 通过年月日进行分组 例:2023-06-06
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ISO_LOCAL_DATE;
|
||||
Map<String, Long> statistic = allDate.stream()
|
||||
.collect(Collectors.groupingBy(datetime -> datetime.format(formatter),
|
||||
TreeMap::new,Collectors.counting()));
|
||||
// 列举startDate和endDate之间所有日期(已考虑闰年情况)
|
||||
// 没有报警日志的日期,对应的值设置为0
|
||||
LocalDate start = LocalDate.parse(startDate);
|
||||
LocalDate end = LocalDate.parse(endDate);
|
||||
while (!start.isAfter(end)) {
|
||||
String date = start.format(formatter);
|
||||
statistic.putIfAbsent(date,0L);
|
||||
start = start.plusDays(1);
|
||||
}
|
||||
// 返回x轴和y轴数据
|
||||
xData = statistic.keySet();
|
||||
yData = statistic.values();
|
||||
result.put("xData",xData);
|
||||
result.put("yData",yData);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> byStatoin(String startDate, String endDate) {
|
||||
Set<String> xData = new HashSet<>();
|
||||
Collection<Long> yData = new ArrayList<>();
|
||||
Map<String,Long> statistic = new TreeMap<>();
|
||||
Map<String,Object> result = new HashMap<>();
|
||||
List<AlarmAnalysisLog> analysisLogs = getLogs(startDate, endDate);
|
||||
if (CollUtil.isEmpty(analysisLogs)){
|
||||
result.put("xData",xData);
|
||||
result.put("yData",yData);
|
||||
return result;
|
||||
}
|
||||
Map<String, Long> stationGroup = analysisLogs.stream()
|
||||
.filter(log -> StrUtil.isNotBlank(log.getStationId()))
|
||||
.map(AlarmAnalysisLog::getStationId)
|
||||
.collect(Collectors.groupingBy(stationId -> stationId, Collectors.counting()));
|
||||
Set<String> stationIds = stationGroup.keySet();
|
||||
Map<String, String> stationCodesMap = systemClient.stationCodesMap(stationIds);
|
||||
for (String stationId : stationIds) {
|
||||
String stationCode = stationCodesMap.get(stationId);
|
||||
Long count = stationGroup.get(stationId);
|
||||
statistic.put(stationCode,count);
|
||||
}
|
||||
xData = statistic.keySet();
|
||||
yData = statistic.values();
|
||||
result.put("xData",xData);
|
||||
result.put("yData",yData);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> bySource(String startDate, String endDate) {
|
||||
List<AlarmAnalysisLog> analysisLogs = getLogs(startDate, endDate);
|
||||
Map<String, Long> group = analysisLogs.stream()
|
||||
.map(AlarmAnalysisLog::getDatasource)
|
||||
.filter(StrUtil::isNotBlank)
|
||||
.collect(Collectors.groupingBy(datasource -> datasource, Collectors.counting()));
|
||||
List<TypeDto> pieData = new ArrayList<>();
|
||||
for (Map.Entry<String, Long> entry : group.entrySet()) {
|
||||
String datasource = entry.getKey();
|
||||
Long count = entry.getValue();
|
||||
switch (datasource){
|
||||
case CommonConstant.ARMDARR:
|
||||
pieData.add(new TypeDto("ARMDARR",count));
|
||||
break;
|
||||
case CommonConstant.ARMDRRR:
|
||||
pieData.add(new TypeDto("ARMDRRR",count));
|
||||
break;
|
||||
case CommonConstant.IDCARR:
|
||||
pieData.add(new TypeDto("IDCARR",count));
|
||||
break;
|
||||
case CommonConstant.IDCRRR:
|
||||
pieData.add(new TypeDto("IDCRRR",count));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
long total = pieData.stream().mapToLong(TypeDto::getValue).sum();
|
||||
Map<String,Object> result = new HashMap<>();
|
||||
result.put("pieData",pieData);
|
||||
result.put("pieTotal",total);
|
||||
return result;
|
||||
}
|
||||
|
||||
private List<String> getShow(List<DictModel> dictModels,String dict){
|
||||
List<String> show = new ArrayList<>();
|
||||
if (StrUtil.isBlank(dict))
|
||||
|
@ -144,4 +267,13 @@ public class AlarmAnalysisLogServiceImpl extends ServiceImpl<AlarmAnalysisLogMap
|
|||
}
|
||||
return show;
|
||||
}
|
||||
|
||||
private List<AlarmAnalysisLog> getLogs(String startDate,String endDate){
|
||||
startDate += DateConstant.TIME_START;
|
||||
endDate += DateConstant.TIME_END;
|
||||
LambdaQueryWrapper<AlarmAnalysisLog> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.ge(AlarmAnalysisLog::getAlarmStartDate,startDate);
|
||||
wrapper.le(AlarmAnalysisLog::getAlarmStartDate,endDate);
|
||||
return list(wrapper);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,12 @@
|
|||
package org.jeecg.modules.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import org.jeecg.modules.base.dto.NuclideAvgDto;
|
||||
import org.jeecg.modules.base.entity.postgre.AlarmAnalysisNuclideAvg;
|
||||
import org.jeecg.modules.base.vo.NuclideAvgVo;
|
||||
import org.jeecg.modules.mapper.AlarmAnalysisNuclideAvgMapper;
|
||||
import org.jeecg.modules.service.IAlarmAnalysisNuclideAvgService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
@ -9,7 +14,10 @@ import org.springframework.stereotype.Service;
|
|||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
@Service
|
||||
|
@ -24,4 +32,19 @@ public class AlarmAnalysisNuclideAvgServiceImpl extends ServiceImpl<AlarmAnalysi
|
|||
wrapper.in(AlarmAnalysisNuclideAvg::getNuclide,nuclideNames);
|
||||
return list(wrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<NuclideAvgDto> findPage(NuclideAvgVo nuclideAvgVo) {
|
||||
Integer pageNo = nuclideAvgVo.getPageNo();
|
||||
Integer pageSize = nuclideAvgVo.getPageSize();
|
||||
int pageStart = (pageNo - 1) * pageSize;
|
||||
nuclideAvgVo.setPageStart(pageStart);
|
||||
Map<String, Object> params = BeanUtil.beanToMap(nuclideAvgVo);
|
||||
List<NuclideAvgDto> records = baseMapper.findPage(params);
|
||||
params.put("pageFlag","noPage");
|
||||
int total = baseMapper.findPage(params).size();
|
||||
Page<NuclideAvgDto> page = new Page<>(pageNo,pageSize,total);
|
||||
page.setRecords(records);
|
||||
return page;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,4 +28,9 @@ public class AlarmAnalysisNuclideParamServiceImpl extends ServiceImpl<AlarmAnaly
|
|||
BeanUtil.copyProperties(getLatest(),nuclideParam,options);
|
||||
return save(nuclideParam);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean update(AlarmAnalysisNuclideParam nuclideParam) {
|
||||
return updateById(nuclideParam);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.common.constant.DateConstant;
|
||||
import org.jeecg.common.constant.Prompt;
|
||||
import org.jeecg.modules.base.dto.TypeDto;
|
||||
import org.jeecg.modules.base.entity.postgre.AlarmLog;
|
||||
import org.jeecg.modules.entity.AlarmHistory;
|
||||
|
@ -34,18 +35,17 @@ public class AlarmLogServiceImpl extends ServiceImpl<AlarmLogMapper, AlarmLog> i
|
|||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Result viewAll(AlarmVo alarmVo) {
|
||||
public Result<?> viewAll(AlarmVo alarmVo) {
|
||||
String startDate = alarmVo.getStartDate();
|
||||
String endDate = alarmVo.getEndDate();
|
||||
boolean startNotBlank = StrUtil.isNotBlank(startDate);
|
||||
boolean endtNotBlank = StrUtil.isNotBlank(endDate);
|
||||
// 拼接日期为合理的日期+时间范围
|
||||
alarmVo.setStartDate(startDate + " 00:00:00");
|
||||
alarmVo.setEndDate(endDate + " 23:59:59");
|
||||
alarmVo.setStartDate(startDate + DateConstant.TIME_START);
|
||||
alarmVo.setEndDate(endDate + DateConstant.TIME_END);
|
||||
// 定义返回结果
|
||||
Set<String> xData = new HashSet<>();
|
||||
Collection<Integer> yData = new ArrayList<>();
|
||||
Map<String,Integer> statistic = new TreeMap<>();
|
||||
Collection<Long> yData = new ArrayList<>();
|
||||
Map<String,Object> result = new HashMap<>();
|
||||
// 转换参数 数据查询
|
||||
Map<String, Object> params = BeanUtil.beanToMap(alarmVo);
|
||||
|
@ -57,18 +57,13 @@ public class AlarmLogServiceImpl extends ServiceImpl<AlarmLogMapper, AlarmLog> i
|
|||
return Result.OK(result);
|
||||
}
|
||||
// 分情况处理 1.按小时统计 2.按天统计
|
||||
|
||||
/* 1.选择日期为同一天 按照小时划分 0-23小时 */
|
||||
if (startDate.equals(endDate)){
|
||||
Map<Integer, List<LocalDateTime>> groupTime = allDate.stream()
|
||||
.collect(Collectors.groupingBy(LocalDateTime::getHour));
|
||||
for (int i = 0; i < 24; i++) {
|
||||
if(groupTime.containsKey(i)){
|
||||
Integer count = groupTime.get(i).size();
|
||||
statistic.put(timeStr(i),count);
|
||||
}else {
|
||||
statistic.put(timeStr(i),0);
|
||||
}
|
||||
if (StrUtil.equals(startDate,endDate)){
|
||||
Map<String, Long> statistic = allDate.stream()
|
||||
.collect(Collectors.groupingBy(dateTime -> String.format("%02d:00",dateTime.getHour()),
|
||||
TreeMap::new,Collectors.counting()));
|
||||
for (int hour = 0; hour < 24; hour++) {
|
||||
statistic.putIfAbsent(String.format("%02d:00",hour),0L);
|
||||
}
|
||||
// 返回x轴和y轴数据
|
||||
xData = statistic.keySet();
|
||||
|
@ -82,21 +77,16 @@ public class AlarmLogServiceImpl extends ServiceImpl<AlarmLogMapper, AlarmLog> i
|
|||
else {
|
||||
// 通过年月日进行分组 例:2023-06-06
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ISO_LOCAL_DATE;
|
||||
Map<String, List<LocalDateTime>> group = allDate.stream()
|
||||
.collect(Collectors.groupingBy(datetime -> datetime.format(formatter)));
|
||||
|
||||
Map<String, Long> statistic = allDate.stream()
|
||||
.collect(Collectors.groupingBy(datetime -> datetime.format(formatter),
|
||||
TreeMap::new,Collectors.counting()));
|
||||
// 列举startDate和endDate之间所有日期(已考虑闰年情况)
|
||||
// 没有报警日志的日期,对应的值设置为0
|
||||
LocalDate start = LocalDate.parse(startDate);
|
||||
LocalDate end = LocalDate.parse(endDate);
|
||||
while (!start.isAfter(end)) {
|
||||
String key = start.format(formatter);
|
||||
if (group.containsKey(key)){
|
||||
Integer count = group.get(key).size();
|
||||
statistic.put(key,count);
|
||||
}else {
|
||||
statistic.put(key,0);
|
||||
}
|
||||
String date = start.format(formatter);
|
||||
statistic.putIfAbsent(date,0L);
|
||||
start = start.plusDays(1);
|
||||
}
|
||||
// 返回x轴和y轴数据
|
||||
|
@ -114,7 +104,7 @@ public class AlarmLogServiceImpl extends ServiceImpl<AlarmLogMapper, AlarmLog> i
|
|||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Result findPage(AlarmVo alarmVo) {
|
||||
public Result<?> findPage(AlarmVo alarmVo) {
|
||||
Integer pageNo = alarmVo.getPageNo();
|
||||
Integer pageSize = alarmVo.getPageSize();
|
||||
String startDate = alarmVo.getStartDate();
|
||||
|
@ -141,19 +131,19 @@ public class AlarmLogServiceImpl extends ServiceImpl<AlarmLogMapper, AlarmLog> i
|
|||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Result typeAlarms(AlarmVo alarmVo) {
|
||||
public Result<?> typeAlarms(AlarmVo alarmVo) {
|
||||
/* 饼图数据 */
|
||||
String startDate = alarmVo.getStartDate();
|
||||
String endDate = alarmVo.getEndDate();
|
||||
boolean startNotBlank = StrUtil.isNotBlank(startDate);
|
||||
boolean endtNotBlank = StrUtil.isNotBlank(endDate);
|
||||
if (startNotBlank) alarmVo.setStartDate(startDate +" 00:00:00");
|
||||
if (endtNotBlank)alarmVo.setEndDate(endDate +" 23:59:59");
|
||||
if (startNotBlank) alarmVo.setStartDate(startDate + DateConstant.TIME_START);
|
||||
if (endtNotBlank)alarmVo.setEndDate(endDate + DateConstant.TIME_END);
|
||||
// 警报类型-警报数
|
||||
Map<String, Object> params = BeanUtil.beanToMap(alarmVo);
|
||||
List<TypeDto> typeAlarms = baseMapper.typeAlarms(params);
|
||||
// 警报总数
|
||||
Integer total = typeAlarms.stream().mapToInt(TypeDto::getValue).sum();
|
||||
Long total = typeAlarms.stream().mapToLong(TypeDto::getValue).sum();
|
||||
Map<String,Object> result = new HashMap<>();
|
||||
result.put("pieData",typeAlarms);
|
||||
result.put("pieTotal",total);
|
||||
|
@ -165,24 +155,20 @@ public class AlarmLogServiceImpl extends ServiceImpl<AlarmLogMapper, AlarmLog> i
|
|||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Result ruleTop5(AlarmVo alarmVo) {
|
||||
public Result<?> ruleTop5(AlarmVo alarmVo) {
|
||||
/* 柱状图数据 */
|
||||
String startDate = alarmVo.getStartDate();
|
||||
String endDate = alarmVo.getEndDate();
|
||||
boolean startNotBlank = StrUtil.isNotBlank(startDate);
|
||||
boolean endtNotBlank = StrUtil.isNotBlank(endDate);
|
||||
if (startNotBlank) alarmVo.setStartDate(startDate +" 00:00:00");
|
||||
if (endtNotBlank)alarmVo.setEndDate(endDate +" 23:59:59");
|
||||
if (startNotBlank) alarmVo.setStartDate(startDate + DateConstant.TIME_START);
|
||||
if (endtNotBlank)alarmVo.setEndDate(endDate + DateConstant.TIME_END);
|
||||
Map<String, Object> params = BeanUtil.beanToMap(alarmVo);
|
||||
List<TypeDto> ruleTop5 = baseMapper.ruleTop5(params);
|
||||
// x轴数据
|
||||
List<String> xData = ruleTop5.stream()
|
||||
.map(TypeDto::getName)
|
||||
.collect(Collectors.toList());
|
||||
List<String> xData = ruleTop5.stream().map(TypeDto::getName).collect(Collectors.toList());
|
||||
// y轴数据
|
||||
List<Integer> yData = ruleTop5.stream()
|
||||
.map(TypeDto::getValue)
|
||||
.collect(Collectors.toList());
|
||||
List<Long> yData = ruleTop5.stream().map(TypeDto::getValue).collect(Collectors.toList());
|
||||
Map<String,Object> result = new HashMap<>();
|
||||
result.put("xData",xData);
|
||||
result.put("yData",yData);
|
||||
|
@ -190,68 +176,41 @@ public class AlarmLogServiceImpl extends ServiceImpl<AlarmLogMapper, AlarmLog> i
|
|||
}
|
||||
|
||||
@Override
|
||||
public Result findInfo(String id) {
|
||||
Result result = new Result();
|
||||
LambdaQueryWrapper<AlarmLog> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(AlarmLog::getId, id);
|
||||
AlarmLog alarmLog = this.baseMapper.selectOne(queryWrapper);
|
||||
if (Objects.isNull(alarmLog)){
|
||||
result.error500("当前查询数据不存在");
|
||||
return result;
|
||||
}
|
||||
result.setSuccess(true);
|
||||
result.setResult(alarmLog);
|
||||
return result;
|
||||
public Result<?> findInfo(String id) {
|
||||
return Result.OK(getById(id));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result create(AlarmLog alarmLog) {
|
||||
Result result = new Result();
|
||||
Long id = IdWorker.getId();
|
||||
alarmLog.setId(id.toString());
|
||||
if (StringUtils.isNotBlank(alarmLog.getAlarmInfo())){
|
||||
String jsonString = JSON.toJSONString(alarmLog.getAlarmInfo());
|
||||
public Result<?> create(AlarmLog alarmLog) {
|
||||
String alarmInfo = alarmLog.getAlarmInfo();
|
||||
if (StrUtil.isNotBlank(alarmInfo)){
|
||||
String jsonString = JSON.toJSONString(alarmInfo);
|
||||
alarmLog.setAlarmInfo(jsonString);
|
||||
}
|
||||
this.baseMapper.insert(alarmLog);
|
||||
result.setSuccess(true);
|
||||
result.success("新增成功");
|
||||
return result;
|
||||
boolean success = save(alarmLog);
|
||||
if (success)
|
||||
return Result.OK(Prompt.ADD_SUCC);
|
||||
return Result.error(Prompt.ADD_ERR);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result update(AlarmLog alarmLog) {
|
||||
Result result = new Result();
|
||||
LambdaQueryWrapper<AlarmLog> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(AlarmLog::getId, alarmLog.getId());
|
||||
AlarmLog log = this.baseMapper.selectOne(queryWrapper);
|
||||
if (Objects.isNull(log)){
|
||||
result.error500("对应数据不存在,修改失败");
|
||||
return result;
|
||||
}
|
||||
if (StringUtils.isNotBlank(alarmLog.getAlarmInfo())){
|
||||
String jsonString = JSON.toJSONString(alarmLog.getAlarmInfo());
|
||||
public Result<?> update(AlarmLog alarmLog) {
|
||||
String alarmInfo = alarmLog.getAlarmInfo();
|
||||
if (StrUtil.isNotBlank(alarmInfo)){
|
||||
String jsonString = JSON.toJSONString(alarmInfo);
|
||||
alarmLog.setAlarmInfo(jsonString);
|
||||
}
|
||||
this.baseMapper.updateById(alarmLog);
|
||||
result.setSuccess(true);
|
||||
result.success("修改成功");
|
||||
return result;
|
||||
boolean success = updateById(alarmLog);
|
||||
if (success)
|
||||
return Result.OK(Prompt.UPDATE_SUCC);
|
||||
return Result.error(Prompt.UPDATE_ERR);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result deleteById(String id) {
|
||||
Result result = new Result();
|
||||
this.baseMapper.deleteById(id);
|
||||
result.setSuccess(true);
|
||||
result.success("删除成功");
|
||||
return result;
|
||||
}
|
||||
|
||||
private String timeStr(Integer time){
|
||||
if (time < 10){
|
||||
return "0" + time + ":00";
|
||||
}
|
||||
return time + ":00";
|
||||
public Result<?> deleteById(String id) {
|
||||
boolean success = removeById(id);
|
||||
if (success)
|
||||
return Result.OK(Prompt.DELETE_SUCC);
|
||||
return Result.error(Prompt.DELETE_ERR);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
package org.jeecg.modules.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.collection.ListUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.common.constant.DateConstant;
|
||||
import org.jeecg.modules.base.entity.postgre.SysEmailLog;
|
||||
import org.jeecg.modules.mapper.SysEmailLogMapper;
|
||||
import org.jeecg.modules.service.ISysEmailLogService;
|
||||
|
@ -11,10 +13,13 @@ import org.springframework.stereotype.Service;
|
|||
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalTime;
|
||||
import java.time.ZoneId;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
@Service("sysEmailLogService")
|
||||
public class SysEmailLogServiceImpl extends ServiceImpl<SysEmailLogMapper, SysEmailLog> implements ISysEmailLogService {
|
||||
|
@ -25,23 +30,23 @@ public class SysEmailLogServiceImpl extends ServiceImpl<SysEmailLogMapper, SysEm
|
|||
LambdaQueryWrapper<SysEmailLog> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(SysEmailLog::getEmailId,emailId);
|
||||
LocalDate today = LocalDate.now();
|
||||
String todayStart = today + " 00:00:00";
|
||||
String todayEnd = today + " 23:59:59";
|
||||
String todayStart = today + DateConstant.TIME_START;
|
||||
String todayEnd = today + DateConstant.TIME_END;
|
||||
wrapper.between(SysEmailLog::getReceiveTime,todayStart,todayEnd);
|
||||
Long todayCount = this.count(wrapper);
|
||||
// 昨日邮件量
|
||||
wrapper.clear();
|
||||
wrapper.eq(SysEmailLog::getEmailId,emailId);
|
||||
LocalDate yesterday = LocalDate.now().minusDays(1);
|
||||
String yesterdayStart = yesterday + " 00:00:00";
|
||||
String yesterdayEnd = yesterday + " 23:59:59";
|
||||
String yesterdayStart = yesterday + DateConstant.TIME_START;
|
||||
String yesterdayEnd = yesterday + DateConstant.TIME_END;
|
||||
wrapper.between(SysEmailLog::getReceiveTime,yesterdayStart,yesterdayEnd);
|
||||
Long yesterdayCount = this.count(wrapper);
|
||||
// 过去一周邮件量
|
||||
wrapper.clear();
|
||||
wrapper.eq(SysEmailLog::getEmailId,emailId);
|
||||
LocalDate passWeek = LocalDate.now().minusWeeks(1);
|
||||
String weekStart = passWeek + " 00:00:00";
|
||||
String weekStart = passWeek + DateConstant.TIME_START;
|
||||
wrapper.between(SysEmailLog::getReceiveTime,weekStart,todayEnd);
|
||||
Long weekCount = this.count(wrapper);
|
||||
|
||||
|
@ -53,36 +58,57 @@ public class SysEmailLogServiceImpl extends ServiceImpl<SysEmailLogMapper, SysEm
|
|||
}
|
||||
|
||||
@Override
|
||||
public Result today(String emailId) {
|
||||
public Result todayHour(String emailId) {
|
||||
LambdaQueryWrapper<SysEmailLog> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(SysEmailLog::getEmailId,emailId);
|
||||
LocalDate today = LocalDate.now();
|
||||
String todayStart = today + " 00:00:00";
|
||||
String todayEnd = today + " 23:59:59";
|
||||
String todayStart = today + DateConstant.TIME_START;
|
||||
String todayEnd = today + DateConstant.TIME_END;
|
||||
wrapper.between(SysEmailLog::getReceiveTime,todayStart,todayEnd);
|
||||
List<SysEmailLog> emailLogs = this.list(wrapper);
|
||||
// 将Date转换为LocalDateTime
|
||||
List<Date> allDate = emailLogs.stream()
|
||||
List<LocalDateTime> 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();
|
||||
})
|
||||
return item.toInstant().atZone(zoneId).toLocalDateTime();})
|
||||
.collect(Collectors.toList());
|
||||
// 按照小时分组
|
||||
Map<String,Integer> statistic = new TreeMap<>();
|
||||
Map<Integer, List<LocalDateTime>> groupTime = allTime.stream()
|
||||
.collect(Collectors.groupingBy(LocalDateTime::getHour));
|
||||
for (int i = 0; i < 24; i++) {
|
||||
if(groupTime.containsKey(i)){
|
||||
Integer count = groupTime.get(i).size();
|
||||
statistic.put(timeStr(i),count);
|
||||
}else {
|
||||
statistic.put(timeStr(i),0);
|
||||
Map<String, Long> statistic = allDate.stream()
|
||||
.map(dateTime -> String.format("%02d:00",dateTime.getHour()))
|
||||
.collect(Collectors.groupingBy(time -> time,TreeMap::new,Collectors.counting()));
|
||||
for (int hour = 0; hour < 24; hour++) {
|
||||
String time = String.format("%02d:00",hour);
|
||||
statistic.putIfAbsent(time,0L);
|
||||
}
|
||||
return Result.OK(statistic);
|
||||
}
|
||||
|
||||
public Result todayMin(String emailId) {
|
||||
LambdaQueryWrapper<SysEmailLog> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(SysEmailLog::getEmailId,emailId);
|
||||
LocalDate today = LocalDate.now();
|
||||
String todayStart = today + DateConstant.TIME_START;
|
||||
String todayEnd = today + DateConstant.TIME_END;
|
||||
wrapper.between(SysEmailLog::getReceiveTime,todayStart,todayEnd);
|
||||
List<SysEmailLog> emailLogs = this.list(wrapper);
|
||||
// 将Date转换为LocalDateTime
|
||||
List<LocalDateTime> allDate = emailLogs.stream()
|
||||
.map(SysEmailLog::getReceiveTime)
|
||||
.map(item -> {
|
||||
ZoneId zoneId = ZoneId.systemDefault();
|
||||
return item.toInstant().atZone(zoneId).toLocalDateTime();})
|
||||
.collect(Collectors.toList());
|
||||
// 按照小时和分钟分组
|
||||
// 将 LocalDateTime 转换为 HH:mm 格式的字符串,并进行分组统计
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("HH:mm");
|
||||
Map<String, Long> statistic = allDate.stream()
|
||||
.map(dateTime -> dateTime.format(formatter))
|
||||
.collect(Collectors.groupingBy(time -> time, TreeMap::new, Collectors.counting()));
|
||||
for (int hour = 0; hour < 24; hour++) {
|
||||
for (int minute = 0; minute < 60; minute++) {
|
||||
String time = String.format("%02d:%02d", hour, minute);
|
||||
statistic.putIfAbsent(time,0L);
|
||||
}
|
||||
}
|
||||
return Result.OK(statistic);
|
||||
|
@ -90,25 +116,19 @@ public class SysEmailLogServiceImpl extends ServiceImpl<SysEmailLogMapper, SysEm
|
|||
|
||||
@Override
|
||||
public Result analysis(String emailId, String startDate, String endDate) {
|
||||
String startStr = startDate + " 00:00:00";
|
||||
String endStr = endDate + " 23:59:59";
|
||||
String startStr = startDate + DateConstant.TIME_START;
|
||||
String endStr = endDate + DateConstant.TIME_END;
|
||||
LambdaQueryWrapper<SysEmailLog> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(SysEmailLog::getEmailId,emailId);
|
||||
wrapper.between(SysEmailLog::getReceiveTime,startStr,endStr);
|
||||
Set<String> xData = new HashSet<>();
|
||||
Collection<Integer> yData = new ArrayList<>();
|
||||
Map<String,Integer> statistic = new TreeMap<>();
|
||||
Collection<Long> yData = new ArrayList<>();
|
||||
Map<String,Object> result = new HashMap<>();
|
||||
List<Date> allDate = this.listObjs(wrapper,
|
||||
emailLog -> ((SysEmailLog) emailLog).getReceiveTime());
|
||||
// 将Date转换为LocalDateTime
|
||||
List<LocalDateTime> allTime = allDate.stream()
|
||||
List<LocalDateTime> allDate = this.list(wrapper).stream()
|
||||
.map(SysEmailLog::getReceiveTime)
|
||||
.map(item -> {
|
||||
ZoneId zoneId = ZoneId.systemDefault();
|
||||
return item.toInstant()
|
||||
.atZone(zoneId)
|
||||
.toLocalDateTime();
|
||||
})
|
||||
return item.toInstant().atZone(zoneId).toLocalDateTime();})
|
||||
.collect(Collectors.toList());
|
||||
if (CollUtil.isEmpty(allDate)){
|
||||
result.put("xData",xData);
|
||||
|
@ -119,21 +139,17 @@ public class SysEmailLogServiceImpl extends ServiceImpl<SysEmailLogMapper, SysEm
|
|||
/* 支持跨年跨月选择 */
|
||||
// 通过年月日进行分组 例:2023-06-06
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ISO_LOCAL_DATE;
|
||||
Map<String, List<LocalDateTime>> group = allTime.stream()
|
||||
.collect(Collectors.groupingBy(datetime -> datetime.format(formatter)));
|
||||
Map<String, Long> statistic = allDate.stream()
|
||||
.collect(Collectors.groupingBy(datetime -> datetime.format(formatter),
|
||||
TreeMap::new,Collectors.counting()));
|
||||
|
||||
// 列举出startDate-endDate中所有日期(包括闰年)
|
||||
// 没有邮件的日期,对应的值设置为0
|
||||
LocalDate start = LocalDate.parse(startDate);
|
||||
LocalDate end = LocalDate.parse(endDate);
|
||||
while (!start.isAfter(end)) {
|
||||
String key = start.format(formatter);
|
||||
if (group.containsKey(key)){
|
||||
Integer count = group.get(key).size();
|
||||
statistic.put(key,count);
|
||||
}else {
|
||||
statistic.put(key,0);
|
||||
}
|
||||
String date = start.format(formatter);
|
||||
statistic.putIfAbsent(date,0L);
|
||||
start = start.plusDays(1);
|
||||
}
|
||||
// 返回结果
|
||||
|
@ -143,11 +159,4 @@ public class SysEmailLogServiceImpl extends ServiceImpl<SysEmailLogMapper, SysEm
|
|||
result.put("yData",yData);
|
||||
return Result.OK(result);
|
||||
}
|
||||
|
||||
private String timeStr(Integer time){
|
||||
if (time < 10){
|
||||
return "0" + time + ":00";
|
||||
}
|
||||
return time + ":00";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -157,8 +157,10 @@ public class SysEmailServiceImpl extends ServiceImpl<SysEmailMapper, SysEmail> i
|
|||
@Override
|
||||
public List<SourceDto> listAll() {
|
||||
LambdaQueryWrapper<SysEmail> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.orderByDesc(SysEmail::getEnabled);
|
||||
wrapper.orderByAsc(SysEmail::getName);
|
||||
List<SourceDto> sourceDtos = new ArrayList<>();
|
||||
for (SysEmail sysEmail : list()) {
|
||||
for (SysEmail sysEmail : list(wrapper)) {
|
||||
SourceDto sourceDto = new SourceDto();
|
||||
sourceDto.setSourceId(sysEmail.getId());
|
||||
sourceDto.setSourceName(sysEmail.getName());
|
||||
|
|
|
@ -13,7 +13,9 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/gardsStations")
|
||||
|
@ -98,4 +100,10 @@ public class GardsStationsController {
|
|||
public List<String> getCodes(@RequestParam String stationIds){
|
||||
return gardsStationsService.getCodeByIds(stationIds);
|
||||
}
|
||||
|
||||
@GetMapping("getCodesMap")
|
||||
@ApiOperation(value = "获取台站CodeMap", notes = "获取台站CodeMap")
|
||||
public Map<String,String> getCodesMap(@RequestParam Collection<String> stationIds){
|
||||
return gardsStationsService.getCodeMap(stationIds);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ import com.google.common.collect.Lists;
|
|||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.shiro.authz.annotation.RequiresRoles;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.common.aspect.annotation.AutoLog;
|
||||
import org.jeecg.common.exception.JeecgBootException;
|
||||
|
@ -28,41 +29,26 @@ import java.util.List;
|
|||
@RequestMapping("/sys/defaultNuclide")
|
||||
public class SysDefaultNuclideController extends JeecgController<SysDefaultNuclide, ISysDefaultNuclideService> {
|
||||
|
||||
@Autowired
|
||||
private ISysDefaultNuclideService sysDefaultNuclideService;
|
||||
|
||||
@ApiOperation(value = "核素配置信息分页查询", notes = "核素配置信息分页查询")
|
||||
@RequiresRoles("admin")
|
||||
@GetMapping(value = "/findPage")
|
||||
public Result<?> findPage(@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
|
||||
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
|
||||
@RequestParam Integer useType) {
|
||||
Result<IPage<SysDefaultNuclide>> iPageResult = sysDefaultNuclideService.queryNuclideByType(pageNo, pageSize, useType);
|
||||
return Result.ok(iPageResult);
|
||||
return service.queryNuclideByType(pageNo, pageSize, useType);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "核素名称列表", notes = "核素名称列表")
|
||||
@GetMapping(value = "/allName")
|
||||
public Result<?> allName(@RequestParam Integer useType) {
|
||||
return sysDefaultNuclideService.allName(useType);
|
||||
return service.allName(useType);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ApiOperation(value = "添加核素配置信息", notes = "核素默认配置-添加添加核素配置信息")
|
||||
@ApiOperation(value = "添加核素配置信息", notes = "添加添加核素配置信息")
|
||||
@RequiresRoles("admin")
|
||||
@PostMapping(value = "/add")
|
||||
public Result<?> add() {
|
||||
String path = "/Users/later/Library/Containers/com.tencent.xinWeChat/Data/Library/Application Support/com.tencent.xinWeChat/2.0b4.0.9/1cbf41e7428fb5b814d0c66ac2155730/Message/MessageTemp/7a75277a2ac9468655241c0718e9804e/OpenData/P_default.nuclide";
|
||||
List<String> strings = FileUtil.readLines(path, "utf-8");
|
||||
List<SysDefaultNuclide> data = Lists.newArrayList();
|
||||
for (String f : strings) {
|
||||
SysDefaultNuclide nuclide = new SysDefaultNuclide();
|
||||
nuclide.setNuclideName(f);
|
||||
nuclide.setNuclideType("G");
|
||||
nuclide.setUseType(2);
|
||||
data.add(nuclide);
|
||||
}
|
||||
sysDefaultNuclideService.saveBatch(data);
|
||||
System.out.println(strings.toString());
|
||||
return null;
|
||||
public Result<?> add(@RequestBody List<SysDefaultNuclide> nuclides) {
|
||||
return service.add(nuclides);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,7 +6,9 @@ import org.jeecg.common.api.QueryRequest;
|
|||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.modules.base.entity.configuration.GardsStations;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface IGardsStationsService extends IService<GardsStations> {
|
||||
|
||||
|
@ -62,4 +64,6 @@ public interface IGardsStationsService extends IService<GardsStations> {
|
|||
List<GardsStations> getGardsStations();
|
||||
|
||||
List<String> getCodeByIds(String stationIds);
|
||||
|
||||
Map<String,String> getCodeMap(Collection<String> stationIds);
|
||||
}
|
||||
|
|
|
@ -19,7 +19,9 @@ public interface ISysDefaultNuclideService extends IService<SysDefaultNuclide> {
|
|||
* @return
|
||||
*/
|
||||
|
||||
Result<IPage<SysDefaultNuclide>> queryNuclideByType(Integer pageNo, Integer pageSize, Integer useType);
|
||||
Result<?> queryNuclideByType(Integer pageNo, Integer pageSize, Integer useType);
|
||||
|
||||
Result<?> allName(Integer useType);
|
||||
|
||||
Result<?> add(List<SysDefaultNuclide> nuclides);
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@ import org.springframework.transaction.annotation.Propagation;
|
|||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service("gardsStationsService")
|
||||
|
@ -206,4 +207,26 @@ public class GardsStationsServiceImpl extends ServiceImpl<GardsStationsMapper, G
|
|||
}
|
||||
return stationCodes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String> getCodeMap(Collection<String> stationIds) {
|
||||
Map<String, String> stationCodeMap;
|
||||
Map<String, String> result = new HashMap<>();
|
||||
String key = RedisConstant.STATION_CODE_MAP;
|
||||
if (redisUtil.hasKey(key)){
|
||||
stationCodeMap = (Map<String, String>) redisUtil.get(key);
|
||||
}else {
|
||||
List<GardsStations> gardsStations = list();
|
||||
stationCodeMap = gardsStations.stream().collect(Collectors.toMap(
|
||||
station -> String.valueOf(station.getStationId()),
|
||||
GardsStations::getStationCode));
|
||||
redisUtil.set(key,stationCodeMap);
|
||||
}
|
||||
String defaultV = "404";
|
||||
for (String stationId : stationIds) {
|
||||
String stationCode = stationCodeMap.getOrDefault(stationId, defaultV);
|
||||
result.put(stationId,stationCode);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,15 +1,20 @@
|
|||
package org.jeecg.modules.system.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.collection.ListUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.common.constant.Prompt;
|
||||
import org.jeecg.modules.base.entity.postgre.SysDefaultNuclide;
|
||||
import org.jeecg.modules.system.mapper.SysDefaultNuclideMapper;
|
||||
import org.jeecg.modules.system.service.ISysDefaultNuclideService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
@ -18,24 +23,38 @@ import java.util.stream.Collectors;
|
|||
public class SysDefaultNuclideServiceImpl extends ServiceImpl<SysDefaultNuclideMapper, SysDefaultNuclide> implements ISysDefaultNuclideService {
|
||||
|
||||
@Override
|
||||
public Result<IPage<SysDefaultNuclide>> queryNuclideByType(Integer pageNo, Integer pageSize, Integer useType) {
|
||||
Result<IPage<SysDefaultNuclide>> result = new Result<>();
|
||||
public Result<?> queryNuclideByType(Integer pageNo, Integer pageSize, Integer useType) {
|
||||
Page<SysDefaultNuclide> page = new Page<>(pageNo, pageSize);
|
||||
LambdaQueryWrapper<SysDefaultNuclide> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(null != useType, SysDefaultNuclide::getUseType, useType);
|
||||
IPage<SysDefaultNuclide> pageList = this.page(page, queryWrapper);
|
||||
result.setSuccess(true);
|
||||
result.setResult(pageList);
|
||||
return result;
|
||||
IPage<SysDefaultNuclide> result = this.page(page, queryWrapper);
|
||||
return Result.OK(result);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result<?> allName(Integer useType) {
|
||||
LambdaQueryWrapper<SysDefaultNuclide> wrapper = new LambdaQueryWrapper();
|
||||
LambdaQueryWrapper<SysDefaultNuclide> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(SysDefaultNuclide::getUseType,useType);
|
||||
List<String> allName = list(wrapper).stream()
|
||||
.map(SysDefaultNuclide::getNuclideName)
|
||||
.collect(Collectors.toList());
|
||||
return Result.OK(allName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result<?> add(List<SysDefaultNuclide> nuclides) {
|
||||
if (CollUtil.isEmpty(nuclides))
|
||||
return Result.error(Prompt.PARAM_NOT_EMPTY);
|
||||
Integer useType = nuclides.get(0).getUseType();
|
||||
List<Integer> type = ListUtil.toList(1, 2);
|
||||
if (ObjectUtil.isNotNull(useType) && type.contains(useType)){
|
||||
LambdaQueryWrapper<SysDefaultNuclide> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(SysDefaultNuclide::getUseType,useType);
|
||||
remove(wrapper);
|
||||
}
|
||||
boolean success = saveBatch(nuclides);
|
||||
if (success)
|
||||
return Result.OK(Prompt.ADD_SUCC);
|
||||
return Result.error(Prompt.ADD_ERR);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user