Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
F
fill-system
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
廖旭伟
fill-system
Commits
b318119e
Commit
b318119e
authored
Feb 10, 2025
by
赵啸非
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
动态表单添加组件
parent
34e59e10
Pipeline
#2885
canceled with stages
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
100 additions
and
2 deletions
+100
-2
fill-manager/src/main/java/com/mortals/xhx/module/matter/service/impl/MatterDatumServiceImpl.java
...hx/module/matter/service/impl/MatterDatumServiceImpl.java
+100
-2
No files found.
fill-manager/src/main/java/com/mortals/xhx/module/matter/service/impl/MatterDatumServiceImpl.java
View file @
b318119e
...
@@ -16,6 +16,7 @@ import com.deepoove.poi.data.PictureRenderData;
...
@@ -16,6 +16,7 @@ import com.deepoove.poi.data.PictureRenderData;
import
com.deepoove.poi.data.PictureType
;
import
com.deepoove.poi.data.PictureType
;
import
com.deepoove.poi.data.Pictures
;
import
com.deepoove.poi.data.Pictures
;
import
com.deepoove.poi.plugin.table.MultipleRowTableRenderPolicy
;
import
com.deepoove.poi.plugin.table.MultipleRowTableRenderPolicy
;
import
com.deepoove.poi.render.RenderContext
;
import
com.deepoove.poi.template.MetaTemplate
;
import
com.deepoove.poi.template.MetaTemplate
;
import
com.deepoove.poi.util.RegexUtils
;
import
com.deepoove.poi.util.RegexUtils
;
import
com.fasterxml.jackson.core.JsonProcessingException
;
import
com.fasterxml.jackson.core.JsonProcessingException
;
...
@@ -596,8 +597,96 @@ public class MatterDatumServiceImpl extends AbstractCRUDServiceImpl<MatterDatumD
...
@@ -596,8 +597,96 @@ public class MatterDatumServiceImpl extends AbstractCRUDServiceImpl<MatterDatumD
}
}
public
static
FormDesignRoot
parseLocalDocxToJson
(
String
filepath
)
{
ConfigureBuilder
builder
=
Configure
.
builder
();
builder
.
setValidErrorHandler
(
new
Configure
.
DiscardHandler
());
builder
.
useDefaultEL
(
false
);
builder
.
buildGrammerRegex
(
RegexUtils
.
createGeneral
(
"{{"
,
"}}"
));
//builder.buildGramer("[","]");
XWPFTemplate
template
=
XWPFTemplate
.
compile
(
filepath
,
builder
.
build
());
FormDesignRoot
root
=
new
FormDesignRoot
();
FormDesignConfig
config
=
new
FormDesignConfig
();
config
.
initAttribute
();
root
.
setConfig
(
config
);
List
<
ListItem
>
collect
=
new
ArrayList
<>();
HashSet
<
String
>
hs
=
new
HashSet
<>();
//去除重复标签
for
(
MetaTemplate
item
:
template
.
getElementTemplates
())
{
if
(
hs
.
contains
(
item
.
variable
()))
{
continue
;
}
else
{
hs
.
add
(
item
.
variable
());
}
//识别简单输入
String
val
=
StrUtil
.
strip
(
item
.
variable
(),
"{{"
,
"}}"
);
List
<
String
>
keys
=
StrSplitter
.
split
(
val
,
"_"
,
true
,
true
);
//切分分隔符后动态 创建组件 i_1_姓名(第一个代表类型,第二个如果是多个累加,第三个显示label)
if
(
keys
.
size
()
>
2
)
{
String
label
=
keys
.
get
(
2
);
String
type
=
keys
.
get
(
0
);
ComponentCons
cons
=
new
ComponentCons
();
cons
.
setLabel
(
label
);
cons
.
setVal
(
val
);
cons
.
setEl
(
item
.
variable
());
if
(
type
.
equalsIgnoreCase
(
ComponentEnum
.
DYNAMIC_TABLE
.
getValue
()))
{
HashSet
<
String
>
dhs
=
new
HashSet
<>();
//去除重复标签
List
<
TableColItem
>
colList
=
new
ArrayList
<>();
//表格 结构化绑定数据
ConfigureBuilder
builderTable
=
Configure
.
builder
();
builderTable
.
setValidErrorHandler
(
new
Configure
.
ValidErrorHandler
()
{
@Override
public
void
handler
(
RenderContext
<?>
context
)
{
log
.
info
(
"111111111111111"
);
}
});
builderTable
.
useDefaultEL
(
false
);
builderTable
.
buildGramer
(
"["
,
"]"
);
builderTable
.
useSpringEL
();
XWPFTemplate
templateTable
=
XWPFTemplate
.
compile
(
filepath
,
builderTable
.
build
());
for
(
MetaTemplate
col
:
templateTable
.
getElementTemplates
())
{
if
(
dhs
.
contains
(
col
.
variable
()))
{
continue
;
}
else
{
dhs
.
add
(
col
.
variable
());
}
String
colVal
=
StrUtil
.
strip
(
col
.
variable
(),
"["
,
"]"
);
if
(!
StrUtil
.
startWith
(
colVal
,
label
))
{
continue
;
}
List
<
String
>
colKeys
=
StrSplitter
.
split
(
colVal
,
"_"
,
true
,
true
);
//提取当前table中的列元素
if
(
colKeys
.
size
()
>
3
)
{
String
colLabel
=
colKeys
.
get
(
3
);
String
colType
=
colKeys
.
get
(
1
);
TableColItem
tableColItem
=
new
TableColItem
();
tableColItem
.
setLabel
(
colLabel
);
tableColItem
.
setColType
(
colType
);
tableColItem
.
setVal
(
colVal
);
colList
.
add
(
tableColItem
);
log
.
info
(
"列元素"
+
col
.
variable
());
}
}
cons
.
setColList
(
colList
);
DesignComponent
designComponent
=
DesignComponent
.
createType
(
type
);
ListItem
listItem
=
designComponent
.
buildDefaultComponent
(
cons
);
collect
.
add
(
listItem
);
continue
;
}
DesignComponent
designComponent
=
DesignComponent
.
createType
(
type
);
ListItem
listItem
=
designComponent
.
buildDefaultComponent
(
cons
);
collect
.
add
(
listItem
);
}
}
root
.
setList
(
collect
);
return
root
;
}
public
static
void
main
(
String
[]
args
)
{
public
static
void
main
(
String
[]
args
)
{
String
colVal
=
"i_1_变更登记事项"
;
/*
String colVal = "i_1_变更登记事项";
List<String> colKeys = StrSplitter.split(colVal, "_", true, true);
List<String> colKeys = StrSplitter.split(colVal, "_", true, true);
System.out.println(colKeys.size());
System.out.println(colKeys.size());
...
@@ -609,12 +698,21 @@ public class MatterDatumServiceImpl extends AbstractCRUDServiceImpl<MatterDatumD
...
@@ -609,12 +698,21 @@ public class MatterDatumServiceImpl extends AbstractCRUDServiceImpl<MatterDatumD
List<String> strings1 = splitIter.toList(true);
List<String> strings1 = splitIter.toList(true);
strings1.forEach(item -> {
strings1.forEach(item -> {
System.out.println(item);
System.out.println(item);
});
});
*/
// String[] strings = StrSplitter.splitByLength(colVal, 1);
// String[] strings = StrSplitter.splitByLength(colVal, 1);
// for (int i = 0; i <strings.length ; i++) {
// for (int i = 0; i <strings.length ; i++) {
// System.out.println(strings[i]);
// System.out.println(strings[i]);
// }
// }
String
filePath
=
"F:\\1.docx"
;
FormDesignRoot
formDesignRoot
=
parseLocalDocxToJson
(
filePath
);
System
.
out
.
println
(
JSON
.
toJSONString
(
formDesignRoot
));
}
}
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment