Commit 8f9ad9e1 by wangweidong

土工平台修改

parent a3bf27bb
......@@ -1399,15 +1399,309 @@ public class SoilExperimentServiceImpl extends BaseServiceImpl<SoilExperimentMap
}
}else{
int index = 0;
for (SoilExperimentVO vo:voList) {
if (index==0){
xssfWorkbook.setSheetName(index,vo.getSampleCode());
Integer templateSampleNum = template.getTemplateSampleNum();
List<SoilItemVO> soilItemVOList = soilItemService.listVOByExpSampleIds(sampleIdList);
Map<Long,List<SoilItemVO>> sampleSoilItemVOMap =new HashMap<>();
for (SoilItemVO soilItemVO:soilItemVOList) {
if (sampleSoilItemVOMap.containsKey(soilItemVO.getSampleId())){
List<SoilItemVO> sampleItems = sampleSoilItemVOMap.get(soilItemVO.getSampleId());
sampleItems.add(soilItemVO);
sampleSoilItemVOMap.put(soilItemVO.getSampleId(),sampleItems);
}else {
List<SoilItemVO> sampleItems = new ArrayList<>();
sampleItems.add(soilItemVO);
sampleSoilItemVOMap.put(soilItemVO.getSampleId(),sampleItems);
}
}
if (null == templateSampleNum || 1==templateSampleNum){
XSSFSheet xssfSheet = xssfWorkbook.getSheetAt(0);
xssfSheet.setForceFormulaRecalculation(true);
int index = 0;
SoilExperimentVO firstVO = null;
int sheetNum = xssfWorkbook.getNumberOfSheets();
for (SoilExperimentVO vo:voList) {
if (index==0){
index++;
firstVO = vo;
continue;
}
xssfWorkbook.cloneSheet(0);
index++;
continue;
}
xssfWorkbook.setSheetName(index,vo.getSampleCode());
index++;
int nextSample = sheetNum;
boolean start = true;
for (SoilExperimentVO vo:voList) {
if (start){
start = false;
continue;
}
XSSFSheet sheet = xssfWorkbook.getSheetAt(nextSample);
xssfWorkbook.setSheetName(nextSample,vo.getSampleCode());
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("#{sampleDepth}",vo.getSampleDepth());
HSSFWorkbookUtil.replaceModel(mapReplace,xssfWorkbook,sheet);
nextSample++;
}
List<SoilItemVO> itemVOList = sampleSoilItemVOMap.get(firstVO.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}",firstVO.getSampleCode());
HSSFWorkbookUtil.replaceModel(mapReplace,xssfWorkbook,xssfSheet);
int length = voList.size();
// for (int i = 0; i < length; i++) {
//
//
// }
}else{
List<List<SoilExperimentVO>> relList= ListUtils.partition(voList,templateSampleNum);
int templateSheetMum = xssfWorkbook.getNumberOfSheets();
XSSFSheet sheetMy = xssfWorkbook.getSheetAt(0);
boolean first = true;
List<SoilExperimentVO> firstList = null;
for (List<SoilExperimentVO> expVOList:relList) {
XSSFSheet sheet=null;
if (first){
sheet = sheetMy;
firstList = expVOList;
first = false;
continue;
}else{
sheet = xssfWorkbook.cloneSheet(0,sheetMy.getSheetName()+(templateSheetMum));
}
Map<String,String> mapReplaceMy = new HashMap<>();
for (int i = 0; i < templateSampleNum; i++) {
mapReplaceMy.put("#{sampleCode"+i+"}","");
mapReplaceMy.put("#{sampleDepth"+i+"}","");
mapReplaceMy.put("#{含水率"+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());
int entitySize = expVOList.size();
for (int j = 0; j < entitySize; j++) {
SoilExperimentVO vo = expVOList.get(j);
mapReplaceMy.put("#{sampleCode"+j+"}",StringHandleUtils.getString(vo.getSampleCode()));
mapReplaceMy.put("#{sampleDepth"+j+"}",StringHandleUtils.getString(vo.getSampleDepth()));
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("#{密度}")){
mapReplaceMy.put("#{密度}","");
}
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);
templateSheetMum++;
}
int firstSize = firstList.size();
Map<String,String> mapReplaceMy = new HashMap<>();
for (int i = 0; i < templateSampleNum; i++) {
mapReplaceMy.put("#{sampleCode"+i+"}","");
mapReplaceMy.put("#{sampleDepth"+i+"}","");
mapReplaceMy.put("#{含水率"+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("#{sampleDepth"+j+"}",StringHandleUtils.getString(vo.getSampleDepth()));
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("#{含水率}","");
}
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 = 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,sheetMy);
}
}
......
......@@ -18,6 +18,7 @@ import com.patzn.cloud.service.eln.entity.ElnTemplate;
import com.patzn.cloud.service.lims.soil.mapper.SoilOriginalRecordMapper;
import com.patzn.cloud.service.lims.soil.service.ISoilExpRelOriginalRecordService;
import com.patzn.cloud.service.lims.soil.service.ISoilExperimentService;
import com.patzn.cloud.service.lims.soil.service.ISoilItemService;
import com.patzn.cloud.service.lims.soil.service.ISoilOriginalRecordService;
import com.patzn.cloud.commons.service.impl.BaseServiceImpl;
import com.patzn.cloud.service.soil.entity.*;
......@@ -53,6 +54,8 @@ public class SoilOriginalRecordServiceImpl extends BaseServiceImpl<SoilOriginalR
@Autowired
private ISoilExpRelOriginalRecordService soilExpRelOriginalRecordService;
@Autowired
private ISoilItemService soilItemService;
@Autowired
private OssClient ossClient;
......@@ -135,6 +138,18 @@ public class SoilOriginalRecordServiceImpl extends BaseServiceImpl<SoilOriginalR
return r.getId();
}).collect(Collectors.toList());
soilExpRelOriginalRecordService.remove(Condition.create().in("id",relIds));
List<Long> expIdsList = new ArrayList<>();
for (SoilExpRelOriginalRecord originalRecord:relOriginalRecords) {
if (null != originalRecord.getExpId()){
expIdsList.add(originalRecord.getExpId());
}
}
if (CollectionUtils.isNotEmpty(expIdsList)){
soilItemService.remove(Condition.create().in("experiment_id",expIdsList));
}
}
}
return true;
......
......@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.mapper.Condition;
import com.patzn.cloud.commons.api.RestAssert;
import com.patzn.cloud.oss.starter.OssClient;
import com.patzn.cloud.oss.starter.OssFileResult;
import com.patzn.cloud.service.lims.common.HSSFWorkbookUtil;
import com.patzn.cloud.service.lims.handler.ItemCollectEntity;
import com.patzn.cloud.service.lims.handler.SoilItemCollectData;
import com.patzn.cloud.service.lims.soil.mapper.SoilOriginalTemplateMapper;
......@@ -12,8 +13,6 @@ import com.patzn.cloud.commons.service.impl.BaseServiceImpl;
import com.patzn.cloud.service.soil.entity.*;
import com.patzn.cloud.service.soil.vo.SoilExperimentVO;
import com.patzn.cloud.service.soil.vo.SoilItemVO;
import com.patzn.poibox.xwpf.HSSFWorkbookUtil;
import org.apache.bcel.generic.IF_ACMPEQ;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.ss.usermodel.DataFormatter;
......@@ -305,7 +304,8 @@ public class SoilOriginalTemplateServiceImpl extends BaseServiceImpl<SoilOrigina
for (SoilItemVO soilItemVO:indexList) {
stringMap.put(soilItemVO.getSampleCode()+soilItemVO.getExperimentId()+soilItemVO.getName(),soilItemVO.getId());
}
FormulaEvaluator evaluator = xssfWorkbook.getCreationHelper().createFormulaEvaluator();
DataFormatter formatter = new DataFormatter();
if (null ==moreSheet || 0 == moreSheet){
int sampleBeginRow = template.getSampleBeginRow();
int sampleMergerNum = template.getSampleMergerNum();
......@@ -364,8 +364,8 @@ public class SoilOriginalTemplateServiceImpl extends BaseServiceImpl<SoilOrigina
List<SoilItemCollectData> soilItemList = new ArrayList<>();
DataFormatter formatter = new DataFormatter();
FormulaEvaluator evaluator = xssfWorkbook.getCreationHelper().createFormulaEvaluator();
for (int i = sampleBeginRow;i<lastRowNum;i+=sampleMergerNum) {
XSSFRow xssfRow = sheet.getRow(i);
XSSFCell sampleCodeCell = xssfRow.getCell(sampleCol);
......@@ -583,7 +583,7 @@ public class SoilOriginalTemplateServiceImpl extends BaseServiceImpl<SoilOrigina
continue;
}
String value = HSSFWorkbookUtil.getJavaValue(valueCell).toString();
String value = formatter.formatCellValue(valueCell, evaluator);
if (StringUtils.isBlank(value)){
continue;
......
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