Commit 800d6d1c by wangweidong

土工平台修改

parent 928a5fbc
......@@ -1434,7 +1434,62 @@ public class SoilEntrustServiceImpl extends BaseServiceImpl<SoilEntrustMapper, S
}else{
continue;
}
int dataSize = data.size();
Set<String> checkKey = new HashSet<>();
for (int i = 0; i < dataSize; i++) {
Map<String,Object> mapData = data.get(i);
for (Map.Entry<String,Object> s:mapData.entrySet()) {
checkKey.add(s.getKey());
}
}
if (!checkKey.contains("wuxing")){
Map<String,Object> wuxingFales = new HashMap<>();
wuxingFales.put("wuxing",false);
Map<String,Object> wuxingFalesEnd = new HashMap<>();
wuxingFalesEnd.put("wuxingEnd",false);
Map<String,Object> wuxingFalesZiJiao = new HashMap<>();
wuxingFalesZiJiao.put("wuxingZiJiaoCheck",false);
data.add(wuxingFales);
data.add(wuxingFalesEnd);
data.add(wuxingFalesZiJiao);
}
if (!checkKey.contains("lixue")){
Map<String,Object> lixueFales = new HashMap<>();
lixueFales.put("lixue",false);
Map<String,Object> lixueFalesEnd = new HashMap<>();
lixueFalesEnd.put("lixueEnd",false);
Map<String,Object> lixueFalesZiJiao = new HashMap<>();
lixueFalesZiJiao.put("lixueZiJiaoCheck",false);
data.add(lixueFales);
data.add(lixueFalesEnd);
data.add(lixueFalesZiJiao);
}
if (!checkKey.contains("gaoji")){
Map<String,Object> gaojiFales = new HashMap<>();
gaojiFales.put("gaoji",false);
Map<String,Object> gaojiFalesEnd = new HashMap<>();
gaojiFalesEnd.put("gaojiEnd",false);
Map<String,Object> gaojiFalesZiJiao = new HashMap<>();
gaojiFalesZiJiao.put("gaojiZiJiaoCheck",false);
data.add(gaojiFales);
data.add(gaojiFalesEnd);
data.add(gaojiFalesZiJiao);
}
}
page.setRecords(dtoList);
return page;
}
......
......@@ -49,6 +49,7 @@ import net.coobird.thumbnailator.Thumbnails;
import org.apache.commons.collections4.ListUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.math.NumberUtils;
import org.apache.poi.ss.usermodel.BorderStyle;
import org.apache.poi.ss.usermodel.CellType;
import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.xssf.usermodel.*;
......@@ -322,6 +323,10 @@ public class SoilExperimentServiceImpl extends BaseServiceImpl<SoilExperimentMap
mapReplace.put("#{reportCode}",entrust.getEntrustCode());
List<SoilOriginalTemplateConfig> configList = soilOriginalTemplateConfigService.list(Condition.create().eq("template_id",templateId));
boolean attachJIeXianWater = "界限含水率 (碟式液限仪多点法)试验记录表".equals(template.getName());
if (null==template.getMoreSheet() || 0 == template.getMoreSheet()){
logger.error("----------------------3");
......@@ -341,6 +346,12 @@ public class SoilExperimentServiceImpl extends BaseServiceImpl<SoilExperimentMap
int templateSampleNum = template.getTemplateSampleNum();
if (voList.size()<templateSampleNum){
int sampleMergerNum = template.getSampleMergerNum();
int xBegin1 = 9;
int xBegin2 = 10;
int xBegin3 = 11;
int xStep = 5;
for (SoilExperimentVO vo:voList) {
XSSFRow xssfRow = sheetOne.getRow(beginRow);
for (SoilOriginalTemplateConfig config:configList) {
......@@ -351,6 +362,127 @@ public class SoilExperimentServiceImpl extends BaseServiceImpl<SoilExperimentMap
cell.setCellValue(StringHandleUtils.getFieldIfNummReturnBlankValueByFieldName(config.getDataAttribute(),vo));
}
beginRow+=sampleMergerNum;
if (attachJIeXianWater){
XSSFSheet sheet = xssfWorkbook.createSheet("附录"+vo.getSampleCode());
XSSFCellStyle style = xssfWorkbook.createCellStyle();
style.setBorderBottom(BorderStyle.THIN);
style.setBorderLeft(BorderStyle.THIN);
style.setBorderRight(BorderStyle.THIN);
style.setBorderTop(BorderStyle.THIN);
for (int i = 0; i < 5; i++) {
XSSFRow row = sheet.createRow(i);
for (int j = 0; j < 2; j++) {
XSSFCell cell = row.createCell(j);
cell.setCellStyle(style);
}
}
int row2Num = 6;
for (int i = 0; i < 3; i++) {
XSSFRow row = sheet.createRow(row2Num+i);
for (int j = 0; j < 2; j++) {
XSSFCell cell = row.createCell(j);
cell.setCellStyle(style);
}
}
int row3Num = 10;
for (int i = 0; i < 2; i++) {
XSSFRow row = sheet.createRow(row3Num+i);
for (int j = 0; j < 2; j++) {
XSSFCell cell = row.createCell(j);
cell.setCellStyle(style);
}
}
XSSFCell cell00 = sheet.getRow(0).getCell(0);
XSSFFont font = new XSSFFont();
font.setFontName("黑体");
style.setFont(font);
cell00.setCellStyle(style);
cell00.setCellValue("样品编号:");
XSSFCell cell01 = sheet.getRow(0).getCell(1);
cell01.setCellValue(vo.getSampleCode());
XSSFCell cell10 = sheet.getRow(1).getCell(0);
cell10.setCellStyle(style);
cell10.setCellValue("对数x轴");
XSSFCell cell11 = sheet.getRow(1).getCell(1);
cell11.setCellStyle(style);
cell11.setCellValue("对数y轴");
XSSFCell cell20 = sheet.getRow(2).getCell(0);
cell20.setCellFormula("LOG10('界限含水率 (碟式液限仪多点法)'!D"+xBegin1+")");
XSSFCell cell30 = sheet.getRow(3).getCell(0);
cell30.setCellFormula("LOG10('界限含水率 (碟式液限仪多点法)'!D"+xBegin2+")");
XSSFCell cell40 = sheet.getRow(4).getCell(0);
cell40.setCellFormula("LOG10('界限含水率 (碟式液限仪多点法)'!D"+xBegin3+")");
XSSFCell cell21 = sheet.getRow(2).getCell(1);
cell21.setCellFormula("LOG10('界限含水率 (碟式液限仪多点法)'!J"+xBegin1+")");
XSSFCell cell31 = sheet.getRow(3).getCell(1);
cell31.setCellFormula("LOG10('界限含水率 (碟式液限仪多点法)'!J"+xBegin2+")");
XSSFCell cell41 = sheet.getRow(4).getCell(1);
cell41.setCellFormula("LOG10('界限含水率 (碟式液限仪多点法)'!J"+xBegin3+")");
XSSFCell cell60 = sheet.getRow(6).getCell(0);
cell60.setCellValue("备注:y=kx+b");
XSSFCell cell70 = sheet.getRow(7).getCell(0);
cell70.setCellValue("k:");
XSSFCell cell80 = sheet.getRow(8).getCell(0);
cell80.setCellValue("b:");
XSSFCell cell71 = sheet.getRow(7).getCell(1);
cell71.setCellFormula("INDEX(LINEST(B3:B5,A3:A5,1,0),1,1)");
XSSFCell cell81 = sheet.getRow(8).getCell(1);
cell81.setCellFormula("INDEX(LINEST(B3:B5,A3:A5,1,0),1,2)");
XSSFCell cell100 = sheet.getRow(10).getCell(0);
cell100.setCellValue("液限(%) Liquid Limit");
XSSFCell cell101 = sheet.getRow(10).getCell(1);
cell101.setCellFormula("10^(B8*LOG10(25)+B9)");
xBegin1+=xStep;
xBegin2+=xStep;
xBegin3+=xStep;
}
}
for (SoilOriginalTemplateConfig config:configList) {
if (null == config.getMergeRowNum()){
......@@ -411,6 +543,24 @@ public class SoilExperimentServiceImpl extends BaseServiceImpl<SoilExperimentMap
logger.error("----------------------7");
if (attachJIeXianWater){
int length = voList.size();
int begin = 8;
int step = 5;
for (int i = 0; i < length; i++) {
XSSFCell xssfCell = sheetOne.getRow(begin).getCell(10);
xssfCell.setCellFormula("'附录"+voList.get(i).getSampleCode()+"'!B11");
begin+=step;
}
}
}else{
logger.error("----------------------8");
......@@ -424,11 +574,6 @@ public class SoilExperimentServiceImpl extends BaseServiceImpl<SoilExperimentMap
int insertCount = voList.size()-templateSampleNum;
for (int m = 0 ; m<insertCount ;m++) {
for (int i = 0; i < sampleMergerNum; i++) {
......@@ -444,6 +589,12 @@ public class SoilExperimentServiceImpl extends BaseServiceImpl<SoilExperimentMap
}
}
int sn = 1;
int xBegin1 = 9;
int xBegin2 = 10;
int xBegin3 = 11;
int xStep = 5;
for (SoilExperimentVO vo:voList) {
XSSFRow xssfRow = sheetOne.getRow(beginRow);
......@@ -460,6 +611,125 @@ public class SoilExperimentServiceImpl extends BaseServiceImpl<SoilExperimentMap
}
beginRow+=sampleMergerNum;
sn++;
if (attachJIeXianWater){
XSSFSheet sheet = xssfWorkbook.createSheet("附录"+vo.getSampleCode());
XSSFCellStyle style = xssfWorkbook.createCellStyle();
style.setBorderBottom(BorderStyle.THIN);
style.setBorderLeft(BorderStyle.THIN);
style.setBorderRight(BorderStyle.THIN);
style.setBorderTop(BorderStyle.THIN);
for (int i = 0; i < 5; i++) {
XSSFRow row = sheet.createRow(i);
for (int j = 0; j < 2; j++) {
XSSFCell cell = row.createCell(j);
cell.setCellStyle(style);
}
}
int row2Num = 6;
for (int i = 0; i < 3; i++) {
XSSFRow row = sheet.createRow(row2Num+i);
for (int j = 0; j < 2; j++) {
XSSFCell cell = row.createCell(j);
cell.setCellStyle(style);
}
}
int row3Num = 10;
for (int i = 0; i < 2; i++) {
XSSFRow row = sheet.createRow(row3Num+i);
for (int j = 0; j < 2; j++) {
XSSFCell cell = row.createCell(j);
cell.setCellStyle(style);
}
}
XSSFCell cell00 = sheet.getRow(0).getCell(0);
XSSFFont font = new XSSFFont();
font.setFontName("黑体");
style.setFont(font);
cell00.setCellStyle(style);
cell00.setCellValue("样品编号:");
XSSFCell cell01 = sheet.getRow(0).getCell(1);
cell01.setCellValue(vo.getSampleCode());
XSSFCell cell10 = sheet.getRow(1).getCell(0);
cell10.setCellStyle(style);
cell10.setCellValue("对数x轴");
XSSFCell cell11 = sheet.getRow(1).getCell(1);
cell11.setCellStyle(style);
cell11.setCellValue("对数y轴");
XSSFCell cell20 = sheet.getRow(2).getCell(0);
cell20.setCellFormula("LOG10('界限含水率 (碟式液限仪多点法)'!D"+xBegin1+")");
XSSFCell cell30 = sheet.getRow(3).getCell(0);
cell30.setCellFormula("LOG10('界限含水率 (碟式液限仪多点法)'!D"+xBegin2+")");
XSSFCell cell40 = sheet.getRow(4).getCell(0);
cell40.setCellFormula("LOG10('界限含水率 (碟式液限仪多点法)'!D"+xBegin3+")");
XSSFCell cell21 = sheet.getRow(2).getCell(1);
cell21.setCellFormula("LOG10('界限含水率 (碟式液限仪多点法)'!J"+xBegin1+")");
XSSFCell cell31 = sheet.getRow(3).getCell(1);
cell31.setCellFormula("LOG10('界限含水率 (碟式液限仪多点法)'!J"+xBegin2+")");
XSSFCell cell41 = sheet.getRow(4).getCell(1);
cell41.setCellFormula("LOG10('界限含水率 (碟式液限仪多点法)'!J"+xBegin3+")");
XSSFCell cell60 = sheet.getRow(6).getCell(0);
cell60.setCellValue("备注:y=kx+b");
XSSFCell cell70 = sheet.getRow(7).getCell(0);
cell70.setCellValue("k:");
XSSFCell cell80 = sheet.getRow(8).getCell(0);
cell80.setCellValue("b:");
XSSFCell cell71 = sheet.getRow(7).getCell(1);
cell71.setCellFormula("INDEX(LINEST(B3:B5,A3:A5,1,0),1,1)");
XSSFCell cell81 = sheet.getRow(8).getCell(1);
cell81.setCellFormula("INDEX(LINEST(B3:B5,A3:A5,1,0),1,2)");
XSSFCell cell100 = sheet.getRow(10).getCell(0);
cell100.setCellValue("液限(%) Liquid Limit");
XSSFCell cell101 = sheet.getRow(10).getCell(1);
cell101.setCellFormula("10^(B8*LOG10(25)+B9)");
xBegin1+=xStep;
xBegin2+=xStep;
xBegin3+=xStep;
}
}
for (SoilOriginalTemplateConfig config:configList) {
if (null==config.getMergeRowNum()){
......@@ -563,6 +833,15 @@ public class SoilExperimentServiceImpl extends BaseServiceImpl<SoilExperimentMap
while (sampleBgMum<=sampleEnMum) {
if (indexJishu%2==0){
sheetOne.addMergedRegion(new CellRangeAddress(sampleBgMum,sampleBgMum+3-1,config.getMergeBegin(),config.getMergeEnd()));
if (config.getColumnPlace()==10){
XSSFRow teshuRow = sheetOne.getRow(sampleBgMum);
if (null != teshuRow){
XSSFCell teshuCell = teshuRow.getCell(config.getColumnPlace());
XSSFCell teshuCellSampleCode = teshuRow.getCell(1);
teshuCell.setCellFormula("'附录"+HSSFWorkbookUtil.getJavaValue(teshuCellSampleCode).toString()+"'!B11");
}
}
sampleBgMum=sampleBgMum+3;
}else{
sheetOne.addMergedRegion(new CellRangeAddress(sampleBgMum,sampleBgMum+2-1,config.getMergeBegin(),config.getMergeEnd()));
......@@ -588,6 +867,18 @@ public class SoilExperimentServiceImpl extends BaseServiceImpl<SoilExperimentMap
}
}
logger.error("----------------------15");
if (attachJIeXianWater){
int begin = 8;
int step = 5;
for (int i = 0; i < templateSampleNum; i++) {
XSSFCell xssfCell = sheetOne.getRow(begin).getCell(10);
xssfCell.setCellFormula("'附录"+voList.get(i).getSampleCode()+"'!B11");
begin+=step;
}
}
}
}
}else{
......
package com.patzn.cloud.service.lims.test;
import com.patzn.cloud.service.lims.common.HSSFWorkbookUtil;
import org.apache.poi.xssf.usermodel.XSSFCell;
import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartFrame;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.annotations.XYTextAnnotation;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.chart.plot.XYPlot;
import org.jfree.data.xy.DefaultXYDataset;
import org.jfree.ui.RefineryUtilities;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
public class ScatterPlot {
public static void data(String title,String[] a,String[] b)
{
DefaultXYDataset xydataset = new DefaultXYDataset ();
double[][] data=new double[2][a.length];
for(int i=0;i<a.length;i++)
{
data[0][i]=Double.parseDouble(a[i]);
data[1][i]=Double.parseDouble(b[i]);
}
xydataset.addSeries("牛的无线定位", data);
final JFreeChart chart =ChartFactory.createScatterPlot("","","",xydataset,PlotOrientation.VERTICAL,false,false,false);
ChartFrame frame = new ChartFrame(title,chart);
frame.pack();
RefineryUtilities.centerFrameOnScreen(frame);
frame.setVisible(true);
}
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
File file = new File("D://en//ccc.xlsx");
try {
InputStream io = new FileInputStream(file);
XSSFWorkbook xssfWorkbook = HSSFWorkbookUtil.getWorkbookByIO(io);
XSSFSheet sheet = xssfWorkbook.getSheetAt(2);
int xcol = 0;
int xrowBegin = 1;
int xrowEnd = sheet.getLastRowNum();
int ycol = 3;
int yrowBegin = 1;
int yrowEnd = sheet.getLastRowNum();
List<String> xList = new ArrayList<>();
List<String> yList = new ArrayList<>();
for (int i = xrowBegin; i < xrowEnd; i++) {
XSSFRow row = sheet.getRow(i);
if (row == null){
continue;
}
XSSFCell cell = row.getCell(xcol);
if (cell == null){
continue;
}
String xcalue = HSSFWorkbookUtil.getJavaValue(cell).toString();
xList.add(xcalue);
}
for (int i = yrowBegin; i < yrowEnd; i++) {
XSSFRow row = sheet.getRow(i);
if (row == null){
continue;
}
XSSFCell cell = row.getCell(ycol);
if (cell == null){
continue;
}
String ycalue = HSSFWorkbookUtil.getJavaValue(cell).toString();
yList.add(ycalue);
}
int size = xList.size()<yList.size()?xList.size():yList.size();
String[] a =new String[size];
String[] b =new String[size];
for (int i = 0; i < size; i++) {
a[i] = xList.get(i);
b[i] = yList.get(i);
}
ScatterPlot.data("title", a, b);
}catch (Exception e){
}
// String[] a ={"1.11","2.14","4.54"};
// String[] b ={"1.24","2.36","4.69"};
}
}
\ No newline at end of file
package com.patzn.cloud.service.lims.test;
import org.apache.commons.lang3.StringUtils;
public class Ytest {
public static void main(String[] args) {
boolean d = validateNumber("325.312122");
System.out.println(d);
}
private static boolean validateNumber(String str) {
if(StringUtils.isBlank(str)) {
return false;
}
// 说明一下的是该正则只能识别4位小数;如果不限制小数位数的话,写成[+-]?[0-9]+(\\.[0-9]+)?就可以了
return str.matches("[+-]?[0-9]+(\\.[0-9]+)?");
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment