Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
165dce6786
|
|
@ -0,0 +1,26 @@
|
|||
package org.jeecg.common.constant.enums;
|
||||
|
||||
/**
|
||||
* IDC和NDC关联波形事件结果类型
|
||||
*/
|
||||
public enum WaveformEventResultTypeEnum {
|
||||
|
||||
/**
|
||||
* IDC 关联结果
|
||||
*/
|
||||
IDC(1),
|
||||
/**
|
||||
* NDC 关联结果
|
||||
*/
|
||||
NDC(2);
|
||||
|
||||
private Integer key;
|
||||
|
||||
WaveformEventResultTypeEnum(Integer key) {
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
public Integer getKey(){
|
||||
return this.key;
|
||||
}
|
||||
}
|
||||
|
|
@ -21,6 +21,10 @@ public class DataFusionProperties {
|
|||
* srs文件的上级目录有可能是flexpart.x.ecmwf.l1或flexpart.x.ncep.l1
|
||||
*/
|
||||
private String srmParentDir;
|
||||
/**
|
||||
* 浓度值过滤条件
|
||||
*/
|
||||
private String filterConditions;
|
||||
/**
|
||||
* 溯源时间
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -1,8 +1,10 @@
|
|||
package org.jeecg.modules.base.entity;
|
||||
package org.jeecg.modules.base.entity.copsdb;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import org.jeecgframework.poi.excel.annotation.Excel;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
|
|
@ -10,18 +12,26 @@ import java.util.Date;
|
|||
public class Origin {
|
||||
|
||||
@TableField("LAT")
|
||||
@Excel(name = "纬度", width = 20,height = 20,orderNum="2")
|
||||
private Double lat;
|
||||
|
||||
@TableField("LON")
|
||||
@Excel(name = "经度", width = 20,height = 20,orderNum="1")
|
||||
private Double lon;
|
||||
|
||||
@TableField("DEPTH")
|
||||
@Excel(name = "深度", width = 20,height = 20,orderNum="3")
|
||||
private Double depth;
|
||||
|
||||
@TableField("TIME")
|
||||
private Double time;
|
||||
|
||||
@TableField(exist = false)
|
||||
@Excel(name = "时间", width = 30,height = 20,orderNum="4")
|
||||
private String datetime;
|
||||
|
||||
@TableField("ORID")
|
||||
@Excel(name = "ORID", width = 20,height = 20,orderNum="0")
|
||||
private Integer orid;
|
||||
|
||||
@TableField("EVID")
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
package org.jeecg.modules.base.entity.rnauto;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 关联波形事件结果
|
||||
*/
|
||||
@Data
|
||||
@TableName("RNAUTO.GARDS_WAVEFORM_EVENT_RESULT")
|
||||
public class GardsWaveformEventResult {
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@TableField(value = "SAMPLE_ID")
|
||||
private Integer sampleId;
|
||||
|
||||
/**
|
||||
* idc事件
|
||||
*/
|
||||
@TableField(value = "ORID")
|
||||
private Integer orid;
|
||||
|
||||
/**
|
||||
* 1-IDC关联数量,2-NDC关联数量
|
||||
*/
|
||||
@TableField(value = "TYPE")
|
||||
private Integer type;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date moddate;
|
||||
}
|
||||
|
|
@ -5,8 +5,6 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
|||
import org.apache.ibatis.annotations.Param;
|
||||
import org.jeecg.modules.base.entity.rnauto.GardsWaveformEvent;
|
||||
import org.jeecg.modules.base.vo.GardsSampleInfoVO;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
|
||||
|
|
@ -34,6 +32,4 @@ public interface GardsWaveformEventMapper extends BaseMapper<GardsWaveformEvent>
|
|||
* @return
|
||||
*/
|
||||
GardsSampleInfoVO selectSampleInfoBySampleId(@Param("sampleId") Integer sampleId);
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,29 @@
|
|||
package org.jeecg.modules.base.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.jeecg.modules.base.entity.copsdb.Origin;
|
||||
import org.jeecg.modules.base.entity.rnauto.GardsWaveformEventResult;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface GardsWaveformEventResultMapper extends BaseMapper<GardsWaveformEventResult> {
|
||||
|
||||
/**
|
||||
* 分页查询样品关联的波形数据详情
|
||||
* @param page
|
||||
* @param sampleId
|
||||
* @return
|
||||
*/
|
||||
IPage<Map<String, Object>> page(IPage<Map<String, Object>> page,@Param("sampleId") Integer sampleId,@Param("type") Integer type);
|
||||
|
||||
/**
|
||||
* 导出关联结果数据
|
||||
* @param sampleId
|
||||
* @param type
|
||||
* @return
|
||||
*/
|
||||
List<Origin> excelOriginData(@Param("sampleId") Integer sampleId, @Param("type") Integer type);
|
||||
}
|
||||
|
|
@ -2,7 +2,7 @@ package org.jeecg.modules.base.mapper;
|
|||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.jeecg.modules.base.entity.Origin;
|
||||
import org.jeecg.modules.base.entity.copsdb.Origin;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,43 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="org.jeecg.modules.base.mapper.GardsWaveformEventResultMapper">
|
||||
|
||||
<select id="page" resultType="java.util.Map">
|
||||
SELECT
|
||||
n.ORID as "orid",
|
||||
n.LON as "lon",
|
||||
n.LAT as "lat",
|
||||
n.DEPTH as "depth",
|
||||
TO_CHAR(
|
||||
TO_DATE('1970-01-01', 'YYYY-MM-DD') + (n.TIME/86400),
|
||||
'YYYY-MM-DD HH24:MI:SS'
|
||||
) AS "time"
|
||||
FROM
|
||||
RNAUTO.GARDS_WAVEFORM_EVENT_RESULT t
|
||||
INNER JOIN COPSDB.ORIGIN n ON t.ORID = n.ORID
|
||||
WHERE
|
||||
t.SAMPLE_ID = #{sampleId}
|
||||
AND t.TYPE = #{type}
|
||||
ORDER BY n.TIME desc
|
||||
</select>
|
||||
|
||||
<select id="excelOriginData" resultType="org.jeecg.modules.base.entity.copsdb.Origin">
|
||||
SELECT
|
||||
n.ORID as "orid",
|
||||
n.LON as "lon",
|
||||
n.LAT as "lat",
|
||||
n.DEPTH as "depth",
|
||||
TO_CHAR(
|
||||
TO_DATE('1970-01-01', 'YYYY-MM-DD') + (n.TIME/86400),
|
||||
'YYYY-MM-DD HH24:MI:SS'
|
||||
) AS "datetime"
|
||||
FROM
|
||||
RNAUTO.GARDS_WAVEFORM_EVENT_RESULT t
|
||||
INNER JOIN COPSDB.ORIGIN n ON t.ORID = n.ORID
|
||||
WHERE
|
||||
t.SAMPLE_ID = #{sampleId}
|
||||
AND t.TYPE = #{type}
|
||||
ORDER BY n.TIME desc
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="org.jeecg.modules.base.mapper.OriginMapper">
|
||||
|
||||
<select id="selectOriginByTime" resultType="org.jeecg.modules.base.entity.Origin">
|
||||
<select id="selectOriginByTime" resultType="org.jeecg.modules.base.entity.copsdb.Origin">
|
||||
SELECT
|
||||
t.LAT as "lat",
|
||||
t.LON as "lon",
|
||||
|
|
|
|||
|
|
@ -6,15 +6,24 @@ import jakarta.validation.constraints.NotNull;
|
|||
import lombok.RequiredArgsConstructor;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.common.aspect.annotation.AutoLog;
|
||||
import org.jeecg.common.constant.enums.WaveformEventResultTypeEnum;
|
||||
import org.jeecg.common.system.query.PageRequest;
|
||||
import org.jeecg.modules.base.entity.copsdb.Origin;
|
||||
import org.jeecg.service.AssociatedWaveformService;
|
||||
import org.jeecgframework.poi.excel.ExcelExportUtil;
|
||||
import org.jeecgframework.poi.excel.entity.ExportParams;
|
||||
import org.jeecgframework.poi.excel.entity.enmus.ExcelType;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import java.io.IOException;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLEncoder;
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 数据融合-关联波形
|
||||
|
|
@ -36,6 +45,15 @@ public class AssociatedWaveformController {
|
|||
return Result.OK(associatedWaveformService.page(pageRequest,sampleId,status,sampleType,startDate,endDate));
|
||||
}
|
||||
|
||||
@AutoLog(value = "分页查询样品关联的波形数据详情")
|
||||
@Operation(summary = "分页查询样品关联的波形数据详情")
|
||||
@GetMapping("getSampleWaveformsDetails")
|
||||
public Result<?> getSampleWaveformsDetails(PageRequest pageRequest,
|
||||
@NotNull(message = "样品id不能为空") Integer sampleId,
|
||||
@NotNull(message = "类型不能为空") Integer type) {
|
||||
return Result.OK(associatedWaveformService.sampleWaveformsDetailsPage(pageRequest,sampleId,type));
|
||||
}
|
||||
|
||||
@AutoLog(value = "执行关联")
|
||||
@Operation(summary = "执行关联")
|
||||
@PutMapping("execAssociated")
|
||||
|
|
@ -58,4 +76,36 @@ public class AssociatedWaveformController {
|
|||
associatedWaveformService.viewRRR(sampleId,response);
|
||||
}
|
||||
|
||||
@AutoLog(value = "导出样品关联的波形数据详情")
|
||||
@Operation(summary = "导出样品关联的波形数据详情")
|
||||
@GetMapping("excelOriginData")
|
||||
public void excelOriginData(@NotNull(message = "样品id不能为空") Integer sampleId,
|
||||
@NotNull(message = "类型不能为空")Integer type,
|
||||
HttpServletResponse response) throws IOException {
|
||||
String title = "";
|
||||
if (WaveformEventResultTypeEnum.IDC.getKey().equals(type)) {
|
||||
title = "IDC-SRS文件关联的波形数据详情";
|
||||
}else if(WaveformEventResultTypeEnum.NDC.getKey().equals(type)){
|
||||
title = "NDC-SRS文件关联的波形数据详情";
|
||||
}
|
||||
ExportParams params = new ExportParams();
|
||||
params.setTitle(title);
|
||||
params.setFixedTitle(true);
|
||||
params.setTitleHeight((short) 10);
|
||||
params.setHeight((short) 30);
|
||||
params.setType(ExcelType.XSSF);
|
||||
|
||||
List<Origin> origins = associatedWaveformService.excelOriginData(sampleId, type);
|
||||
response.reset();
|
||||
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
|
||||
response.setCharacterEncoding("utf-8");
|
||||
try {
|
||||
response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(title, "UTF-8"));
|
||||
response.setHeader("Access-Control-Expose-Headers","Content-disposition");
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
ExcelExportUtil.exportExcel(params,Origin.class,origins).write(response.getOutputStream());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,8 +4,10 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
|||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import org.jeecg.common.system.query.PageRequest;
|
||||
import org.jeecg.modules.base.entity.copsdb.Origin;
|
||||
import org.jeecg.modules.base.entity.rnauto.GardsWaveformEvent;
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
|
|
@ -25,6 +27,15 @@ public interface AssociatedWaveformService extends IService<GardsWaveformEvent>
|
|||
*/
|
||||
IPage<Map<String,Object>> page(PageRequest pageRequest, Integer sampleId, Integer status, String sampleType, LocalDate startDate, LocalDate endDate);
|
||||
|
||||
/**
|
||||
* 查询样品关联的波形详情数据
|
||||
* @param pageRequest
|
||||
* @param sampleId
|
||||
* @param type
|
||||
* @return
|
||||
*/
|
||||
IPage<Map<String,Object>> sampleWaveformsDetailsPage(PageRequest pageRequest, Integer sampleId,Integer type);
|
||||
|
||||
/**
|
||||
* 样品id不能为空
|
||||
* @param sampleId
|
||||
|
|
@ -42,4 +53,13 @@ public interface AssociatedWaveformService extends IService<GardsWaveformEvent>
|
|||
* @param sampleId
|
||||
*/
|
||||
void viewRRR(Integer sampleId, HttpServletResponse response);
|
||||
|
||||
/**
|
||||
* 导出关联结果数据
|
||||
* @param sampleId
|
||||
* @param type
|
||||
* @return
|
||||
*/
|
||||
List<Origin> excelOriginData(Integer sampleId,Integer type);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,9 +12,11 @@ import lombok.RequiredArgsConstructor;
|
|||
import org.jeecg.common.properties.ArmdReportProperties;
|
||||
import org.jeecg.common.properties.DataFusionProperties;
|
||||
import org.jeecg.common.system.query.PageRequest;
|
||||
import org.jeecg.modules.base.entity.copsdb.Origin;
|
||||
import org.jeecg.modules.base.entity.rnauto.GardsWaveformEvent;
|
||||
import org.jeecg.modules.base.mapper.GardsAnalysesMapper;
|
||||
import org.jeecg.modules.base.mapper.GardsWaveformEventMapper;
|
||||
import org.jeecg.modules.base.mapper.GardsWaveformEventResultMapper;
|
||||
import org.jeecg.modules.base.mapper.OriginMapper;
|
||||
import org.jeecg.modules.base.vo.GardsSampleInfoVO;
|
||||
import org.jeecg.service.AssociatedWaveformService;
|
||||
|
|
@ -28,9 +30,9 @@ import java.io.FileInputStream;
|
|||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
|
|
@ -47,6 +49,7 @@ public class AssociatedWaveformServiceImpl extends ServiceImpl<GardsWaveformEven
|
|||
private final OriginMapper originMapper;
|
||||
private final DataSourceTransactionManager transactionManager;
|
||||
private final TransactionDefinition transactionDefinition;
|
||||
private final GardsWaveformEventResultMapper waveformEventResultMapper;
|
||||
|
||||
/**
|
||||
* 分页查询关联波形数据
|
||||
|
|
@ -72,6 +75,20 @@ public class AssociatedWaveformServiceImpl extends ServiceImpl<GardsWaveformEven
|
|||
return this.baseMapper.page(page,sampleId,status,sampleType,startTime,endTime);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询样品关联的波形详情数据
|
||||
* @param pageRequest
|
||||
* @param sampleId
|
||||
* @param type
|
||||
* @return
|
||||
*/
|
||||
@DS(value = "ora")
|
||||
@Override
|
||||
public IPage<Map<String, Object>> sampleWaveformsDetailsPage(PageRequest pageRequest, Integer sampleId,Integer type) {
|
||||
IPage<Map<String, Object>> page = new Page<>(pageRequest.getPageNum(), pageRequest.getPageSize());
|
||||
return this.waveformEventResultMapper.page(page,sampleId,type);
|
||||
}
|
||||
|
||||
/**
|
||||
* 样品id不能为空
|
||||
*
|
||||
|
|
@ -90,6 +107,7 @@ public class AssociatedWaveformServiceImpl extends ServiceImpl<GardsWaveformEven
|
|||
dataFusionProperties,
|
||||
this.baseMapper,
|
||||
originMapper,
|
||||
waveformEventResultMapper,
|
||||
sampleInfo.getSampleId(),
|
||||
sampleInfo.getAcqEndTime(),
|
||||
sampleInfo.getStationCode());
|
||||
|
|
@ -186,4 +204,17 @@ public class AssociatedWaveformServiceImpl extends ServiceImpl<GardsWaveformEven
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出关联结果数据
|
||||
*
|
||||
* @param sampleId
|
||||
* @param type
|
||||
* @return
|
||||
*/
|
||||
@DS(value = "ora")
|
||||
@Override
|
||||
public List<Origin> excelOriginData(Integer sampleId, Integer type) {
|
||||
return this.waveformEventResultMapper.excelOriginData(sampleId,type);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,15 +2,18 @@ package org.jeecg.task.waveformtask;
|
|||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.time.StopWatch;
|
||||
import org.apache.logging.log4j.util.Strings;
|
||||
import org.jeecg.common.constant.enums.*;
|
||||
import org.jeecg.common.properties.DataFusionProperties;
|
||||
import org.jeecg.config.datasource.DataSourceSwitcher;
|
||||
import org.jeecg.modules.base.entity.Origin;
|
||||
import org.jeecg.modules.base.entity.copsdb.Origin;
|
||||
import org.jeecg.modules.base.entity.rnauto.GardsWaveformEvent;
|
||||
import org.jeecg.modules.base.entity.rnauto.GardsWaveformEventResult;
|
||||
import org.jeecg.modules.base.mapper.GardsWaveformEventMapper;
|
||||
import org.jeecg.modules.base.mapper.GardsWaveformEventResultMapper;
|
||||
import org.jeecg.modules.base.mapper.OriginMapper;
|
||||
import org.jeecg.vo.SRSRecord;
|
||||
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
|
||||
|
|
@ -23,10 +26,10 @@ import java.math.RoundingMode;
|
|||
import java.nio.charset.StandardCharsets;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.zip.GZIPInputStream;
|
||||
|
||||
|
|
@ -37,6 +40,7 @@ public class AssociatedWaveformTaskExec extends Thread{
|
|||
private TransactionDefinition transactionDefinition;
|
||||
private DataFusionProperties dataFusionProperties;
|
||||
private GardsWaveformEventMapper waveformEventMapper;
|
||||
private GardsWaveformEventResultMapper waveformEventResultMapper;
|
||||
private OriginMapper originMapper;
|
||||
private Integer sampleId;
|
||||
private Date acqEndTime;
|
||||
|
|
@ -45,11 +49,6 @@ public class AssociatedWaveformTaskExec extends Thread{
|
|||
private File ndcSrsFile = null;
|
||||
private List<String> idcSrsContents;
|
||||
private List<String> ndcSrsContents;
|
||||
//idc srs关联到的波形事件信息
|
||||
private Integer idcEvents;
|
||||
//ndc srs关联到的波形事件信息
|
||||
private Integer ndcEvents;
|
||||
|
||||
|
||||
/**
|
||||
* 初始化
|
||||
|
|
@ -60,14 +59,16 @@ public class AssociatedWaveformTaskExec extends Thread{
|
|||
DataFusionProperties dataFusionProperties,
|
||||
GardsWaveformEventMapper waveformEventMapper,
|
||||
OriginMapper originMapper,
|
||||
Integer sampleId,
|
||||
Date acqEndTime,
|
||||
String stationCode){
|
||||
GardsWaveformEventResultMapper waveformEventResultMapper,
|
||||
Integer sampleId,
|
||||
Date acqEndTime,
|
||||
String stationCode){
|
||||
this.transactionManager = transactionManager;
|
||||
this.transactionDefinition = transactionDefinition;
|
||||
this.dataFusionProperties = dataFusionProperties;
|
||||
this.waveformEventMapper = waveformEventMapper;
|
||||
this.originMapper = originMapper;
|
||||
this.waveformEventResultMapper = waveformEventResultMapper;
|
||||
this.sampleId = sampleId;
|
||||
this.acqEndTime = acqEndTime;
|
||||
this.stationCode = stationCode;
|
||||
|
|
@ -85,6 +86,8 @@ public class AssociatedWaveformTaskExec extends Thread{
|
|||
StopWatch stopWatch = new StopWatch();
|
||||
stopWatch.start();
|
||||
try{
|
||||
//清除历史关联结果
|
||||
this.cleanHistoryResult(this.sampleId);
|
||||
//修改任务状态为执行中
|
||||
this.updateTaskStatus(this.sampleId, AssociatedWaveformTaskEnum.IN_PROCESS.getValue());
|
||||
//检查srs文件是否存在
|
||||
|
|
@ -126,14 +129,22 @@ public class AssociatedWaveformTaskExec extends Thread{
|
|||
* 关联波形数据
|
||||
*/
|
||||
private void associationWaveform(){
|
||||
Integer idcEvents = this.associationSrs(this.idcSrsContents);
|
||||
Integer ndcEvents = this.associationSrs(this.ndcSrsContents);
|
||||
Set<Integer> idcEvents = this.associationSrs(this.idcSrsContents);
|
||||
Set<Integer> ndcEvents = this.associationSrs(this.ndcSrsContents);
|
||||
DataSourceSwitcher.switchToOracle();
|
||||
final TransactionStatus transactionStatus = this.transactionManager.getTransaction(this.transactionDefinition);
|
||||
try {
|
||||
//保存关联结果
|
||||
if (CollUtil.isNotEmpty(idcEvents)){
|
||||
this.saveWaveformEventResult(idcEvents,WaveformEventResultTypeEnum.IDC.getKey());
|
||||
}
|
||||
if (CollUtil.isNotEmpty(ndcEvents)){
|
||||
this.saveWaveformEventResult(ndcEvents,WaveformEventResultTypeEnum.NDC.getKey());
|
||||
}
|
||||
//修改关联结果统计
|
||||
GardsWaveformEvent waveformEvent = this.waveformEventMapper.selectById(sampleId);
|
||||
waveformEvent.setIdcEvents(idcEvents);
|
||||
waveformEvent.setNdcEvents(ndcEvents);
|
||||
waveformEvent.setIdcEvents(idcEvents.size());
|
||||
waveformEvent.setNdcEvents(ndcEvents.size());
|
||||
waveformEvent.setDescription(Strings.EMPTY);
|
||||
waveformEvent.setModdate(new Date());
|
||||
waveformEvent.setStatus(AssociatedWaveformTaskEnum.COMPLETE.getValue());
|
||||
|
|
@ -147,10 +158,7 @@ public class AssociatedWaveformTaskExec extends Thread{
|
|||
/**
|
||||
* 关联idc srs文件
|
||||
*/
|
||||
private Integer associationSrs(List<String> srsContents){
|
||||
if (CollUtil.isEmpty(srsContents)) {
|
||||
return 0;
|
||||
}
|
||||
private Set<Integer> associationSrs(List<String> srsContents){
|
||||
// 台站经度 台站纬度 开始测量日期 小时 结束测量时间 小时 系数 总共模拟时长 小时数 网格大小 台站编码
|
||||
// 139.08 36.30 20241203 12 20241203 18 0.1300000E+16 336 1 1 0.50 0.50 "JPX38"
|
||||
String[] firstLine = srsContents.get(0).split("\\s+");
|
||||
|
|
@ -161,6 +169,8 @@ public class AssociatedWaveformTaskExec extends Thread{
|
|||
LocalDateTime endTime = LocalDateTime.ofInstant(this.acqEndTime.toInstant(), ZoneId.of("Asia/Shanghai"));
|
||||
endTime = endTime.withMinute(0).withSecond(0);
|
||||
LocalDateTime startTime = endTime.minusHours(totalHour).minusHours(dataFusionProperties.getTraceabilityTime()*24);
|
||||
System.out.println(startTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
|
||||
System.out.println(endTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
|
||||
//查询范围内波形事件
|
||||
List<Origin> origins = this.selectOriginByTime(startTime,endTime);
|
||||
//处理srs文件中的坐标记录格式化成对象
|
||||
|
|
@ -170,8 +180,7 @@ public class AssociatedWaveformTaskExec extends Thread{
|
|||
.collect(Collectors.groupingBy(record ->
|
||||
new AbstractMap.SimpleImmutableEntry<>(record.getLon(), record.getLat())
|
||||
));
|
||||
Integer totalEvents = this.queryWaveform(origins, srsRecordsGroup, gridSize);
|
||||
return totalEvents;
|
||||
return this.queryWaveform(origins, srsRecordsGroup, gridSize);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -240,19 +249,26 @@ public class AssociatedWaveformTaskExec extends Thread{
|
|||
private List<SRSRecord> buildSRSRecord(List<String> contents,Integer hourlyCoefficient,LocalDateTime acqEndTime){
|
||||
List<SRSRecord> list = contents.parallelStream().skip(1).map(content->{
|
||||
String[] line = content.split("\\s+");
|
||||
SRSRecord srsRecord = new SRSRecord();
|
||||
srsRecord.setLat(Double.parseDouble(line[1]));
|
||||
srsRecord.setLon(Double.parseDouble(line[2]));
|
||||
srsRecord.setHour(Integer.parseInt(line[3])*hourlyCoefficient);
|
||||
srsRecord.setConc(line[4]);
|
||||
LocalDateTime endTime = acqEndTime.minusHours(srsRecord.getHour());
|
||||
LocalDateTime startTime = acqEndTime.minusHours(srsRecord.getHour()+dataFusionProperties.getTraceabilityTime()*24);
|
||||
long startSecond = startTime.atZone(ZoneId.of("Asia/Shanghai")).toEpochSecond();
|
||||
long endSecond = endTime.atZone(ZoneId.of("Asia/Shanghai")).toEpochSecond();
|
||||
srsRecord.setStartSecond(startSecond);
|
||||
srsRecord.setEndSecond(endSecond);
|
||||
return srsRecord;
|
||||
}).toList();
|
||||
BigDecimal val1 = new BigDecimal(line[4]);
|
||||
BigDecimal val2 = new BigDecimal(dataFusionProperties.getFilterConditions());
|
||||
//过滤掉比较小的值
|
||||
if(val1.compareTo(val2) > 0){
|
||||
SRSRecord srsRecord = new SRSRecord();
|
||||
srsRecord.setLat(Double.parseDouble(line[1]));
|
||||
srsRecord.setLon(Double.parseDouble(line[2]));
|
||||
srsRecord.setHour(Integer.parseInt(line[3])*hourlyCoefficient);
|
||||
srsRecord.setConc(line[4]);
|
||||
LocalDateTime endTime = acqEndTime.minusHours(srsRecord.getHour());
|
||||
LocalDateTime startTime = acqEndTime.minusHours(srsRecord.getHour()+dataFusionProperties.getTraceabilityTime()*24);
|
||||
long startSecond = startTime.atZone(ZoneId.of("Asia/Shanghai")).toEpochSecond();
|
||||
long endSecond = endTime.atZone(ZoneId.of("Asia/Shanghai")).toEpochSecond();
|
||||
srsRecord.setStartSecond(startSecond);
|
||||
srsRecord.setEndSecond(endSecond);
|
||||
return srsRecord;
|
||||
}
|
||||
return null;
|
||||
}).filter(Objects::nonNull)
|
||||
.toList();
|
||||
return list;
|
||||
}
|
||||
|
||||
|
|
@ -260,27 +276,29 @@ public class AssociatedWaveformTaskExec extends Thread{
|
|||
* 根据经纬度及时间查询范围内的波形数据,并进行计数,最后的计数就是关联的波形结果
|
||||
* @param srsRecordsGroup
|
||||
*/
|
||||
private Integer queryWaveform(List<Origin> origins,Map<Map.Entry<Double, Double>, List<SRSRecord>> srsRecordsGroup,Double gridSize){
|
||||
Set<Integer> idcOrids = ConcurrentHashMap.newKeySet();
|
||||
private Set<Integer> queryWaveform(List<Origin> origins,Map<Map.Entry<Double, Double>, List<SRSRecord>> srsRecordsGroup,Double gridSize){
|
||||
Set<Integer> result = ConcurrentHashMap.newKeySet();
|
||||
if (CollUtil.isNotEmpty(srsRecordsGroup) && CollUtil.isNotEmpty(origins)){
|
||||
srsRecordsGroup.forEach((key,srsRecords)->{
|
||||
double leftLon = Math.floor(key.getKey() / gridSize) * gridSize;
|
||||
double bottomLat = Math.floor(key.getValue() / gridSize) * gridSize;
|
||||
double rightLon = leftLon + gridSize;
|
||||
double topLat = bottomLat + gridSize;
|
||||
//统计srs中每条记录内关联的波形数据
|
||||
srsRecords.parallelStream().forEach(record->{
|
||||
Set<Integer> orids = origins.stream()
|
||||
.filter(origin ->origin.getLon() >= leftLon && origin.getLon() < rightLon &&
|
||||
origin.getLat() >= bottomLat && origin.getLat() < topLat &&
|
||||
origin.getTime() >= record.getStartSecond() && origin.getTime() <= record.getEndSecond())
|
||||
.map(Origin::getOrid).collect(Collectors.toSet());
|
||||
idcOrids.addAll(orids);
|
||||
});
|
||||
double leftLon = Math.floor(key.getKey() / gridSize) * gridSize;
|
||||
double bottomLat = Math.floor(key.getValue() / gridSize) * gridSize;
|
||||
double rightLon = leftLon + gridSize;
|
||||
double topLat = bottomLat + gridSize;
|
||||
//统计srs中每条记录内关联的波形数据
|
||||
srsRecords.parallelStream().forEach(record->{
|
||||
Set<Integer> orids = origins.stream()
|
||||
.filter(origin ->origin.getLon() >= leftLon && origin.getLon() < rightLon &&
|
||||
origin.getLat() >= bottomLat && origin.getLat() < topLat &&
|
||||
origin.getTime() >= record.getStartSecond() && origin.getTime() <= record.getEndSecond())
|
||||
.map(Origin::getOrid).collect(Collectors.toSet());
|
||||
if (CollUtil.isNotEmpty(orids)){
|
||||
result.addAll(orids);
|
||||
}
|
||||
});
|
||||
});
|
||||
return idcOrids.size();
|
||||
return result;
|
||||
}
|
||||
return idcOrids.size();
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -297,6 +315,9 @@ public class AssociatedWaveformTaskExec extends Thread{
|
|||
waveformEvent.setModdate(new Date());
|
||||
this.waveformEventMapper.updateById(waveformEvent);
|
||||
this.transactionManager.commit(transactionStatus);
|
||||
}catch (Exception e){
|
||||
this.transactionManager.rollback(transactionStatus);
|
||||
log.error(e.getMessage(),e);
|
||||
}finally {
|
||||
DataSourceSwitcher.clearDataSource();
|
||||
}
|
||||
|
|
@ -316,6 +337,29 @@ public class AssociatedWaveformTaskExec extends Thread{
|
|||
waveformEvent.setModdate(new Date());
|
||||
this.waveformEventMapper.updateById(waveformEvent);
|
||||
this.transactionManager.commit(transactionStatus);
|
||||
}catch (Exception e){
|
||||
this.transactionManager.rollback(transactionStatus);
|
||||
log.error(e.getMessage(),e);
|
||||
}finally {
|
||||
DataSourceSwitcher.clearDataSource();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 清除历史关联结果
|
||||
* @param sampleId
|
||||
*/
|
||||
private void cleanHistoryResult(Integer sampleId) {
|
||||
DataSourceSwitcher.switchToOracle();
|
||||
final TransactionStatus transactionStatus = this.transactionManager.getTransaction(this.transactionDefinition);
|
||||
try {
|
||||
LambdaQueryWrapper<GardsWaveformEventResult> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(GardsWaveformEventResult::getSampleId, sampleId);
|
||||
this.waveformEventResultMapper.delete(queryWrapper);
|
||||
this.transactionManager.commit(transactionStatus);
|
||||
}catch (Exception e){
|
||||
this.transactionManager.rollback(transactionStatus);
|
||||
log.error(e.getMessage(),e);
|
||||
}finally {
|
||||
DataSourceSwitcher.clearDataSource();
|
||||
}
|
||||
|
|
@ -338,6 +382,32 @@ public class AssociatedWaveformTaskExec extends Thread{
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存关联结果
|
||||
* @param orids
|
||||
*/
|
||||
private void saveWaveformEventResult(Set<Integer> orids,Integer type){
|
||||
DataSourceSwitcher.switchToOracle();
|
||||
final TransactionStatus transactionStatus = this.transactionManager.getTransaction(this.transactionDefinition);
|
||||
try {
|
||||
if(CollUtil.isNotEmpty(orids)){
|
||||
List<GardsWaveformEventResult> waveformEventResults = new ArrayList<>();
|
||||
orids.forEach(orid->{
|
||||
GardsWaveformEventResult waveformEventResult = new GardsWaveformEventResult();
|
||||
waveformEventResult.setSampleId(this.sampleId);
|
||||
waveformEventResult.setOrid(orid);
|
||||
waveformEventResult.setType(type);
|
||||
waveformEventResult.setModdate(new Date());
|
||||
waveformEventResults.add(waveformEventResult);
|
||||
});
|
||||
this.waveformEventResultMapper.insert(waveformEventResults);
|
||||
this.transactionManager.commit(transactionStatus);
|
||||
}
|
||||
}finally {
|
||||
DataSourceSwitcher.clearDataSource();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 读取srm文件
|
||||
* @param gzFile
|
||||
|
|
@ -383,4 +453,17 @@ public class AssociatedWaveformTaskExec extends Thread{
|
|||
}
|
||||
this.updateTaskStatus(this.sampleId,taskStatus);
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
LocalDateTime endTime = LocalDateTime.of(2024,12, 3,18, 0, 0);
|
||||
LocalDateTime startTime = endTime.minusDays(74);
|
||||
|
||||
long startSecond = startTime.atZone(ZoneId.of("Asia/Shanghai")).toEpochSecond();
|
||||
long endSecond = endTime.atZone(ZoneId.of("Asia/Shanghai")).toEpochSecond();
|
||||
|
||||
System.out.println(startSecond);
|
||||
System.out.println(endSecond);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user