Commit 5e869911 by wangweidong

土工

parent 51a30ac2
......@@ -19,12 +19,27 @@ public class AsposeUtil {
protected static final Logger logger = LoggerFactory.getLogger(AsposeUtil.class);
public static boolean getLicense() {
// boolean result = false;
// try {
// InputStream is = Word2Pdf.class.getClassLoader()
// .getResourceAsStream("classpath:statis/Aspose.Total.Product.Family(3).lic");
// License aposeLic = new License();
// aposeLic.setLicense(is);
// result = true;
// } catch (Exception e) {
// logger.error("授权失败"+e.getMessage());
// e.printStackTrace();
// }
// return result;
boolean result = false;
try {
InputStream is = Word2Pdf.class.getClassLoader()
.getResourceAsStream("classpath:statis/license.xml");
License aposeLic = new License();
aposeLic.setLicense(is);
InputStream is = License.class.getResourceAsStream("/com.aspose.cells.lic_2999.xml");
License asposeLicense = new License();
asposeLicense.setLicense(is);
is.close();
result = true;
} catch (Exception e) {
e.printStackTrace();
......@@ -54,7 +69,6 @@ public class AsposeUtil {
XSSFWorkbook workbookOk = new XSSFWorkbook(tempFile);
workbookOk.setActiveSheet(0);
workbookOk.removeSheetAt(workbookOk.getNumberOfSheets()-1);
logger.error("mergeWork----------6");
File file = File.createTempFile(DateUtils.toYearMonthDayEasy(new Date())+name,".xlsx");
logger.error("mergeWork----------7");
......
package com.patzn.cloud.service.lims.common;
import com.baomidou.mybatisplus.toolkit.CollectionUtils;
import com.google.common.collect.Maps;
import com.patzn.cloud.service.soil.vo.SoilExperimentVO;
import com.patzn.cloud.service.soil.vo.SoilItemVO;
import org.apache.commons.lang.StringUtils;
import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFRow;
......@@ -17,12 +20,30 @@ import java.math.BigInteger;
import java.text.DateFormat;
import java.text.DecimalFormat;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.regex.Pattern;
public class HSSFWorkbookUtil {
public static String getFieldValue(String dataAttribute, SoilExperimentVO vo, List<SoilItemVO> soilItemVOList) {
if (org.apache.commons.lang3.StringUtils.isBlank(dataAttribute)){
return "";
}
if (StringHandleUtils.is_alpha(dataAttribute)){
return StringHandleUtils.getFieldIfNummReturnBlankValueByFieldName(dataAttribute,vo);
}else{
if (CollectionUtils.isEmpty(soilItemVOList)){
return "";
}
for (SoilItemVO soilItemVO : soilItemVOList) {
if (dataAttribute.equals(soilItemVO.getName())){
return soilItemVO.getTestValue();
}
}
}
return "";
}
public static HSSFWorkbook replaceModel(Map item, HSSFWorkbook wb) {
try {
HSSFSheet sheet = wb.getSheetAt(0);
......@@ -285,17 +306,13 @@ public class HSSFWorkbookUtil {
if (resize){
// 指定我想要的长宽
double standardWidth = 600;
double standardHeight = 830;
double standardWidth = 580;
double standardHeight = 810;
double w = sheet.getColumnWidth(cell.getColumnIndex());
double h = cell.getRow().getHeight();
double cellWidth = sheet.getColumnWidthInPixels(cell.getColumnIndex());
double cellHeight = cell.getRow().getHeightInPoints()/72*96;
// 计算需要的长宽比例的系数
double a = standardWidth / cellWidth;
double b = standardHeight / cellHeight;
......@@ -303,7 +320,6 @@ public class HSSFWorkbookUtil {
}else{
pict.resize();
}
}
}
}
......
package com.patzn.cloud.service.lims.original;
import com.patzn.cloud.service.soil.entity.SoilEntrust;
import java.util.Map;
public class InitMapReplace {
public static void initMapReplace(Map<String, String> mapReplace, SoilEntrust entrust){
mapReplace.put("#{projectName}",entrust.getProjectName());
mapReplace.put("#{client}",entrust.getClient());
mapReplace.put("#{boreholeName}",entrust.getBoreholeName());
mapReplace.put("#{projectNo}",entrust.getProjectNo());
if (null == entrust.getWaterDepth()){
mapReplace.put("#{waterDepth}","");
}else{
mapReplace.put("#{waterDepth}",entrust.getWaterDepth().toString());
}
mapReplace.put("#{reportCode}",entrust.getEntrustCode());
}
}
package com.patzn.cloud.service.lims.original;
public interface Operation {
void doProductOriginal();
}
package com.patzn.cloud.service.lims.original;
import com.patzn.cloud.service.soil.entity.SoilOriginalTemplateConfig;
import com.patzn.cloud.service.soil.vo.SoilItemVO;
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 java.util.List;
public final class OriginalUtil {
public static void doForValue(int sampleMergerNum, XSSFSheet sheetOne, int beginRow, SoilOriginalTemplateConfig config, String name, List<SoilItemVO> soilItemVOS ){
for (int i = 0; i < sampleMergerNum; i++) {
XSSFRow zhuiRow = sheetOne.getRow(beginRow+i);
if (null!=zhuiRow){
XSSFCell cellZhui = zhuiRow.getCell(config.getColumnPlace());
if (null!=cellZhui){
for (SoilItemVO itemVO:soilItemVOS) {
if ((name+(i+1)).equals(itemVO.getName())){
cellZhui.setCellValue(itemVO.getTestValue());
break;
}
}
}
}
}
}
public static boolean skipDoExcel(SoilOriginalTemplateConfig config){
if (StringUtils.isBlank(config.getFormula())||
null == config.getColumnPlace()||
null == config.getMergeRowNum()){
return true;
}
return false;
}
}
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.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.SoilOriginalTemplate;
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 org.apache.commons.lang3.StringUtils;
import org.apache.poi.ss.usermodel.PrintSetup;
import org.apache.poi.xssf.usermodel.XSSFCell;
import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.InputStream;
import java.math.BigDecimal;
import java.util.List;
import java.util.Map;
public class SheetMoreSingleOperation implements Operation {
private XSSFWorkbook xssfWorkbook;
private InputStream io;
private Map<String, String> mapReplace;
private List<SoilOriginalTemplateConfig> configList;
private SoilOriginalTemplate template;
private List<SoilExperimentVO> voList;
private Map<Long,List<SoilItemVO>> sampleSoilItemVOMap;
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) {
this.xssfWorkbook = xssfWorkbook;
this.io = io;
this.mapReplace = mapReplace;
this.configList = configList;
this.template = template;
this.voList = voList;
this.sampleSoilItemVOMap = sampleSoilItemVOMap;
}
public void doProductOriginal(){
XSSFSheet xssfSheet = xssfWorkbook.getSheetAt(0);
xssfSheet.setForceFormulaRecalculation(true);
int index = 0;
SoilExperimentVO firstVO = null;
int sheetNum = xssfWorkbook.getNumberOfSheets();
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)","小于某直径之百分数(%)");
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();
boolean printRound= printSetup.getLandscape();
for (SoilExperimentVO vo:voList) {
if (index==0){
index++;
firstVO = vo;
continue;
}
XSSFSheet sheet = xssfWorkbook.cloneSheet(0);
sheet.getPrintSetup().setLandscape(printRound);
if (keliJIa){
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)","小于某直径之百分数(%)");
ApachePoiLineChart4.productZhexianAstm(xssfSheet,position);
}
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("#{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++;
HSSFWorkbookUtil.replaceModel(mapReplace,xssfWorkbook,sheet);
}
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());
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);
}
}
......@@ -431,7 +431,7 @@
<select id="selectByEntrustId" resultType="com.patzn.cloud.service.soil.vo.SoilExperimentVO">
SELECT i.id,i.name,s.sample_code,s.site_no FROM soil_experiment i
SELECT i.id,i.name,s.sample_code,s.site_no, e.entrust_code FROM soil_experiment i
JOIN soil_sample s ON i.sample_id = s.id
JOIN soil_entrust e ON s.entrust_id = e.id
......
<?xml version="1.0"?>
<License>
<Data>
<LicensedTo>evget</LicensedTo>
<EmailTo>zouyw@evget.com</EmailTo>
<LicenseType>Developer OEM</LicenseType>
<LicenseNote>1 Developer And Unlimited Deployment Locations</LicenseNote>
<OrderID>201130075911</OrderID>
<UserID>826696</UserID>
<OEM>This is a redistributable license</OEM>
<Products>
<Product>Aspose.Total Product Family</Product>
</Products>
<EditionType>Professional</EditionType>
<SerialNumber>1deeda7a-1403-46c5-8fbd-ca4c176737f4</SerialNumber>
<SubscriptionExpiry>20220325</SubscriptionExpiry>
<LicenseExpiry>20210425</LicenseExpiry>
<ExpiryNote>This is a temporary license for non-commercial use only and it will expire on 2021-04-25</ExpiryNote>
<LicenseVersion>3.0</LicenseVersion>
<LicenseInstructions>https://purchase.aspose.com/policies/use-license</LicenseInstructions>
</Data>
<Signature>lU2XvPdwtYE3jExkkK87Cf5LgcUzFPUfDIVtkG1LO9S+RqwUdu3BlafVoIXZX+FREJP0RoLuwR12IDiThKPAw5mpC+1L645e7qoKg8JQizwf4P+P5uO8VsHlCJrBo2vrGvJbCXvtiLetA+d5eGRId94cMnOJJw9rb14xH9cjJXM=</Signature>
</License>
\ No newline at end of file
<?xml version="1.0"?>
<License>
<Data>
<LicensedTo>南京中普安信</LicensedTo>
<EmailTo>zhangmengqi@qd-partner.com</EmailTo>
<LicenseType>Developer Small Business</LicenseType>
<LicenseNote>1 Developer And 1 Deployment Location</LicenseNote>
<OrderID>210401015312</OrderID>
<UserID>879938</UserID>
<OEM>This is not a redistributable license</OEM>
<Data>
<LicensedTo>evget</LicensedTo>
<EmailTo>zouyw@evget.com</EmailTo>
<LicenseType>Developer OEM</LicenseType>
<LicenseNote>1 Developer And Unlimited Deployment Locations</LicenseNote>
<OrderID>201130075911</OrderID>
<UserID>826696</UserID>
<OEM>This is a redistributable license</OEM>
<Products>
<Product>Aspose.Cells Product Family</Product>
<Product>Aspose.Total Product Family</Product>
</Products>
<EditionType>Professional</EditionType>
<SerialNumber>511eb1f9-57ff-4254-bbeb-b9ee82f390cb</SerialNumber>
<SubscriptionExpiry>20220401</SubscriptionExpiry>
<LicenseExpiry>20210501</LicenseExpiry>
<ExpiryNote>This is a temporary license for non-commercial use only and it will expire on 2021-05-01</ExpiryNote>
<SerialNumber>1deeda7a-1403-46c5-8fbd-ca4c176737f4</SerialNumber>
<SubscriptionExpiry>20220325</SubscriptionExpiry>
<LicenseExpiry>20210425</LicenseExpiry>
<ExpiryNote>This is a temporary license for non-commercial use only and it will expire on 2021-04-25</ExpiryNote>
<LicenseVersion>3.0</LicenseVersion>
<LicenseInstructions>https://purchase.aspose.com/policies/use-license</LicenseInstructions>
</Data>
<Signature>gvk7I3r/lKw/n0K5FhxBBvoAgyYZ/HwbguDGsOCzMFvhbYAabwxly9RVncRENZLSMiZ570I+lG/NK9cfq9IRxyS/2mvuM0IKfIX7QVtnzUZof4/bU55/dj1+obPI6j7T8E+oCqo8O1ec/BdAGw05tJ+GlWvvhcaBfJw9C5b4CRU=</Signature>
</Data>
<Signature>lU2XvPdwtYE3jExkkK87Cf5LgcUzFPUfDIVtkG1LO9S+RqwUdu3BlafVoIXZX+FREJP0RoLuwR12IDiThKPAw5mpC+1L645e7qoKg8JQizwf4P+P5uO8VsHlCJrBo2vrGvJbCXvtiLetA+d5eGRId94cMnOJJw9rb14xH9cjJXM=</Signature>
</License>
\ No newline at end of file
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