Commit 65671bc2 by wangweidong

土工试验

parent 759289cd
...@@ -8,12 +8,30 @@ import java.util.ArrayList; ...@@ -8,12 +8,30 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
public class CollectHandlerChain { public class CollectHandlerChain {
private CollectHandlerChain(){
}
private static CollectHandlerChain collectHandlerChain=null;
public static CollectHandlerChain getInstance(){
if (null == collectHandlerChain){
synchronized (CollectHandlerChain.class){
collectHandlerChain = new CollectHandlerChain();
}
}
return collectHandlerChain;
}
// 持有所有Handler: // 持有所有Handler:
private List<ICollectHandler> handlers = new ArrayList<>(); private List<ICollectHandler> handlers = new ArrayList<>();
public void addHandler(ICollectHandler handler) { public void addHandler(ICollectHandler handler) {
if (!this.handlers.contains(handler)){
this.handlers.add(handler); this.handlers.add(handler);
} }
}
public boolean process(CollectDataType request, ISoilExperimentService soilExperimentService) { public boolean process(CollectDataType request, ISoilExperimentService soilExperimentService) {
// 依次调用每个Handler: // 依次调用每个Handler:
...@@ -21,7 +39,7 @@ public class CollectHandlerChain { ...@@ -21,7 +39,7 @@ public class CollectHandlerChain {
Boolean r = handler.process(request,soilExperimentService); Boolean r = handler.process(request,soilExperimentService);
if (r != null) { if (r != null) {
// 如果返回TRUE或FALSE,处理结束: // 如果返回TRUE或FALSE,处理结束:
System.out.println(request + " " + (r ? "Approved by " : "Denied by ") + handler.getClass().getSimpleName()); System.out.println(request + " " + (r ? " Approved by " : "Denied by ") + handler.getClass().getSimpleName());
return r; return r;
} }
} }
......
...@@ -29,6 +29,16 @@ public class CollectDataType { ...@@ -29,6 +29,16 @@ public class CollectDataType {
private String experiment; private String experiment;
private String templateType;
public String getTemplateType() {
return templateType;
}
public void setTemplateType(String templateType) {
this.templateType = templateType;
}
public Long getEquipId() { public Long getEquipId() {
return equipId; return equipId;
} }
......
...@@ -7,6 +7,24 @@ import com.patzn.cloud.service.lims.soil.service.ISoilExperimentService; ...@@ -7,6 +7,24 @@ import com.patzn.cloud.service.lims.soil.service.ISoilExperimentService;
import jcifs.smb.SmbFile; import jcifs.smb.SmbFile;
public class GdsFileHandle implements ICollectHandler { public class GdsFileHandle implements ICollectHandler {
private GdsFileHandle(){
}
private static GdsFileHandle gdsFileHandle=null;
public static GdsFileHandle getInstance(){
if (null == gdsFileHandle){
synchronized (GdsFileHandle.class){
gdsFileHandle = new GdsFileHandle();
}
}
return gdsFileHandle;
}
@Override @Override
public Boolean process(CollectDataType request, ISoilExperimentService soilExperimentService) { public Boolean process(CollectDataType request, ISoilExperimentService soilExperimentService) {
String type = request.getType(); String type = request.getType();
......
...@@ -11,6 +11,21 @@ import org.slf4j.LoggerFactory; ...@@ -11,6 +11,21 @@ import org.slf4j.LoggerFactory;
public class PngReportHandle implements ICollectHandler { public class PngReportHandle implements ICollectHandler {
private PngReportHandle(){
}
private static PngReportHandle pngReportHandle=null;
public static PngReportHandle getInstance(){
if (null == pngReportHandle){
synchronized (PngReportHandle.class){
pngReportHandle = new PngReportHandle();
}
}
return pngReportHandle;
}
protected static final Logger logger = LoggerFactory.getLogger(PngReportHandle.class); protected static final Logger logger = LoggerFactory.getLogger(PngReportHandle.class);
@Override @Override
...@@ -18,7 +33,6 @@ public class PngReportHandle implements ICollectHandler { ...@@ -18,7 +33,6 @@ public class PngReportHandle implements ICollectHandler {
String type = request.getType(); String type = request.getType();
String collectionAddress = request.getCollectionAddress(); String collectionAddress = request.getCollectionAddress();
String acquisitionCommand = request.getAcquisitionCommand(); String acquisitionCommand = request.getAcquisitionCommand();
String entrustCode = request.getEntrustCode();
String boreholeName = request.getBoreholeName(); String boreholeName = request.getBoreholeName();
String sampleCode = request.getSampleCode(); String sampleCode = request.getSampleCode();
String expName = request.getExperiment(); String expName = request.getExperiment();
......
...@@ -10,6 +10,23 @@ import org.slf4j.LoggerFactory; ...@@ -10,6 +10,23 @@ import org.slf4j.LoggerFactory;
public class WuCollectHandle implements ICollectHandler { public class WuCollectHandle implements ICollectHandler {
private WuCollectHandle(){
}
private static WuCollectHandle wuCollectHandle=null;
public static WuCollectHandle getInstance(){
if (null == wuCollectHandle){
synchronized (WuCollectHandle.class){
wuCollectHandle = new WuCollectHandle();
}
}
return wuCollectHandle;
}
protected final Logger logger = LoggerFactory.getLogger(WuCollectHandle.class); protected final Logger logger = LoggerFactory.getLogger(WuCollectHandle.class);
@Override @Override
......
package com.patzn.cloud.service.lims.collect.tool;
public class CollectContext {
private String input;
private String output;
public CollectContext(String input) {
this.input = input;
}
public String getInput() {
return input;
}
public void setInput(String input) {
this.input = input;
}
public String getOutput() {
return output;
}
public void setOutput(String output) {
this.output = output;
}
}
package com.patzn.cloud.service.lims.collect.tool;
public abstract class Expression {
abstract void interpret(CollectContext c);
}
package com.patzn.cloud.service.lims.collect.tool;
public class LixueExpression extends Expression {
@Override
void interpret(CollectContext c) {
}
}
package com.patzn.cloud.service.lims.original; package com.patzn.cloud.service.lims.original;
import com.patzn.cloud.service.lims.common.StringHandleUtils;
import com.patzn.cloud.service.soil.entity.SoilEntrust; import com.patzn.cloud.service.soil.entity.SoilEntrust;
import com.patzn.cloud.service.soil.entity.SoilOriginalTemplate;
import com.patzn.cloud.service.soil.entity.SoilOriginalTemplateConfig;
import com.patzn.cloud.service.soil.vo.SoilExperimentVO;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.xssf.usermodel.XSSFCell;
import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.math.BigDecimal;
import java.util.Map; import java.util.Map;
public class InitMapReplace { public final class InitMapReplace {
public static void initMapReplace(Map<String, String> mapReplace, SoilEntrust entrust){ protected final static Logger logger = LoggerFactory.getLogger(InitMapReplace.class);
public static final void initMapReplace(Map<String, String> mapReplace, SoilEntrust entrust){
mapReplace.put("#{projectName}",entrust.getProjectName()); mapReplace.put("#{projectName}",entrust.getProjectName());
mapReplace.put("#{client}",entrust.getClient()); mapReplace.put("#{client}",entrust.getClient());
mapReplace.put("#{boreholeName}",entrust.getBoreholeName()); mapReplace.put("#{boreholeName}",entrust.getBoreholeName());
...@@ -17,4 +29,215 @@ public class InitMapReplace { ...@@ -17,4 +29,215 @@ public class InitMapReplace {
} }
mapReplace.put("#{reportCode}",entrust.getEntrustCode()); mapReplace.put("#{reportCode}",entrust.getEntrustCode());
} }
public final static Map<String, String> setCommonMapReplace(Map<String, String> mapReplaceMy,int length,SoilEntrust entrust){
mapReplaceMy.put("#{reportCode}",entrust.getEntrustCode());
for (int i = 0; i < length; i++) {
mapReplaceMy.put("#{sampleCode"+i+"}","");
mapReplaceMy.put("#{sampleDepth"+i+"}","");
mapReplaceMy.put("#{describeDetail"+i+"}","");
mapReplaceMy.put("#{siteNo"+i+"}","");
mapReplaceMy.put("#{含水率"+i+"}","");
mapReplaceMy.put("#{容重9.81"+i+"}","");
mapReplaceMy.put("#{密度9.81"+i+"}","");
}
mapReplaceMy.put("#{projectName}",entrust.getProjectName());
mapReplaceMy.put("#{client}",entrust.getClient());
mapReplaceMy.put("#{boreholeName}",entrust.getBoreholeName());
mapReplaceMy.put("#{projectNo}",entrust.getProjectNo());
return mapReplaceMy;
}
public final static void setValueMapCheck(Map<String, String> mapReplaceMy,int j){
if (!mapReplaceMy.containsKey("#{含水率"+j+"}")){
mapReplaceMy.put("#{含水率"+j+"}","");
mapReplaceMy.put("#{含水率"+j+"}","");
}
if (!mapReplaceMy.containsKey("#{液限"+j+"}")){
mapReplaceMy.put("#{液限"+j+"}","");
}
if (!mapReplaceMy.containsKey("#{塑限"+j+"}")){
mapReplaceMy.put("#{塑限"+j+"}","");
}
if (!mapReplaceMy.containsKey("#{比重"+j+"}")){
mapReplaceMy.put("#{比重"+j+"}","");
}
if (!mapReplaceMy.containsKey("#{密度"+j+"}")){
mapReplaceMy.put("#{密度"+j+"}","");
}
}
public final static void setMiDuValue(Map<String, String> mapReplaceMy, int j) {
if (!mapReplaceMy.containsKey("#{密度"+j+"}")){
mapReplaceMy.put("#{密度"+j+"}","");
mapReplaceMy.put("#{密度9.81"+j+"}","");
}else{
String miDu = mapReplaceMy.get("#{密度"+j+"}");
if (StringUtils.isBlank(miDu)){
mapReplaceMy.put("#{密度9.81"+j+"}","");
}else {
if (StringHandleUtils.validateNumber(miDu)){
BigDecimal mi = new BigDecimal(miDu);
BigDecimal chengShu = new BigDecimal("9.81");
BigDecimal ji = mi.multiply(chengShu);
mapReplaceMy.put("#{密度9.81"+j+"}",ji.toString());
}else{
mapReplaceMy.put("#{密度9.81"+j+"}","");
}
}
}
}
public final static void setBulkDensityValue(Map<String, String> mapReplaceMy, int j) {
if (!mapReplaceMy.containsKey("#{容重"+j+"}")){
mapReplaceMy.put("#{容重"+j+"}","");
mapReplaceMy.put("#{容重9.81"+j+"}","");
}else{
String bulkDensity = mapReplaceMy.get("#{容重"+j+"}");
if (StringUtils.isBlank(bulkDensity)){
mapReplaceMy.put("#{容重9.81"+j+"}","");
}else {
if (StringHandleUtils.validateNumber(bulkDensity)){
BigDecimal bulkDensityDecimal = new BigDecimal(bulkDensity);
BigDecimal chengShu = new BigDecimal("9.81");
BigDecimal ji = bulkDensityDecimal.multiply(chengShu);
mapReplaceMy.put("#{容重9.81"+j+"}",ji.toString());
}else{
mapReplaceMy.put("#{容重9.81"+j+"}","");
}
}
}
}
public final static void setSingleValueMapCheck(Map<String, String> mapReplace, SoilExperimentVO vo) {
if (!mapReplace.containsKey("#{含水率}")){
mapReplace.put("#{含水率}","");
}
if (!mapReplace.containsKey("#{液限}")){
mapReplace.put("#{液限}","");
}
if (!mapReplace.containsKey("#{塑限}")){
mapReplace.put("#{塑限}","");
}
if (!mapReplace.containsKey("#{比重}")){
mapReplace.put("#{比重}","");
}
if (!mapReplace.containsKey("#{密度}")){
mapReplace.put("#{密度}","");
}
mapReplace.put("#{sampleCode}",vo.getSampleCode());
mapReplace.put("#{siteNo}",vo.getSiteNo());
mapReplace.put("#{sampleDepth}",vo.getSampleDepth());
mapReplace.put("#{describeDetail}",StringHandleUtils.getString(vo.getSampleDepth()));
}
public final static void doMIDUSingle(Map<String, String> myMapReplace) {
String density = myMapReplace.get("#{密度}");
if (StringUtils.isNotBlank(density)){
try {
BigDecimal bigDecimal = new BigDecimal(density);
BigDecimal mul = new BigDecimal("9.81");
BigDecimal rz981 = bigDecimal.multiply(mul);
myMapReplace.put("#{密度9.81}",rz981.toString());
}catch (Exception e){
myMapReplace.put("#{密度9.81}","");
myMapReplace.put("#{密度}","");
logger.error("密度转化失败"+density+e.getMessage());
}
}else{
myMapReplace.put("#{密度9.81}","");
myMapReplace.put("#{密度}","");
}
}
public final static String doFormula(String formula,int i) {
formula = formula.replace("#{sn}",(i+1)+"");
if (formula.contains("#{sneven1}")){
if (StringHandleUtils.isEven(i)){
formula= formula.replace("#{sneven1}",(i+1)+"");
}else{
formula= formula.replace("#{sneven1}",i+"");
}
}
if (formula.contains("#{snodd1}")){
if (!StringHandleUtils.isEven(i)){
formula= formula.replace("#{snodd1}",(i+1)+"");
}else{
formula= formula.replace("#{snodd1}",i+"");
}
}
if (formula.contains("#{sn+1}")){
formula= formula.replace("#{sn+1}",(i+2)+"");
}
if (formula.contains("#{sn+2}")){
formula= formula.replace("#{sn+2}",(i+3)+"");
}
if (formula.contains("#{sn+3}")){
formula= formula.replace("#{sn+3}",(i+4)+"");
}
if (formula.contains("#{sn+4}")){
formula= formula.replace("#{sn+4}",(i+5)+"");
}
if (formula.contains("#{sn+5}")){
formula= formula.replace("#{sn+5}",(i+6)+"");
}
if (formula.contains("#{sn+6}")){
formula= formula.replace("#{sn+6}",(i+7)+"");
}
if (formula.contains("#{sn+7}")){
formula= formula.replace("#{sn+7}",(i+8)+"");
}
return formula;
}
public final static void initFormula(SoilOriginalTemplateConfig config, SoilOriginalTemplate template, int sampleMergerNum, int templateSampleNum, XSSFSheet sheetOne) {
if (null == config.getMergeRowNum()){
config.setMergeRowNum(1);
}
if(OriginalUtil.skipDoExcel(config)){
return;
}
Integer sampleBgMum = template.getSampleBeginRow();
Integer mergeRowNum = config.getMergeRowNum();
int formulaNum = template.getSampleBeginRow()+sampleMergerNum*templateSampleNum-1 ;
for (int i =sampleBgMum ; i <= formulaNum; i+=mergeRowNum) {
XSSFRow row = sheetOne.getRow(i);
if (null == row){
return;
}
XSSFCell cell = row.getCell(config.getColumnPlace());
if (null == cell){
return;
}
cell.setCellFormula(InitMapReplace.doFormula(config.getFormula(),i));
}
}
} }
...@@ -9,7 +9,6 @@ import org.apache.poi.xssf.usermodel.XSSFWorkbook; ...@@ -9,7 +9,6 @@ import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import java.io.InputStream; import java.io.InputStream;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
...@@ -24,7 +23,8 @@ public class OriginalOperationFactory { ...@@ -24,7 +23,8 @@ public class OriginalOperationFactory {
private Map<Long,List<SoilItemVO>> sampleSoilItemVOMap=new ConcurrentHashMap<>(); private Map<Long,List<SoilItemVO>> sampleSoilItemVOMap=new ConcurrentHashMap<>();
private SoilEntrust entrust; private SoilEntrust entrust;
public OriginalOperationFactory(XSSFWorkbook xssfWorkbook, InputStream io, Map<String, String> mapReplace, List<SoilOriginalTemplateConfig> configList, SoilOriginalTemplate template, List<SoilExperimentVO> voList, List<SoilItemVO> soilItemVOList ,SoilEntrust entrust) {
public void initParams(XSSFWorkbook xssfWorkbook, InputStream io, Map<String, String> mapReplace, List<SoilOriginalTemplateConfig> configList, SoilOriginalTemplate template, List<SoilExperimentVO> voList, List<SoilItemVO> soilItemVOList ,SoilEntrust entrust) {
this.xssfWorkbook = xssfWorkbook; this.xssfWorkbook = xssfWorkbook;
this.io = io; this.io = io;
this.mapReplace = mapReplace; this.mapReplace = mapReplace;
...@@ -62,16 +62,24 @@ public class OriginalOperationFactory { ...@@ -62,16 +62,24 @@ public class OriginalOperationFactory {
if (null==template.getMoreSheet() || 0 == template.getMoreSheet()){ if (null==template.getMoreSheet() || 0 == template.getMoreSheet()){
//单模板 //单模板
if (voList.size()<templateSampleNum){ if (voList.size()<templateSampleNum){
return new SingleLessOperation(xssfWorkbook,io,mapReplace,configList,template,voList,sampleSoilItemVOMap); SingleLessOperation singleLessOperation = new SingleLessOperation();
singleLessOperation.initParam(xssfWorkbook,io,mapReplace,configList,template,voList,sampleSoilItemVOMap);
return singleLessOperation;
}else{ }else{
return new SingleMoreOperation(xssfWorkbook,io,mapReplace,configList,template,voList,sampleSoilItemVOMap); SingleMoreOperation singleMoreOperation = new SingleMoreOperation();
singleMoreOperation.initParam(xssfWorkbook,io,mapReplace,configList,template,voList,sampleSoilItemVOMap);
return singleMoreOperation;
} }
}else{ }else{
//多sheet模板 //多sheet模板
if (null == templateSampleNum || 1==templateSampleNum){ if (null == templateSampleNum || 1==templateSampleNum){
return new SheetMoreSingleOperation(xssfWorkbook,io,mapReplace,configList,template,voList,sampleSoilItemVOMap); SheetMoreSingleOperation sheetMoreSingleOperation = new SheetMoreSingleOperation();
sheetMoreSingleOperation.initParam(xssfWorkbook,io,mapReplace,configList,template,voList,sampleSoilItemVOMap);
return sheetMoreSingleOperation;
}else{ }else{
return new SheetMoreMuchOperation(xssfWorkbook,io,mapReplace,configList,template,voList,sampleSoilItemVOMap,entrust); SheetMoreMuchOperation sheetMoreMuchOperation = new SheetMoreMuchOperation();
sheetMoreMuchOperation.initParam(xssfWorkbook,io,mapReplace,configList,template,voList,sampleSoilItemVOMap,entrust);
return sheetMoreMuchOperation;
} }
} }
} }
......
package com.patzn.cloud.service.lims.original; package com.patzn.cloud.service.lims.original;
import com.baomidou.mybatisplus.toolkit.CollectionUtils;
import com.patzn.cloud.service.lims.common.HSSFWorkbookUtil; import com.patzn.cloud.service.lims.common.HSSFWorkbookUtil;
import com.patzn.cloud.service.soil.entity.SoilOriginalTemplate; import com.patzn.cloud.service.soil.entity.SoilOriginalTemplate;
import com.patzn.cloud.service.soil.entity.SoilOriginalTemplateConfig; import com.patzn.cloud.service.soil.entity.SoilOriginalTemplateConfig;
...@@ -17,6 +18,12 @@ import java.util.Map; ...@@ -17,6 +18,12 @@ import java.util.Map;
public final class OriginalUtil { public final class OriginalUtil {
public static void doForValue(int sampleMergerNum, XSSFSheet sheetOne, int beginRow, SoilOriginalTemplateConfig config, String name, List<SoilItemVO> soilItemVOS ){ public static void doForValue(int sampleMergerNum, XSSFSheet sheetOne, int beginRow, SoilOriginalTemplateConfig config, String name, List<SoilItemVO> soilItemVOS ){
if (CollectionUtils.isEmpty(soilItemVOS)){
return;
}
if (StringUtils.isBlank(name)){
return;
}
for (int i = 0; i < sampleMergerNum; i++) { for (int i = 0; i < sampleMergerNum; i++) {
XSSFRow zhuiRow = sheetOne.getRow(beginRow+i); XSSFRow zhuiRow = sheetOne.getRow(beginRow+i);
if (null!=zhuiRow){ if (null!=zhuiRow){
......
...@@ -3,15 +3,12 @@ package com.patzn.cloud.service.lims.original; ...@@ -3,15 +3,12 @@ package com.patzn.cloud.service.lims.original;
import com.baomidou.mybatisplus.toolkit.CollectionUtils; import com.baomidou.mybatisplus.toolkit.CollectionUtils;
import com.patzn.cloud.service.lims.common.HSSFWorkbookUtil; import com.patzn.cloud.service.lims.common.HSSFWorkbookUtil;
import com.patzn.cloud.service.lims.common.StringHandleUtils; import com.patzn.cloud.service.lims.common.StringHandleUtils;
import com.patzn.cloud.service.lims.gideon.utils.ApachePoiLineChart4;
import com.patzn.cloud.service.lims.gideon.utils.DrawXlsxUtil;
import com.patzn.cloud.service.soil.entity.SoilEntrust; import com.patzn.cloud.service.soil.entity.SoilEntrust;
import com.patzn.cloud.service.soil.entity.SoilOriginalTemplate; import com.patzn.cloud.service.soil.entity.SoilOriginalTemplate;
import com.patzn.cloud.service.soil.entity.SoilOriginalTemplateConfig; import com.patzn.cloud.service.soil.entity.SoilOriginalTemplateConfig;
import com.patzn.cloud.service.soil.vo.SoilExperimentVO; import com.patzn.cloud.service.soil.vo.SoilExperimentVO;
import com.patzn.cloud.service.soil.vo.SoilItemVO; import com.patzn.cloud.service.soil.vo.SoilItemVO;
import org.apache.commons.collections4.ListUtils; import org.apache.commons.collections4.ListUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.ss.usermodel.PrintSetup; import org.apache.poi.ss.usermodel.PrintSetup;
import org.apache.poi.xssf.usermodel.XSSFSheet; import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook; import org.apache.poi.xssf.usermodel.XSSFWorkbook;
...@@ -19,7 +16,6 @@ import org.slf4j.Logger; ...@@ -19,7 +16,6 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.io.InputStream; import java.io.InputStream;
import java.math.BigDecimal;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -38,7 +34,7 @@ public class SheetMoreMuchOperation implements Operation { ...@@ -38,7 +34,7 @@ public class SheetMoreMuchOperation implements Operation {
protected final Logger logger = LoggerFactory.getLogger(SheetMoreMuchOperation.class); protected final Logger logger = LoggerFactory.getLogger(SheetMoreMuchOperation.class);
public SheetMoreMuchOperation(XSSFWorkbook xssfWorkbook, InputStream io, Map<String, String> mapReplace, List<SoilOriginalTemplateConfig> configList, SoilOriginalTemplate template, List<SoilExperimentVO> voList, Map<Long, List<SoilItemVO>> sampleSoilItemVOMap, public void initParam (XSSFWorkbook xssfWorkbook, InputStream io, Map<String, String> mapReplace, List<SoilOriginalTemplateConfig> configList, SoilOriginalTemplate template, List<SoilExperimentVO> voList, Map<Long, List<SoilItemVO>> sampleSoilItemVOMap,
SoilEntrust entrust) { SoilEntrust entrust) {
this.xssfWorkbook = xssfWorkbook; this.xssfWorkbook = xssfWorkbook;
this.io = io; this.io = io;
...@@ -49,250 +45,69 @@ public class SheetMoreMuchOperation implements Operation { ...@@ -49,250 +45,69 @@ public class SheetMoreMuchOperation implements Operation {
this.sampleSoilItemVOMap = sampleSoilItemVOMap; this.sampleSoilItemVOMap = sampleSoilItemVOMap;
this.entrust = entrust; this.entrust = entrust;
} }
public synchronized void doProductOriginal(){ public synchronized void doProductOriginal(){
Integer templateSampleNum = template.getTemplateSampleNum(); Integer templateSampleNum = template.getTemplateSampleNum();
List<List<SoilExperimentVO>> relList= ListUtils.partition(voList,templateSampleNum); List<List<SoilExperimentVO>> relList= ListUtils.partition(voList,templateSampleNum);
int templateSheetMum = xssfWorkbook.getNumberOfSheets();
XSSFSheet sheetMy = xssfWorkbook.getSheetAt(0); XSSFSheet sheetMy = xssfWorkbook.getSheetAt(0);
PrintSetup printSetup= sheetMy.getPrintSetup(); PrintSetup printSetup= sheetMy.getPrintSetup();
boolean printRound= printSetup.getLandscape(); boolean printRound= printSetup.getLandscape();
boolean first = true;
List<SoilExperimentVO> firstList = null; List<SoilExperimentVO> firstList = null;
for (List<SoilExperimentVO> expVOList:relList) { int sizeLength= relList.size();
XSSFSheet sheet=null;
if (first){ for (int i = 0; i < sizeLength; i++) {
sheet = sheetMy; List<SoilExperimentVO> expVOList = relList.get(i);
XSSFSheet sheet;
if (i==0){
firstList = expVOList; firstList = expVOList;
first = false;
continue; continue;
}else{ }else{
sheet = xssfWorkbook.cloneSheet(0,sheetMy.getSheetName()+(templateSheetMum)); sheet = xssfWorkbook.cloneSheet(0,sheetMy.getSheetName()+(i+1));
sheet.getPrintSetup().setLandscape(printRound); sheet.getPrintSetup().setLandscape(printRound);
} }
Map<String,String> mapReplaceMy = new HashMap<>();
mapReplaceMy.put("#{reportCode}",entrust.getEntrustCode());
for (int i = 0; i < templateSampleNum; i++) {
mapReplaceMy.put("#{sampleCode"+i+"}","");
mapReplaceMy.put("#{sampleDepth"+i+"}","");
mapReplaceMy.put("#{siteNo"+i+"}","");
mapReplaceMy.put("#{含水率"+i+"}","");
mapReplaceMy.put("#{容重9.81"+i+"}","");
mapReplaceMy.put("#{密度9.81"+i+"}","");
}
mapReplaceMy.put("#{projectName}",entrust.getProjectName()); Map<String,String> mapReplaceMy = new HashMap<>();
mapReplaceMy.put("#{client}",entrust.getClient()); mapReplaceMy = InitMapReplace.setCommonMapReplace(mapReplaceMy,templateSampleNum,entrust);
mapReplaceMy.put("#{boreholeName}",entrust.getBoreholeName());
mapReplaceMy.put("#{projectNo}",entrust.getProjectNo());
int entitySize = expVOList.size(); int entitySize = expVOList.size();
for (int j = 0; j < entitySize; j++) { for (int j = 0; j < entitySize; j++) {
SoilExperimentVO vo = expVOList.get(j); doExcelFill(mapReplaceMy,expVOList.get(j),j);
mapReplaceMy.put("#{sampleCode"+j+"}", StringHandleUtils.getString(vo.getSampleCode()));
mapReplaceMy.put("#{sampleDepth"+j+"}",StringHandleUtils.getString(vo.getSampleDepth()));
mapReplaceMy.put("#{siteNo"+j+"}",StringHandleUtils.getString(vo.getSiteNo()));
List<SoilItemVO> itemVOList = sampleSoilItemVOMap.get(vo.getSampleId());
if (CollectionUtils.isNotEmpty(itemVOList)){
for (SoilItemVO itemVO:itemVOList) {
mapReplaceMy.put("#{"+itemVO.getName()+"}",itemVO.getTestValue());
}
}
if (!mapReplaceMy.containsKey("#{含水率}")){
mapReplaceMy.put("#{含水率}","");
mapReplaceMy.put("#{含水率"+j+"}","");
}
if (!mapReplaceMy.containsKey("#{液限}")){
mapReplaceMy.put("#{液限}","");
}
if (!mapReplaceMy.containsKey("#{塑限}")){
mapReplaceMy.put("#{塑限}","");
}
if (!mapReplaceMy.containsKey("#{比重}")){
mapReplaceMy.put("#{比重}","");
} }
if (!mapReplaceMy.containsKey("#{密度}")){ HSSFWorkbookUtil.replaceModel(mapReplaceMy,xssfWorkbook,sheet);
mapReplaceMy.put("#{密度}","");
} }
if (!mapReplaceMy.containsKey("#{密度}")){
mapReplaceMy.put("#{密度}","");
mapReplaceMy.put("#{密度9.81}","");
mapReplaceMy.put("#{密度"+j+"}",""); int firstSize = firstList.size();
mapReplaceMy.put("#{密度9.81"+j+"}",""); Map<String,String> mapReplaceMy = new HashMap<>();
}else{ mapReplaceMy = InitMapReplace.setCommonMapReplace(mapReplaceMy,templateSampleNum,entrust);
String midu = mapReplaceMy.get("#{密度}");
if (StringUtils.isBlank(midu)){
mapReplaceMy.put("#{密度9.81}","");
mapReplaceMy.put("#{密度9.81"+j+"}","");
}else {
if (StringHandleUtils.validateNumber(midu)){
BigDecimal mi = new BigDecimal(midu);
BigDecimal chengshu = new BigDecimal("9.81");
BigDecimal ji = mi.multiply(chengshu);
mapReplaceMy.put("#{密度9.81}",ji.toString());
mapReplaceMy.put("#{密度9.81"+j+"}",ji.toString());
}else{
mapReplaceMy.put("#{密度9.81}","");
mapReplaceMy.put("#{密度9.81"+j+"}","");
}
}
for (int j = 0; j < firstSize; j++) {
doExcelFill(mapReplaceMy,firstList.get(j),j);
} }
HSSFWorkbookUtil.replaceModel(mapReplaceMy,xssfWorkbook,sheetMy);
if (!mapReplaceMy.containsKey("#{容重}")){
mapReplaceMy.put("#{容重}","");
mapReplaceMy.put("#{容重9.81}","");
mapReplaceMy.put("#{容重"+j+"}","");
mapReplaceMy.put("#{容重9.81"+j+"}","");
}else{
String rongzhong = mapReplace.get("#{容重}");
if (StringUtils.isBlank(rongzhong)){
mapReplaceMy.put("#{容重9.81}","");
mapReplaceMy.put("#{容重9.81"+j+"}","");
}else {
if (StringHandleUtils.validateNumber(rongzhong)){
BigDecimal rong = new BigDecimal(rongzhong);
BigDecimal chengshu = new BigDecimal("9.81");
BigDecimal ji = rong.multiply(chengshu);
mapReplaceMy.put("#{容重9.81}",ji.toString());
mapReplaceMy.put("#{容重9.81"+j+"}",ji.toString());
}else{
mapReplaceMy.put("#{容重9.81}","");
mapReplaceMy.put("#{容重9.81"+j+"}","");
}
} }
}
}
HSSFWorkbookUtil.replaceModel(mapReplaceMy,xssfWorkbook,sheet); public void doExcelFill(Map<String,String> mapReplaceMy,SoilExperimentVO vo,int j){
templateSheetMum++;
}
int firstSize = firstList.size();
Map<String,String> mapReplaceMy = new HashMap<>();
InitMapReplace.initMapReplace(mapReplaceMy,entrust);
for (int i = 0; i < templateSampleNum; i++) {
mapReplaceMy.put("#{sampleCode"+i+"}","");
mapReplaceMy.put("#{sampleDepth"+i+"}","");
mapReplaceMy.put("#{siteNo"+i+"}","");
mapReplaceMy.put("#{含水率"+i+"}","");
mapReplaceMy.put("#{密度9.81"+i+"}","");
mapReplaceMy.put("#{容重9.81"+i+"}","");
}
mapReplaceMy.put("#{projectName}",entrust.getProjectName());
mapReplaceMy.put("#{client}",entrust.getClient());
mapReplaceMy.put("#{boreholeName}",entrust.getBoreholeName());
mapReplaceMy.put("#{projectNo}",entrust.getProjectNo());
for (int j = 0; j < firstSize; j++) {
SoilExperimentVO vo = firstList.get(j);
mapReplaceMy.put("#{sampleCode"+j+"}",StringHandleUtils.getString(vo.getSampleCode())); mapReplaceMy.put("#{sampleCode"+j+"}",StringHandleUtils.getString(vo.getSampleCode()));
mapReplaceMy.put("#{sampleDepth"+j+"}",StringHandleUtils.getString(vo.getSampleDepth())); mapReplaceMy.put("#{sampleDepth"+j+"}",StringHandleUtils.getString(vo.getSampleDepth()));
mapReplaceMy.put("#{siteNo"+j+"}",StringHandleUtils.getString(vo.getSiteNo())); mapReplaceMy.put("#{siteNo"+j+"}",StringHandleUtils.getString(vo.getSiteNo()));
mapReplaceMy.put("#{describeDetail"+j+"}",StringHandleUtils.getString(vo.getDescribeDetail()));
List<SoilItemVO> itemVOList = sampleSoilItemVOMap.get(vo.getSampleId()); List<SoilItemVO> itemVOList = sampleSoilItemVOMap.get(vo.getSampleId());
if (CollectionUtils.isNotEmpty(itemVOList)){ if (CollectionUtils.isNotEmpty(itemVOList)){
for (SoilItemVO itemVO:itemVOList) { for (SoilItemVO itemVO:itemVOList) {
mapReplaceMy.put("#{"+itemVO.getName()+"}",itemVO.getTestValue()); mapReplaceMy.put("#{"+itemVO.getName()+j+"}",itemVO.getTestValue());
}
}else{
continue;
}
if (!mapReplaceMy.containsKey("#{含水率}")){
mapReplaceMy.put("#{含水率}","");
}
if (!mapReplaceMy.containsKey("#{液限}")){
mapReplaceMy.put("#{液限}","");
}
if (!mapReplaceMy.containsKey("#{塑限}")){
mapReplaceMy.put("#{塑限}","");
}
if (!mapReplaceMy.containsKey("#{比重}")){
mapReplaceMy.put("#{比重}","");
}
if (!mapReplaceMy.containsKey("#{密度}")){
mapReplaceMy.put("#{密度}","");
}
if (!mapReplaceMy.containsKey("#{含水率}")){
mapReplaceMy.put("#{含水率"+j+"}","");
}else{
mapReplaceMy.put("#{含水率"+j+"}",mapReplaceMy.get("#{含水率}"));
}
if (!mapReplaceMy.containsKey("#{密度}")){
mapReplaceMy.put("#{密度}","");
mapReplaceMy.put("#{密度9.81}","");
mapReplaceMy.put("#{密度"+j+"}","");
mapReplaceMy.put("#{密度9.81"+j+"}","");
}else{
String rongzhong = mapReplaceMy.get("#{密度}");
if (StringUtils.isBlank(rongzhong)){
mapReplaceMy.put("#{密度9.81}","");
mapReplaceMy.put("#{密度9.81"+j+"}","");
}else {
if (StringHandleUtils.validateNumber(rongzhong)){
BigDecimal rong = new BigDecimal(rongzhong);
BigDecimal chengshu = new BigDecimal("9.81");
BigDecimal ji = rong.multiply(chengshu);
mapReplaceMy.put("#{密度9.81}",ji.toString());
mapReplaceMy.put("#{密度9.81"+j+"}",ji.toString());
}else{
mapReplaceMy.put("#{密度9.81}","");
mapReplaceMy.put("#{密度9.81"+j+"}","");
}
}
}
if (!mapReplaceMy.containsKey("#{容重}")){
mapReplaceMy.put("#{容重}","");
mapReplaceMy.put("#{容重9.81}","");
mapReplaceMy.put("#{容重"+j+"}","");
mapReplaceMy.put("#{容重9.81"+j+"}","");
}else{
String rongzhong = mapReplace.get("#{容重}");
if (StringUtils.isBlank(rongzhong)){
mapReplaceMy.put("#{容重9.81}","");
mapReplaceMy.put("#{容重9.81"+j+"}","");
}else {
if (StringHandleUtils.validateNumber(rongzhong)){
BigDecimal rong = new BigDecimal(rongzhong);
BigDecimal chengshu = new BigDecimal("9.81");
BigDecimal ji = rong.multiply(chengshu);
mapReplaceMy.put("#{容重9.81}",ji.toString());
mapReplaceMy.put("#{容重9.81"+j+"}",ji.toString());
}else{
mapReplaceMy.put("#{容重9.81}","");
mapReplaceMy.put("#{容重9.81"+j+"}","");
} }
} }
InitMapReplace.setValueMapCheck(mapReplaceMy,j);
} InitMapReplace.setMiDuValue(mapReplaceMy,j);
} InitMapReplace.setBulkDensityValue(mapReplaceMy,j);
HSSFWorkbookUtil.replaceModel(mapReplaceMy,xssfWorkbook,sheetMy);
} }
} }
package com.patzn.cloud.service.lims.original; package com.patzn.cloud.service.lims.original;
import com.baomidou.mybatisplus.toolkit.CollectionUtils; import com.baomidou.mybatisplus.toolkit.CollectionUtils;
import com.google.common.collect.Maps;
import com.patzn.cloud.service.lims.common.HSSFWorkbookUtil; import com.patzn.cloud.service.lims.common.HSSFWorkbookUtil;
import com.patzn.cloud.service.lims.common.StringHandleUtils; import com.patzn.cloud.service.lims.common.StringHandleUtils;
import com.patzn.cloud.service.lims.gideon.utils.ApachePoiLineChart4; import com.patzn.cloud.service.lims.gideon.utils.ApachePoiLineChart4;
...@@ -35,7 +36,7 @@ public class SheetMoreSingleOperation implements Operation { ...@@ -35,7 +36,7 @@ public class SheetMoreSingleOperation implements Operation {
protected final Logger logger = LoggerFactory.getLogger(SheetMoreSingleOperation.class); protected final Logger logger = LoggerFactory.getLogger(SheetMoreSingleOperation.class);
public SheetMoreSingleOperation(XSSFWorkbook xssfWorkbook, InputStream io, Map<String, String> mapReplace, List<SoilOriginalTemplateConfig> configList, SoilOriginalTemplate template, List<SoilExperimentVO> voList, Map<Long, List<SoilItemVO>> sampleSoilItemVOMap) { public void initParam (XSSFWorkbook xssfWorkbook, InputStream io, Map<String, String> mapReplace, List<SoilOriginalTemplateConfig> configList, SoilOriginalTemplate template, List<SoilExperimentVO> voList, Map<Long, List<SoilItemVO>> sampleSoilItemVOMap) {
this.xssfWorkbook = xssfWorkbook; this.xssfWorkbook = xssfWorkbook;
this.io = io; this.io = io;
this.mapReplace = mapReplace; this.mapReplace = mapReplace;
...@@ -44,156 +45,68 @@ public class SheetMoreSingleOperation implements Operation { ...@@ -44,156 +45,68 @@ public class SheetMoreSingleOperation implements Operation {
this.voList = voList; this.voList = voList;
this.sampleSoilItemVOMap = sampleSoilItemVOMap; this.sampleSoilItemVOMap = sampleSoilItemVOMap;
} }
public synchronized void doProductOriginal(){ public synchronized void doProductOriginal(){
XSSFSheet xssfSheet = xssfWorkbook.getSheetAt(0); XSSFSheet xssfSheet = xssfWorkbook.getSheetAt(0);
xssfSheet.setForceFormulaRecalculation(true); xssfSheet.setForceFormulaRecalculation(true);
int index = 0; int index = 0;
SoilExperimentVO firstVO = null; SoilExperimentVO firstVO = null;
int sheetNum = xssfWorkbook.getNumberOfSheets(); int sheetNum = xssfWorkbook.getNumberOfSheets();
boolean kFNail = "颗粒分析实验(甲种)".equals(template.getName()) || "颗粒分析实验(乙种)".equals(template.getName())||"颗粒分析实验(ASTM)".equals(template.getName());
if (kFNail){
boolean keliJIa = "颗粒分析实验(甲种)".equals(template.getName()) || "颗粒分析实验(乙种)".equals(template.getName());
boolean keliAstm = "颗粒分析实验(ASTM)".equals(template.getName()) ;
if (keliJIa){
DrawXlsxUtil.AnchorPosition position = new DrawXlsxUtil.AnchorPosition(21,2,28,8,"颗粒大小分布曲线","颗粒大小(mm)","小于某直径之百分数(%)"); DrawXlsxUtil.AnchorPosition position = new DrawXlsxUtil.AnchorPosition(21,2,28,8,"颗粒大小分布曲线","颗粒大小(mm)","小于某直径之百分数(%)");
ApachePoiLineChart4.productZhexian(xssfSheet,position); ApachePoiLineChart4.productZhexian(xssfSheet,position);
} }
if (keliAstm){
DrawXlsxUtil.AnchorPosition position = new DrawXlsxUtil.AnchorPosition(21,2,28,8,"颗粒大小分布曲线","颗粒大小(mm)","小于某直径之百分数(%)");
ApachePoiLineChart4.productZhexianAstm(xssfSheet,position);
}
PrintSetup printSetup= xssfSheet.getPrintSetup(); PrintSetup printSetup= xssfSheet.getPrintSetup();
boolean printRound= printSetup.getLandscape(); boolean printRound= printSetup.getLandscape();
for (SoilExperimentVO vo:voList) { for (SoilExperimentVO vo:voList) {
if (index==0){ if (index==0){
index++; index++;
firstVO = vo; firstVO = vo;
continue; continue;
} }
XSSFSheet sheet = xssfWorkbook.cloneSheet(0); XSSFSheet sheet = xssfWorkbook.cloneSheet(0);
sheet.getPrintSetup().setLandscape(printRound); sheet.getPrintSetup().setLandscape(printRound);
if (keliJIa){ if (kFNail){
DrawXlsxUtil.AnchorPosition position = new DrawXlsxUtil.AnchorPosition(21,2,28,8,"颗粒大小分布曲线","颗粒大小(mm)","小于某直径之百分数(%)");
ApachePoiLineChart4.productZhexian(sheet,position);
}
if (keliAstm){
DrawXlsxUtil.AnchorPosition position = new DrawXlsxUtil.AnchorPosition(21,2,28,8,"颗粒大小分布曲线","颗粒大小(mm)","小于某直径之百分数(%)"); DrawXlsxUtil.AnchorPosition position = new DrawXlsxUtil.AnchorPosition(21,2,28,8,"颗粒大小分布曲线","颗粒大小(mm)","小于某直径之百分数(%)");
ApachePoiLineChart4.productZhexianAstm(xssfSheet,position); ApachePoiLineChart4.productZhexian(xssfSheet,position);
} }
index++; index++;
} }
int nextSample = sheetNum; int nextSample = sheetNum;
int itemSize = voList.size();
boolean start = true; for (int i = 0; i < itemSize; i++) {
for (SoilExperimentVO vo:voList) { if (i==0){
if (start){
start = false;
continue; continue;
} }
SoilExperimentVO vo = voList.get(i);
XSSFSheet sheet = xssfWorkbook.getSheetAt(nextSample); XSSFSheet sheet = xssfWorkbook.getSheetAt(nextSample);
xssfWorkbook.setSheetName(nextSample,vo.getSampleCode()); xssfWorkbook.setSheetName(nextSample,vo.getSampleCode());
Map<String,String> myMapReplace = Maps.newHashMap(mapReplace) ;
doExcelFill(vo,myMapReplace,sheet);
List<SoilItemVO> itemVOList = sampleSoilItemVOMap.get(vo.getSampleId());
if (CollectionUtils.isNotEmpty(itemVOList)){
for (SoilItemVO itemVO:itemVOList) {
mapReplace.put("#{"+itemVO.getName()+"}",itemVO.getTestValue());
}
}
if (!mapReplace.containsKey("#{含水率}")){
mapReplace.put("#{含水率}","");
}
if (!mapReplace.containsKey("#{液限}")){
mapReplace.put("#{液限}","");
}
if (!mapReplace.containsKey("#{塑限}")){
mapReplace.put("#{塑限}","");
}
if (!mapReplace.containsKey("#{比重}")){
mapReplace.put("#{比重}","");
}
if (!mapReplace.containsKey("#{密度}")){
mapReplace.put("#{密度}","");
}
mapReplace.put("#{sampleCode}",vo.getSampleCode());
mapReplace.put("#{siteNo}",vo.getSiteNo());
mapReplace.put("#{sampleDepth}",vo.getSampleDepth());
String midu = mapReplace.get("#{密度}");
if (StringUtils.isNotBlank(midu)){
try {
BigDecimal bigDecimal = new BigDecimal(midu);
BigDecimal mul = new BigDecimal("9.81");
BigDecimal rz981 = bigDecimal.multiply(mul);
mapReplace.put("#{密度9.81}",rz981.toString());
}catch (Exception e){
logger.error("密度9.81失败"+e.getMessage());
mapReplace.put("#{密度9.81}","");
}
}else{
mapReplace.put("#{密度9.81}","");
}
nextSample++; nextSample++;
HSSFWorkbookUtil.replaceModel(mapReplace,xssfWorkbook,sheet); }
Map<String,String> myMapReplace = Maps.newHashMap(mapReplace) ;
doExcelFill(firstVO,myMapReplace,xssfSheet);
} }
public void doExcelFill(SoilExperimentVO vo,Map<String,String> myMapReplace, XSSFSheet sheet){
List<SoilItemVO> itemVOList = sampleSoilItemVOMap.get(firstVO.getSampleId()); List<SoilItemVO> itemVOList = sampleSoilItemVOMap.get(vo.getSampleId());
if (CollectionUtils.isNotEmpty(itemVOList)){ if (CollectionUtils.isNotEmpty(itemVOList)){
for (SoilItemVO itemVO:itemVOList) { for (SoilItemVO itemVO:itemVOList) {
mapReplace.put("#{"+itemVO.getName()+"}",itemVO.getTestValue()); myMapReplace.put("#{"+itemVO.getName()+"}",itemVO.getTestValue());
}
} }
if (!mapReplace.containsKey("#{含水率}")){
mapReplace.put("#{含水率}","");
}
if (!mapReplace.containsKey("#{液限}")){
mapReplace.put("#{液限}","");
} }
InitMapReplace.setSingleValueMapCheck(myMapReplace,vo);
if (!mapReplace.containsKey("#{塑限}")){ InitMapReplace.doMIDUSingle(myMapReplace);
mapReplace.put("#{塑限}","");
}
if (!mapReplace.containsKey("#{比重}")){ HSSFWorkbookUtil.replaceModel(myMapReplace,xssfWorkbook,sheet);
mapReplace.put("#{比重}","");
}
if (!mapReplace.containsKey("#{密度}")){
mapReplace.put("#{密度}","");
}
mapReplace.put("#{sampleCode}",firstVO.getSampleCode());
mapReplace.put("#{siteNo}",firstVO.getSiteNo());
mapReplace.put("#{sampleDepth}",firstVO.getSampleDepth());
String midu = mapReplace.get("#{密度}");
if (StringUtils.isNotBlank(midu)){
try {
BigDecimal bigDecimal = new BigDecimal(midu);
BigDecimal mul = new BigDecimal("9.81");
BigDecimal rz981 = bigDecimal.multiply(mul);
mapReplace.put("#{密度9.81}",rz981.toString());
}catch (Exception e){
logger.error("密度9.81失败"+e.getMessage());
mapReplace.put("#{密度9.81}","");
}
}else{
mapReplace.put("#{密度9.81}","");
}
HSSFWorkbookUtil.replaceModel(mapReplace,xssfWorkbook,xssfSheet);
} }
} }
...@@ -27,7 +27,7 @@ public class SingleLessOperation implements Operation { ...@@ -27,7 +27,7 @@ public class SingleLessOperation implements Operation {
protected final Logger logger = LoggerFactory.getLogger(SingleLessOperation.class); protected final Logger logger = LoggerFactory.getLogger(SingleLessOperation.class);
public SingleLessOperation(XSSFWorkbook xssfWorkbook, InputStream io, Map<String, String> mapReplace, List<SoilOriginalTemplateConfig> configList, SoilOriginalTemplate template, List<SoilExperimentVO> voList, Map<Long, List<SoilItemVO>> sampleSoilItemVOMap) { public void initParam (XSSFWorkbook xssfWorkbook, InputStream io, Map<String, String> mapReplace, List<SoilOriginalTemplateConfig> configList, SoilOriginalTemplate template, List<SoilExperimentVO> voList, Map<Long, List<SoilItemVO>> sampleSoilItemVOMap) {
this.xssfWorkbook = xssfWorkbook; this.xssfWorkbook = xssfWorkbook;
this.io = io; this.io = io;
this.mapReplace = mapReplace; this.mapReplace = mapReplace;
...@@ -40,6 +40,7 @@ public class SingleLessOperation implements Operation { ...@@ -40,6 +40,7 @@ public class SingleLessOperation implements Operation {
public synchronized void doProductOriginal(){ public synchronized void doProductOriginal(){
HSSFWorkbookUtil.replaceModel(mapReplace,xssfWorkbook,0); HSSFWorkbookUtil.replaceModel(mapReplace,xssfWorkbook,0);
XSSFSheet sheetOne = xssfWorkbook.getSheetAt(0); XSSFSheet sheetOne = xssfWorkbook.getSheetAt(0);
...@@ -82,67 +83,7 @@ public class SingleLessOperation implements Operation { ...@@ -82,67 +83,7 @@ public class SingleLessOperation implements Operation {
beginRow+=sampleMergerNum; beginRow+=sampleMergerNum;
} }
for (SoilOriginalTemplateConfig config:configList) { for (SoilOriginalTemplateConfig config:configList) {
if (null == config.getMergeRowNum()){ InitMapReplace.initFormula(config,template,sampleMergerNum,templateSampleNum,sheetOne);
config.setMergeRowNum(1);
}
if(OriginalUtil.skipDoExcel(config)){
continue;
}
Integer sampleBgMum = template.getSampleBeginRow();
Integer mergeRowNum = config.getMergeRowNum();
int formulaNum = template.getSampleBeginRow()+sampleMergerNum*templateSampleNum-1 ;
for (int i =sampleBgMum ; i <= formulaNum; i+=mergeRowNum) {
XSSFRow row = sheetOne.getRow(i);
if (null == row){
continue;
}
XSSFCell cell = row.getCell(config.getColumnPlace());
if (null == cell){
continue;
}
String formula = config.getFormula();
formula = formula.replace("#{sn}",(i+1)+"");
if (formula.contains("#{sneven1}")){
if (StringHandleUtils.isEven(i)){
formula= formula.replace("#{sneven1}",(i+1)+"");
}else{
formula= formula.replace("#{sneven1}",i+"");
}
}
if (formula.contains("#{snodd1}")){
if (!StringHandleUtils.isEven(i)){
formula= formula.replace("#{snodd1}",(i+1)+"");
}else{
formula= formula.replace("#{snodd1}",i+"");
}
}
if (formula.contains("#{sn+1}")){
formula= formula.replace("#{sn+1}",(i+2)+"");
}
if (formula.contains("#{sn+2}")){
formula= formula.replace("#{sn+2}",(i+3)+"");
}
if (formula.contains("#{sn+3}")){
formula= formula.replace("#{sn+3}",(i+4)+"");
}
if (formula.contains("#{sn+4}")){
formula= formula.replace("#{sn+4}",(i+5)+"");
}
if (formula.contains("#{sn+5}")){
formula= formula.replace("#{sn+5}",(i+6)+"");
}
if (formula.contains("#{sn+6}")){
formula= formula.replace("#{sn+6}",(i+7)+"");
}
if (formula.contains("#{sn+7}")){
formula= formula.replace("#{sn+7}",(i+8)+"");
}
cell.setCellFormula(formula);
}
} }
logger.error("----------------------7"); logger.error("----------------------7");
} }
......
...@@ -28,7 +28,7 @@ public class SingleMoreOperation implements Operation{ ...@@ -28,7 +28,7 @@ public class SingleMoreOperation implements Operation{
private List<SoilExperimentVO> voList; private List<SoilExperimentVO> voList;
private Map<Long,List<SoilItemVO>> sampleSoilItemVOMap; private Map<Long,List<SoilItemVO>> sampleSoilItemVOMap;
public SingleMoreOperation(XSSFWorkbook xssfWorkbook, InputStream io, Map<String, String> mapReplace, List<SoilOriginalTemplateConfig> configList, SoilOriginalTemplate template, List<SoilExperimentVO> voList, Map<Long, List<SoilItemVO>> sampleSoilItemVOMap) { public void initParam(XSSFWorkbook xssfWorkbook, InputStream io, Map<String, String> mapReplace, List<SoilOriginalTemplateConfig> configList, SoilOriginalTemplate template, List<SoilExperimentVO> voList, Map<Long, List<SoilItemVO>> sampleSoilItemVOMap) {
this.xssfWorkbook = xssfWorkbook; this.xssfWorkbook = xssfWorkbook;
this.io = io; this.io = io;
this.mapReplace = mapReplace; this.mapReplace = mapReplace;
...@@ -38,6 +38,8 @@ public class SingleMoreOperation implements Operation{ ...@@ -38,6 +38,8 @@ public class SingleMoreOperation implements Operation{
this.sampleSoilItemVOMap = sampleSoilItemVOMap; this.sampleSoilItemVOMap = sampleSoilItemVOMap;
} }
protected final Logger logger = LoggerFactory.getLogger(SingleMoreOperation.class); protected final Logger logger = LoggerFactory.getLogger(SingleMoreOperation.class);
...@@ -79,41 +81,33 @@ public class SingleMoreOperation implements Operation{ ...@@ -79,41 +81,33 @@ public class SingleMoreOperation implements Operation{
} }
XSSFRow row = sheetOne.createRow(insertRow); XSSFRow row = sheetOne.createRow(insertRow);
row.setHeight(zeroRow.getHeight()); row.setHeight(zeroRow.getHeight());
for (int j = 0; j < lastCellNum; j++) { for (int j = 0; j < lastCellNum; j++) {
XSSFCellStyle cellStyle = zeroRow.getCell(j).getCellStyle(); XSSFCellStyle cellStyle = zeroRow.getCell(j).getCellStyle();
XSSFCell xssfCell = row.createCell(j); XSSFCell xssfCell = row.createCell(j);
xssfCell.setCellStyle(cellStyle); xssfCell.setCellStyle(cellStyle);
} }
insertRow++; insertRow++;
} }
} }
int sn = 1; int sn = 1;
Map<String,String> siteNoSampleCodeMap = new HashMap<>(); Map<String,String> siteNoSampleCodeMap = new HashMap<>();
for (SoilExperimentVO vo:voList){ for (SoilExperimentVO vo:voList){
siteNoSampleCodeMap.put(vo.getSiteNo(),vo.getSampleCode()); siteNoSampleCodeMap.put(vo.getSiteNo(),vo.getSampleCode());
} }
for (SoilExperimentVO vo:voList) { for (SoilExperimentVO vo:voList) {
List<SoilItemVO> soilItemVOS = sampleSoilItemVOMap.get(vo.getSampleId()); List<SoilItemVO> soilItemVOS = sampleSoilItemVOMap.get(vo.getSampleId());
XSSFRow xssfRow = sheetOne.getRow(beginRow); XSSFRow xssfRow = sheetOne.getRow(beginRow);
for (SoilOriginalTemplateConfig config:configList) { for (SoilOriginalTemplateConfig config:configList) {
if (null == config.getColumnPlace()){ if (null == config.getColumnPlace()){
continue; continue;
} }
XSSFCell cell = xssfRow.getCell(config.getColumnPlace()); XSSFCell cell = xssfRow.getCell(config.getColumnPlace());
if (null!=config.getDataAttribute()&&config.getDataAttribute().contains("for")){ if (null!=config.getDataAttribute()&&config.getDataAttribute().contains("for")){
String name = config.getDataAttribute().replace("for",""); String name = config.getDataAttribute().replace("for","");
OriginalUtil.doForValue(sampleMergerNum,sheetOne,beginRow,config,name,soilItemVOS); OriginalUtil.doForValue(sampleMergerNum,sheetOne,beginRow,config,name,soilItemVOS);
continue; continue;
} }
if ("sn".equals(config.getDataAttribute())){ if ("sn".equals(config.getDataAttribute())){
cell.setCellValue(sn); cell.setCellValue(sn);
}else{ }else{
...@@ -124,67 +118,7 @@ public class SingleMoreOperation implements Operation{ ...@@ -124,67 +118,7 @@ public class SingleMoreOperation implements Operation{
sn++; sn++;
} }
for (SoilOriginalTemplateConfig config:configList) { for (SoilOriginalTemplateConfig config:configList) {
if (null==config.getMergeRowNum()){ InitMapReplace.initFormula(config,template,sampleMergerNum,templateSampleNum,sheetOne);
config.setMergeRowNum(1);
}
if (OriginalUtil.skipDoExcel(config)){
continue;
}
Integer sampleBgMum = template.getSampleBeginRow();
Integer mergeRowNum = config.getMergeRowNum();
int formulaNum = template.getSampleBeginRow()+sampleMergerNum*voList.size()-1 ;
for (int i =sampleBgMum ; i <= formulaNum; i+=mergeRowNum) {
XSSFRow row = sheetOne.getRow(i);
if (null == row){
continue;
}
XSSFCell cell = row.getCell(config.getColumnPlace());
if (null == cell){
continue;
}
String formula = config.getFormula();
formula = formula.replace("#{sn}",(i+1)+"");
if (formula.contains("#{sneven1}")){
if (StringHandleUtils.isEven(i)){
formula= formula.replace("#{sneven1}",(i+1)+"");
}else{
formula= formula.replace("#{sneven1}",i+"");
}
}
if (formula.contains("#{snodd1}")){
if (!StringHandleUtils.isEven(i)){
formula= formula.replace("#{snodd1}",(i+1)+"");
}else{
formula= formula.replace("#{snodd1}",i+"");
}
}
if (formula.contains("#{sn+1}")){
formula= formula.replace("#{sn+1}",(i+2)+"");
}
if (formula.contains("#{sn+2}")){
formula= formula.replace("#{sn+2}",(i+3)+"");
}
if (formula.contains("#{sn+3}")){
formula= formula.replace("#{sn+3}",(i+4)+"");
}
if (formula.contains("#{sn+4}")){
formula= formula.replace("#{sn+4}",(i+5)+"");
}
if (formula.contains("#{sn+5}")){
formula= formula.replace("#{sn+5}",(i+6)+"");
}
if (formula.contains("#{sn+6}")){
formula= formula.replace("#{sn+6}",(i+7)+"");
}
if (formula.contains("#{sn+7}")){
formula= formula.replace("#{sn+7}",(i+8)+"");
}
cell.setCellFormula(formula);
}
} }
...@@ -200,7 +134,6 @@ public class SingleMoreOperation implements Operation{ ...@@ -200,7 +134,6 @@ public class SingleMoreOperation implements Operation{
OriginalUtil.mergeExcel(sheetOne,template,step,templateSampleNum,sampleMergerNum,voList,config); OriginalUtil.mergeExcel(sheetOne,template,step,templateSampleNum,sampleMergerNum,voList,config);
}else{ }else{
OriginalUtil.mergeSpecialExcel(sheetOne,template,step,siteNoSampleCodeMap,templateSampleNum,sampleMergerNum,voList,config); OriginalUtil.mergeSpecialExcel(sheetOne,template,step,siteNoSampleCodeMap,templateSampleNum,sampleMergerNum,voList,config);
} }
} }
} }
......
package com.patzn.cloud.service.lims.socket;
import com.patzn.cloud.service.lims.soil.service.ISoilItemService;
import com.patzn.cloud.service.lims.soil.service.impl.SoilItemServiceImpl;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStreamWriter;
import java.net.Socket;
import java.net.SocketException;
import java.net.SocketTimeoutException;
import java.util.zip.DataFormatException;
public class ServerConfig extends Thread {
private Socket socket;
public ServerConfig(Socket socket) {
this.socket = socket;
}
// 获取spring容器管理的类,可以获取到sevrice的类
private ISoilItemService service = SpringUtil.getBean(SoilItemServiceImpl.class);
private String handle(InputStream inputStream) throws IOException, DataFormatException {
byte[] bytes = new byte[1024];
int len = inputStream.read(bytes);
if (len != -1) {
StringBuffer request = new StringBuffer();
request.append(new String(bytes, 0, len, "UTF-8"));
System.out.println("接受的数据: " + request);
System.out.println("from client ... " + request + "当前线程" + Thread.currentThread().getName());
} else {
throw new DataFormatException("数据处理异常");
}
return "";
}
@Override
public void run() {
BufferedWriter writer = null;
try {
// 设置连接超时9秒
socket.setSoTimeout(9000);
System.out.println("客户 - " + socket.getRemoteSocketAddress() + " -> 机连接成功");
InputStream inputStream = socket.getInputStream();
writer = new BufferedWriter(new OutputStreamWriter(socket.getOutputStream()));
String result = null;
try {
result = handle(inputStream);
writer.write(result);
writer.newLine();
writer.flush();
} catch (IOException | DataFormatException | IllegalArgumentException e) {
writer.write("error");
writer.newLine();
writer.flush();
System.out.println("发生异常");
try {
System.out.println("再次接受!");
result = handle(inputStream);
writer.write(result);
writer.newLine();
writer.flush();
} catch (DataFormatException | SocketTimeoutException ex) {
System.out.println("再次接受, 发生异常,连接关闭");
}
}
} catch (SocketException socketException) {
socketException.printStackTrace();
try {
writer.close();
} catch (IOException ioException) {
ioException.printStackTrace();
}
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
writer.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
package com.patzn.cloud.service.lims.socket;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Component;
@Component
@Configuration
@PropertySource("classpath:application.yml")
@ConfigurationProperties(prefix = "socket")
public class SocketProperties {
private Integer port;
private Integer poolKeep;
private Integer poolCore;
private Integer poolMax;
private Integer poolQueueInit;
public Integer getPort() {
return port;
}
public void setPort(Integer port) {
this.port = port;
}
public Integer getPoolKeep() {
return poolKeep;
}
public void setPoolKeep(Integer poolKeep) {
this.poolKeep = poolKeep;
}
public Integer getPoolCore() {
return poolCore;
}
public void setPoolCore(Integer poolCore) {
this.poolCore = poolCore;
}
public Integer getPoolMax() {
return poolMax;
}
public void setPoolMax(Integer poolMax) {
this.poolMax = poolMax;
}
public Integer getPoolQueueInit() {
return poolQueueInit;
}
public void setPoolQueueInit(Integer poolQueueInit) {
this.poolQueueInit = poolQueueInit;
}
}
...@@ -94,6 +94,25 @@ public class SoilExpReportController extends ServiceController { ...@@ -94,6 +94,25 @@ public class SoilExpReportController extends ServiceController {
} }
@ApiOperation("试验项目报告复核退回")
@PostMapping("/back_exp_report_check")
public RestResult<Boolean> backExpReportCheck(@RequestParam("ids") Long [] ids,@RequestParam("remark") String remark) {
return success(soilExpReportService.backExpReportCheck(ids,remark,getAccount()));
}
@ApiOperation("试验项目报告签发退回")
@PostMapping("/back_exp_report_issue")
public RestResult<Boolean> backExpReportIssue(@RequestParam("ids") Long [] ids,@RequestParam("remark") String remark) {
return success(soilExpReportService.backExpReportIssue(ids,remark,getAccount()));
}
@ApiOperation("试验项目报告编制提交") @ApiOperation("试验项目报告编制提交")
@PostMapping("/exp_report_approve") @PostMapping("/exp_report_approve")
public RestResult<Boolean> expReportCheckApprove(@RequestParam("ids") Long [] ids) { public RestResult<Boolean> expReportCheckApprove(@RequestParam("ids") Long [] ids) {
...@@ -103,6 +122,9 @@ public class SoilExpReportController extends ServiceController { ...@@ -103,6 +122,9 @@ public class SoilExpReportController extends ServiceController {
@ApiOperation("试验项目报告复核") @ApiOperation("试验项目报告复核")
@PostMapping("/exp_report_check_back") @PostMapping("/exp_report_check_back")
public RestResult<Boolean> expReportCheckBack(@RequestParam("ids") Long [] ids,@RequestParam("remark") String remark) { public RestResult<Boolean> expReportCheckBack(@RequestParam("ids") Long [] ids,@RequestParam("remark") String remark) {
......
...@@ -43,4 +43,8 @@ public interface ISoilExpReportService extends IBaseService<SoilExpReport> { ...@@ -43,4 +43,8 @@ public interface ISoilExpReportService extends IBaseService<SoilExpReport> {
SoilExpReport generateAppendix(Long id, Account account); SoilExpReport generateAppendix(Long id, Account account);
SoilExpReport itemReportMerge(Long[] ids); SoilExpReport itemReportMerge(Long[] ids);
boolean backExpReportIssue(Long[] ids, String remark, Account account);
boolean backExpReportCheck(Long[] ids, String remark, Account account);
} }
...@@ -790,6 +790,42 @@ public class SoilExpReportServiceImpl extends BaseServiceImpl<SoilExpReportMappe ...@@ -790,6 +790,42 @@ public class SoilExpReportServiceImpl extends BaseServiceImpl<SoilExpReportMappe
return null; return null;
} }
@Override
public boolean backExpReportIssue(Long[] ids, String remark, Account account) {
RestAssert.fail(ArrayUtils.isEmpty(ids),"请选择要复核驳回的试验报告");
RestAssert.fail(StringUtils.isBlank(remark),"请填写驳回的原因");
List<SoilExpReport> expReportList = list(Condition.create().in("id",ids));
List<SoilExpReport> updateList = new ArrayList<>();
for (SoilExpReport soilExpReport:expReportList) {
SoilExpReport expReport = new SoilExpReport();
expReport.setStatus(SoilExpReportStatusEnum.MAKE);
expReport.setProgress(SoilExpReportStatusEnum.BACK_ISSUE);
expReport.setId(soilExpReport.getId());
expReport.setRemark(soilExpReport.getRemark()+" "+remark);
updateList.add(expReport);
}
return updateBatchById(updateList);
}
@Override
public boolean backExpReportCheck(Long[] ids, String remark, Account account) {
RestAssert.fail(ArrayUtils.isEmpty(ids),"请选择要复核驳回的试验报告");
RestAssert.fail(StringUtils.isBlank(remark),"请填写驳回的原因");
List<SoilExpReport> expReportList = list(Condition.create().in("id",ids));
List<SoilExpReport> updateList = new ArrayList<>();
for (SoilExpReport soilExpReport:expReportList) {
SoilExpReport expReport = new SoilExpReport();
expReport.setStatus(SoilExpReportStatusEnum.MAKE);
expReport.setProgress(SoilExpReportStatusEnum.BACK_CHECK);
expReport.setId(soilExpReport.getId());
expReport.setRemark(soilExpReport.getRemark()+" "+remark);
updateList.add(expReport);
}
return updateBatchById(updateList);
}
public InputStream exportToExcelInputStream(XSSFWorkbook workbook) { public InputStream exportToExcelInputStream(XSSFWorkbook workbook) {
......
...@@ -104,10 +104,10 @@ public class SoilExperimentRelEquipServiceImpl extends BaseServiceImpl<SoilExper ...@@ -104,10 +104,10 @@ public class SoilExperimentRelEquipServiceImpl extends BaseServiceImpl<SoilExper
for (SoilExperimentVO experimentVO:experimentVOList) { for (SoilExperimentVO experimentVO:experimentVOList) {
expMap.put(experimentVO.getId(),experimentVO); expMap.put(experimentVO.getId(),experimentVO);
} }
CollectHandlerChain chain = new CollectHandlerChain(); CollectHandlerChain chain = CollectHandlerChain.getInstance();
chain.addHandler(new PngReportHandle()); chain.addHandler( PngReportHandle.getInstance());
chain.addHandler(new WuCollectHandle()); chain.addHandler(WuCollectHandle.getInstance());
chain.addHandler(new GdsFileHandle()); chain.addHandler(GdsFileHandle.getInstance());
for (SoilExperimentRelEquip equip:saveRelEquipList) { for (SoilExperimentRelEquip equip:saveRelEquipList) {
SoilExperimentVO experimentVO = expMap.get(equip.getExpId()); SoilExperimentVO experimentVO = expMap.get(equip.getExpId());
CollectDataType collectDataType = new CollectDataType(); CollectDataType collectDataType = new CollectDataType();
......
...@@ -110,6 +110,9 @@ public class SoilExperimentServiceImpl extends BaseServiceImpl<SoilExperimentMap ...@@ -110,6 +110,9 @@ public class SoilExperimentServiceImpl extends BaseServiceImpl<SoilExperimentMap
private ISoilEntrustService soilEntrustService; private ISoilEntrustService soilEntrustService;
@Autowired @Autowired
private ISoilSampleOperationService soilSampleOperationService;
@Autowired
private ISoilExperimentOperationService soilExperimentOperationService; private ISoilExperimentOperationService soilExperimentOperationService;
@Autowired @Autowired
private ISoilExperimentRecordService soilExperimentRecordService; private ISoilExperimentRecordService soilExperimentRecordService;
...@@ -350,9 +353,20 @@ public class SoilExperimentServiceImpl extends BaseServiceImpl<SoilExperimentMap ...@@ -350,9 +353,20 @@ public class SoilExperimentServiceImpl extends BaseServiceImpl<SoilExperimentMap
Map<String, String> mapReplace = new HashMap<>(); Map<String, String> mapReplace = new HashMap<>();
InitMapReplace.initMapReplace(mapReplace,entrust); InitMapReplace.initMapReplace(mapReplace,entrust);
List<SoilOriginalTemplateConfig> configList = soilOriginalTemplateConfigService.list(Condition.create().eq("template_id",templateId));
OriginalOperationFactory operationFactory = new OriginalOperationFactory(xssfWorkbook,io,mapReplace,configList,template,voList,soilItemVOList,entrust); List<SoilSampleOperation> operationList = soilSampleOperationService.list(Condition.create().setSqlSelect("make_time").in("sample_id",sampleIdList).isNotNull("make_time"));
if (CollectionUtils.isEmpty(operationList)){
mapReplace.put("#{testDate}","");
}else{
List<Date> dateList = operationList.stream().map(d->{
return d.getMakeTime();
}).collect(Collectors.toList());
mapReplace.put("#{testDate}",DateUtils.toYearMonthDay(DateUtils.getMinDateByDateList(dateList)));
}
List<SoilOriginalTemplateConfig> configList = soilOriginalTemplateConfigService.list(Condition.create().eq("template_id",templateId));
OriginalOperationFactory operationFactory =new OriginalOperationFactory();
operationFactory.initParams(xssfWorkbook,io,mapReplace,configList,template,voList,soilItemVOList,entrust);
Operation operation = operationFactory.getOperation(template,template.getTemplateSampleNum(),voList); Operation operation = operationFactory.getOperation(template,template.getTemplateSampleNum(),voList);
operation.doProductOriginal(); operation.doProductOriginal();
FileOutputStream os = null; FileOutputStream os = null;
...@@ -1253,6 +1267,45 @@ public class SoilExperimentServiceImpl extends BaseServiceImpl<SoilExperimentMap ...@@ -1253,6 +1267,45 @@ public class SoilExperimentServiceImpl extends BaseServiceImpl<SoilExperimentMap
} }
public List<SoilExperimentVO> getExpVOHaveIndex( Long entrustId){
List<SoilExperimentVO> voList = baseMapper.selectByEntrustId(entrustId);
if (CollectionUtils.isEmpty(voList)){
return voList;
}
List<Long> expIds = voList.stream().map(s->{
return s.getId();
}).collect(Collectors.toList());
List<SoilItemVO> itemVOList = soilItemService.listVOByExpIds(expIds);
if (CollectionUtils.isEmpty(itemVOList)){
return voList;
}
Map<Long,List<SoilItemVO>> voMap = new HashMap<>();
for (SoilItemVO itemVO : itemVOList) {
if (voMap.containsKey(itemVO.getExperimentId())){
List<SoilItemVO> vos = voMap.get(itemVO.getExperimentId());
vos.add(itemVO);
voMap.put(itemVO.getExperimentId(),vos);
}else{
List<SoilItemVO> vos=new ArrayList<>();
vos.add(itemVO);
voMap.put(itemVO.getExperimentId(),vos);
}
}
for (SoilExperimentVO vo : voList) {
if (voMap.containsKey(vo.getId())){
vo.setItemVOList(voMap.get(vo.getId()));
}
}
return voList;
}
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
@Override @Override
public boolean uploadDynamicsCollect(MultipartHttpServletRequest multipartHttpServletRequest, Long entrustId, Account account) { public boolean uploadDynamicsCollect(MultipartHttpServletRequest multipartHttpServletRequest, Long entrustId, Account account) {
...@@ -1267,37 +1320,23 @@ public class SoilExperimentServiceImpl extends BaseServiceImpl<SoilExperimentMap ...@@ -1267,37 +1320,23 @@ public class SoilExperimentServiceImpl extends BaseServiceImpl<SoilExperimentMap
Map<String,SoilExperimentVO> nameCodeList = new HashMap<>(); Map<String,SoilExperimentVO> nameCodeList = new HashMap<>();
for (SoilExperimentVO experimentVO:voList) { for (SoilExperimentVO experimentVO:voList) {
if (experimentVO.getName().contains("三轴压缩")){
if (experimentVO.getName().contains("重塑")){
nameCodeList.put("三轴压缩重塑"+experimentVO.getSampleCode(),experimentVO);
nameCodeList.put("三轴压缩重塑"+experimentVO.getSiteNo(),experimentVO);
}else{
nameCodeList.put("三轴压缩"+experimentVO.getSampleCode(),experimentVO);
nameCodeList.put("三轴压缩"+experimentVO.getSiteNo(),experimentVO);
}
}else{
nameCodeList.put(experimentVO.getName()+experimentVO.getSampleCode(),experimentVO); nameCodeList.put(experimentVO.getName()+experimentVO.getSampleCode(),experimentVO);
nameCodeList.put(experimentVO.getName()+experimentVO.getSiteNo(),experimentVO); nameCodeList.put(experimentVO.getName()+experimentVO.getSiteNo(),experimentVO);
} }
}
Iterator<String> fileNamesIt = multipartHttpServletRequest.getFileNames(); Iterator<String> fileNamesIt = multipartHttpServletRequest.getFileNames();
List<String> failedNameList = new ArrayList<>(); List<String> failedNameList = new ArrayList<>();
while (fileNamesIt.hasNext()) { while (fileNamesIt.hasNext()) {
String fileName = fileNamesIt.next(); String fileName = fileNamesIt.next();
// 获取文件 // 获取文件
MultipartFile multipartFile = multipartHttpServletRequest.getFile(fileName); MultipartFile multipartFile = multipartHttpServletRequest.getFile(fileName);
String name = multipartFile.getName();
String originalFilename = multipartFile.getOriginalFilename(); String originalFilename = multipartFile.getOriginalFilename();
if (originalFilename.contains(".bmp")||originalFilename.contains(".txt")){ if (originalFilename.contains(".bmp")||originalFilename.contains(".txt")){
String nameCode = originalFilename.replace(".bmp","").replace(".txt",""); String nameCode = originalFilename.replace(".bmp","").replace(".txt","");
String lastName = nameCode.substring(nameCode.length()-1,nameCode.length()); String lastName = nameCode.substring(nameCode.length()-1,nameCode.length());
if ("r".equals(lastName)){ if (lastName.equals("D")){
if (nameCode.contains("三轴压缩")&&(!nameCode.contains("重塑"))){ nameCode = nameCode.replace("D","");
nameCode = nameCode.replace("三轴压缩","三轴压缩重塑"); }else if (lastName.equals("G")){
nameCode = nameCode.substring(0, nameCode.length() - 1); nameCode = nameCode.replace("G","");
}
} }
if (!nameCodeList.containsKey(nameCode)){ if (!nameCodeList.containsKey(nameCode)){
RestAssert.fail("请正确上传委托下的数据采集文件"); RestAssert.fail("请正确上传委托下的数据采集文件");
...@@ -1313,20 +1352,14 @@ public class SoilExperimentServiceImpl extends BaseServiceImpl<SoilExperimentMap ...@@ -1313,20 +1352,14 @@ public class SoilExperimentServiceImpl extends BaseServiceImpl<SoilExperimentMap
String fileName = fileNamesItOk.next(); String fileName = fileNamesItOk.next();
// 获取文件 // 获取文件
MultipartFile multipartFile = multipartHttpServletRequest.getFile(fileName); MultipartFile multipartFile = multipartHttpServletRequest.getFile(fileName);
String name = multipartFile.getName();
String originalFilename = multipartFile.getOriginalFilename(); String originalFilename = multipartFile.getOriginalFilename();
if (originalFilename.contains(".bmp")||originalFilename.contains(".txt")){ if (originalFilename.contains(".bmp")||originalFilename.contains(".txt")){
String nameCode = originalFilename.replace(".bmp","").replace(".txt",""); String nameCode = originalFilename.replace(".bmp","").replace(".txt","");
String lastName = nameCode.substring(nameCode.length()-1,nameCode.length()); String lastName = nameCode.substring(nameCode.length()-1,nameCode.length());
if ("r".equals(lastName)){ if (lastName.equals("D")){
if (nameCode.contains("三轴压缩")&&(!nameCode.contains("重塑"))){ nameCode = nameCode.replace("D","");
nameCode = nameCode.replace("三轴压缩","三轴压缩重塑"); }else if (lastName.equals("G")){
nameCode = nameCode.substring(0, nameCode.length() - 1); nameCode = nameCode.replace("G","");
}
} }
SoilExperimentVO vo = nameCodeList.get(nameCode); SoilExperimentVO vo = nameCodeList.get(nameCode);
CollectDataType dataType = new CollectDataType(); CollectDataType dataType = new CollectDataType();
...@@ -1337,7 +1370,20 @@ public class SoilExperimentServiceImpl extends BaseServiceImpl<SoilExperimentMap ...@@ -1337,7 +1370,20 @@ public class SoilExperimentServiceImpl extends BaseServiceImpl<SoilExperimentMap
dataType.setExperiment(vo.getName()); dataType.setExperiment(vo.getName());
dataType.setEntrustCode(vo.getEntrustCode()); dataType.setEntrustCode(vo.getEntrustCode());
if (originalFilename.contains(".bmp")){ if (originalFilename.contains(".bmp")){
uploadCollectPng(multipartFile,dataType); if (nameCode.contains("颗粒分析")){
if (lastName.equals("G")){
dataType.setTemplateType("颗粒分析GB");
}else{
dataType.setTemplateType("颗粒分析ASTM");
}
}else if (nameCode.contains("界限含水率")){
if (lastName.equals("D")){
dataType.setTemplateType("界限含水率多点法");
}else{
dataType.setTemplateType("界限含水率联合测定");
}
}
uploadCollectPngWuXing(multipartFile,dataType);
}else if (originalFilename.contains(".txt")){ }else if (originalFilename.contains(".txt")){
parseTxt(multipartFile,dataType); parseTxt(multipartFile,dataType);
} }
...@@ -1488,6 +1534,142 @@ public class SoilExperimentServiceImpl extends BaseServiceImpl<SoilExperimentMap ...@@ -1488,6 +1534,142 @@ public class SoilExperimentServiceImpl extends BaseServiceImpl<SoilExperimentMap
} }
public void uploadCollectPngWuXing(MultipartFile smbFile, CollectDataType type) {
if (type.getExpId()!=null){
SoilExperimentCollectFile collectFile = new SoilExperimentCollectFile();
collectFile.setExpId(type.getExpId());
InputStream is = null;
File fileNew = null;
try {
is= smbFile.getInputStream();
File file = File.createTempFile(StringHandleUtils.getFileNameNoEx(smbFile.getOriginalFilename()),smbFile.getOriginalFilename().replace(StringHandleUtils.getFileNameNoEx(smbFile.getOriginalFilename()),""));
FileOutputStream fos = new FileOutputStream(file);
byte[] bytes = new byte[1024*1024];
int index;
while ((index = is.read(bytes)) != -1) {
fos.write(bytes, 0, index);
fos.flush();
}
String name = smbFile.getOriginalFilename();
String expname= type.getExperiment();
String nouKuoZhanName = name.replace(".bmp","");
if (name.contains(expname)){
SoilSample sample = soilSampleService.getBySampleCode(type.getSampleCode());
if (null !=sample){
XSSFWorkbook xssfWorkbook= null;
if (type.getTemplateType()==null){
xssfWorkbook = exportService.getXSSFWorkbook("AttachmentTemplateSZYS.xlsx");
}else if ("颗粒分析GB".equals(type.getTemplateType())){
xssfWorkbook = exportService.getXSSFWorkbook("AppendixKFGB.xlsx");
}else if ("颗粒分析ASTM".equals(type.getTemplateType())){
xssfWorkbook = exportService.getXSSFWorkbook("AppendixKFASTM.xlsx");
}else if ("界限含水率多点法".equals(type.getTemplateType())){
xssfWorkbook = exportService.getXSSFWorkbook("AppendixJXHSLDD.xlsx");
}else{
xssfWorkbook = exportService.getXSSFWorkbook("AttachmentTemplateSZYS.xlsx");
}
Map<String,File> fileMap=new HashMap<>();
fileMap.put("${picTest}",file);
Map<String,String> replaceMap=new HashMap<>();
String testEnglish = "FIGURE OF GRAIN DISTRIBUTION ANALYSIS TEST";
replaceMap.put("#{reportCode}",StringHandleUtils.getString(type.getEntrustCode()));
replaceMap.put("#{title}","附录"+sample.getSiteNo()+" "+type.getExperiment()+"试验成果图\n" +
"APPENDIX "+sample.getSiteNo()+" "+testEnglish);
replaceMap.put("#{颗粒组成(mm)>25}","");
replaceMap.put("#{颗粒组成(mm)25~19}","");
replaceMap.put("#{颗粒组成(mm)19~4.75}","");
replaceMap.put("#{颗粒组成(mm)4.75~2.0}","");
replaceMap.put("#{颗粒组成(mm)2.0~0.425}","");
replaceMap.put("#{颗粒组成(mm)0.425~0.075}","");
replaceMap.put("#{颗粒组成(mm)0.075~0.005}","");
replaceMap.put("#{颗粒组成(mm)<0.005}","");
replaceMap.put("#{25mm筛下颗粒百分含量}","");
replaceMap.put("#{19mm筛下颗粒百分含量}","");
replaceMap.put("#{4.75mm筛下颗粒百分含量}","");
replaceMap.put("#{2mm筛下颗粒百分含量}","");
replaceMap.put("#{0.425mm筛下颗粒百分含量}","");
replaceMap.put("#{0.075mm筛下颗粒百分含量}","");
replaceMap.put("#{D10}","");
replaceMap.put("#{D60}","");
replaceMap.put("#{D30}","");
replaceMap.put("#{CU}","");
replaceMap.put("#{D50}","");
replaceMap.put("#{CC}","");
replaceMap.put("#{siteNo}","");
replaceMap.put("#{sampleDepth}","");
replaceMap.put("#{颗粒组成(mm)>20.0}","");
replaceMap.put("#{颗粒组成(mm)20.0~2.00}","");
replaceMap.put("#{颗粒组成(mm)2.00~0.50}","");
replaceMap.put("#{颗粒组成(mm)0.50~0.25}","");
replaceMap.put("#{颗粒组成(mm)0.25~0.075}","");
replaceMap.put("#{20mm筛下颗粒百分含量}","");
replaceMap.put("#{0.5mm筛下颗粒百分含量}","");
replaceMap.put("#{0.25mm筛下颗粒百分含量}","");
List<SoilItem> vosList = soilItemService.list(Condition.create().setSqlSelect("id,name,test_value").eq("experiment_id",type.getExpId()));
for (SoilItem vo:vosList) {
replaceMap.put("#{"+vo.getName()+"}",StringHandleUtils.getString(vo.getTestValue()));
}
try {
HSSFWorkbookUtil.replaceModel(replaceMap,xssfWorkbook);
HSSFWorkbookUtil.insertImage(xssfWorkbook,fileMap,false);
}catch (Exception e){
logger.error("generateExcelReport错误"+e.getMessage());
}
xssfWorkbook.setSheetName(0,"附录"+sample.getSiteNo()+type.getExperiment());
FileOutputStream os;
fileNew = File.createTempFile(type.getSampleCode()+type.getExperiment(), ".xlsx");
os = new FileOutputStream(fileNew);
xssfWorkbook.write(os);
os.flush();
os.close();
xssfWorkbook.close();
OssFileResult result = ossClient.upload(fileNew);
SoilAppendix appendix = new SoilAppendix();
appendix.setSampleId(sample.getId());
appendix.setEntrustId(sample.getEntrustId());
appendix.setUname(LoginHelper.getAccount().getUserName());
appendix.setObjectKey(result.getObjectKey());
appendix.setName("附录"+sample.getSiteNo()+" "+type.getExperiment()+"试验成果图");
appendix.setTitle("附录"+sample.getSiteNo());
appendix.setExpId(type.getExpId());
appendix.setSampleCode(type.getSiteNo());
appendix.setRemark(type.getExperiment());
appendix.setEntrustCode(type.getEntrustCode());
soilAppendixService.save(appendix);
}
}
is.close();
fos.close();
OssFileResult result = ossClient.upload(file);
collectFile.setObjectKey(result.getObjectKey());
collectFile.setBucketName(result.getBucketName());
collectFile.setVersionId(result.getVersionId());
collectFile.setFileName(result.getName());
soilExperimentCollectFileService.save(collectFile);
FileUtils.deleteFiles(file);
if (null!=fileNew){
FileUtils.deleteFiles(fileNew);
}
}catch (Exception e){
e.printStackTrace();
}
}
System.out.println(smbFile.getName());
System.out.println(type.getEntrustCode());
}
public void uploadCollectPng(MultipartFile smbFile, CollectDataType type) { public void uploadCollectPng(MultipartFile smbFile, CollectDataType type) {
if (type.getExpId()!=null){ if (type.getExpId()!=null){
SoilExperimentCollectFile collectFile = new SoilExperimentCollectFile(); SoilExperimentCollectFile collectFile = new SoilExperimentCollectFile();
...@@ -2303,7 +2485,7 @@ public class SoilExperimentServiceImpl extends BaseServiceImpl<SoilExperimentMap ...@@ -2303,7 +2485,7 @@ public class SoilExperimentServiceImpl extends BaseServiceImpl<SoilExperimentMap
List<Long> originalIds = new ArrayList<>(); Set<Long> originalIds = new HashSet<>();
Map<Long, Long> map =new HashMap<>(); Map<Long, Long> map =new HashMap<>();
for (SoilExpRelOriginalRecord expRelOriginalRecord:relOriginalRecordList) { for (SoilExpRelOriginalRecord expRelOriginalRecord:relOriginalRecordList) {
map.put(expRelOriginalRecord.getExpId(),expRelOriginalRecord.getRecordId()); map.put(expRelOriginalRecord.getExpId(),expRelOriginalRecord.getRecordId());
......
...@@ -293,7 +293,7 @@ ...@@ -293,7 +293,7 @@
<select id="selectListVOByIds" resultType="com.patzn.cloud.service.soil.vo.SoilExperimentVO"> <select id="selectListVOByIds" resultType="com.patzn.cloud.service.soil.vo.SoilExperimentVO">
SELECT t.id,t.name,t.short_name,s.sample_code,s.site_no,s.sample_depth,s.sample_pack,e.entrust_code,e.borehole_name,e.id AS "entrustId",e.borehole_name,t.sample_id,t.test_method FROM soil_experiment t SELECT t.id,t.name,t.short_name,s.sample_code,s.site_no,s.sample_depth,s.describe_detail,s.sample_pack,e.entrust_code,e.borehole_name,e.id AS "entrustId",e.borehole_name,t.sample_id,t.test_method FROM soil_experiment t
JOIN soil_sample s ON t.sample_id = s.id JOIN soil_sample s ON t.sample_id = s.id
JOIN soil_entrust e ON s.entrust_id = e.id JOIN soil_entrust e ON s.entrust_id = e.id
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
<mapper namespace="com.patzn.cloud.service.lims.soil.mapper.SoilItemMapper"> <mapper namespace="com.patzn.cloud.service.lims.soil.mapper.SoilItemMapper">
<select id="listVOByExpIds" resultType="com.patzn.cloud.service.soil.vo.SoilItemVO"> <select id="listVOByExpIds" resultType="com.patzn.cloud.service.soil.vo.SoilItemVO">
SELECT i.id,i.name,i.experiment_id,s.sample_code FROM soil_item i JOIN SELECT i.id,i.name,i.test_value,i.experiment_id,s.sample_code FROM soil_item i JOIN
soil_experiment t ON i.experiment_id = t.id soil_experiment t ON i.experiment_id = t.id
......
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