update
This commit is contained in:
@@ -17,7 +17,6 @@ import org.jeecg.common.aspect.annotation.AutoLog;
|
||||
import org.jeecg.common.system.base.controller.JeecgController;
|
||||
import org.jeecg.common.system.query.QueryGenerator;
|
||||
import org.jeecg.modules.database.dto.NasaDataRecordPage;
|
||||
import org.jeecg.modules.database.entity.Experiment;
|
||||
import org.jeecg.modules.database.entity.NasaDataRecord;
|
||||
import org.jeecg.modules.database.service.IExperimentService;
|
||||
import org.jeecg.modules.database.service.INasaDataRecordService;
|
||||
@@ -78,22 +77,16 @@ public class NasaDataRecordController extends JeecgController<NasaDataRecord, IN
|
||||
@GetMapping(value = "/statistics")
|
||||
public Result<NasaDataRecordPage> queryPageList(NasaDataRecord nasaDataRecord) {
|
||||
NasaDataRecordPage result = new NasaDataRecordPage();
|
||||
List<NasaDataRecord> list = nasaDataRecordService.list();
|
||||
long totalCountLhs = list.stream().filter(Objects::nonNull).mapToLong(NasaDataRecord::getTotalCountLhs).filter(Objects::nonNull)
|
||||
.sum();
|
||||
long totalCountXhy = list.stream().filter(Objects::nonNull).mapToLong(NasaDataRecord::getTotalCountNasa).filter(Objects::nonNull)
|
||||
.sum();
|
||||
Long nasaCountLhs = nasaDataRecordService.sumLhs();
|
||||
Long nasaCountXhy = nasaDataRecordService.sumXhy();
|
||||
|
||||
List<Experiment> experimentList = experimentService.list();
|
||||
long experimentLhs = experimentList.stream().filter(Objects::nonNull).mapToLong(Experiment::getTotalCountLhs).filter(
|
||||
Objects::nonNull).sum();
|
||||
long experimentXhy = experimentList.stream().filter(Objects::nonNull).mapToLong(Experiment::getTotalCountXhy).filter(
|
||||
Objects::nonNull).sum();
|
||||
Long localCountLhs = experimentService.sumLhs();
|
||||
Long localCountXhy = experimentService.sumXhy();
|
||||
|
||||
result.setLhsCount(totalCountLhs);
|
||||
result.setLhsTotal(totalCountLhs + experimentLhs);
|
||||
result.setXhyCount(totalCountXhy);
|
||||
result.setXyhTotal(totalCountXhy + experimentXhy);
|
||||
result.setLhsCount(nasaCountLhs);
|
||||
result.setLhsTotal(nasaCountLhs + localCountLhs);
|
||||
result.setXhyCount(nasaCountXhy);
|
||||
result.setXyhTotal(nasaCountXhy + localCountXhy);
|
||||
return Result.OK(result);
|
||||
}
|
||||
|
||||
|
||||
@@ -15,8 +15,8 @@ import org.jeecg.modules.database.entity.NasaDataRecord;
|
||||
|
||||
@Data
|
||||
public class NasaDataRecordPage {
|
||||
private long lhsCount;
|
||||
private long lhsTotal;
|
||||
private long xhyCount;
|
||||
private long xyhTotal;
|
||||
private Long lhsCount;
|
||||
private Long lhsTotal;
|
||||
private Long xhyCount;
|
||||
private Long xyhTotal;
|
||||
}
|
||||
@@ -3,6 +3,7 @@ package org.jeecg.modules.database.mapper;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
import org.jeecg.modules.database.entity.Experiment;
|
||||
|
||||
/**
|
||||
@@ -14,4 +15,10 @@ import org.jeecg.modules.database.entity.Experiment;
|
||||
public interface ExperimentMapper extends BaseMapper<Experiment> {
|
||||
|
||||
IPage<Experiment> join(Page<Experiment> page, Experiment experiment);
|
||||
|
||||
@Select("SELECT SUM(total_count_lhs) FROM experiment where total_count_lhs is not null")
|
||||
Long sumLhs();
|
||||
|
||||
@Select("SELECT SUM(total_count_xhy) FROM experiment where total_count_xhy is not null")
|
||||
Long sumXhy();
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package org.jeecg.modules.database.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
import org.jeecg.modules.database.entity.NasaDataRecord;
|
||||
|
||||
/**
|
||||
@@ -11,4 +12,9 @@ import org.jeecg.modules.database.entity.NasaDataRecord;
|
||||
*/
|
||||
public interface NasaDataRecordMapper extends BaseMapper<NasaDataRecord> {
|
||||
|
||||
@Select("SELECT SUM(total_count_lhs) FROM nasa_data_record where total_count_lhs is not null")
|
||||
Long sumLhs();
|
||||
|
||||
@Select("SELECT SUM(total_count_nasa) FROM nasa_data_record where total_count_lhs is not null")
|
||||
Long sumXhy();
|
||||
}
|
||||
|
||||
@@ -25,4 +25,8 @@ public interface IExperimentService extends IService<Experiment> {
|
||||
Integer getLastIndex();
|
||||
|
||||
IPage<Experiment> join(Page<Experiment> page, Experiment experiment, QueryWrapper<Experiment> queryWrapper);
|
||||
|
||||
Long sumLhs();
|
||||
|
||||
Long sumXhy();
|
||||
}
|
||||
|
||||
@@ -11,4 +11,7 @@ import org.jeecg.modules.database.entity.NasaDataRecord;
|
||||
*/
|
||||
public interface INasaDataRecordService extends IService<NasaDataRecord> {
|
||||
|
||||
Long sumLhs();
|
||||
|
||||
Long sumXhy();
|
||||
}
|
||||
|
||||
@@ -18,8 +18,7 @@ import org.jeecg.modules.system.service.ISysUserService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
@@ -278,4 +277,14 @@ public class ExperimentServiceImpl extends ServiceImpl<ExperimentMapper, Experim
|
||||
public IPage<Experiment> join(Page<Experiment> page, Experiment experiment, QueryWrapper<Experiment> queryWrapper) {
|
||||
return baseMapper.join(page, experiment);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long sumLhs() {
|
||||
return Optional.ofNullable(baseMapper.sumLhs()).orElse(0L);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long sumXhy() {
|
||||
return Optional.ofNullable(baseMapper.sumXhy()).orElse(0L);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,8 @@ import org.jeecg.modules.database.mapper.NasaDataRecordMapper;
|
||||
import org.jeecg.modules.database.service.INasaDataRecordService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* @Description: NASA数据管理
|
||||
* @Author: jeecg-boot
|
||||
@@ -15,4 +17,14 @@ import org.springframework.stereotype.Service;
|
||||
@Service
|
||||
public class NasaDataRecordServiceImpl extends ServiceImpl<NasaDataRecordMapper, NasaDataRecord> implements INasaDataRecordService {
|
||||
|
||||
@Override
|
||||
public Long sumLhs() {
|
||||
return Optional.ofNullable(baseMapper.sumLhs()).orElse(0L);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long sumXhy() {
|
||||
return Optional.ofNullable(baseMapper.sumXhy()).orElse(0L);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user