Compare commits

...

2 Commits

Author SHA1 Message Date
  xhxu d7768b9d65 金茂合同, 3 years ago
  Stormeye Wu 25c6ff313e 支持前缀 4 years ago
11 changed files with 106 additions and 5 deletions
Split View
  1. +1
    -1
      easypoi-annotation/pom.xml
  2. +5
    -0
      easypoi-annotation/src/main/java/cn/afterturn/easypoi/excel/annotation/Excel.java
  3. +1
    -1
      easypoi-base/pom.xml
  4. +4
    -0
      easypoi-base/src/main/java/cn/afterturn/easypoi/excel/entity/params/ExcelExportEntity.java
  5. +4
    -0
      easypoi-base/src/main/java/cn/afterturn/easypoi/excel/entity/params/ExcelImportEntity.java
  6. +4
    -0
      easypoi-base/src/main/java/cn/afterturn/easypoi/excel/export/base/ExportCommonService.java
  7. +18
    -0
      easypoi-base/src/main/java/cn/afterturn/easypoi/excel/imports/CellValueService.java
  8. +1
    -0
      easypoi-base/src/main/java/cn/afterturn/easypoi/excel/imports/base/ImportBaseService.java
  9. +65
    -0
      easypoi-base/src/main/java/cn/afterturn/easypoi/word/parse/ParseWord07.java
  10. +1
    -1
      easypoi-web/pom.xml
  11. +2
    -2
      pom.xml

+ 1
- 1
easypoi-annotation/pom.xml View File

@@ -4,7 +4,7 @@
<parent>
<groupId>cn.afterturn</groupId>
<artifactId>easypoi</artifactId>
<version>4.1.3</version>
<version>4.1.3.A</version>
</parent>
<artifactId>easypoi-annotation</artifactId>
<description>base annotation</description>

+ 5
- 0
easypoi-annotation/src/main/java/cn/afterturn/easypoi/excel/annotation/Excel.java View File

