Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gjjs-bd-common
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
s_guodong
gjjs-bd-common
Commits
6d4fc52e
Commit
6d4fc52e
authored
Jul 28, 2023
by
s_guodong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
支持快照
parent
06950f76
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
113 additions
and
14 deletions
+113
-14
demo.zul
gjjs-bd-business/src/main/resources/displayTemplate/demo.zul
+9
-0
FileDisplayManager.java
...om/brilliance/mda/support/mybatis/FileDisplayManager.java
+19
-13
IContext.java
...rc/main/java/com/brilliance/mda/runtime/mda/IContext.java
+6
-1
IDisplay.java
...rc/main/java/com/brilliance/mda/runtime/mda/IDisplay.java
+5
-0
MdaContext.java
...ava/com/brilliance/mda/runtime/mda/driver/MdaContext.java
+74
-0
No files found.
gjjs-bd-business/src/main/resources/displayTemplate/demo.zul
0 → 100644
View file @
6d4fc52e
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<window
xmlns=
"http://www.zkoss.org/2005/zul"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
height=
"100%"
width=
"100%"
xsi:schemaLocation=
"http://www.zkoss.org/2005/zul http://www.zkoss.org/2005/zul/zul.xsd"
>
<style
src=
"/public/template.css"
/>
<script
src=
"/public/template.js"
type=
"text/javascript"
/>
<label
multiline=
"true"
style=
"position:absolute;left:140px;top:80px;height:16px;"
value=
"姓名"
zclass=
"z-label"
/>
<textbox
readonly=
"true"
rows=
"1"
style=
"position:absolute;left:240px;top:80px;height:16px;width:201.0px;ime-mode:disabled;border-bottom:solid red;"
text=
"${nan}"
zclass=
"z-textbox"
/>
<label
multiline=
"true"
style=
"position:absolute;left:140px;top:120px;height:16px;"
value=
"电话"
zclass=
"z-label"
/>
<textbox
readonly=
"true"
rows=
"1"
style=
"position:absolute;left:240px;top:120px;height:16px;width:201.0px;ime-mode:disabled;border-bottom:solid red;"
text=
"${tel}"
zclass=
"z-textbox"
/>
</window>
gjjs-bd-mybatis-support/src/main/java/com/brilliance/mda/support/mybatis/FileDisplayManager.java
View file @
6d4fc52e
...
...
@@ -3,54 +3,60 @@ package com.brilliance.mda.support.mybatis;
import
com.brilliance.mda.runtime.mda.IDisplay
;
import
org.apache.commons.io.IOUtils
;
import
org.apache.commons.lang3.text.StrSubstitutor
;
import
org.springframework.stereotype.Component
;
import
java.io.File
;
import
java.io.FileReader
;
import
java.io.FileWriter
;
import
java.util.Map
;
/**
* 快照保存器
* @author fukai
*
* @author fukai
*/
@Component
public
class
FileDisplayManager
implements
IDisplay
{
@Override
public
boolean
saveDisplay
(
String
filePathOrKey
,
String
data
)
{
public
boolean
saveDisplay
(
String
filePathOrKey
,
String
data
)
{
File
file
=
new
File
(
filePathOrKey
);
File
parentFolder
=
file
.
getParentFile
();
if
(!
parentFolder
.
exists
()
&&
!
parentFolder
.
mkdirs
())
if
(!
parentFolder
.
exists
()
&&
!
parentFolder
.
mkdirs
())
return
false
;
FileWriter
fr
=
null
;
try
{
try
{
file
.
createNewFile
();
fr
=
new
FileWriter
(
file
);
IOUtils
.
write
(
data
,
fr
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
catch
(
Exception
e
)
{
return
false
;
}
finally
{
IOUtils
.
closeQuietly
(
fr
);
}
return
true
;
}
@Override
public
boolean
saveDisplay
(
String
filePathOrKey
,
String
templateContent
,
Map
valueMap
)
{
String
data
=
StrSubstitutor
.
replace
(
templateContent
,
valueMap
);
return
this
.
saveDisplay
(
filePathOrKey
,
data
);
}
@SuppressWarnings
(
"deprecation"
)
@Override
public
String
readDisplay
(
String
filePathOrKey
)
{
File
file
=
new
File
(
filePathOrKey
);
if
(!
file
.
exists
())
if
(!
file
.
exists
())
return
null
;
FileReader
fr
=
null
;
try
{
try
{
fr
=
new
FileReader
(
file
);
return
IOUtils
.
toString
(
fr
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
finally
{
}
finally
{
IOUtils
.
closeQuietly
(
fr
);
}
return
null
;
...
...
gjjs-bd-runtime/src/main/java/com/brilliance/mda/runtime/mda/IContext.java
View file @
6d4fc52e
...
...
@@ -3,7 +3,6 @@ package com.brilliance.mda.runtime.mda;
import
com.brilliance.mda.runtime.mda.impl.EnvConfig
;
import
java.io.Serializable
;
import
java.util.List
;
import
java.util.Locale
;
import
java.util.Map
;
...
...
@@ -58,6 +57,12 @@ public interface IContext extends Serializable {
boolean
saveDisplay
(
String
fileName
);
boolean
saveDisplay
(
IPanel
[]
panels
,
String
fileName
);
boolean
saveDisplay
(
IPanel
panel
,
String
fileName
);
boolean
saveDisplay
(
String
panelPath
,
String
fileName
);
int
getErrorCode
();
void
setErrorCode
(
int
errorCode
);
...
...
gjjs-bd-runtime/src/main/java/com/brilliance/mda/runtime/mda/IDisplay.java
View file @
6d4fc52e
package
com
.
brilliance
.
mda
.
runtime
.
mda
;
import
java.util.Map
;
/**
* 快照保存接口,保存的东西,可以使文件路径/或者是文件保存key。具体实现由实施情况决定。
* 可以使保存至数据库/保存至NOSQL数据库/保存至文件存储器
...
...
@@ -9,5 +11,8 @@ package com.brilliance.mda.runtime.mda;
*/
public
interface
IDisplay
{
boolean
saveDisplay
(
String
filePathOrKey
,
String
data
);
boolean
saveDisplay
(
String
filePathOrKey
,
String
templateContent
,
Map
valueMap
);
String
readDisplay
(
String
filePathOrKey
);
}
gjjs-bd-runtime/src/main/java/com/brilliance/mda/runtime/mda/driver/MdaContext.java
View file @
6d4fc52e
...
...
@@ -2,9 +2,16 @@ package com.brilliance.mda.runtime.mda.driver;
import
com.brilliance.mda.runtime.annotation.Transaction
;
import
com.brilliance.mda.runtime.mda.*
;
import
com.brilliance.mda.runtime.mda.impl.Argument
;
import
com.brilliance.mda.runtime.mda.impl.EnvConfig
;
import
com.brilliance.mda.runtime.request.BaseVO
;
import
org.apache.commons.io.IOUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
java.io.File
;
import
java.io.FileReader
;
import
java.io.UnsupportedEncodingException
;
import
java.net.URL
;
import
java.util.*
;
import
static
com
.
brilliance
.
mda
.
runtime
.
mda
.
Constants
.
NO_ERROR
;
...
...
@@ -12,6 +19,8 @@ import static com.brilliance.mda.runtime.mda.Constants.NO_ERROR;
public
class
MdaContext
implements
IContext
{
private
static
final
String
DISPLAY_TEMPLATE_PATH
=
"displayTemplate/"
;
private
transient
final
IDaoSession
daoSession
;
private
transient
final
EnvConfig
config
;
private
transient
final
IDisplay
display
;
...
...
@@ -240,6 +249,47 @@ public class MdaContext implements IContext {
return
false
;
}
@Override
public
boolean
saveDisplay
(
IPanel
[]
panels
,
String
fileName
)
{
return
false
;
}
@Override
public
boolean
saveDisplay
(
IPanel
panel
,
String
fileName
)
{
return
false
;
}
@Override
public
boolean
saveDisplay
(
String
panelPath
,
String
fileName
)
{
IContext
ctx
=
MdaEnv
.
getContext
();
ctx
.
setErrorCode
(
NO_ERROR
);
String
templateContent
=
getTemplateContent
(
panelPath
);
if
(
StringUtils
.
isBlank
(
templateContent
))
{
return
false
;
}
// 根据trninr查找
int
b
=
fileName
.
lastIndexOf
(
"\\"
);
int
e
=
fileName
.
lastIndexOf
(
"."
);
String
trninr
=
fileName
.
substring
(
b
+
1
,
e
);
String
sql
=
"select * from trn where inr='"
+
trninr
+
"'"
;
ctx
.
getDaoSession
().
dbExecuteSQL
(
sql
);
Argument
<
String
>
objtyp
=
new
Argument
<
String
>(
"objtyp"
);
ctx
.
getDaoSession
().
dbFetchFields
(
objtyp
);
ctx
.
getDaoSession
().
dbCloseCursor
();
int
errorCode
=
ctx
.
getErrorCode
();
if
(
errorCode
!=
NO_ERROR
)
{
return
false
;
}
// 将模板中需要的值放入map todo
Map
valueMap
=
new
HashMap
();
valueMap
.
put
(
"trninr"
,
trninr
);
if
(
this
.
display
!=
null
)
{
return
this
.
display
.
saveDisplay
(
fileName
,
templateContent
,
valueMap
);
}
return
false
;
}
public
int
getErrorCode
()
{
int
temp
=
this
.
errorCode
;
this
.
errorCode
=
NO_ERROR
;
...
...
@@ -421,4 +471,28 @@ public class MdaContext implements IContext {
}
private
String
getTemplateContent
(
String
panelPath
)
{
URL
root
=
ClassLoader
.
getSystemResource
(
""
);
String
filePath
=
null
;
try
{
filePath
=
java
.
net
.
URLDecoder
.
decode
(
root
.
getPath
(),
"utf-8"
);
}
catch
(
UnsupportedEncodingException
e
)
{
}
File
file
=
new
File
(
filePath
+
DISPLAY_TEMPLATE_PATH
+
panelPath
+
".zul"
);
if
(!
file
.
exists
())
return
null
;
FileReader
fr
=
null
;
try
{
fr
=
new
FileReader
(
file
);
return
IOUtils
.
toString
(
fr
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
finally
{
IOUtils
.
closeQuietly
(
fr
);
}
return
null
;
}
}
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