fix:Bug Fix

This commit is contained in:
nieziyan 2023-09-11 22:11:13 +08:00
parent 136920dfeb
commit f74a2a8358
6 changed files with 27 additions and 1 deletions

View File

@ -0,0 +1,20 @@
package org.jeecg.common.util;
import cn.hutool.core.util.ObjectUtil;
import java.math.BigDecimal;
import java.math.RoundingMode;
public class NumUtil {
public static Double fixedMax(int bit, Double value){
if (ObjectUtil.isNull(value))
return value;
// 获取整数位数
int length = String.valueOf(value).split("\\.")[0].length();
if (length >= bit)
return value;
int scale = bit - length;
BigDecimal decimal = new BigDecimal(value);
return decimal.setScale(scale, RoundingMode.HALF_UP).doubleValue();
}
}

View File

@ -5,6 +5,7 @@ import cn.hutool.core.collection.ListUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.io.FileUtil;
import cn.hutool.core.map.MapUtil;
import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.ReUtil;
import cn.hutool.core.util.StrUtil;
@ -47,6 +48,7 @@ import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.text.DecimalFormat;
import java.text.ParseException;
import java.time.LocalDateTime;
import java.util.*;
@ -1865,7 +1867,7 @@ public class GammaServiceImpl implements IGammaService {
}
item.setName(name);
item.setFlag(iter.getValue().isBPass() ? "PASS" : "FAIL");
item.setValue(iter.getValue().getValue());
item.setValue(NumUtil.fixedMax(6 ,iter.getValue().getValue()));
String standard="";
List<String> strList = Arrays.asList(iter.getValue().getStandard().split(StringPool.COMMA));
for (String str : strList) {
@ -1890,6 +1892,8 @@ public class GammaServiceImpl implements IGammaService {
}
}
item.setStandard(standard);
if(StrUtil.equals(name, "Xe133-MDC (uBq/m3)"))
qcResultList.add(0, item);
qcResultList.add(item);
}
result.setSuccess(true);

View File

@ -1183,6 +1183,8 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService {
QCResult qcResult = result.getResult();
if (ObjectUtil.isNull(qcResult)) return;
Map<String, Object> dataMap = BeanUtil.beanToMap(qcResult);
// 将Null值替换为"",避免空指针异常(或者在模板中进行判断)
dataMap.replaceAll((key, value) -> ObjectUtil.isNull(value) ? "" : value);
String export = "QCResult-Beta.xls";
String template = QcResult_B.getName();
ExportUtil.exportXls(response,template,dataMap,export);