feat:bugs

This commit is contained in:
nieziyan 2023-10-27 19:19:39 +08:00
parent 94ed1907d8
commit 6c2f0a5415
20 changed files with 1929 additions and 1827 deletions

View File

@ -1,14 +1,15 @@
package org.jeecg.common.util; package org.jeecg.common.util;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.ListUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import org.jeecgframework.poi.excel.entity.TemplateExportParams; import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.DefaultResourceLoader; import org.springframework.core.io.DefaultResourceLoader;
import org.springframework.core.io.Resource; import org.springframework.core.io.Resource;
import org.springframework.core.io.ResourceLoader; import org.springframework.core.io.ResourceLoader;
import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -71,6 +72,17 @@ public class ClassUtil {
} }
} }
public static InputStream classPathStream(String classPath){
try {
ClassPathResource resource = new ClassPathResource(classPath);
return resource.getInputStream();
} catch (IOException e) {
e.printStackTrace();
return null;
}
}
public static <T1,T2> void copyProperties(T1 source, T2 target){ public static <T1,T2> void copyProperties(T1 source, T2 target){
Class<?> sourceClass = source.getClass(); Class<?> sourceClass = source.getClass();
Class<?> targetClass = target.getClass(); Class<?> targetClass = target.getClass();

View File

@ -12,15 +12,15 @@ import org.springframework.core.io.Resource;
import org.springframework.core.io.ResourceLoader; import org.springframework.core.io.ResourceLoader;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.IOException; import java.io.*;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.net.URLEncoder; import java.net.URLEncoder;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import static org.jeecg.common.util.ClassUtil.classPathStream;
public class ExportUtil { public class ExportUtil {
private static final String UTF_8 = StandardCharsets.UTF_8.name(); private static final String UTF_8 = StandardCharsets.UTF_8.name();
@ -101,7 +101,9 @@ public class ExportUtil {
public static TemplateExportParams excelTemplate(String template){ public static TemplateExportParams excelTemplate(String template){
String pathPrefix = "excelTemplate/"; String pathPrefix = "excelTemplate/";
String path = pathPrefix + template; String path = pathPrefix + template;
String templatePath = ClassUtil.classPath(path); InputStream inputStream = classPathStream(path);
String templatePath = "";
return new TemplateExportParams(templatePath); return new TemplateExportParams(templatePath);
} }

View File

@ -12,4 +12,14 @@ public class ConcDto implements Serializable {
private String conc; private String conc;
private Date analysisBegin; private Date analysisBegin;
public ConcDto() {
}
public ConcDto(String nuclideName, String conc, Date analysisBegin) {
this.nuclideName = nuclideName;
this.conc = conc;
this.analysisBegin = analysisBegin;
}
} }

View File

@ -0,0 +1,16 @@
package org.jeecg.modules.base.dto;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
@Data
public class ConcDtoXe implements Serializable {
private String nuclideName;
private Double conc;
private Date analysisBegin;
}

View File

@ -3,6 +3,7 @@ package org.jeecg.modules.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.jeecg.modules.base.dto.ConcDto; import org.jeecg.modules.base.dto.ConcDto;
import org.jeecg.modules.base.dto.ConcDtoXe;
import org.jeecg.modules.base.entity.rnauto.GardsNuclIded; import org.jeecg.modules.base.entity.rnauto.GardsNuclIded;
import java.util.List; import java.util.List;

View File

@ -3,6 +3,7 @@ package org.jeecg.modules.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.jeecg.modules.base.dto.ConcDto; import org.jeecg.modules.base.dto.ConcDto;
import org.jeecg.modules.base.dto.ConcDtoXe;
import org.jeecg.modules.base.entity.rnauto.GardsXeResults; import org.jeecg.modules.base.entity.rnauto.GardsXeResults;
import java.util.List; import java.util.List;
@ -12,7 +13,7 @@ import java.util.Set;
@Mapper @Mapper
public interface GardsXeResultsAutoMapper extends BaseMapper<GardsXeResults> { public interface GardsXeResultsAutoMapper extends BaseMapper<GardsXeResults> {
List<ConcDto> getConc(Map<String,Object> params); List<ConcDtoXe> getConc(Map<String,Object> params);
List<String> nuclideNames(Set<String> nuclideNames); List<String> nuclideNames(Set<String> nuclideNames);
} }

View File

@ -3,6 +3,7 @@ package org.jeecg.modules.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.jeecg.modules.base.dto.ConcDto; import org.jeecg.modules.base.dto.ConcDto;
import org.jeecg.modules.base.dto.ConcDtoXe;
import org.jeecg.modules.base.entity.rnman.GardsXeResults; import org.jeecg.modules.base.entity.rnman.GardsXeResults;
import java.util.List; import java.util.List;
@ -12,7 +13,7 @@ import java.util.Set;
@Mapper @Mapper
public interface GardsXeResultsManMapper extends BaseMapper<GardsXeResults> { public interface GardsXeResultsManMapper extends BaseMapper<GardsXeResults> {
List<ConcDto> getConc(Map<String,Object> params); List<ConcDtoXe> getConc(Map<String,Object> params);
List<String> nuclideNames(Set<String> nuclideNames); List<String> nuclideNames(Set<String> nuclideNames);
} }

View File

@ -2,7 +2,7 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.jeecg.modules.mapper.GardsXeResultsAutoMapper"> <mapper namespace="org.jeecg.modules.mapper.GardsXeResultsAutoMapper">
<select id="getConc" resultType="org.jeecg.modules.base.dto.ConcDto"> <select id="getConc" resultType="org.jeecg.modules.base.dto.ConcDtoXe">
SELECT SELECT
xe.NUCLIDE_NAME, xe.NUCLIDE_NAME,
xe.CONC, xe.CONC,

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?> <?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"> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.jeecg.modules.mapper.GardsXeResultsManMapper"> <mapper namespace="org.jeecg.modules.mapper.GardsXeResultsManMapper">
<select id="getConc" resultType="org.jeecg.modules.base.dto.ConcDto"> <select id="getConc" resultType="org.jeecg.modules.base.dto.ConcDtoXe">
SELECT SELECT
xe.NUCLIDE_NAME, xe.NUCLIDE_NAME,
xe.CONC, xe.CONC,

View File

@ -2,6 +2,7 @@ package org.jeecg.modules.service;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import org.jeecg.modules.base.dto.ConcDto; import org.jeecg.modules.base.dto.ConcDto;
import org.jeecg.modules.base.dto.ConcDtoXe;
import org.jeecg.modules.base.entity.rnauto.GardsNuclIded; import org.jeecg.modules.base.entity.rnauto.GardsNuclIded;
import java.util.List; import java.util.List;

View File

@ -2,6 +2,7 @@ package org.jeecg.modules.service;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import org.jeecg.modules.base.dto.ConcDto; import org.jeecg.modules.base.dto.ConcDto;
import org.jeecg.modules.base.dto.ConcDtoXe;
import org.jeecg.modules.base.entity.rnauto.GardsXeResults; import org.jeecg.modules.base.entity.rnauto.GardsXeResults;
import java.util.List; import java.util.List;
@ -10,7 +11,7 @@ import java.util.Set;
public interface IGardsXeResultsAutoService extends IService<GardsXeResults> { public interface IGardsXeResultsAutoService extends IService<GardsXeResults> {
List<ConcDto> getConc(Map<String,Object> params); List<ConcDtoXe> getConc(Map<String,Object> params);
List<String> nuclideNames(Set<String> nuclideNames); List<String> nuclideNames(Set<String> nuclideNames);
} }

View File

@ -2,6 +2,7 @@ package org.jeecg.modules.service;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import org.jeecg.modules.base.dto.ConcDto; import org.jeecg.modules.base.dto.ConcDto;
import org.jeecg.modules.base.dto.ConcDtoXe;
import org.jeecg.modules.base.entity.rnman.GardsXeResults; import org.jeecg.modules.base.entity.rnman.GardsXeResults;
import java.util.List; import java.util.List;
@ -10,7 +11,7 @@ import java.util.Set;
public interface IGardsXeResultsManService extends IService<GardsXeResults> { public interface IGardsXeResultsManService extends IService<GardsXeResults> {
List<ConcDto> getConc(Map<String,Object> params); List<ConcDtoXe> getConc(Map<String,Object> params);
List<String> nuclideNames(Set<String> nuclideNames); List<String> nuclideNames(Set<String> nuclideNames);
} }

View File

@ -7,6 +7,7 @@ import org.jeecg.common.constant.CommonConstant;
import org.jeecg.common.constant.DateConstant; import org.jeecg.common.constant.DateConstant;
import org.jeecg.common.constant.SymbolConstant; import org.jeecg.common.constant.SymbolConstant;
import org.jeecg.modules.base.dto.ConcDto; import org.jeecg.modules.base.dto.ConcDto;
import org.jeecg.modules.base.dto.ConcDtoXe;
import org.jeecg.modules.base.entity.postgre.AlarmAnalysisNuclideAvg; import org.jeecg.modules.base.entity.postgre.AlarmAnalysisNuclideAvg;
import org.jeecg.modules.base.entity.postgre.AlarmAnalysisNuclideParam; import org.jeecg.modules.base.entity.postgre.AlarmAnalysisNuclideParam;
import org.jeecg.modules.base.entity.postgre.AlarmAnalysisRule; import org.jeecg.modules.base.entity.postgre.AlarmAnalysisRule;
@ -69,24 +70,25 @@ public class CalculateConcServiceImpl implements CalculateConcService {
params.put("endDate",endDate + DateConstant.TIME_END); params.put("endDate",endDate + DateConstant.TIME_END);
/* Auto自动处理 */ /* Auto自动处理 */
// beta-gamma // beta-gamma
List<ConcDto> xeConcAuto = xeResultsAutoService.getConc(params); List<ConcDtoXe> xeConcAuto = xeResultsAutoService.getConc(params);
// gamma // gamma
List<ConcDto> nuclConcAuto = nuclIdedAutoService.getConc(params); List<ConcDto> nuclConcAuto = nuclIdedAutoService.getConc(params);
Map<String,String> autoResult = new HashMap<>(); Map<String,String> autoResult = new HashMap<>();
autoResult.putAll(calculate(xeConcAuto,index)); autoResult.putAll(calculate(concDto(xeConcAuto), index));
autoResult.putAll(calculate(nuclConcAuto,index)); autoResult.putAll(calculate(nuclConcAuto, index));
List<AlarmAnalysisNuclideAvg> autoAvgs = autoResult.entrySet().stream() List<AlarmAnalysisNuclideAvg> autoAvgs = autoResult.entrySet().stream()
.map(entry -> new AlarmAnalysisNuclideAvg(entry.getKey(), entry.getValue())) .map(entry -> new AlarmAnalysisNuclideAvg(entry.getKey(), entry.getValue()))
.collect(Collectors.toList()); .collect(Collectors.toList());
autoAvgs.forEach(item -> item.setDataSourceType(CommonConstant.ARMDARR)); autoAvgs.forEach(item -> item.setDataSourceType(CommonConstant.ARMDARR));
/* Man人工交互 */ /* Man人工交互 */
// beta-gamma // beta-gamma
List<ConcDto> xeConcMan = xeResultsManService.getConc(params); List<ConcDtoXe> xeConcMan = xeResultsManService.getConc(params);
// gamma // gamma
List<ConcDto> nuclConcMan = nuclIdedManService.getConc(params); List<ConcDto> nuclConcMan = nuclIdedManService.getConc(params);
Map<String,String> manResult = new HashMap<>(); Map<String,String> manResult = new HashMap<>();
manResult.putAll(calculate(xeConcMan,index)); manResult.putAll(calculate(concDto(xeConcMan), index));
manResult.putAll(calculate(nuclConcMan,index)); manResult.putAll(calculate(nuclConcMan, index));
List<AlarmAnalysisNuclideAvg> manAvgs = manResult.entrySet().stream() List<AlarmAnalysisNuclideAvg> manAvgs = manResult.entrySet().stream()
.map(entry -> new AlarmAnalysisNuclideAvg(entry.getKey(), entry.getValue())) .map(entry -> new AlarmAnalysisNuclideAvg(entry.getKey(), entry.getValue()))
.collect(Collectors.toList()); .collect(Collectors.toList());
@ -103,7 +105,7 @@ public class CalculateConcServiceImpl implements CalculateConcService {
@Override @Override
public Map<String, String> calculate(List<ConcDto> concDtos, BigDecimal index) { public Map<String, String> calculate(List<ConcDto> concDtos, BigDecimal index) {
Map<String,String> result = new HashMap<>(); Map<String, String> result = new HashMap<>();
// 按照核素名进行分组 // 按照核素名进行分组
Map<String, List<ConcDto>> concDtoMap = concDtos.stream() Map<String, List<ConcDto>> concDtoMap = concDtos.stream()
.collect(Collectors.groupingBy(ConcDto::getNuclideName)); .collect(Collectors.groupingBy(ConcDto::getNuclideName));
@ -119,8 +121,18 @@ public class CalculateConcServiceImpl implements CalculateConcService {
BigDecimal line = new BigDecimal(baseLine); BigDecimal line = new BigDecimal(baseLine);
int i = line.multiply(index).setScale(0, RoundingMode.HALF_UP).intValue(); int i = line.multiply(index).setScale(0, RoundingMode.HALF_UP).intValue();
int j = Math.max(i - 1, 0); int j = Math.max(i - 1, 0);
result.put(nuclide,values.get(j).getConc()); result.put(nuclide, values.get(j).getConc());
} }
return result; return result;
} }
private List<ConcDto> concDto(List<ConcDtoXe> concDtoXes){
List<ConcDto> concDtos = new ArrayList<>();
if (CollUtil.isEmpty(concDtoXes)) return concDtos;
concDtos = concDtoXes.stream()
.map(xe -> new ConcDto(xe.getNuclideName(), String.valueOf(xe.getConc()), xe.getAnalysisBegin()))
.collect(Collectors.toList());
return concDtos;
}
} }

View File

@ -4,6 +4,7 @@ import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.jeecg.common.constant.DateConstant; import org.jeecg.common.constant.DateConstant;
import org.jeecg.modules.base.dto.ConcDto; import org.jeecg.modules.base.dto.ConcDto;
import org.jeecg.modules.base.dto.ConcDtoXe;
import org.jeecg.modules.base.entity.rnauto.GardsNuclIded; import org.jeecg.modules.base.entity.rnauto.GardsNuclIded;
import org.jeecg.modules.base.entity.rnauto.GardsXeResults; import org.jeecg.modules.base.entity.rnauto.GardsXeResults;
import org.jeecg.modules.mapper.GardsNuclIdedAutoMapper; import org.jeecg.modules.mapper.GardsNuclIdedAutoMapper;

View File

@ -4,6 +4,7 @@ import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.jeecg.common.constant.DateConstant; import org.jeecg.common.constant.DateConstant;
import org.jeecg.modules.base.dto.ConcDto; import org.jeecg.modules.base.dto.ConcDto;
import org.jeecg.modules.base.dto.ConcDtoXe;
import org.jeecg.modules.base.entity.rnauto.GardsXeResults; import org.jeecg.modules.base.entity.rnauto.GardsXeResults;
import org.jeecg.modules.mapper.GardsXeResultsAutoMapper; import org.jeecg.modules.mapper.GardsXeResultsAutoMapper;
import org.jeecg.modules.service.IGardsXeResultsAutoService; import org.jeecg.modules.service.IGardsXeResultsAutoService;
@ -23,7 +24,7 @@ public class GardsXeResultsAutoServiceImpl extends ServiceImpl<GardsXeResultsAut
@Override @Override
public List<ConcDto> getConc(Map<String, Object> params) { public List<ConcDtoXe> getConc(Map<String, Object> params) {
return baseMapper.getConc(params); return baseMapper.getConc(params);
} }

View File

@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.jeecg.common.constant.DateConstant; import org.jeecg.common.constant.DateConstant;
import org.jeecg.modules.base.dto.ConcDto; import org.jeecg.modules.base.dto.ConcDto;
import org.jeecg.modules.base.dto.ConcDtoXe;
import org.jeecg.modules.base.entity.rnman.GardsXeResults; import org.jeecg.modules.base.entity.rnman.GardsXeResults;
import org.jeecg.modules.mapper.GardsXeResultsManMapper; import org.jeecg.modules.mapper.GardsXeResultsManMapper;
import org.jeecg.modules.service.IGardsXeResultsManService; import org.jeecg.modules.service.IGardsXeResultsManService;
@ -23,7 +24,7 @@ public class GardsXeResultsManServiceImpl extends ServiceImpl<GardsXeResultsManM
@Override @Override
public List<ConcDto> getConc(Map<String, Object> params) { public List<ConcDtoXe> getConc(Map<String, Object> params) {
return baseMapper.getConc(params); return baseMapper.getConc(params);
} }

View File

@ -230,4 +230,10 @@ public class SpectrumAnalysesController {
@RequestBody BgDataAnlyseResultIn anlyseResultIn){ @RequestBody BgDataAnlyseResultIn anlyseResultIn){
spectrumAnalysisService.saveToTxt(anlyseResultIn, response); spectrumAnalysisService.saveToTxt(anlyseResultIn, response);
} }
@GetMapping("viewAutomaticAnalysisLog")
@ApiOperation(value = "查看Automatic Analysis Log页面数据", notes = "查看Automatic Analysis Log页面数据")
public void viewAutomaticAnalysisLog(Integer sampleId, HttpServletResponse response) {
spectrumAnalysisService.viewAutomaticAnalysisLog(sampleId, response);
}
} }

View File

@ -81,4 +81,6 @@ public interface ISpectrumAnalysisService {
void saveToExcel(BgDataAnlyseResultIn anlyseResultIn, HttpServletResponse response); void saveToExcel(BgDataAnlyseResultIn anlyseResultIn, HttpServletResponse response);
void saveToTxt(BgDataAnlyseResultIn anlyseResultIn, HttpServletResponse response); void saveToTxt(BgDataAnlyseResultIn anlyseResultIn, HttpServletResponse response);
void viewAutomaticAnalysisLog(Integer sampleId, HttpServletResponse response);
} }