feat:导出功能完善

This commit is contained in:
nieziyan 2023-07-19 08:50:49 +08:00
parent 4410bf68d3
commit a704571b04
32 changed files with 961 additions and 173 deletions

View File

@ -0,0 +1,41 @@
package org.jeecg.common.util;
import cn.hutool.core.collection.ListUtil;
import cn.hutool.core.util.CharsetUtil;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.OutputStream;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import static com.google.common.net.MediaType.OCTET_STREAM;
public class ExportUtil {
private static final String UTF_8 = StandardCharsets.UTF_8.name();
public static OutputStream xls(HttpServletResponse response,String fileName) throws IOException {
response.setCharacterEncoding(UTF_8);
response.setContentType("application/vnd.ms-excel");
String name = URLEncoder.encode(fileName, UTF_8);
response.setHeader("Content-disposition", "attachment;filename=" + name);
return response.getOutputStream();
}
public static OutputStream xlsx(HttpServletResponse response,String fileName) throws IOException {
response.setCharacterEncoding(UTF_8);
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
String name = URLEncoder.encode(fileName, UTF_8);
response.setHeader("Content-disposition", "attachment;filename=" + name);
return response.getOutputStream();
}
public static OutputStream stream(HttpServletResponse response,String fileName) throws IOException {
response.setCharacterEncoding(UTF_8);
response.setContentType("application/octet-stream");
String name = URLEncoder.encode(fileName, UTF_8);
response.setHeader("Content-disposition", "attachment;filename=" + name);
return response.getOutputStream();
}
}

View File

@ -0,0 +1,51 @@
package org.jeecg.modules.base.dto;
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.GardsSampleData;
import org.jeecgframework.poi.excel.annotation.Excel;
import org.springframework.format.annotation.DateTimeFormat;
import java.io.Serializable;
import java.util.Date;
@Data
public class SampleDataDto implements Serializable {
@Excel(name = "NO" ,orderNum = "1")
private Integer no;
/**
* 台站名称
*/
@Excel(name = "STATION" ,orderNum = "2")
private String stationName;
/**
* 样品采集开始时间
*/
@Excel(name = "START TIME",format = "yyyy-MM-dd HH:mm:ss",orderNum = "3",width = 30)
private Date collectStart;
/**
* 样品采集结束时间
*/
@Excel(name = "STOP TIME",format = "yyyy-MM-dd HH:mm:ss",orderNum = "4",width = 30)
private Date collectStop;
/**
* 样品id
*/
@Excel(name = "SID" ,orderNum = "5")
private Integer sampleId;
public SampleDataDto(GardsSampleData sampleData) {
this.no = sampleData.getNo();
this.stationName = sampleData.getStationName();
this.collectStart = sampleData.getCollectStart();
this.collectStop = sampleData.getCollectStop();
this.sampleId = sampleData.getSampleId();
}
}

View File

