Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
T
tjmdp
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Redmine
Redmine
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
other-project
tjmdp
Commits
3c59d26c
Commit
3c59d26c
authored
May 10, 2019
by
liuchao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
no message
parent
abdf28c2
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
149 additions
and
20 deletions
+149
-20
CertificateController.java
...in/java/com/qiankun/controller/CertificateController.java
+18
-0
MdpController.java
src/main/java/com/qiankun/controller/mdp/MdpController.java
+9
-3
RainbowPlanWebController.java
...nkun/controller/rainbowplan/RainbowPlanWebController.java
+39
-12
UserUtils.java
src/main/java/com/qiankun/utils/UserUtils.java
+47
-0
system.properties
src/main/resources/system.properties
+2
-2
save.jsp
src/main/webapp/WEB-INF/pages/certificate/save.jsp
+6
-1
index.jsp
src/main/webapp/WEB-INF/pages/index.jsp
+4
-2
certificate.js
src/main/webapp/resources/js/certificate/certificate.js
+24
-0
No files found.
src/main/java/com/qiankun/controller/CertificateController.java
View file @
3c59d26c
package
com
.
qiankun
.
controller
;
import
java.io.File
;
import
java.util.List
;
import
java.util.ResourceBundle
;
import
javax.servlet.http.HttpServletRequest
;
...
...
@@ -21,6 +22,8 @@ import com.qiankun.annotation.Auth;
import
com.qiankun.controller.base.BaseController
;
import
com.qiankun.entity.Certificate
;
import
com.qiankun.service.CertificateService
;
import
com.qiankun.utils.UserUtils
;
import
com.qiankun.vo.CertificateVo
;
@Controller
public
class
CertificateController
extends
BaseController
<
Object
>{
...
...
@@ -52,6 +55,21 @@ public class CertificateController extends BaseController<Object>{
return
view
;
}
@RequestMapping
(
"/certificate/test"
)
public
ModelAndView
test
(
String
id
)
throws
Exception
{
ModelAndView
view
=
new
ModelAndView
();
Certificate
certificate
=
certificateService
.
findById
(
id
);
List
<
CertificateVo
>
addTexts
=
UserUtils
.
addTexts
(
"志愿者"
,
"0000000"
,
certificate
);
String
certificatePath
=
File
.
separator
+
"mdp"
+
File
.
separator
+
"certificate"
+
File
.
separator
+
"test"
;
String
outputFilePath
=
rb
.
getString
(
"file_path"
)
+
certificatePath
+
File
.
separator
+
"test.png"
;
String
certificateTemplate
=
rb
.
getString
(
"file_path"
)
+
certificate
.
getUploadImage
();
UserUtils
.
generateCertificate
(
certificateTemplate
,
outputFilePath
,
addTexts
);
view
.
getModel
().
put
(
"certificate"
,
certificate
);
view
.
getModel
().
put
(
"status"
,
"success"
);
return
view
;
}
@RequestMapping
(
value
=
"/api/certificate/save"
,
method
=
RequestMethod
.
POST
)
public
ModelAndView
save
(
@RequestParam
(
value
=
"file"
,
required
=
false
)
MultipartFile
file
,
Certificate
certificate
,
HttpServletResponse
response
,
HttpServletRequest
request
)
throws
Exception
{
...
...
src/main/java/com/qiankun/controller/mdp/MdpController.java
View file @
3c59d26c
...
...
@@ -17,6 +17,7 @@ import com.qiankun.entity.*;
import
com.qiankun.pages.IPageList
;
import
com.qiankun.service.ActivityService
;
import
com.qiankun.service.BloodService
;
import
com.qiankun.service.CertificateService
;
import
com.qiankun.service.UserService
;
import
com.qiankun.utils.JwtTokenUtil
;
import
com.qiankun.utils.QRCodeUtil
;
...
...
@@ -59,7 +60,10 @@ public class MdpController extends BaseController<Object> {
@Autowired
private
ActivityService
activityService
;
@Autowired
private
BloodService
bloodService
;
private
BloodService
bloodService
;
@Autowired
private
CertificateService
certificateService
;
private
ResourceBundle
rb
=
ResourceBundle
.
getBundle
(
"system"
);
private
String
getAppid
(){
return
propertis
.
getConfigs
().
get
(
1
).
getAppid
();
...
...
@@ -480,15 +484,17 @@ public class MdpController extends BaseController<Object> {
result
.
put
(
"certificateImage"
,
user
.
getCerfificatePath
());
return
result
;
}
private
void
generateCertificate
(
User
user
,
String
code
)
throws
IOException
{
List
<
CertificateVo
>
addTexts
=
Lists
.
newArrayList
();
Calendar
now
=
Calendar
.
getInstance
();
String
year
=
now
.
get
(
Calendar
.
YEAR
)
+
""
;
String
month
=
now
.
get
(
Calendar
.
MONTH
)
+
1
>=
10
?
""
+
(
now
.
get
(
Calendar
.
MONTH
)
+
1
)
:
"0"
+
(
now
.
get
(
Calendar
.
MONTH
)
+
1
);
String
day
=
now
.
get
(
Calendar
.
DATE
)
>=
10
?
""
+
now
.
get
(
Calendar
.
DATE
)
:
"0"
+
now
.
get
(
Calendar
.
DATE
);
List
<
CertificateVo
>
addTexts
=
Lists
.
newArrayList
();
addTexts
.
add
(
new
CertificateVo
(
user
.
getName
(),
new
Font
(
"宋体"
,
Font
.
BOLD
,
50
),
190
,
570
));
addTexts
.
add
(
new
CertificateVo
(
code
,
new
Font
(
"宋体"
,
Font
.
BOLD
,
30
),
270
,
1265
));
addTexts
.
add
(
new
CertificateVo
(
code
,
new
Font
(
"宋体"
,
Font
.
PLAIN
,
30
),
270
,
1265
));
addTexts
.
add
(
new
CertificateVo
(
year
,
new
Font
(
"宋体"
,
Font
.
PLAIN
,
30
),
525
,
1200
));
addTexts
.
add
(
new
CertificateVo
(
month
,
new
Font
(
"宋体"
,
Font
.
PLAIN
,
30
),
650
,
1200
));
addTexts
.
add
(
new
CertificateVo
(
day
,
new
Font
(
"宋体"
,
Font
.
PLAIN
,
30
),
740
,
1200
));
...
...
src/main/java/com/qiankun/controller/rainbowplan/RainbowPlanWebController.java
View file @
3c59d26c
...
...
@@ -17,6 +17,7 @@ import org.apache.poi.hssf.usermodel.HSSFSheet;
import
org.apache.poi.ss.usermodel.BorderStyle
;
import
org.apache.poi.ss.usermodel.CellStyle
;
import
org.apache.poi.ss.usermodel.Font
;
import
org.apache.poi.ss.usermodel.IndexedColors
;
import
org.apache.poi.ss.usermodel.PaperSize
;
import
org.apache.poi.xssf.usermodel.XSSFCell
;
import
org.apache.poi.xssf.usermodel.XSSFCellStyle
;
...
...
@@ -298,8 +299,8 @@ public class RainbowPlanWebController extends BaseController<Object>{
XSSFSheet
sheet
=
wb
.
createSheet
(
"心愿"
);
sheet
.
setMargin
(
HSSFSheet
.
TopMargin
,(
double
)
0.5
);
// 上边距
sheet
.
setMargin
(
HSSFSheet
.
BottomMargin
,(
double
)
0.5
);
// 下边距
sheet
.
setMargin
(
HSSFSheet
.
LeftMargin
,(
double
)
0.
3
);
// 左边距
sheet
.
setMargin
(
HSSFSheet
.
RightMargin
,(
double
)
0.
2
);
// 右边距
sheet
.
setMargin
(
HSSFSheet
.
LeftMargin
,(
double
)
0.
2
);
// 左边距
sheet
.
setMargin
(
HSSFSheet
.
RightMargin
,(
double
)
0.
0
);
// 右边距
XSSFPrintSetup
print
=
sheet
.
getPrintSetup
();
...
...
@@ -312,17 +313,19 @@ public class RainbowPlanWebController extends BaseController<Object>{
sheet
.
setColumnWidth
(
2
,
3500
);
sheet
.
setColumnWidth
(
3
,
1500
);
sheet
.
setColumnWidth
(
4
,
3000
);
sheet
.
setColumnWidth
(
5
,
40
00
);
sheet
.
setColumnWidth
(
6
,
8
000
);
sheet
.
setColumnWidth
(
5
,
25
00
);
sheet
.
setColumnWidth
(
6
,
6
000
);
sheet
.
setColumnWidth
(
7
,
3000
);
sheet
.
setColumnWidth
(
8
,
3000
);
sheet
.
setColumnWidth
(
9
,
6000
);
sheet
.
setColumnWidth
(
9
,
4000
);
sheet
.
setColumnWidth
(
10
,
6000
);
XSSFFont
font
=
wb
.
createFont
();
font
.
setFontName
(
"宋体"
);
font
.
setFontHeightInPoints
((
short
)
12
);
font
.
setBoldweight
(
Font
.
BOLDWEIGHT_BOLD
);
XSSFFont
topfont
=
wb
.
createFont
();
topfont
.
setFontName
(
"宋体"
);
topfont
.
setFontHeightInPoints
((
short
)
11
);
topfont
.
setBold
(
true
);
//topfont.setBoldweight(Font.BOLDWEIGHT_BOLD);
...
...
@@ -333,7 +336,9 @@ public class RainbowPlanWebController extends BaseController<Object>{
cellTopStyle
.
setBorderRight
(
BorderStyle
.
THIN
);
//setBorderRight(CellStyle.BORDER_THIN);
cellTopStyle
.
setBorderTop
(
BorderStyle
.
THIN
);
//setBorderTop(CellStyle.BORDER_THIN);
cellTopStyle
.
setVerticalAlignment
(
XSSFCellStyle
.
VERTICAL_CENTER
);
cellTopStyle
.
setFont
(
font
);
cellTopStyle
.
setFont
(
topfont
);
cellTopStyle
.
setFillForegroundColor
(
IndexedColors
.
WHITE
.
getIndex
());
XSSFRow
row
=
sheet
.
createRow
(
0
);
row
.
setHeightInPoints
(
30
);
...
...
@@ -377,6 +382,9 @@ public class RainbowPlanWebController extends BaseController<Object>{
cell
.
setCellValue
(
"邮寄地址"
);
cell
.
setCellStyle
(
cellTopStyle
);
cell
=
row
.
createCell
(
10
);
cell
.
setCellValue
(
"爱心人士"
);
cell
.
setCellStyle
(
cellTopStyle
);
XSSFCellStyle
cellStyle
=
wb
.
createCellStyle
();
cellStyle
.
setWrapText
(
true
);
...
...
@@ -387,10 +395,15 @@ public class RainbowPlanWebController extends BaseController<Object>{
cellStyle
.
setBorderRight
(
BorderStyle
.
THIN
);
//setBorderRight(CellStyle.BORDER_THIN);
cellStyle
.
setBorderTop
(
BorderStyle
.
THIN
);
//setBorderTop(CellStyle.BORDER_THIN);
cellStyle
.
setVerticalAlignment
(
XSSFCellStyle
.
VERTICAL_CENTER
);
cellStyle
.
setFillForegroundColor
(
IndexedColors
.
WHITE
.
getIndex
());
XSSFFont
cellfont
=
wb
.
createFont
();
cellfont
.
setFontName
(
"宋体"
);
cellfont
.
setFontHeightInPoints
((
short
)
10
);
cellStyle
.
setFont
(
cellfont
);
IPageList
<
Wish
>
wishPage
=
wishDao
.
findPages
(
wishVo
.
getSearchStr
(),
wishVo
.
getActivityId
(),
wishVo
.
getStatus
(),
wishVo
.
getType
(),
wishVo
.
getOrder
(),
wishVo
.
getSort
(),
new
Hints
(
getStartRow
(
request
),
getPageCount
(
request
)
));
wishVo
.
getOrder
(),
wishVo
.
getSort
(),
new
Hints
(
0
));
List
<
Wish
>
wish
=
wishPage
.
getRecords
();
XSSFRow
rows
;
...
...
@@ -398,7 +411,7 @@ public class RainbowPlanWebController extends BaseController<Object>{
for
(
int
i
=
0
;
i
<
wish
.
size
();
i
++)
{
// 第三步:在这个sheet页里创建一行
rows
=
sheet
.
createRow
(
i
+
1
);
rows
.
setHeightInPoints
(
6
0
);
rows
.
setHeightInPoints
(
7
0
);
// 第四步:在该行创建一个单元格
Wish
data
=
wish
.
get
(
i
);
...
...
@@ -447,6 +460,20 @@ public class RainbowPlanWebController extends BaseController<Object>{
cells
=
rows
.
createCell
(
9
);
cells
.
setCellValue
(
data
.
getChildren
().
getReceiveAddress
());
cells
.
setCellStyle
(
cellStyle
);
cells
=
rows
.
createCell
(
10
);
if
(
data
.
getVolunteer
()!=
null
)
{
String
tel
=
data
.
getVolunteer
().
getConnectTel
();
tel
=
tel
==
null
?
""
:
"\n"
+
tel
;
String
addr
=
data
.
getVolunteer
().
getReceiveAddress
();
addr
=
addr
==
null
?
""
:
"\n"
+
addr
;
cells
.
setCellValue
(
data
.
getVolunteer
().
getName
()
+
tel
+
addr
);
}
else
{
cells
.
setCellValue
(
""
);
}
cells
.
setCellStyle
(
cellStyle
);
}
...
...
src/main/java/com/qiankun/utils/UserUtils.java
View file @
3c59d26c
package
com
.
qiankun
.
utils
;
import
com.fasterxml.jackson.databind.JsonNode
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.google.common.collect.Lists
;
import
com.qiankun.entity.Certificate
;
import
com.qiankun.entity.Contacts
;
import
com.qiankun.entity.User
;
import
com.qiankun.vo.CertificateVo
;
...
...
@@ -100,6 +103,50 @@ public class UserUtils {
URL
url
=
ResourceUtils
.
getURL
(
imageTemplatePath
);
return
url
.
openStream
();
}
public
static
List
<
CertificateVo
>
addTexts
(
String
userName
,
String
code
,
Certificate
certificate
)
throws
Exception
{
ResourceBundle
rb
=
ResourceBundle
.
getBundle
(
"system"
);
InputStream
templateInput
=
null
;
templateInput
=
loadTemplateImage
(
rb
.
getString
(
"file_path"
)
+
certificate
.
getUploadImage
());
Image
image
=
ImageIO
.
read
(
templateInput
);
int
imageWidth
=
image
.
getWidth
(
null
);
int
imageHeight
=
image
.
getHeight
(
null
);
ObjectMapper
mapper
=
new
ObjectMapper
();
JsonNode
request
=
mapper
.
readTree
(
certificate
.
getPosition
());
Calendar
now
=
Calendar
.
getInstance
();
String
year
=
now
.
get
(
Calendar
.
YEAR
)
+
""
;
String
month
=
now
.
get
(
Calendar
.
MONTH
)
+
1
>=
10
?
""
+
(
now
.
get
(
Calendar
.
MONTH
)
+
1
)
:
"0"
+
(
now
.
get
(
Calendar
.
MONTH
)
+
1
);
String
day
=
now
.
get
(
Calendar
.
DATE
)
>=
10
?
""
+
now
.
get
(
Calendar
.
DATE
)
:
"0"
+
now
.
get
(
Calendar
.
DATE
);
Map
<
String
,
String
>
data
=
new
HashMap
<>();
data
.
put
(
"name"
,
userName
);
data
.
put
(
"code"
,
code
);
data
.
put
(
"year"
,
year
);
data
.
put
(
"month"
,
month
);
data
.
put
(
"day"
,
day
);
List
<
CertificateVo
>
addTexts
=
Lists
.
newArrayList
();
Iterator
<
JsonNode
>
its
=
request
.
elements
();
while
(
its
.
hasNext
())
{
JsonNode
json
=
its
.
next
();
String
name
=
json
.
get
(
"name"
).
asText
();
Float
x
=
json
.
get
(
"x"
).
floatValue
()*
imageWidth
;
Float
y
=
json
.
get
(
"y"
).
floatValue
()*
imageHeight
;
addTexts
.
add
(
new
CertificateVo
(
data
.
get
(
name
),
new
Font
(
"宋体"
,
Font
.
BOLD
,
50
),
Math
.
round
(
x
),
Math
.
round
(
y
)+
30
));
}
// addTexts.add(new CertificateVo(user.getName(),new Font("宋体",Font.BOLD,50),190,570));
// addTexts.add(new CertificateVo(code,new Font("宋体",Font.PLAIN,30),270,1265));
// addTexts.add(new CertificateVo(year,new Font("宋体",Font.PLAIN,30),525,1200));
// addTexts.add(new CertificateVo(month,new Font("宋体",Font.PLAIN,30),650,1200));
// addTexts.add(new CertificateVo(day,new Font("宋体",Font.PLAIN,30),740,1200));
return
addTexts
;
}
/*
public static void main(String[] args){
...
...
src/main/resources/system.properties
View file @
3c59d26c
#
file_path=D:/file/
file_path
=
D:/file/
#file_path=/Users/liuyang/work/argus_work/tjmdp/udata
file_path
=
/var/tjmdp/udata
#
file_path=/var/tjmdp/udata
account
=
admin
...
...
src/main/webapp/WEB-INF/pages/certificate/save.jsp
View file @
3c59d26c
...
...
@@ -97,12 +97,17 @@
<i class="icon-reply bigger-110"></i>
返回
</a>
<c:if test="${certificate.id!=null}">
<a class="btn btn-sm btn-success" href="javascript:;" onclick="certificate.test('${certificate.id}')">
<i class="icon-play bigger-110"></i>
测试
</a></c:if>
</div>
</div>
<div class="col-xs-7">
<c:if test="${certificate.uploadImage!='' && certificate.uploadImage!=null}">
<a href="javascript:;"
onclick="certificate.editpic()"><img id="pic" src="<webpath:path/>/wx/rainbowplan/loadResource?imageName=${certificate.uploadImage}" width="300
"/></a><br></c:if>
<a href="javascript:;"
style="width:300px"><img id="pic" src="<webpath:path/>/wx/rainbowplan/loadResource?imageName=${certificate.uploadImage}" width="300" onclick="certificate.editpic()
"/></a><br></c:if>
</div>
</div>
...
...
src/main/webapp/WEB-INF/pages/index.jsp
View file @
3c59d26c
...
...
@@ -28,9 +28,11 @@
</div>
<div class="page-content">
</div>
</div>
src/main/webapp/resources/js/certificate/certificate.js
View file @
3c59d26c
...
...
@@ -170,6 +170,30 @@ var certificate = {
}
})
},
test
:
function
(
id
)
{
$
.
ajax
({
url
:
webPath
+
'/certificate/test?id='
+
id
,
type
:
'GET'
,
cache
:
false
,
processData
:
false
,
contentType
:
false
,
dataType
:
"json"
,
beforeSend
:
function
(){
},
success
:
function
(
data
){
if
(
"success"
==
data
.
status
){
var
html
=
'<img src="'
+
webPath
+
'/wx/rainbowplan/loadResource?imageName=
\\
mdp
\\
certificate
\\
test
\\
test.png" height="100%"/>'
;
layer
.
open
({
type
:
1
,
skin
:
'layui-layer-rim'
,
//加上边框
area
:
[
'auto'
,
'100%'
],
//宽高
content
:
html
});
}
}
})
}
}
...
...
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