人工交互分析,自动处理分页查询修改

This commit is contained in:
qiaoqinzheng 2023-07-26 10:58:44 +08:00
parent dc39e67308
commit 9b747338d7
6 changed files with 171 additions and 70 deletions

View File

@ -1,7 +1,16 @@
package org.jeecg.modules.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.jeecg.modules.base.entity.GardsSampleData;
import java.util.Date;
import java.util.List;
public interface GardsSampleDataWebMapper extends BaseMapper<GardsSampleData> {
Page<GardsSampleData> findAutoPage(String startDate, String endDate, List<Integer> stationIdList, Page<GardsSampleData> page);
Page<GardsSampleData> findReviewedPage(String startDate, String endDate, List<Integer> stationIdList, Page<GardsSampleData> page);
}

View File

@ -0,0 +1,84 @@
<?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.mapper.GardsSampleDataWebMapper">
<select id="findAutoPage" resultType="org.jeecg.modules.base.entity.GardsSampleData">
SELECT
sam.SITE_DET_CODE,
sam.SAMPLE_ID,
sam.STATION_ID,
sam.DETECTOR_ID,
sam.INPUT_FILE_NAME,
sam.SAMPLE_TYPE,
sam.DATA_TYPE,
sam.GEOMETRY,
sam.SPECTRAL_QUALIFIE,
sam.TRANSMIT_DTG,
sam.COLLECT_START,
sam.COLLECT_STOP,
sam.ACQUISITION_START,
sam.ACQUISITION_STOP,
sam.ACQUISITION_REAL_SEC,
sam.ACQUISITION_LIVE_SEC,
sam.QUANTITY,
sam.STATUS,
sam.MODDATE
FROM
ORIGINAL.GARDS_SAMPLE_DATA sam
INNER JOIN RNAUTO.GARDS_ANALYSES ana on ana.SAMPLE_ID = sam.SAMPLE_ID
<where>
sam.COLLECT_START >= TO_DATE(#{startDate}, 'yyyy-mm-dd hh24:mi:ss')
and sam.COLLECT_STOP &lt;= TO_DATE(#{endDate}, 'yyyy-mm-dd hh24:mi:ss')
<if test="stationIdList.size==0 and stationIdList != null">
and sam.STATION_ID in ('')
</if>
<if test="stationIdList.size>0 and stationIdList != null">
and sam.STATION_ID in
<foreach collection="stationIdList" item="stationId" open="(" close=")" separator=",">
#{stationId}
</foreach>
</if>
</where>
</select>
<select id="findReviewedPage" resultType="org.jeecg.modules.base.entity.GardsSampleData">
SELECT
sam.SITE_DET_CODE,
sam.SAMPLE_ID,
sam.STATION_ID,
sam.DETECTOR_ID,
sam.INPUT_FILE_NAME,
sam.SAMPLE_TYPE,
sam.DATA_TYPE,
sam.GEOMETRY,
sam.SPECTRAL_QUALIFIE,
sam.TRANSMIT_DTG,
sam.COLLECT_START,
sam.COLLECT_STOP,
sam.ACQUISITION_START,
sam.ACQUISITION_STOP,
sam.ACQUISITION_REAL_SEC,
sam.ACQUISITION_LIVE_SEC,
sam.QUANTITY,
sam.STATUS,
sam.MODDATE
FROM
ORIGINAL.GARDS_SAMPLE_DATA sam
INNER JOIN RNMAN.GARDS_ANALYSES ana on ana.SAMPLE_ID = sam.SAMPLE_ID
<where>
sam.COLLECT_START >= TO_DATE(#{startDate}, 'yyyy-mm-dd hh24:mi:ss')
and sam.COLLECT_STOP &lt;= TO_DATE(#{endDate}, 'yyyy-mm-dd hh24:mi:ss')
<if test="stationIdList.size ==0 and stationIdList != null">
and sam.STATION_ID in ('')
</if>
<if test="stationIdList.size>0 and stationIdList != null">
and sam.STATION_ID in
<foreach collection="stationIdList" item="stationId" open="(" close=")" separator=",">
#{stationId}
</foreach>
</if>
</where>
</select>
</mapper>

View File

@ -31,12 +31,6 @@ public interface IGardsSampleDataWebService extends IService<GardsSampleData> {
*/
Result findGeneratedReport(Integer sampleId);
/**
* 查询全部基础数据
* @return
*/
Result findPageBySampleIds(QueryRequest queryRequest, Integer[] stationIds, Date startTime, Date endTime, List<Integer> sampleIds);
GardsSampleData getOneSample(Integer sampleId);
void radionuclideExport(Integer[] stationIds,

View File

@ -7,16 +7,21 @@ 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.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.util.DateUtils;
import org.jeecg.common.util.ExportUtil;
import org.jeecg.common.util.RedisUtil;
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.mapper.GardsSampleDataWebMapper;
import org.jeecg.modules.service.IAutoService;
import org.jeecg.modules.service.IGardsSampleDataWebService;
import org.jeecgframework.poi.excel.ExcelExportUtil;
@ -27,9 +32,8 @@ 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.text.ParseException;
import java.util.*;
import java.util.stream.Collectors;
@Service("autoService")
@ -38,21 +42,43 @@ public class AutoServiceImpl extends ServiceImpl<GardsAnalysesAutoMapper, GardsA
@Autowired
private IGardsSampleDataWebService gardsSampleDataService;
@Autowired
private GardsSampleDataWebMapper gardsSampleDataWebMapper;
@Autowired
private RedisUtil redisUtil;
@Override
public Result findAutoPage(QueryRequest queryRequest, Integer[] stationIds, Date startTime, Date endTime) {
//查询自动处理后的
LambdaQueryWrapper<GardsAnalysesAuto> analysesQueryWrapper = new LambdaQueryWrapper<>();
List<GardsAnalysesAuto> gardsAnalyses = this.baseMapper.selectList(analysesQueryWrapper);
if (CollectionUtils.isNotEmpty(gardsAnalyses)){
//获取全部样品id
List<Integer> sampleIds = gardsAnalyses.stream().map(GardsAnalysesAuto::getSampleId).collect(Collectors.toList());
//查询全部样品基础数据
Result result = gardsSampleDataService.findPageBySampleIds(queryRequest, stationIds, startTime, endTime, sampleIds);
Result result = new Result();
//获取redis中缓存的台站信息
Map<Integer, String> stationMap = (Map<Integer, String>)redisUtil.get("stationMap");
if (Objects.isNull(startTime)){
result.error500("开始时间不能为空");
return result;
}else {
return null;
}
String startDate = DateUtils.formatDate(startTime, "yyyy-MM-dd") + " 00:00:00";
if (Objects.isNull(endTime)){
result.error500("结束时间不能为空");
return result;
}
String endDate = DateUtils.formatDate(endTime, "yyyy-MM-dd") + " 23:59:59";
if (Objects.isNull(stationIds)){
result.error500("台站所选id不能为空");
return result;
}
List<Integer> stationIdList = Arrays.asList(stationIds);
Page<GardsSampleData> page = new Page(queryRequest.getPageNo(), queryRequest.getPageSize());
Page<GardsSampleData> sampleDataPage = gardsSampleDataWebMapper.findAutoPage(startDate, endDate, stationIdList, page);
sampleDataPage.getRecords().forEach(item->{
item.setSiteDetCode(StringUtils.trim(item.getSiteDetCode()));
if (stationMap.containsKey(item.getStationId().toString()) && CollectionUtils.isNotEmpty(stationMap)){
String stationName = stationMap.get(item.getStationId().toString());
item.setStationName(stationName);
}
});
result.setSuccess(true);
result.setResult(sampleDataPage);
return result;
}
@Override

View File

@ -577,44 +577,6 @@ public class GardsSampleDataWebServiceImpl extends ServiceImpl<GardsSampleDataWe
report.setCertificateBlock(certificateBlock);
}
@Transactional(propagation = Propagation.REQUIRES_NEW,rollbackFor = Exception.class)
public Result findPageBySampleIds(QueryRequest queryRequest, Integer[] stationIds, Date startTime, Date endTime, List<Integer> sampleIds){
Result result = new Result();
try {
//获取redis中缓存的台站信息
Map<Integer, String> stationMap = (Map<Integer, String>)redisUtil.get("stationMap");
Page<GardsSampleData> page = new Page<>(queryRequest.getPageNo(), queryRequest.getPageSize());
if (Objects.isNull(startTime)){
result.error500("开始时间不能为空");
return result;
}
Date startDate = DateUtils.parseDate(DateUtils.formatDate(startTime, "yyyy-MM-dd") + " 00:00:00", "yyyy-MM-dd HH:mm:ss");
if (Objects.isNull(endTime)){
result.error500("结束时间不能为空");
return result;
}
Date endDate = DateUtils.parseDate(DateUtils.formatDate(endTime, "yyyy-MM-dd") + " 23:59:59", "yyyy-MM-dd HH:mm:ss");
LambdaQueryWrapper<GardsSampleData> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.in(GardsSampleData::getStationId, stationIds);
queryWrapper.in(GardsSampleData::getSampleId, sampleIds);
queryWrapper.ge(GardsSampleData::getCollectStart, startDate);
queryWrapper.le(GardsSampleData::getCollectStop, endDate);
Page<GardsSampleData> sampleDataPage = this.baseMapper.selectPage(page, queryWrapper);
sampleDataPage.getRecords().forEach(item->{
item.setSiteDetCode(StringUtils.trim(item.getSiteDetCode()));
if (stationMap.containsKey(item.getStationId().toString()) && CollectionUtils.isNotEmpty(stationMap)){
String stationName = stationMap.get(item.getStationId().toString());
item.setStationName(stationName);
}
});
result.setSuccess(true);
result.setResult(sampleDataPage);
return result;
} catch (ParseException e) {
throw new RuntimeException(e);
}
}
@Override
public GardsSampleData getOneSample(Integer sampleId) {
LambdaQueryWrapper<GardsSampleData> wrapper = new LambdaQueryWrapper<>();

View File

@ -5,16 +5,21 @@ 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.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.util.DateUtils;
import org.jeecg.common.util.ExportUtil;
import org.jeecg.common.util.RedisUtil;
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.mapper.GardsSampleDataWebMapper;
import org.jeecg.modules.service.IGardsSampleDataWebService;
import org.jeecg.modules.service.IReviewedService;
import org.jeecgframework.poi.excel.ExcelExportUtil;
@ -25,9 +30,8 @@ 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.text.ParseException;
import java.util.*;
import java.util.stream.Collectors;
@Service("reviewedService")
@ -36,21 +40,43 @@ public class ReviewedServiceImpl extends ServiceImpl<GardsAnalysesManMapper, Gar
@Autowired
private IGardsSampleDataWebService gardsSampleDataService;
@Autowired
private GardsSampleDataWebMapper gardsSampleDataWebMapper;
@Autowired
private RedisUtil redisUtil;
@Override
public Result findReviewedPage(QueryRequest queryRequest, Integer[] stationIds, Date startTime, Date endTime) {
//查询自动处理后的
LambdaQueryWrapper<GardsAnalysesMan> analysesQueryWrapper = new LambdaQueryWrapper<>();
List<GardsAnalysesMan> gardsAnalyses = this.baseMapper.selectList(analysesQueryWrapper);
if (CollectionUtils.isNotEmpty(gardsAnalyses)){
//获取全部样品id
List<Integer> sampleIds = gardsAnalyses.stream().map(GardsAnalysesMan::getSampleId).collect(Collectors.toList());
//查询全部样品基础数据
Result result = gardsSampleDataService.findPageBySampleIds(queryRequest, stationIds, startTime, endTime, sampleIds);
Result result = new Result();
//获取redis中缓存的台站信息
Map<Integer, String> stationMap = (Map<Integer, String>)redisUtil.get("stationMap");
if (Objects.isNull(startTime)){
result.error500("开始时间不能为空");
return result;
}else {
return null;
}
String startDate = DateUtils.formatDate(startTime, "yyyy-MM-dd") + " 00:00:00";
if (Objects.isNull(endTime)){
result.error500("结束时间不能为空");
return result;
}
String endDate = DateUtils.formatDate(endTime, "yyyy-MM-dd") + " 23:59:59";
if (Objects.isNull(stationIds)){
result.error500("台站所选id不能为空");
return result;
}
List<Integer> stationIdList = Arrays.asList(stationIds);
Page<GardsSampleData> page = new Page(queryRequest.getPageNo(), queryRequest.getPageSize());
Page<GardsSampleData> sampleDataPage = gardsSampleDataWebMapper.findReviewedPage(startDate, endDate, stationIdList, page);
sampleDataPage.getRecords().forEach(item->{
item.setSiteDetCode(StringUtils.trim(item.getSiteDetCode()));
if (stationMap.containsKey(item.getStationId().toString()) && CollectionUtils.isNotEmpty(stationMap)){
String stationName = stationMap.get(item.getStationId().toString());
item.setStationName(stationName);
}
});
result.setSuccess(true);
result.setResult(sampleDataPage);
return result;
}
@Override