Commit 759289cd by wangweidong

土工试验优化

parent b2ee5275
package com.patzn.cloud.service.lims.original; package com.patzn.cloud.service.lims.original;
import com.patzn.cloud.service.lims.common.HSSFWorkbookUtil;
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.SoilItemVO; import com.patzn.cloud.service.soil.vo.SoilItemVO;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.xssf.usermodel.XSSFCell; import org.apache.poi.xssf.usermodel.XSSFCell;
import org.apache.poi.xssf.usermodel.XSSFRow; import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet; import org.apache.poi.xssf.usermodel.XSSFSheet;
import java.util.List; import java.util.List;
import java.util.Map;
public final class OriginalUtil { public final class OriginalUtil {
...@@ -39,4 +44,97 @@ public final class OriginalUtil { ...@@ -39,4 +44,97 @@ public final class OriginalUtil {
return false; return false;
} }
public static boolean skipMerge(SoilOriginalTemplateConfig config){
if (null == config.getMergeBegin()){
return true;
}
if (null == config.getMergeEnd()){
return true;
}
if (config.getMergeRowNum()==1 && config.getMergeEnd() == config.getMergeBegin()){
return true;
}
if (null == config.getColumnPlace()){
return true;
}
if ( null == config.getMergeRowNum()){
return true;
}
if (null == config.getColumnPlace()){
return true;
}
if ( null == config.getMergeRowNum()){
return true;
}
return false;
}
public static void mergeExcel(XSSFSheet sheetOne,SoilOriginalTemplate template,int step,int templateSampleNum,int sampleMergerNum,List<SoilExperimentVO> voList,SoilOriginalTemplateConfig config){
Integer sampleBgMum = template.getSampleBeginRow()+templateSampleNum*sampleMergerNum;
Integer sampleEnMum = template.getSampleBeginRow()+voList.size()*sampleMergerNum-1;
while (sampleBgMum<=sampleEnMum) {
sheetOne.addMergedRegion(new CellRangeAddress(sampleBgMum,sampleBgMum+step-1,config.getMergeBegin(),config.getMergeEnd()));
sampleBgMum=sampleBgMum+step;
}
}
public static void mergeSpecialExcel(XSSFSheet sheetOne, SoilOriginalTemplate template,int step, Map<String,String> siteNoSampleCodeMap, int templateSampleNum, int sampleMergerNum, List<SoilExperimentVO> voList, SoilOriginalTemplateConfig config){
if (config.getColumnPlace() !=10 &&config.getColumnPlace() !=12 ){
Integer sampleBgMum = template.getSampleBeginRow()+templateSampleNum*sampleMergerNum;
Integer sampleEnMum = template.getSampleBeginRow()+voList.size()*sampleMergerNum-1;
while (sampleBgMum<=sampleEnMum) {
sheetOne.addMergedRegion(new CellRangeAddress(sampleBgMum,sampleBgMum+step-1,config.getMergeBegin(),config.getMergeEnd()));
sampleBgMum=sampleBgMum+step;
}
}else{
Integer sampleBgMum = template.getSampleBeginRow()+templateSampleNum*sampleMergerNum;
Integer sampleEnMum = template.getSampleBeginRow()+voList.size()*sampleMergerNum-1;
int indexJishu=0;
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);
String code = HSSFWorkbookUtil.getJavaValue(teshuCellSampleCode).toString();
String mapCode = siteNoSampleCodeMap.get(code);
if (StringUtils.isNotBlank(mapCode)){
teshuCell.setCellFormula("'附录"+mapCode+"'!B11");
}else{
teshuCell.setCellFormula("'附录"+code+"'!B11");
}
}
}
sampleBgMum=sampleBgMum+3;
}else{
sheetOne.addMergedRegion(new CellRangeAddress(sampleBgMum,sampleBgMum+2-1,config.getMergeBegin(),config.getMergeEnd()));
if (config.getColumnPlace()==10){
XSSFRow teshuRow = sheetOne.getRow(sampleBgMum);
if (null != teshuRow){
XSSFCell teshuCell = teshuRow.getCell(config.getColumnPlace());
teshuCell.setCellFormula("IF(OR(J"+(sampleBgMum+1)+"=\"\",J"+(sampleBgMum+2)+"=\"\",J"+(sampleBgMum+1)+"=\"/\",J"+(sampleBgMum+2)+"=\"/\"),\"\",(J"+(sampleBgMum+1)+"+J"+((sampleBgMum+2))+")/2)");
}
}
sampleBgMum=sampleBgMum+2;
}
indexJishu++;
}
}
}
} }
...@@ -49,7 +49,7 @@ public class SheetMoreMuchOperation implements Operation { ...@@ -49,7 +49,7 @@ public class SheetMoreMuchOperation implements Operation {
this.sampleSoilItemVOMap = sampleSoilItemVOMap; this.sampleSoilItemVOMap = sampleSoilItemVOMap;
this.entrust = entrust; this.entrust = entrust;
} }
public 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(); int templateSheetMum = xssfWorkbook.getNumberOfSheets();
......
...@@ -44,7 +44,7 @@ public class SheetMoreSingleOperation implements Operation { ...@@ -44,7 +44,7 @@ public class SheetMoreSingleOperation implements Operation {
this.voList = voList; this.voList = voList;
this.sampleSoilItemVOMap = sampleSoilItemVOMap; this.sampleSoilItemVOMap = sampleSoilItemVOMap;
} }
public 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;
......
...@@ -40,7 +40,7 @@ public class SingleLessOperation implements Operation { ...@@ -40,7 +40,7 @@ public class SingleLessOperation implements Operation {
public 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);
sheetOne.setForceFormulaRecalculation(true); sheetOne.setForceFormulaRecalculation(true);
......
...@@ -41,7 +41,7 @@ public class SingleMoreOperation implements Operation{ ...@@ -41,7 +41,7 @@ public class SingleMoreOperation implements Operation{
protected final Logger logger = LoggerFactory.getLogger(SingleMoreOperation.class); protected final Logger logger = LoggerFactory.getLogger(SingleMoreOperation.class);
public 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);
sheetOne.setForceFormulaRecalculation(true); sheetOne.setForceFormulaRecalculation(true);
...@@ -72,8 +72,15 @@ public class SingleMoreOperation implements Operation{ ...@@ -72,8 +72,15 @@ public class SingleMoreOperation implements Operation{
int insertCount = voList.size()-templateSampleNum; int insertCount = voList.size()-templateSampleNum;
for (int m = 0 ; m<insertCount ;m++) { for (int m = 0 ; m<insertCount ;m++) {
for (int i = 0; i < sampleMergerNum; i++) { for (int i = 0; i < sampleMergerNum; i++) {
try {
sheetOne.shiftRows(insertRow, sheetOne.getLastRowNum(), 1,true,false);
}catch (Exception e){
e.printStackTrace();
}
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);
...@@ -115,7 +122,6 @@ public class SingleMoreOperation implements Operation{ ...@@ -115,7 +122,6 @@ public class SingleMoreOperation implements Operation{
} }
beginRow+=sampleMergerNum; beginRow+=sampleMergerNum;
sn++; sn++;
} }
for (SoilOriginalTemplateConfig config:configList) { for (SoilOriginalTemplateConfig config:configList) {
if (null==config.getMergeRowNum()){ if (null==config.getMergeRowNum()){
...@@ -186,83 +192,16 @@ public class SingleMoreOperation implements Operation{ ...@@ -186,83 +192,16 @@ public class SingleMoreOperation implements Operation{
if (null==config.getMergeRowNum()){ if (null==config.getMergeRowNum()){
config.setMergeRowNum(1); config.setMergeRowNum(1);
} }
if (null == config.getMergeBegin()){ if (OriginalUtil.skipMerge(config)){
continue;
}
if (null == config.getMergeEnd()){
continue; continue;
} }
int step= config.getMergeRowNum(); int step= config.getMergeRowNum();
if (step==1 && config.getMergeEnd() == config.getMergeBegin()){
continue;
}
if (null == config.getColumnPlace()){
continue;
}
if ( null == config.getMergeRowNum()){
continue;
}
if (!teShu){ if (!teShu){
Integer sampleBgMum = template.getSampleBeginRow()+templateSampleNum*sampleMergerNum; OriginalUtil.mergeExcel(sheetOne,template,step,templateSampleNum,sampleMergerNum,voList,config);
Integer sampleEnMum = template.getSampleBeginRow()+voList.size()*sampleMergerNum-1; }else{
OriginalUtil.mergeSpecialExcel(sheetOne,template,step,siteNoSampleCodeMap,templateSampleNum,sampleMergerNum,voList,config);
while (sampleBgMum<=sampleEnMum) {
sheetOne.addMergedRegion(new CellRangeAddress(sampleBgMum,sampleBgMum+step-1,config.getMergeBegin(),config.getMergeEnd()));
sampleBgMum=sampleBgMum+step;
}
}else{
if (config.getColumnPlace() !=10 &&config.getColumnPlace() !=12 ){
Integer sampleBgMum = template.getSampleBeginRow()+templateSampleNum*sampleMergerNum;
Integer sampleEnMum = template.getSampleBeginRow()+voList.size()*sampleMergerNum-1;
while (sampleBgMum<=sampleEnMum) {
sheetOne.addMergedRegion(new CellRangeAddress(sampleBgMum,sampleBgMum+step-1,config.getMergeBegin(),config.getMergeEnd()));
sampleBgMum=sampleBgMum+step;
}
}else{
Integer sampleBgMum = template.getSampleBeginRow()+templateSampleNum*sampleMergerNum;
Integer sampleEnMum = template.getSampleBeginRow()+voList.size()*sampleMergerNum-1;
int indexJishu=0;
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);
String code = HSSFWorkbookUtil.getJavaValue(teshuCellSampleCode).toString();
String mapCode = siteNoSampleCodeMap.get(code); }
if (StringUtils.isNotBlank(mapCode)){
teshuCell.setCellFormula("'附录"+mapCode+"'!B11");
}else{
teshuCell.setCellFormula("'附录"+code+"'!B11");
}
}
}
sampleBgMum=sampleBgMum+3;
}else{
sheetOne.addMergedRegion(new CellRangeAddress(sampleBgMum,sampleBgMum+2-1,config.getMergeBegin(),config.getMergeEnd()));
if (config.getColumnPlace()==10){
XSSFRow teshuRow = sheetOne.getRow(sampleBgMum);
if (null != teshuRow){
XSSFCell teshuCell = teshuRow.getCell(config.getColumnPlace());
teshuCell.setCellFormula("IF(OR(J"+(sampleBgMum+1)+"=\"\",J"+(sampleBgMum+2)+"=\"\",J"+(sampleBgMum+1)+"=\"/\",J"+(sampleBgMum+2)+"=\"/\"),\"\",(J"+(sampleBgMum+1)+"+J"+((sampleBgMum+2))+")/2)");
}
}
sampleBgMum=sampleBgMum+2;
}
indexJishu++;
}
}
}
}
} }
}
} }
package com.patzn.cloud.service.lims.rcp;
import com.alibaba.fastjson.JSON;
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.ByteToMessageDecoder;
import java.util.List;
public class RpcDecoder extends ByteToMessageDecoder {
//目标对象类型进行解码
private Class<?> target;
public RpcDecoder(Class target) {
this.target = target;
}
@Override
protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception {
if (in.readableBytes() < 4) { //不够长度丢弃
return;
}
in.markReaderIndex(); //标记一下当前的readIndex的位置
int dataLength = in.readInt(); // 读取传送过来的消息的长度。ByteBuf 的readInt()方法会让他的readIndex增加4
if (in.readableBytes() < dataLength) { //读到的消息体长度如果小于我们传送过来的消息长度,则resetReaderIndex. 这个配合markReaderIndex使用的。把readIndex重置到mark的地方
in.resetReaderIndex();
return;
}
byte[] data = new byte[dataLength];
in.readBytes(data);
Object obj = JSON.parseObject(data, target); //将byte数据转化为我们需要的对象
out.add(obj);
}
}
package com.patzn.cloud.service.lims.rcp;
/*
* @author uv
* @date 2018/10/13 18:09
* 编码器(将实体类转换成可传输的数据)
*/
import com.alibaba.fastjson.JSON;
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToByteEncoder;
public class RpcEncoder extends MessageToByteEncoder {
//目标对象类型进行编码
private Class<?> target;
public RpcEncoder(Class target) {
this.target = target;
}
@Override
protected void encode(ChannelHandlerContext ctx, Object msg, ByteBuf out) throws Exception {
if (target.isInstance(msg)) {
byte[] data = JSON.toJSONBytes(msg); //使用fastJson将对象转换为byte
out.writeInt(data.length); //先将消息长度写入,也就是消息头
out.writeBytes(data); //消息体中包含我们要发送的数据
}
}
}
\ No newline at end of file
package com.patzn.cloud.service.lims.rcp;
/*
* @author uv
* @date 2018/10/13 18:10
* 传输请求对象
*/
public class RpcRequest {
private String id;
private Object data;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public Object getData() {
return data;
}
public void setData(Object data) {
this.data = data;
}
@Override
public String toString() {
return "RpcRequest{" + "id='" + id + '\'' + ", data=" + data + '}';
}
}
package com.patzn.cloud.service.lims.rcp;
/*
* @author uv
* @date 2018/10/13 18:10
* 传输响应对象
*/
public class RpcResponse {
private String id;
private Object data;
// 0=success -1=fail
private int status;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public Object getData() {
return data;
}
public void setData(Object data) {
this.data = data;
}
public int getStatus() {
return status;
}
public void setStatus(int status) {
this.status = status;
}
@Override
public String toString() {
return "RpcResponse{" + "id='" + id + '\'' + ", data=" + data + ", status=" + status + '}';
}
}
package com.patzn.cloud.service.lims.rcp; package com.patzn.cloud.service.lims.rcp;
import com.patzn.cloud.service.lims.socket.SocketProperties;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.InitializingBean; import org.springframework.beans.factory.InitializingBean;
...@@ -13,8 +12,6 @@ import java.util.concurrent.ExecutorService; ...@@ -13,8 +12,6 @@ import java.util.concurrent.ExecutorService;
public class Runner implements InitializingBean { public class Runner implements InitializingBean {
private static final Logger logger = LoggerFactory.getLogger(Runner.class); private static final Logger logger = LoggerFactory.getLogger(Runner.class);
@Autowired @Autowired
private SocketProperties properties;
@Autowired
@Qualifier(value = "crawlExecutorPool") @Qualifier(value = "crawlExecutorPool")
private ExecutorService pool; private ExecutorService pool;
......
package com.patzn.cloud.service.lims.report;
public interface ReportOperation {
void doMakeReport();
}
package com.patzn.cloud.service.lims.report;
import com.baomidou.mybatisplus.toolkit.CollectionUtils;
import com.patzn.cloud.service.lims.common.StringHandleUtils;
import com.patzn.cloud.service.soil.entity.SoilAppendix;
import com.patzn.cloud.service.soil.entity.SoilItem;
import com.patzn.cloud.service.soil.vo.SoilExperimentVO;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.xssf.usermodel.XSSFCell;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public final class ReportUtil {
public static void initChongSu(List<SoilExperimentVO> voList,List<SoilItem> soilItemList){
Map<String,Integer> checkChongSuMap = new HashMap<>();
for (SoilExperimentVO vo : voList) {
String name = vo.getName().replace("-重塑","")+vo.getSampleCode();
if (checkChongSuMap.containsKey(name)){
Integer num = checkChongSuMap.get(name);
num=num+1;
checkChongSuMap.put(name,num);
}else{
checkChongSuMap.put(name,1);
}
}
List<SoilExperimentVO> newVOList = new ArrayList<>();
Map<String,SoilExperimentVO> newChongSuMap = new HashMap<>();
for (SoilExperimentVO vo:voList) {
String name = vo.getName().replace("-重塑","")+vo.getSampleCode();
if (!vo.getName().contains("重塑")){
newVOList.add(vo);
}else{
Integer num = checkChongSuMap.get(name);
if (null==num||num == 1) {
newVOList.add(vo);
}
newChongSuMap.put(vo.getName()+vo.getSampleCode(),vo);
}
}
voList = newVOList;
List<SoilItem> saveNewItemList = new ArrayList<>();
for (SoilExperimentVO vo:voList) {
SoilExperimentVO chongSu = newChongSuMap.get(vo.getName()+"-重塑"+vo.getSampleCode());
if (null!=chongSu){
for (SoilItem item : soilItemList) {
if (item.getExperimentId().equals(chongSu.getId())){
SoilItem soilItem = item.convert(SoilItem.class);
soilItem.setExperimentId(vo.getId());
saveNewItemList.add(soilItem);
}
}
}
}
for (SoilItem item : saveNewItemList) {
soilItemList.add(item);
}
}
public static void setExcellCellValue (String prepory, SoilExperimentVO vo, XSSFCell cell, List<SoilItem> itemList){
if (StringUtils.isNotBlank(prepory)){
if (prepory.equals("{appendix}")){
SoilAppendix soilAppendix = vo.getSoilAppendix();
if (null != soilAppendix){
cell.setCellValue("见附录");
}
}else{
if (StringHandleUtils.is_alpha(prepory)){
cell.setCellValue(StringHandleUtils.getFieldIfNummReturnBlankValueByFieldName(prepory,vo));
}else{
if (CollectionUtils.isNotEmpty(itemList)){
for (SoilItem item:itemList) {
if (prepory.equals(item.getName())){
cell.setCellValue(item.getTestValue());
break;
}
}
}
}
}
}
}
}
package com.patzn.cloud.service.lims.report;
import com.baomidou.mybatisplus.mapper.Condition;
import com.patzn.cloud.commons.api.RestAssert;
import com.patzn.cloud.service.lims.common.HSSFWorkbookUtil;
import com.patzn.cloud.service.lims.original.SheetMoreMuchOperation;
import com.patzn.cloud.service.soil.entity.SoilExpReportTemplate;
import com.patzn.cloud.service.soil.entity.SoilExpReportTemplateConfig;
import com.patzn.cloud.service.soil.entity.SoilItem;
import com.patzn.cloud.service.soil.vo.SoilExperimentVO;
import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.xssf.usermodel.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
public class SingleSheetReportOperation implements ReportOperation {
protected final Logger logger = LoggerFactory.getLogger(SheetMoreMuchOperation.class);
private Map<String, String> mapReplace;
private XSSFWorkbook xssfWorkbook;
private XSSFSheet sheetOne;
private SoilExpReportTemplate template;
private List<SoilExpReportTemplateConfig> configList;
private List<SoilExperimentVO> voList;
private Map<Long,List<SoilItem>> expItemMap;
public SingleSheetReportOperation(Map<String, String> mapReplace, XSSFWorkbook xssfWorkbook, XSSFSheet sheetOne, SoilExpReportTemplate template, List<SoilExpReportTemplateConfig> configList, List<SoilExperimentVO> voList, Map<Long, List<SoilItem>> expItemMap) {
this.mapReplace = mapReplace;
this.xssfWorkbook = xssfWorkbook;
this.sheetOne = sheetOne;
this.template = template;
this.configList = configList;
this.voList = voList;
this.expItemMap = expItemMap;
}
@Override
public synchronized void doMakeReport() {
HSSFWorkbookUtil.replaceModel(mapReplace,xssfWorkbook,0);
sheetOne.setForceFormulaRecalculation(true);
Integer beginRow = template.getSampleBeginRow();
Integer sampleMergerNumOri = template.getSampleMergerNum();
RestAssert.fail(null == template.getTemplateSampleNum(),"模板样品数不能为空");
int templateSampleNum = template.getTemplateSampleNum();
if (null != beginRow
&& null!=sampleMergerNumOri
&& null!=template.getTemplateSampleNum()){
if (voList.size()<templateSampleNum){
int sampleMergerNum =sampleMergerNumOri;
for (SoilExperimentVO vo:voList) {
List<SoilItem> itemList = expItemMap.get(vo.getId());
if (null == itemList){
itemList = new ArrayList<>();
}
XSSFRow xssfRow = sheetOne.getRow(beginRow);
for (SoilExpReportTemplateConfig config:configList) {
if ("sn".equals(config.getDataAttribute())){
continue;
}
ReportUtil.setExcellCellValue(config.getDataAttribute(),vo,xssfRow.getCell(config.getColumnPlace()),itemList);
}
beginRow+=sampleMergerNum;
}
}else{
int sampleMergerNum = sampleMergerNumOri;
int insertRow = beginRow+sampleMergerNum*templateSampleNum;
XSSFRow zeroRow = sheetOne.getRow(beginRow);
int lastCellNum = zeroRow.getLastCellNum();
int insertCount = voList.size()-templateSampleNum;
for (int m = 0 ; m<insertCount ;m++) {
for (int i = 0; i < sampleMergerNum; i++) {
sheetOne.shiftRows(insertRow, sheetOne.getLastRowNum(), 1,true,false);
XSSFRow row = sheetOne.createRow(insertRow);
row.setHeight(zeroRow.getHeight());
for (int j = 0; j < lastCellNum; j++) {
XSSFCell xssfCell = row.createCell(j);
XSSFCellStyle cellStyle = zeroRow.getCell(j).getCellStyle();
xssfCell.setCellStyle(cellStyle);
xssfCell.setCellValue("/");
}
insertRow++;
}
}
int sn = 1;
for (SoilExperimentVO vo:voList) {
XSSFRow xssfRow = sheetOne.getRow(beginRow);
List<SoilItem> itemList = expItemMap.get(vo.getId());
if (null == itemList){
itemList = new ArrayList<>();
}
for (SoilExpReportTemplateConfig config:configList) {
if (null == config.getColumnPlace()){
continue;
}
XSSFCell cell = xssfRow.getCell(config.getColumnPlace());
if ("sn".equals(config.getDataAttribute())){
cell.setCellValue(sn);
continue;
}
ReportUtil.setExcellCellValue(config.getDataAttribute(),vo,cell,itemList);
}
beginRow+=sampleMergerNum;
sn++;
}
for (SoilExpReportTemplateConfig config:configList) {
if (null==config.getMergeRowNum()){
config.setMergeRowNum(1);
}
if (null == config.getMergeBegin()){
continue;
}
if (null == config.getMergeEnd()){
continue;
}
int step= config.getMergeRowNum();
if (step==1 && config.getMergeEnd() == config.getMergeBegin()){
continue;
}
if (null != config.getColumnPlace() && null != config.getMergeRowNum()){
Integer sampleBgMum = template.getSampleBeginRow()+templateSampleNum*sampleMergerNum;
Integer sampleEnMum = template.getSampleBeginRow()+voList.size()*sampleMergerNum-1;
while (sampleBgMum<=sampleEnMum) {
sheetOne.addMergedRegion(new CellRangeAddress(sampleBgMum,sampleBgMum+step-1,config.getMergeBegin(),config.getMergeEnd()));
sampleBgMum=sampleBgMum+step;
}
}
}
logger.error("----------------------15");
}
}
}
}
...@@ -24,4 +24,6 @@ public interface ISoilAppendixService extends IBaseService<SoilAppendix> { ...@@ -24,4 +24,6 @@ public interface ISoilAppendixService extends IBaseService<SoilAppendix> {
SoilAppendix getByExpId(Long expId); SoilAppendix getByExpId(Long expId);
void downloadFile(Long id, HttpServletResponse response); void downloadFile(Long id, HttpServletResponse response);
List<SoilAppendix> getByExpIds(List<Long> ids);
} }
...@@ -73,6 +73,8 @@ public interface ISoilExperimentService extends IBaseService<SoilExperiment> { ...@@ -73,6 +73,8 @@ public interface ISoilExperimentService extends IBaseService<SoilExperiment> {
List<SoilExperimentVO> listVOByIds(Long [] expIds); List<SoilExperimentVO> listVOByIds(Long [] expIds);
List<SoilExperimentVO> listVOByIdsInit(Long [] expIds);
boolean parseTxt(SmbFile smbFile, CollectDataType request); boolean parseTxt(SmbFile smbFile, CollectDataType request);
boolean parseWuxingTxt(SmbFile smbFile, CollectDataType request); boolean parseWuxingTxt(SmbFile smbFile, CollectDataType request);
......
...@@ -75,4 +75,9 @@ public class SoilAppendixServiceImpl extends BaseServiceImpl<SoilAppendixMapper, ...@@ -75,4 +75,9 @@ public class SoilAppendixServiceImpl extends BaseServiceImpl<SoilAppendixMapper,
} }
ossClient.download(attachment.getObjectKey(), attachment.getName() + ".xlsx", response); ossClient.download(attachment.getObjectKey(), attachment.getName() + ".xlsx", response);
} }
@Override
public List<SoilAppendix> getByExpIds(List<Long> ids) {
return super.list(Condition.create().in("exp_id",ids));
}
} }
...@@ -20,9 +20,11 @@ ...@@ -20,9 +20,11 @@
o.alloter, o.alloter,
o.allot_time, o.allot_time,
s.sample_code, s.sample_code,
s.site_no,
s.sample_depth, s.sample_depth,
s.describe_detail, s.describe_detail,
s.sample_pack s.sample_pack,
e.borehole_name
FROM soil_experiment t FROM soil_experiment t
...@@ -366,7 +368,8 @@ ...@@ -366,7 +368,8 @@
s.sample_pack, s.sample_pack,
o.alloter, o.alloter,
o.allot_time, o.allot_time,
e.client e.client,
e.borehole_name
FROM soil_experiment t FROM soil_experiment t
JOIN soil_sample s ON t.sample_id = s.id JOIN soil_sample s ON t.sample_id = s.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