@ -4,8 +4,10 @@ import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.jeecgframework.poi.excel.annotation.Excel;
import org.springframework.format.annotation.DateTimeFormat;
import javax.validation.constraints.Email;
import java.io.Serializable;
import java.util.Date;
@ -37,6 +39,7 @@ public class GardsMetData implements Serializable {
@TableField(value = "START_TIME")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Excel(name = "START TIME",orderNum = "2",width = 30,format = "yyyy-MM-dd HH:mm:ss")
private Date startTime;
/**
@ -45,18 +48,21 @@ public class GardsMetData implements Serializable {
@TableField(value = "END_TIME")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Excel(name = "END TIME",orderNum = "3",width = 30,format = "yyyy-MM-dd HH:mm:ss")
private Date endTime;
/**
* 平均湿度
*/
@TableField(value = "AVE_HUMIDITY")
@Excel(name = "AVG.REL.HUMIDITY",orderNum = "5",width = 30)
private Integer aveHumidity;
/**
* 平均温度
*/
@TableField(value = "AVGTEMPERATURE")
@Excel(name = "AVG.TEMP",orderNum = "7",width = 30)
private Integer avgtemperature;
/**
@ -69,18 +75,21 @@ public class GardsMetData implements Serializable {
* 平均风向偏离正北的度数
*/
@TableField(value = "AVE_WIND_DIR")
@Excel(name = "AVG.WIND.DIRECTION",orderNum = "8",width = 30)
private Integer aveWindDir;
/**
* 平均风速m/s
*/
@TableField(value = "AVE_WIND_SPEED")
@Excel(name = "AVG.WIND.SPEED",orderNum = "9",width = 30)
private Integer aveWindSpeed;
/**
* 降雨量mm
*/
@TableField(value = "RAINFALL")
@Excel(name = "RAINFALL", orderNum = "4",width = 20)
private Integer rainfall;
/**
@ -97,4 +106,8 @@ public class GardsMetData implements Serializable {
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date moddate;
@TableField(exist = false)
@Excel(name = "NO",orderNum = "1")
private Integer no;
}

View File

@ -4,6 +4,9 @@ import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.jeecgframework.poi.excel.annotation.Excel;
import org.jeecgframework.poi.excel.annotation.ExcelIgnore;
import org.jeecgframework.poi.excel.annotation.ExcelTarget;
import org.springframework.format.annotation.DateTimeFormat;
import java.io.Serializable;
@ -16,12 +19,14 @@ public class GardsSampleData implements Serializable {
/**
* 探测器编码
*/
@Excel(name = "DETECTOR CODE",orderNum = "3",width = 20)
@TableField(value = "SITE_DET_CODE")
private String siteDetCode;
/**
* 样品id
*/
@TableField(value = "SAMPLE_ID")
private Integer sampleId;
@ -34,12 +39,14 @@ public class GardsSampleData implements Serializable {
/**
* 探测器id
*/
@TableField(value = "DETECTOR_ID")
private Integer detectorId;
/**
* 导入文件名称
*/
@TableField(value = "INPUT_FILE_NAME")
private String inputFileName;
@ -48,6 +55,7 @@ public class GardsSampleData implements Serializable {
* γ-spectrometry or 2-D β-γ coincidence
* detection)
*/
@TableField(value = "SAMPLE_TYPE")
private String sampleType;
@ -59,6 +67,7 @@ public class GardsSampleData implements Serializable {
* CCALIBPHD
* QQCPHD
*/
@TableField(value = "DATA_TYPE")
private String dataType;
@ -71,6 +80,7 @@ public class GardsSampleData implements Serializable {
/**
* 能谱限定符: 过程谱(PREL) 全谱(FULL)
*/
@Excel(name = "SPECTRAL QUALIFIER",orderNum = "4",width = 30)
@TableField(value = "SPECTRAL_QUALIFIE")
private String spectralQualifie;
@ -88,6 +98,7 @@ public class GardsSampleData implements Serializable {
@TableField(value = "COLLECT_START")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@Excel(name = "COLLECTION START TIME",format = "yyyy-MM-dd HH:mm:ss",orderNum = "5",width = 30)
private Date collectStart;
/**
@ -96,6 +107,7 @@ public class GardsSampleData implements Serializable {
@TableField(value = "COLLECT_STOP")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@Excel(name = "COLLECTION STOP TIME",format = "yyyy-MM-dd HH:mm:ss",orderNum = "6",width = 30)
private Date collectStop;
/**
@ -104,6 +116,7 @@ public class GardsSampleData implements Serializable {
@TableField(value = "ACQUISITION_START")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@Excel(name = "ACQUISITION START TIME",format = "yyyy-MM-dd HH:mm:ss",orderNum = "5",width = 30)
private Date acquisitionStart;
/**
@ -112,29 +125,34 @@ public class GardsSampleData implements Serializable {
@TableField(value = "ACQUISITION_STOP")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@Excel(name = "ACQUISITION STOP TIME",format = "yyyy-MM-dd HH:mm:ss",orderNum = "6",width = 30)
private Date acquisitionStop;
/**
* 能谱获取实时间
*/
@TableField(value = "ACQUISITION_REAL_SEC")
private Double acquisitionRealSec;
/**
* 能谱获取活时间
*/
@TableField(value = "ACQUISITION_LIVE_SEC")
private Double acquisitionLiveSec;
/**
* 采样量立方米
*/
@TableField(value = "QUANTITY")
private Double quantity;
/**
* 样品处理状态
*/
@TableField(value = "STATUS")
private String status;
@ -142,6 +160,7 @@ public class GardsSampleData implements Serializable {
* 操作时间
*/
@TableField(value = "MODDATE")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date moddate;
@ -149,6 +168,7 @@ public class GardsSampleData implements Serializable {
* 台站名称
*/
@TableField(exist = false)
@Excel(name = "STATION" ,orderNum = "2")
private String stationName;
/**
@ -159,9 +179,13 @@ public class GardsSampleData implements Serializable {
@TableField(exist = false)
@Excel(name = "CALIB REPORTS" ,orderNum = "7")
private String calibReports;
@TableField(exist = false)
private String dbName;
@TableField(exist = false)
@Excel(name = "NO" ,orderNum = "1")
private Integer no;
}

View File

@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.jeecgframework.poi.excel.annotation.Excel;
import org.springframework.format.annotation.DateTimeFormat;
import java.io.Serializable;
@ -22,6 +23,7 @@ public class GardsSohData implements Serializable {
/**
* 台站代码
*/
@Excel(name = "STATION",orderNum = "2")
@TableField(value = "STATION_CODE")
private String stationCode;
@ -29,6 +31,7 @@ public class GardsSohData implements Serializable {
* 报警ID号
*/
@TableField(value = "SOH_ID")
@Excel(name = "SID",orderNum = "5")
private Integer sohId;
/**
@ -37,6 +40,7 @@ public class GardsSohData implements Serializable {
@TableField(value = "START_TIME")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Excel(name = "START TIME",orderNum = "3",width = 30,format = "yyyy-MM-dd HH:mm:ss")
private Date startTime;
/**
@ -89,6 +93,10 @@ public class GardsSohData implements Serializable {
@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

@ -1,7 +1,8 @@
package org.jeecg.modules.base.enums;
public enum PageType {
ARR("arr"), RRR("rrr");
ARR("arr"), RRR("rrr"),
ACQ("ACQ"), CALIB("CALIB"), COLL("COLL");
private String type;

View File

@ -1,5 +1,6 @@
package org.jeecg.modules.controller;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.jeecg.common.api.QueryRequest;
import org.jeecg.common.api.dto.message.MessageDTO;
@ -17,6 +18,7 @@ import java.util.Map;
@RestController
@RequestMapping("alarmLog")
@Api(value = "报警日志服务", tags = "报警日志服务")
public class AlarmLogController {
@Autowired
@ -67,19 +69,4 @@ 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

@ -1,6 +1,7 @@
package org.jeecg.modules.controller;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.constant.EmailConstant;
import org.jeecg.common.util.RedisStreamUtil;
@ -17,7 +18,7 @@ import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("sysEmailLog")
@Api(value = "邮箱日志", tags = "邮箱日志")
@Api(value = "邮箱日志服务", tags = "邮箱日志服务")
public class SysEmailLogController {
@Autowired
private ISysEmailLogService sysEmailLogService;
@ -25,15 +26,8 @@ public class SysEmailLogController {
@Autowired
private RedisUtil redisUtil;
@Autowired
private RedisStreamUtil redisStreamUtil;
/**
* 邮箱服务器连接状态 正常/断开
*
* @param emailId 电子邮件id
*/
@GetMapping("status")
@ApiOperation("邮箱服务器状态")
public Result status(@RequestParam("emailId") String emailId){
String key = EmailConstant.EMAIL_STATUS_PREFIX;
Boolean emailSatus = (Boolean) redisUtil.hget(key, emailId);
@ -41,49 +35,28 @@ public class SysEmailLogController {
}
@GetMapping("space")
@ApiOperation("邮箱服务器空间")
public Result space(@RequestParam("emailId") String emailId){
return null;
}
/**
* 分别获取今天昨天过去一周邮件量
*
* @param emailId 电子邮件id
*/
@GetMapping("total")
@ApiOperation("今天|昨天|过去一周邮件量")
public Result totalEmail(@RequestParam("emailId") String emailId){
return sysEmailLogService.totalEmail(emailId);
}
/**
* 今天邮件接收量 按小时划分
*
* @param emailId 电子邮件id
*/
@GetMapping("today")
@ApiOperation("今日邮件接收量")
public Result today(@RequestParam("emailId") String emailId){
return sysEmailLogService.today(emailId);
}
/**
* 根据日期筛选(折线图)
*
* @param emailId 电子邮件id
*/
@GetMapping("analysis")
@ApiOperation("根据日期统计-折线图")
public Result analysis(@RequestParam("emailId") String emailId,
@RequestParam("startDate") String startDate,
@RequestParam("endDate") String endDate){
return sysEmailLogService.analysis(emailId, startDate, endDate);
}
@GetMapping("test")
public void test(String groupId){
// sendMessage.send(groupId);
WarnDto warnDto = new WarnDto();
warnDto.setSourceType(SourceType.DATABASE).setValue(80d)
.setSourceId("1").setItem(Item.CPU_UTILIZ);
redisStreamUtil.pushWarn(warnDto);
}
}

View File

@ -0,0 +1,57 @@
package org.jeecg.modules.feignclient;
import org.jeecg.common.api.vo.Result;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.*;
import java.util.Map;
@Component
@FeignClient(name = "monitorClient",url = "${monitor.url}")
public interface MonitorClient {
@GetMapping("list")
Result<?> monList(@RequestParam String code,
@RequestParam String hostId,
@RequestParam Integer pageNo,
@RequestParam Integer pageSize,
@RequestParam String status,
@RequestParam String type);
@GetMapping("log")
Result<?> monLog(@RequestParam String code,
@RequestParam String deviceType,
@RequestParam String end,
@RequestParam Integer pageNo,
@RequestParam Integer pageSize,
@RequestParam String start,
@RequestParam String status);
@GetMapping("log/{hostId}")
Result<?> monOneLog(@PathVariable("hostId") String hostId,
@RequestParam String end,
@RequestParam Integer pageNo,
@RequestParam Integer pageSize,
@RequestParam String start,
@RequestParam String status);
@GetMapping("queryHostDetails")
Result<?> monDetail(@RequestParam String hostId,
@RequestParam String pageName,
@RequestParam String end,
@RequestParam Integer pageNo,
@RequestParam Integer pageSize,
@RequestParam String start);
@GetMapping("queryItemHistory")
Result<?> itemHistory(@RequestParam String end,
@RequestParam String itemId,
@RequestParam Integer itemType,
@RequestParam String start);
@GetMapping("queryItemHistoryData")
Result<?> itemHistoryData(@RequestParam String end,
@RequestParam String itemId,
@RequestParam Integer itemType,
@RequestParam String start);
}

View File

@ -1,5 +1,5 @@
#code_generate_project_path
project_path=E:\\workspace\\jeecg-boot
project_path=C:\\Users\\a\\Desktop
#bussi_package[User defined]
bussi_package=org.jeecg.modules.demo

View File

@ -1,16 +1,16 @@
#mysql
diver_name=com.mysql.jdbc.Driver
url=jdbc:mysql://localhost:3306/jeecg-boot?useUnicode=true&characterEncoding=UTF-8
username=root
password=root
database_name=jeecg-boot
#diver_name=com.mysql.jdbc.Driver
#url=jdbc:mysql://localhost:3306/jeecg-boot?useUnicode=true&characterEncoding=UTF-8
#username=root
#password=root
#database_name=jeecg-boot
#oracle
#diver_name=oracle.jdbc.driver.OracleDriver
#url=jdbc:oracle:thin:@192.168.1.200:1521:ORCL
#username=scott
#password=tiger
#database_name=ORCL
diver_name=oracle.jdbc.driver.OracleDriver
url=jdbc:oracle:thin:@82.157.234.81:1521:orcl
username=original
password=123456
database_name=original
#postgre
#diver_name=org.postgresql.Driver

View File

@ -12,16 +12,16 @@
<artifactId>jeecg-module-web-statistics</artifactId>
<dependencies>
<dependency>
<groupId>org.jeecgframework.boot</groupId>
<artifactId>jeecg-boot-base-core</artifactId>
</dependency>
<!-- 引入jeecg-boot-starter-cloud依赖 -->
<dependency>
<groupId>org.jeecgframework.boot</groupId>
<artifactId>jeecg-boot-starter-cloud</artifactId>
</dependency>
<dependency>
<groupId>org.jeecgframework.boot</groupId>
<artifactId>jeecg-boot-base-core</artifactId>
</dependency>
</dependencies>
</project>

View File

@ -10,6 +10,7 @@ import org.apache.commons.io.FileUtils;
import org.apache.commons.net.ftp.FTP;
import org.apache.commons.net.ftp.FTPClient;
import org.apache.commons.net.ftp.FTPFile;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.constant.SymbolConstant;
import org.jeecg.common.enums.SampleFileHeader;
import org.jeecg.modules.entity.data.HistogramData;
@ -142,14 +143,12 @@ public class ReadLineUtil {
OutputStream outputStream = null;
try {
String fileName = FileUtil.getName(filePath);
// 设置响应头
response.setContentType("application/octet-stream");
response.setHeader("Content-Disposition", "attachment; filename=" + fileName);
// 获取文件输入流
inputStream = new FileInputStream(filePath);
// 获取输出流
outputStream = response.getOutputStream();
outputStream = ExportUtil.stream(response,fileName);
// 缓冲区大小
byte[] buffer = new byte[4096];
@ -160,7 +159,7 @@ public class ReadLineUtil {
outputStream.write(buffer, 0, bytesRead);
}
} catch (FileNotFoundException e){
log.error("文件["+filePath+"]不存在!");
log.error("File["+filePath+"]does not exist!");
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
@ -175,7 +174,7 @@ public class ReadLineUtil {
}
}
public void readFtpFile(String filePath, HttpServletResponse response){
public Result readFtpFile(String filePath, HttpServletResponse response){
// 连接FTP
FTPClient ftpClient = ftpUtil.LoginFTP();
// 判断FTP是否连接成功
@ -192,14 +191,16 @@ public class ReadLineUtil {
// 判断FTP服务器上是否存在此文件
String[] files = ftpClient.listNames(filePath);
if (ArrayUtil.isEmpty(files)){
log.error("文件["+filePath+"]不存在!");
return;
String message = "File["+filePath+"]does not exist!";
log.error(message);
return Result.error(message);
}
// 存在多个文件名表示此路径为目录而非文件
if (ArrayUtil.length(files) > 1){
log.error("路径["+filePath+"]存在多个文件名,可能是一个目录!");
return;
String message = "["+filePath+"]There are multiple files, possibly one directory!";
log.error(message);
return Result.error(message);
}
// 获取文件名
@ -212,10 +213,8 @@ public class ReadLineUtil {
ftpClient.setControlEncoding(encoding);
ftpClient.setFileTransferMode(FTPClient.STREAM_TRANSFER_MODE);
inputStream = ftpClient.retrieveFileStream(filePath);
outputStream = response.getOutputStream();
// 设置响应头
response.setContentType("application/octet-stream");
response.setHeader("Content-Disposition", "attachment; filename=" + fileName);
outputStream = ExportUtil.stream(response,fileName);
// 缓冲区大小
byte[] buffer = new byte[4096];
int bytesRead;
@ -227,6 +226,7 @@ public class ReadLineUtil {
}
catch (IOException e) {
e.printStackTrace();
return Result.error(e.getMessage());
}finally {
try {
if (ObjectUtil.isNotNull(inputStream))inputStream.close();
@ -236,6 +236,7 @@ public class ReadLineUtil {
e.printStackTrace();
}
}
return null;
}
}

View File

@ -1,41 +1,23 @@
package org.jeecg.modules.controller;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import io.swagger.annotations.ApiOperation;
import org.jeecg.common.api.QueryRequest;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.util.ReadLineUtil;
import org.jeecg.modules.base.enums.PageType;
import org.jeecg.modules.entity.GardsAnalysesAuto;
import org.jeecg.modules.entity.GardsAnalysesMan;
import org.jeecg.modules.service.IAutoService;
import org.jeecg.modules.service.IManService;
import org.jeecg.modules.service.IReviewedService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletResponse;
import java.util.Date;
import java.util.Optional;
@RestController
@RequestMapping("radionuclide")
public class RadionuclideController {
@Autowired
private ReadLineUtil readLineUtil;
@Autowired
private IManService manService;
@Autowired
private IAutoService autoService;
@Autowired
private IReviewedService reviewedService;
@ -52,29 +34,4 @@ public class RadionuclideController {
@DateTimeFormat(pattern = "yyyy-MM-dd")Date startTime, @DateTimeFormat(pattern = "yyyy-MM-dd") Date endTime){
return reviewedService.findReviewedPage(queryRequest, stationIds, startTime, endTime);
}
@GetMapping("reportContent")
public void reportContent(@RequestParam String type,
@RequestParam Integer sampleId,
HttpServletResponse response){
String reportPath = "";
if (PageType.ARR.getType().equals(type)){ // 自动处理
LambdaQueryWrapper<GardsAnalysesAuto> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(GardsAnalysesAuto::getSampleId,sampleId);
GardsAnalysesAuto gardsAnalyses = autoService.getOne(wrapper);
reportPath = Optional.ofNullable(gardsAnalyses)
.orElse(new GardsAnalysesAuto())
.getReportPath();
}else if (PageType.RRR.getType().equals(type)){ // 人工交互
LambdaQueryWrapper<GardsAnalysesMan> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(GardsAnalysesMan::getSampleId,sampleId);
GardsAnalysesMan gardsAnalyses = manService.getOne(wrapper);
reportPath = Optional.ofNullable(gardsAnalyses)
.orElse(new GardsAnalysesMan())
.getReportPath();
}
if (StrUtil.isBlank(reportPath))return;
// 将FTP上的文件转为文件流返回到前端
readLineUtil.readFtpFile(reportPath,response);
}
}

View File

@ -1,26 +1,44 @@
package org.jeecg.modules.controller;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.jeecg.common.api.QueryRequest;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.util.ReadLineUtil;
import org.jeecg.modules.base.entity.GardsSampleData;
import org.jeecg.modules.base.entity.GardsSohData;
import org.jeecg.modules.base.enums.PageType;
import org.jeecg.modules.entity.GardsAnalysesAuto;
import org.jeecg.modules.entity.GardsAnalysesMan;
import org.jeecg.modules.service.*;
import org.jeecg.modules.system.entity.GardsStations;
import org.jeecgframework.poi.excel.ExcelExportUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletResponse;
import java.util.Date;
import java.util.List;
import java.util.Optional;
@RestController
@RequestMapping("webStatistics")
@Api(value = "统计分析管理", tags = "统计分析管理")
public class WebStatisticsController {
@Autowired
private IReviewedService reviewedService;
@Autowired
private IAutoService autoService;
@Autowired
private ReadLineUtil readLineUtil;
@Autowired
private IGardsSampleDataWebService gardsSampleDataWebService;
@Autowired
@ -28,10 +46,9 @@ public class WebStatisticsController {
@Autowired
private IGardsSohDataService gardsSohDataService;
@Autowired
private IMenuNameService menuNameService;
private IGardsAlertDataService gardsAlertDataService;
@Autowired
private IGardsSampleCertService gardsSampleCertService;
private IMenuNameService menuNameService;
@GetMapping("findStationList")
@ApiOperation(value = "根据菜单名称查询对应的台站信息", notes = "根据菜单名称查询对应的台站信息")
@ -73,4 +90,100 @@ public class WebStatisticsController {
return gardsSampleDataWebService.findGeneratedReport(sampleId);
}
@GetMapping("radionuclideFile")
@ApiOperation("查看Radionuclide的文件")
public Result radionuclideFile(@RequestParam Integer sampleId,
HttpServletResponse response){
GardsSampleData sampleData = gardsSampleDataWebService.getOneSample(sampleId);
String filePath = sampleData.getInputFileName();
if (StrUtil.isBlank(filePath))
return Result.error("The file you are looking for does not exist!");
return readLineUtil.readFtpFile(filePath,response);
}
@GetMapping("sohFile")
@ApiOperation(value = "查看RMSSHO的文件",notes = "查看RMSSHO的文件")
public Result sohFile(@RequestParam Integer sohId,
HttpServletResponse response){
GardsSohData soh = gardsSohDataService.getOneSoh(sohId);
String filePath = soh.getInputFileName();
if (StrUtil.isBlank(filePath))
return Result.error("The file you are looking for does not exist!");
return readLineUtil.readFtpFile(filePath,response);
}
@GetMapping("arFile")
@ApiOperation(value = "查看ARR/RRR的文件", notes = "查看ARR/RRR的文件")
public Result arFile(@RequestParam String type,
@RequestParam Integer sampleId,
HttpServletResponse response){
String reportPath = "";
if (PageType.ARR.getType().equals(type)){ // 自动处理
reportPath = autoService.getOne(sampleId).getReportPath();
}else if (PageType.RRR.getType().equals(type)){ // 人工交互
reportPath = reviewedService.getOne(sampleId).getReportPath();
}
if (StrUtil.isBlank(reportPath))
return Result.error("The file you are looking for does not exist!");
// 将FTP上的文件转为文件流返回到前端
return readLineUtil.readFtpFile(reportPath,response);
}
@GetMapping("radionuclideExport")
@ApiOperation(value = "导出Radionuclide的Excel",notes = "导出Radionuclide的Excel")
public void radionuclideExport(@RequestParam Integer[] stationIds,
@RequestParam String dataType,
@RequestParam String pageType,
String spectralQualifie,
@RequestParam String startTime,
@RequestParam String endTime,
HttpServletResponse response){
gardsSampleDataWebService.radionuclideExport(stationIds,
dataType, pageType, spectralQualifie, startTime, endTime, response);
}
@GetMapping("alertsExport")
@ApiOperation(value = "导出Alerts的Excel",notes = "导出Alerts的Excel")
public void alertsExport(@RequestParam Integer[] stationIds,
@RequestParam String startTime,
@RequestParam String endTime,
HttpServletResponse response){
gardsAlertDataService.alertsExport(stationIds, startTime, endTime,response);
}
@GetMapping("sohExport")
@ApiOperation(value = "导出RMSSOH的Excel",notes = "导出RMSSOH的Excel")
public void sohExport(@RequestParam Integer[] stationIds,
@RequestParam String startTime,
@RequestParam String endTime,
HttpServletResponse response){
gardsSohDataService.sohExport(stationIds, startTime, endTime, response);
}
@GetMapping("metExport")
@ApiOperation(value = "导出Met的Excel",notes = "导出Met的Excel")
public void metExport(@RequestParam Integer[] stationIds,
@RequestParam String startTime,
@RequestParam String endTime,
HttpServletResponse response){
gardsMetDataService.metExport(stationIds, startTime, endTime, response);
}
@GetMapping("arrExport")
@ApiOperation(value = "导出ARR的Excel",notes = "导出ARR的Excel")
public void arrExport(@RequestParam Integer[] stationIds,
@RequestParam String startTime,
@RequestParam String endTime,
HttpServletResponse response){
autoService.arrExport(stationIds,startTime,endTime,response);
}
@GetMapping("rrrExport")
@ApiOperation(value = "导出RRR的Excel",notes = "导出RRR的Excel")
public void rrrExport(@RequestParam Integer[] stationIds,
@RequestParam String startTime,
@RequestParam String endTime,
HttpServletResponse response){
reviewedService.rrrExport(stationIds, startTime, endTime,response);
}
}

View File

@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.jeecgframework.poi.excel.annotation.Excel;
import org.springframework.format.annotation.DateTimeFormat;
import java.io.Serializable;
@ -16,6 +17,7 @@ public class GardsAlertData implements Serializable {
@TableField(value = "STATION_ID")
private Integer stationId;
@Excel(name = "STATION",orderNum = "4")
@TableField(value = "STATION_CODE")
private String stationCode;
@ -25,15 +27,21 @@ public class GardsAlertData implements Serializable {
@TableField(value = "TIME")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@Excel(name = "TIME",orderNum = "3" ,format = "yyyy-MM-dd HH:mm:ss",width = 30)
private Date time;
@Excel(name = "TYPE",orderNum = "2")
@TableField(value = "ALERT_TYPE")
private String alertType;
@Excel(name = "ENTRIES",orderNum = "5",width = 30)
@TableField(value = "ALERT_TEXT")
private String alertText;
@TableField(value = "INPUT_FILE_NAME")
private String inputFileName;
@Excel(name = "NO",orderNum = "1")
@TableField(exist = false)
private Integer no;
}

View File

@ -4,4 +4,5 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.jeecg.modules.entity.GardsAlertData;
public interface GardsAlertDataMapper extends BaseMapper<GardsAlertData> {
}

View File

@ -4,11 +4,16 @@ 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.GardsAnalysesAuto;
import org.springframework.web.bind.annotation.RequestParam;
import javax.servlet.http.HttpServletResponse;
import java.util.Date;
public interface IAutoService extends IService<GardsAnalysesAuto> {
Result findAutoPage(QueryRequest queryRequest, Integer[] stationIds, Date startTime, Date endTime);
GardsAnalysesAuto getOne(Integer sampleId);
void arrExport(Integer[] stationIds, String startTime, String endTime, HttpServletResponse response);
}

View File

@ -0,0 +1,19 @@
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.base.entity.GardsSohData;
import org.jeecg.modules.entity.GardsAlertData;
import org.springframework.web.bind.annotation.RequestParam;
import javax.servlet.http.HttpServletResponse;
import java.util.Date;
public interface IGardsAlertDataService extends IService<GardsAlertData> {
void alertsExport(Integer[] stationIds,
String startTime,
String endTime,
HttpServletResponse response);
}

View File

@ -4,7 +4,9 @@ import com.baomidou.mybatisplus.extension.service.IService;
import org.jeecg.common.api.QueryRequest;
import org.jeecg.common.api.vo.Result;
import org.jeecg.modules.base.entity.GardsMetData;
import org.springframework.web.bind.annotation.RequestParam;
import javax.servlet.http.HttpServletResponse;
import java.util.Date;
public interface IGardsMetDataService extends IService<GardsMetData> {
@ -19,4 +21,8 @@ public interface IGardsMetDataService extends IService<GardsMetData> {
*/
Result findMetPage(QueryRequest queryRequest, Integer[] stationIds, Date startTime, Date endTime);
void metExport(Integer[] stationIds,
String startTime,
String endTime,
HttpServletResponse response);
}

View File

@ -5,6 +5,7 @@ import org.jeecg.common.api.QueryRequest;
import org.jeecg.common.api.vo.Result;
import org.jeecg.modules.base.entity.GardsSampleData;
import javax.servlet.http.HttpServletResponse;
import java.util.Date;
import java.util.List;
@ -36,4 +37,18 @@ public interface IGardsSampleDataWebService extends IService<GardsSampleData> {
*/
Result findPageBySampleIds(QueryRequest queryRequest, Integer[] stationIds, Date startTime, Date endTime, List<Integer> sampleIds);
GardsSampleData getOneSample(Integer sampleId);
void radionuclideExport(Integer[] stationIds,
String dataType,
String pageType,
String spectralQualifie,
String startTime,
String endTime,
HttpServletResponse response);
List<GardsSampleData> listBySampleIds(Integer[] stationIds,
String startTime,
String endTime,
List<Integer> sampleIds);
}

View File

@ -5,7 +5,9 @@ import org.jeecg.common.api.QueryRequest;
import org.jeecg.common.api.vo.Result;
import org.jeecg.modules.base.entity.GardsSohData;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.RequestParam;
import javax.servlet.http.HttpServletResponse;
import java.util.Date;
public interface IGardsSohDataService extends IService<GardsSohData> {
@ -30,4 +32,15 @@ public interface IGardsSohDataService extends IService<GardsSohData> {
*/
Result findAlertSohPage(QueryRequest queryRequest, Integer[] stationIds, Date startTime, Date endTime);
/**
* 获取单个SOH对象
*
* @param sohId
*/
GardsSohData getOneSoh(Integer sohId);
void sohExport(Integer[] stationIds,
String startTime,
String endTime,
HttpServletResponse response);
}

View File

@ -1,14 +0,0 @@
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.GardsAnalysesAuto;
import org.jeecg.modules.entity.GardsAnalysesMan;
import java.util.Date;
public interface IManService extends IService<GardsAnalysesMan> {
}

View File

@ -5,10 +5,14 @@ import org.jeecg.common.api.QueryRequest;
import org.jeecg.common.api.vo.Result;
import org.jeecg.modules.entity.GardsAnalysesMan;
import javax.servlet.http.HttpServletResponse;
import java.util.Date;
public interface IReviewedService extends IService<GardsAnalysesMan> {
Result findReviewedPage(QueryRequest queryRequest, Integer[] stationIds, Date startTime, Date endTime);
GardsAnalysesMan getOne(Integer sampleId);
void rrrExport(Integer[] stationIds, String startTime, String endTime, HttpServletResponse response);
}

View File

@ -1,20 +1,35 @@
package org.jeecg.modules.service.impl;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.ListUtil;
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.core.toolkit.CollectionUtils;
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.ExportUtil;
import org.jeecg.modules.base.dto.SampleDataDto;
import org.jeecg.modules.base.entity.GardsMetData;
import org.jeecg.modules.base.entity.GardsSampleData;
import org.jeecg.modules.entity.GardsAnalysesAuto;
import org.jeecg.modules.mapper.GardsAnalysesAutoMapper;
import org.jeecg.modules.service.IAutoService;
import org.jeecg.modules.service.IGardsSampleDataWebService;
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.util.Date;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
@Service("autoService")
@ -40,4 +55,61 @@ public class AutoServiceImpl extends ServiceImpl<GardsAnalysesAutoMapper, GardsA
}
}
@Override
public GardsAnalysesAuto getOne(Integer sampleId) {
LambdaQueryWrapper<GardsAnalysesAuto> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(GardsAnalysesAuto::getSampleId,sampleId);
GardsAnalysesAuto gardsAnalyses = getOne(wrapper);
return Optional.ofNullable(gardsAnalyses)
.orElse(new GardsAnalysesAuto());
}
@Override
public void arrExport(Integer[] stationIds,
String startTime,
String endTime,
HttpServletResponse response) {
// 查询自动处理后的
List<GardsAnalysesAuto> gardsAnalyses = this.list();
// 获取全部样品id
List<Integer> sampleIds = gardsAnalyses
.stream()
.map(GardsAnalysesAuto::getSampleId)
.collect(Collectors.toList());
if (CollUtil.isEmpty(sampleIds)) return;
// 查询全部样品基础数据
List<GardsSampleData> sampleData = gardsSampleDataService.listBySampleIds(stationIds,
startTime, endTime, sampleIds);
// 导出Excel文件
List<SampleDataDto> sampleDataDtos = sampleData
.stream()
.map(SampleDataDto::new)
.collect(Collectors.toList());
ExportParams params = new ExportParams();
params.setSheetName("ARR");
Workbook workbook = null;
OutputStream outputStream = null;
try {
// 设置文件名Excel类型(xls|xlsx)
outputStream = ExportUtil.xls(response,"ARR.xls");
workbook = ExcelExportUtil.
exportExcel(params, SampleDataDto.class, sampleDataDtos);
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();
}
}
}
}

View File

@ -0,0 +1,90 @@
package org.jeecg.modules.service.impl;
import cn.hutool.core.collection.ListUtil;
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.base.entity.GardsSampleData;
import org.jeecg.modules.base.entity.GardsSohData;
import org.jeecg.modules.entity.GardsAlertData;
import org.jeecg.modules.mapper.GardsAlertDataMapper;
import org.jeecg.modules.mapper.GardsSohDataMapper;
import org.jeecg.modules.service.IGardsAlertDataService;
import org.jeecg.modules.service.IGardsSohDataService;
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.*;
import static org.jeecg.modules.base.enums.PageType.*;
@Service
@DS("ora")
public class GardsAlertDataServiceImpl extends ServiceImpl<GardsAlertDataMapper, GardsAlertData> implements IGardsAlertDataService {
@Override
public void alertsExport(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<GardsAlertData> wrapper = new LambdaQueryWrapper<>();
wrapper.in(GardsAlertData::getStationId, stationIds);
wrapper.ge(GardsAlertData::getTime, startDate);
wrapper.le(GardsAlertData::getTime, endDate);
List<GardsAlertData> gardsAlertData = this.list(wrapper);
int no = 1;
for (GardsAlertData alertData : gardsAlertData) {
alertData.setNo(no++);
}
// 导出Excel文件
ExportParams params = new ExportParams();
params.setSheetName("Alerts");
Workbook workbook = null;
OutputStream outputStream = null;
try {
// 设置文件名Excel类型(xls|xlsx)
outputStream = ExportUtil.xls(response,"Alerts.xls");
workbook = ExcelExportUtil.
exportExcel(params, GardsAlertData.class, gardsAlertData);
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();
}
}
}
}

View File

@ -1,20 +1,32 @@
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.modules.base.entity.GardsMetData;
import org.jeecg.modules.entity.GardsAlertData;
import org.jeecg.modules.mapper.GardsMetDataMapper;
import org.jeecg.modules.service.IGardsMetDataService;
import org.jeecgframework.poi.excel.ExcelExportUtil;
import org.jeecgframework.poi.excel.entity.ExportParams;
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.Collections;
import java.util.Date;
import java.util.List;
import java.util.Objects;
@Service("gardsMetDataService")
@ -53,4 +65,52 @@ public class GardsMetDataServiceImpl extends ServiceImpl<GardsMetDataMapper, Gar
}
}
@Override
public void metExport(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();
LambdaQueryWrapper<GardsMetData> wrapper = new LambdaQueryWrapper<>();
wrapper.in(GardsMetData::getStationId, stationIds);
wrapper.ge(GardsMetData::getStartTime, startDate);
wrapper.le(GardsMetData::getEndTime, endDate);
List<GardsMetData> gardsMetData = this.list(wrapper);
int no = 1;
for (GardsMetData metData : gardsMetData) {
metData.setNo(no++);
}
// 导出Excel文件
ExportParams params = new ExportParams();
params.setSheetName("Met");
Workbook workbook = null;
OutputStream outputStream = null;
try {
// 设置文件名Excel类型(xls|xlsx)
outputStream = ExportUtil.xls(response,"Met.xls");
workbook = ExcelExportUtil.
exportExcel(params, GardsMetData.class, gardsMetData);
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();
}
}
}
}

View File

@ -1,31 +1,52 @@
package org.jeecg.modules.service.impl;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.ListUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.map.MapUtil;
import cn.hutool.core.util.ArrayUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.ss.usermodel.Workbook;
import org.jeecg.common.api.QueryRequest;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.enums.SampleFileHeader;
import org.jeecg.common.util.DateUtils;
import org.jeecg.common.util.ExportUtil;
import org.jeecg.common.util.ReadLineUtil;
import org.jeecg.common.util.RedisUtil;
import org.jeecg.modules.base.entity.GardsSampleData;
import org.jeecg.modules.base.entity.GardsSohData;
import org.jeecg.modules.base.enums.PageType;
import org.jeecg.modules.entity.*;
import org.jeecg.modules.entity.data.*;
import org.jeecg.modules.mapper.*;
import org.jeecg.modules.service.IGardsSampleDataWebService;
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 org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.OutputStream;
import java.net.URLEncoder;
import java.text.ParseException;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.stream.Collectors;
import static org.jeecg.modules.base.enums.PageType.*;
@Service("gardsSampleDataWebService")
@DS("ora")
public class GardsSampleDataWebServiceImpl extends ServiceImpl<GardsSampleDataWebMapper,GardsSampleData> implements IGardsSampleDataWebService {
@ -497,4 +518,137 @@ public class GardsSampleDataWebServiceImpl extends ServiceImpl<GardsSampleDataWe
}
}
@Override
public GardsSampleData getOneSample(Integer sampleId) {
LambdaQueryWrapper<GardsSampleData> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(GardsSampleData::getSampleId,sampleId);
return Optional.ofNullable(getOne(wrapper))
.orElse(new GardsSampleData());
}
@Override
public void radionuclideExport(Integer[] stationIds,
String dataType,
String pageType,
String spectralQualifie,
String startTime,
String endTime,
HttpServletResponse response) {
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();
// 声明Lambda 传递参数进行条件查询
LambdaQueryWrapper<GardsSampleData> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(GardsSampleData::getDataType, dataType);
// 数据分为全谱与过程谱则使用采集日期进行日期查询
if (StringUtils.isNotBlank(spectralQualifie)) {
queryWrapper.eq(GardsSampleData::getSpectralQualifie, spectralQualifie);
queryWrapper.ge(GardsSampleData::getCollectStart, startDate);
queryWrapper.le(GardsSampleData::getCollectStop, endDate);
} else { //数据不区分全谱与过程谱则使用
queryWrapper.ge(GardsSampleData::getAcquisitionStart, startDate);
queryWrapper.le(GardsSampleData::getAcquisitionStop, endDate);
}
boolean notEmpty = ArrayUtil.isNotEmpty(stationIds);
queryWrapper.in(notEmpty, GardsSampleData::getStationId, stationIds);
// 封装信息
List<GardsSampleData> sampleDatas = this.list(queryWrapper);
// 获取redis中缓存的台站信息
Map<String, String> stationMap = (Map<String, String>) redisUtil.get("stationMap");
int no = 1;
for (GardsSampleData sampleData : sampleDatas) {
sampleData.setNo(no++);
sampleData.setSiteDetCode(StringUtils.trim(sampleData.getSiteDetCode()));
String stationId = sampleData.getStationId().toString();
boolean noEmpty = MapUtil.isNotEmpty(stationMap);
boolean hasKey = noEmpty ? stationMap.containsKey(stationId) : false;
if (noEmpty && hasKey) {
String stationName = stationMap.get(stationId);
sampleData.setStationName(stationName);
}
}
List<String> commonFiled = ListUtil
.toList("no","stationName","siteDetCode","spectralQualifie");
// 根据页面类型导出不同列字段的Execl文档
ExportParams params = new ExportParams();
params.setSheetName("Radionuclide");
Workbook workbook = null;
OutputStream outputStream = null;
try {
// 设置文件名Excel类型(xls|xlsx)
outputStream = ExportUtil.xls(response,"Radionuclide.xls");
if (ACQ.getType().equals(pageType)){
commonFiled.addAll(ListUtil.toList("acquisitionStart","acquisitionStop"));
String[] fileds = ArrayUtil.toArray(commonFiled,String.class);
workbook = ExcelExportUtil.
exportExcel(params, GardsSampleData.class, sampleDatas, fileds);
workbook.write(outputStream);
} else if (COLL.getType().equals(pageType)) {
commonFiled.addAll(ListUtil.toList("collectStart","collectStop"));
String[] fileds = ArrayUtil.toArray(commonFiled,String.class);
workbook = ExcelExportUtil.
exportExcel(params, GardsSampleData.class, sampleDatas,fileds);
workbook.write(outputStream);
} else if (CALIB.getType().equals(pageType)) {
commonFiled.addAll(ListUtil.toList("acquisitionStart","acquisitionStop","calibReports"));
String[] fileds = ArrayUtil.toArray(commonFiled,String.class);
workbook = ExcelExportUtil.
exportExcel(params, GardsSampleData.class, sampleDatas, fileds);
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<GardsSampleData> listBySampleIds(Integer[] stationIds,
String startTime,
String endTime,
List<Integer> sampleIds) {
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();
LambdaQueryWrapper<GardsSampleData> wrapper = new LambdaQueryWrapper<>();
wrapper.in(GardsSampleData::getStationId, stationIds);
wrapper.in(GardsSampleData::getSampleId, sampleIds);
wrapper.ge(GardsSampleData::getCollectStart, startDate);
wrapper.le(GardsSampleData::getCollectStop, endDate);
List<GardsSampleData> sampleData = this.list(wrapper);
// 获取redis中缓存的台站信息
Map<Integer, String> stationMap = (Map<Integer, String>)redisUtil.get("stationMap");
int no = 1;
boolean emptyMap = MapUtil.isEmpty(stationMap);
for (GardsSampleData sampleDatum : sampleData) {
sampleDatum.setNo(no++);
String stationId = sampleDatum.getStationId().toString();
boolean hasKey = emptyMap ? false : stationMap.containsKey(stationId) ;
if (hasKey){
String stationName = stationMap.get(stationId);
sampleDatum.setStationName(stationName);
}
}
return sampleData;
}
}

View File

@ -1,26 +1,35 @@
package org.jeecg.modules.service.impl;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.map.MapUtil;
import cn.hutool.core.util.ArrayUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
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.base.entity.GardsSohData;
import org.jeecg.modules.entity.GardsAlertData;
import org.jeecg.modules.mapper.GardsAlertDataMapper;
import org.jeecg.modules.mapper.GardsSohDataMapper;
import org.jeecg.modules.service.IGardsSohDataService;
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.Collections;
import java.util.Date;
import java.util.Map;
import java.util.Objects;
import java.util.*;
@Service("gardsSohDataService")
@DS("ora")
@ -111,4 +120,76 @@ public class GardsSohDataServiceImpl extends ServiceImpl<GardsSohDataMapper, Gar
}
}
@Override
public GardsSohData getOneSoh(Integer sohId) {
LambdaQueryWrapper<GardsSohData> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(GardsSohData::getSohId,sohId);
return Optional.ofNullable(getOne(wrapper))
.orElse(new GardsSohData());
}
@Override
public void sohExport(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<GardsSohData> wrapper = new LambdaQueryWrapper<>();
wrapper.in(GardsSohData::getStationId, stationIds);
wrapper.ge(GardsSohData::getStartTime, startDate);
wrapper.le(GardsSohData::getStartTime, endDate);
List<GardsSohData> sohData = this.list(wrapper);
int no = 1;
for (GardsSohData sohDatum : sohData) {
sohDatum.setNo(no++);
/*String detectorId = sohDatum.getDetectorId().toString();
boolean hasKey = MapUtil.isEmpty(detectorsMap) ? false : detectorsMap.containsKey(detectorId) ;
if (hasKey) {
String detectorName = detectorsMap.get(detectorId);
sohDatum.setDetectorName(detectorName);
}*/
Date startT = sohDatum.getStartTime();
if (ObjectUtil.isNotNull(startT)) {
long stratSecod = startT.getTime() / 1000;
long endSecond = stratSecod + Long.valueOf(sohDatum.getTime());
Date endDateTime = new Date(endSecond * 1000);
sohDatum.setEndTime(endDateTime);
}
}
// 导出Excel文件
ExportParams params = new ExportParams();
params.setSheetName("RMSSOH");
Workbook workbook = null;
OutputStream outputStream = null;
try {
// 设置文件名Excel类型(xls|xlsx)
outputStream = ExportUtil.xls(response,"RMSSOH.xls");
workbook = ExcelExportUtil.
exportExcel(params, GardsSohData.class, sohData);
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();
}
}
}
}

View File

@ -1,28 +0,0 @@
package org.jeecg.modules.service.impl;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.jeecg.common.api.QueryRequest;
import org.jeecg.common.api.vo.Result;
import org.jeecg.modules.entity.GardsAnalysesAuto;
import org.jeecg.modules.entity.GardsAnalysesMan;
import org.jeecg.modules.mapper.GardsAnalysesAutoMapper;
import org.jeecg.modules.mapper.GardsAnalysesManMapper;
import org.jeecg.modules.service.IAutoService;
import org.jeecg.modules.service.IGardsSampleDataWebService;
import org.jeecg.modules.service.IManService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
@Service("manService")
@DS("ora")
public class ManServiceImpl extends ServiceImpl<GardsAnalysesManMapper, GardsAnalysesMan> implements IManService {
}

View File

@ -1,20 +1,33 @@
package org.jeecg.modules.service.impl;
import cn.hutool.core.collection.CollUtil;
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.core.toolkit.CollectionUtils;
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.ExportUtil;
import org.jeecg.modules.base.dto.SampleDataDto;
import org.jeecg.modules.base.entity.GardsSampleData;
import org.jeecg.modules.entity.GardsAnalysesAuto;
import org.jeecg.modules.entity.GardsAnalysesMan;
import org.jeecg.modules.mapper.GardsAnalysesManMapper;
import org.jeecg.modules.service.IGardsSampleDataWebService;
import org.jeecg.modules.service.IReviewedService;
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.util.Date;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
@Service("reviewedService")
@ -39,4 +52,61 @@ public class ReviewedServiceImpl extends ServiceImpl<GardsAnalysesManMapper, Gar
return null;
}
}
@Override
public GardsAnalysesMan getOne(Integer sampleId) {
LambdaQueryWrapper<GardsAnalysesMan> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(GardsAnalysesMan::getSampleId,sampleId);
GardsAnalysesMan gardsAnalyses = getOne(wrapper);
return Optional.ofNullable(gardsAnalyses)
.orElse(new GardsAnalysesMan());
}
@Override
public void rrrExport(Integer[] stationIds,
String startTime,
String endTime,
HttpServletResponse response) {
// 查询自动处理后的
List<GardsAnalysesMan> gardsAnalyses = this.list();
// 获取全部样品id
List<Integer> sampleIds = gardsAnalyses
.stream()
.map(GardsAnalysesMan::getSampleId)
.collect(Collectors.toList());
if (CollUtil.isEmpty(sampleIds)) return;
// 查询全部样品基础数据
List<GardsSampleData> sampleData = gardsSampleDataService.listBySampleIds(stationIds,
startTime, endTime, sampleIds);
// 导出Excel文件
List<SampleDataDto> sampleDataDtos = sampleData
.stream()
.map(SampleDataDto::new)
.collect(Collectors.toList());
ExportParams params = new ExportParams();
params.setSheetName("RRR");
Workbook workbook = null;
OutputStream outputStream = null;
try {
// 设置文件名Excel类型(xls|xlsx)
outputStream = ExportUtil.xls(response,"RRR.xls");
workbook = ExcelExportUtil.
exportExcel(params, SampleDataDto.class, sampleDataDtos);
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();
}
}
}
}

View File

@ -15,4 +15,10 @@ spring:
config:
import:
- optional:nacos:jeecg.yaml
- optional:nacos:jeecg-@profile.name@.yaml
- optional:nacos:jeecg-@profile.name@.yaml
# 调用监控服务配置信息
monitor:
username: wmhr
password: Wmhr.123
url: http://218.249.158.97:7008/mobile/monitor