@@ -67,6 +67,11 @@ public @interface Excel {
*/
public int imageType() default 1;
/**
* 文字前缀,如1234567890112242335 变成`1234567890112242335
*/
public String prefix() default "";
/**
* 文字后缀,如% 90 变成90%
*/


+ 1
- 1
easypoi-base/pom.xml View File

@@ -4,7 +4,7 @@
<parent>
<groupId>cn.afterturn</groupId>
<artifactId>easypoi</artifactId>
<version>4.1.3</version>
<version>4.1.3.A</version>
</parent>
<artifactId>easypoi-base</artifactId>
<dependencies>


+ 4
- 0
easypoi-base/src/main/java/cn/afterturn/easypoi/excel/entity/params/ExcelExportEntity.java View File

@@ -84,6 +84,10 @@ public class ExcelExportEntity extends ExcelBaseEntity implements Comparable<Exc
* 合并依赖`
*/
private int[] mergeRely;
/**
* 前缀
*/
private String prefix;
/**
* 后缀
*/


+ 4
- 0
easypoi-base/src/main/java/cn/afterturn/easypoi/excel/entity/params/ExcelImportEntity.java View File

@@ -44,6 +44,10 @@ public class ExcelImportEntity extends ExcelBaseEntity {
* 对应exportType
*/
private String classType;
/**
* 前缀
*/
private String prefix;
/**
* 后缀
*/


+ 4
- 0
easypoi-base/src/main/java/cn/afterturn/easypoi/excel/export/base/ExportCommonService.java View File

@@ -223,6 +223,9 @@ public class ExportCommonService {
if (needHandlerList != null && needHandlerList.contains(entity.getName())) {
value = dataHandler.exportHandler(obj, entity.getName(), value);
}
if (StringUtils.isNotBlank(entity.getPrefix()) && value != null) {
value = entity.getPrefix() + value;
}
if (StringUtils.isNotEmpty(entity.getSuffix()) && value != null) {
value = value + entity.getSuffix();
}
@@ -262,6 +265,7 @@ public class ExportCommonService {
Integer.valueOf(PoiPublicUtil.getValueByTargetId(excel.orderNum(), targetId, "0")));
excelEntity.setWrap(excel.isWrap());
excelEntity.setExportImageType(excel.imageType());
excelEntity.setPrefix(excel.prefix());
excelEntity.setSuffix(excel.suffix());
excelEntity.setDatabaseFormat(excel.databaseFormat());
excelEntity.setFormat(


+ 18
- 0
easypoi-base/src/main/java/cn/afterturn/easypoi/excel/imports/CellValueService.java View File

@@ -227,6 +227,7 @@ public class CellValueService {
result = cell;
}
if (entity != null) {
result = handlerPrefix(entity.getPrefix(), result);
result = handlerSuffix(entity.getSuffix(), result);
result = replaceValue(entity.getReplace(), result);
result = replaceValue(entity.getReplace(), result);
@@ -257,12 +258,29 @@ public class CellValueService {
Type[] ts = setMethod.getGenericParameterTypes();
String classFullName = ts[0].toString();
Object result = cellEntity.getValue();
result = handlerPrefix(entity.getPrefix(), result);
result = handlerSuffix(entity.getSuffix(), result);
result = replaceValue(entity.getReplace(), result);
result = handlerValue(dataHandler, object, result, titleString);
return getValueByType(classFullName, result, entity, (Class) ts[0]);
}

/**
* 把前缀删除掉
*
* @param result
* @param prefix
* @return
*/
private Object handlerPrefix(String prefix, Object result) {
if (StringUtils.isNotEmpty(prefix) && result != null
&& result.toString().startsWith(prefix)) {
String temp = result.toString();
return temp.substring(prefix.length(), temp.length());
}
return result;
}

/**
* 把后缀删除掉
*


+ 1
- 0
easypoi-base/src/main/java/cn/afterturn/easypoi/excel/imports/base/ImportBaseService.java View File

@@ -70,6 +70,7 @@ public class ImportBaseService {
excelEntity.setSaveType(excel.imageType());
excelEntity.setReplace(excel.replace());
excelEntity.setDatabaseFormat(excel.databaseFormat());
excelEntity.setPrefix(excel.prefix());
excelEntity.setSuffix(excel.suffix());
excelEntity.setImportField(Boolean
.valueOf(PoiPublicUtil.getValueByTargetId(excel.isImportField(), targetId, "false")));


+ 65
- 0
easypoi-base/src/main/java/cn/afterturn/easypoi/word/parse/ParseWord07.java View File

@@ -24,6 +24,7 @@ import cn.afterturn.easypoi.word.parse.excel.ExcelEntityParse;
import cn.afterturn.easypoi.word.parse.excel.ExcelMapParse;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.xwpf.usermodel.*;
import org.apache.xmlbeans.XmlCursor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -255,6 +256,10 @@ public class ParseWord07 {
}
private void parseWordSetValue(MyXWPFDocument doc, Map<String, Object> map) throws Exception {
//时间紧迫,先写死(金茂合同)
if(map.get("operationType") != null && "3".equals(map.get("operationType").toString())){
parseJinmaoParagraphic(doc, map);
}
// 第一步解析文档
parseAllParagraphic(doc.getParagraphs(), map);
// 第二步解析页眉,页脚
@@ -294,4 +299,64 @@ public class ParseWord07 {
}
/**
* 处理金茂合同(时间紧迫,先写死)
*
* @param doc
* @param map
* @throws Exception
*/
private void parseJinmaoParagraphic(MyXWPFDocument doc, Map<String, Object> map) throws Exception {
String typeStr = map.get("type") == null ?"":map.get("type").toString();
String countRatioListStr = map.get("countRatioList") == null ?"":map.get("countRatioList").toString();
if(StringUtils.isBlank(typeStr) || StringUtils.isBlank(countRatioListStr)){
return ;
}
int type = 0,countRatioList = 0;
try {
type = Integer.parseInt(typeStr);
countRatioList = Integer.parseInt(countRatioListStr);
} catch (NumberFormatException e) {
return ;
}
if(type < 1 || type > 3 || countRatioList < 2){
return ;
}
int index = 0;
List<XWPFParagraph> paragraphs = doc.getParagraphs();
XWPFParagraph paragraph;
for (int i = 0; i < paragraphs.size(); i++) {
paragraph = paragraphs.get(i);
if (paragraph.getText().indexOf("b.租金递增:") != -1) {
index++;
if(index == type){
List<XWPFRun> runs = paragraph.getRuns();
XmlCursor xmlCursor = paragraph.getCTP().newCursor();
for (int k = 1;k < countRatioList;k++){
int n = k+2;
xmlCursor.toNextSibling();
XWPFParagraph newParagraph = doc.insertNewParagraph(xmlCursor);
i++;
newParagraph.getCTP().setPPr(paragraph.getCTP().getPPr());
for (int j = 1;j < runs.size(); j++){
XWPFRun run = runs.get(j);
String text = run.getText(0);
if(text.endsWith("2")){
text = text.replace("2",n+"");
}
System.out.println("--"+text);
XWPFRun newRun = newParagraph.createRun();
newRun.setText(text);
newRun.getCTR().setRPr(run.getCTR().getRPr());
}
xmlCursor = newParagraph.getCTP().newCursor();
}
}
}
}
}
}

+ 1
- 1
easypoi-web/pom.xml View File

@@ -4,7 +4,7 @@
<parent>
<groupId>cn.afterturn</groupId>
<artifactId>easypoi</artifactId>
<version>4.1.3</version>
<version>4.1.3.A</version>
</parent>
<artifactId>easypoi-web</artifactId>
<dependencies>


+ 2
- 2
pom.xml View File

@@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>cn.afterturn</groupId>
<artifactId>easypoi</artifactId>
<version>4.1.3</version>
<version>4.1.3.A</version>
<packaging>pom</packaging>
<name>easypoi</name>
<modules>
@@ -45,7 +45,7 @@
</organization>

<properties>
<sub.version>4.1.3</sub.version>
<sub.version>4.1.3.A</sub.version>
<poi.version>4.1.1</poi.version>
<xerces.version>2.9.1</xerces.version>
<guava.version>16.0.1</guava.version>


Loading…
Cancel
Save