fix:增加新谱DOS web模块

This commit is contained in:
xiaoguangbin 2024-10-10 20:14:29 +08:00
parent 717f758595
commit 76e07badd5
5 changed files with 270 additions and 0 deletions

View File

@ -9,6 +9,7 @@ import org.jeecg.common.constant.Prompt;
import org.jeecg.common.util.ReadLineUtil;
import org.jeecg.modules.base.entity.configuration.GardsStations;
import org.jeecg.modules.base.enums.PageType;
import org.jeecg.modules.entity.GardsDosDataWeb;
import org.jeecg.modules.entity.GardsSampleDataWeb;
import org.jeecg.modules.entity.GardsSohDataWeb;
import org.jeecg.modules.service.*;
@ -45,6 +46,8 @@ public class WebStatisticsController {
@Autowired
private IGardsAlertDataService gardsAlertDataService;
@Autowired
private IGardsDosDataService gardsDosDataService;
@Autowired
private IMenuNameService menuNameService;
@GetMapping("findStationList")
@ -92,6 +95,12 @@ public class WebStatisticsController {
return gardsSohDataService.findAlertSohPage(queryRequest, stationIds, startTime, endTime);
}
@GetMapping("findDosPage")
@ApiOperation(value = "台站溴化镧谱数据分页查询", notes = "台站溴化镧谱数据分页查询")
public Result findDosPage(QueryRequest queryRequest, Integer[] stationIds,@DateTimeFormat(pattern = "yyyy-MM-dd") Date startTime,@DateTimeFormat(pattern = "yyyy-MM-dd") Date endTime){
return gardsDosDataService.findDosPage(queryRequest, stationIds, startTime, endTime);
}
@GetMapping("findGeneratedReport")
@ApiOperation(value = "查询报告详情页面", notes = "查询报告详情页面")
public Result findGeneratedReport(Integer sampleId){
@ -132,6 +141,17 @@ public class WebStatisticsController {
return readLineUtil.readFtpFile(filePath,response);
}
@GetMapping("dosFile")
@ApiOperation(value = "查看RMSDOS的文件",notes = "查看RMSDOS的文件")
public Result dosFile(@RequestParam Integer sohId,
HttpServletResponse response){
GardsDosDataWeb dos = gardsDosDataService.getOneDos(sohId);
String filePath = dos.getInputFileName();
if (StrUtil.isBlank(filePath))
return Result.error(Prompt.FILE_NOT_EXITS);
return readLineUtil.readFtpFile(filePath,response);
}
@GetMapping("arFile")
@ApiOperation(value = "查看ARR/RRR的文件", notes = "查看ARR/RRR的文件")
public Result arFile(@RequestParam String type,
@ -182,6 +202,15 @@ public class WebStatisticsController {
gardsSohDataService.sohExport(stationIds, startTime, endTime, response);
}
@GetMapping("dosExport")
@ApiOperation(value = "导出RMSDOS的Excel",notes = "导出RMSDOS的Excel")
public void dosExport(@RequestParam Integer[] stationIds,
@RequestParam String startTime,
@RequestParam String endTime,
HttpServletResponse response){
gardsDosDataService.dosExport(stationIds, startTime, endTime, response);
}
@GetMapping("metExport")
@ApiOperation(value = "导出Met的Excel",notes = "导出Met的Excel")
public void metExport(@RequestParam Integer[] stationIds,

View File

@ -0,0 +1,37 @@
package org.jeecg.modules.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.jeecg.modules.base.entity.original.GardsDOSData;
import org.jeecg.modules.base.entity.original.GardsSohData;
import org.jeecgframework.poi.excel.annotation.Excel;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
@Data
@TableName(value = "ORIGINAL.GARDS_DOS_DATA")
public class GardsDosDataWeb extends GardsDOSData {
/**
* 探测器名称
*/
@TableField(exist = false)
private String detectorName;
/**
* 结束时间
*/
@TableField(exist = false)
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Excel(name = "START TIME",orderNum = "4",width = 30,format = "yyyy-MM-dd HH:mm:ss")
private Date endTime;
@TableField(exist = false)
@Excel(name = "NO",orderNum = "1")
private Integer no;
}

View File

@ -0,0 +1,8 @@
package org.jeecg.modules.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.jeecg.modules.entity.GardsDosDataWeb;
import org.jeecg.modules.entity.GardsSohDataWeb;
public interface GardsDosDataMapper extends BaseMapper<GardsDosDataWeb> {
}

View File

@ -0,0 +1,38 @@
package org.jeecg.modules.service;
import com.baomidou.mybatisplus.extension.service.IService;
import org.jeecg.common.api.QueryRequest;
import org.jeecg.common.api.vo.Result;
import org.jeecg.modules.entity.GardsDosDataWeb;
import javax.servlet.http.HttpServletResponse;
import java.util.Date;
import java.util.List;
public interface IGardsDosDataService extends IService<GardsDosDataWeb> {
/**
* 分页查询状态数据信息
* @param queryRequest
* @param stationIds
* @param startTime
* @param endTime
* @return
*/
Result findDosPage(QueryRequest queryRequest, Integer[] stationIds, Date startTime, Date endTime);
/**
* 获取单个SOH对象
*
* @param sohId
*/
GardsDosDataWeb getOneDos(Integer sohId);
void dosExport(Integer[] stationIds,
String startTime,
String endTime,
HttpServletResponse response);
List<GardsDosDataWeb> queryByModDate(Date startTime, Date endTime);
}

View File

@ -0,0 +1,158 @@
package org.jeecg.modules.service.impl;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ArrayUtil;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.poi.ss.usermodel.Workbook;
import org.jeecg.common.api.QueryRequest;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.util.DateUtils;
import org.jeecg.common.util.ExportUtil;
import org.jeecg.common.util.RedisUtil;
import org.jeecg.modules.entity.GardsDosDataWeb;
import org.jeecg.modules.feignclient.SystemClient;
import org.jeecg.modules.mapper.GardsDosDataMapper;
import org.jeecg.modules.service.IGardsDosDataService;
import org.jeecgframework.poi.excel.ExcelExportUtil;
import org.jeecgframework.poi.excel.entity.ExportParams;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.OutputStream;
import java.text.ParseException;
import java.util.*;
@Service("gardsDosDataService")
@DS("ora")
public class GardsDosDataServiceImpl extends ServiceImpl<GardsDosDataMapper, GardsDosDataWeb> implements IGardsDosDataService {
@Autowired
private RedisUtil redisUtil;
@Override
public Result findDosPage(QueryRequest queryRequest, Integer[] stationIds, Date startTime, Date endTime) {
try {
Result result = new Result();
if (Objects.isNull(stationIds)){
result.setResult(Collections.emptyList());
return result;
}
if (Objects.isNull(startTime)){
result.error500("The start time cannot be empty");
return result;
}
if (Objects.isNull(endTime)){
result.error500("The end time cannot be empty");
return result;
}
Date startDate = DateUtils.parseDate(DateUtils.formatDate(startTime, "yyyy-MM-dd") + " 00:00:00", "yyyy-MM-dd HH:mm:ss");
Date endDate = DateUtils.parseDate(DateUtils.formatDate(endTime, "yyyy-MM-dd") + " 23:59:59", "yyyy-MM-dd HH:mm:ss");
//获取redis中缓存的探测器信息
Map<Integer, String> detectorsMap = (Map<Integer, String>)redisUtil.get("detectorsMap");
Page<GardsDosDataWeb> page = new Page<>(queryRequest.getPageNo(), queryRequest.getPageSize());
LambdaQueryWrapper<GardsDosDataWeb> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.in(GardsDosDataWeb::getStationId, stationIds);
queryWrapper.ge(GardsDosDataWeb::getStartTime, startDate);
queryWrapper.le(GardsDosDataWeb::getStartTime, endDate);
queryWrapper.orderByDesc(GardsDosDataWeb::getStartTime);
Page<GardsDosDataWeb> dosDataPage = this.baseMapper.selectPage(page, queryWrapper);
dosDataPage.getRecords().forEach(item->{
if (Objects.nonNull(item.getDetectorId()) && detectorsMap.containsKey(item.getDetectorId().toString())) {
String detectorName = detectorsMap.get(item.getDetectorId().toString());
item.setDetectorName(detectorName);
}
if (Objects.nonNull(item.getStartTime())) {
long endSecond = (item.getStartTime().getTime() / 1000) + Math.round(item.getTime());
Date endDateTime = new Date();
endDateTime.setTime(endSecond*1000);
item.setEndTime(endDateTime);
}
});
result.setSuccess(true);
result.setResult(dosDataPage);
return result;
} catch (ParseException e) {
throw new RuntimeException(e);
}
}
@Override
public GardsDosDataWeb getOneDos(Integer dosId) {
LambdaQueryWrapper<GardsDosDataWeb> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(GardsDosDataWeb::getDosId,dosId);
return Optional.ofNullable(getOne(wrapper))
.orElse(new GardsDosDataWeb());
}
@Override
public void dosExport(Integer[] stationIds,
String startTime,
String endTime,
HttpServletResponse response) {
if (ArrayUtil.isEmpty(stationIds)) return;
Date startDate = DateUtil
.parse(startTime + " 00:00:00", "yyyy-MM-dd HH:mm:ss")
.toJdkDate();
Date endDate = DateUtil
.parse(endTime + " 23:59:59", "yyyy-MM-dd HH:mm:ss")
.toJdkDate();
// 获取redis中缓存的探测器信息
// Map<Integer, String> detectorsMap = (Map<Integer, String>) redisUtil.get("detectorsMap");
LambdaQueryWrapper<GardsDosDataWeb> wrapper = new LambdaQueryWrapper<>();
wrapper.in(GardsDosDataWeb::getStationId, stationIds);
wrapper.ge(GardsDosDataWeb::getStartTime, startDate);
wrapper.le(GardsDosDataWeb::getStartTime, endDate);
List<GardsDosDataWeb> dosData = this.list(wrapper);
int no = 1;
for (GardsDosDataWeb dosDatum : dosData) {
dosDatum.setNo(no++);
Date startT = dosDatum.getStartTime();
if (ObjectUtil.isNotNull(startT)) {
long stratSecod = startT.getTime() / 1000;
long endSecond = stratSecod + Math.round(dosDatum.getTime());
Date endDateTime = new Date(endSecond * 1000);
dosDatum.setEndTime(endDateTime);
}
}
// 导出Excel文件
ExportParams params = new ExportParams();
params.setSheetName("RMSDOS");
Workbook workbook = null;
OutputStream outputStream = null;
try {
// 设置文件名Excel类型(xls|xlsx)
outputStream = ExportUtil.xls(response,"RMSDOS.xls");
workbook = ExcelExportUtil.
exportExcel(params, GardsDosDataWeb.class, dosData);
workbook.write(outputStream);
} catch (IOException e) {
e.printStackTrace();
}finally {
try {
if (ObjectUtil.isNotNull(outputStream))
outputStream.close();
if (ObjectUtil.isNotNull(workbook))
workbook.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
@Override
public List<GardsDosDataWeb> queryByModDate(Date startTime, Date endTime) {
LambdaQueryWrapper<GardsDosDataWeb> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.between(GardsDosDataWeb::getModdate, startTime, endTime);
return list(queryWrapper);
}
}