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
9a6c9942
Commit
9a6c9942
authored
Apr 29, 2019
by
liuyang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
证书增加编号
parent
6620ea92
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
61 additions
and
22 deletions
+61
-22
MdpController.java
src/main/java/com/qiankun/controller/mdp/MdpController.java
+24
-6
BloodDao.java
src/main/java/com/qiankun/dao/BloodDao.java
+3
-2
BloodDaoImpl.java
src/main/java/com/qiankun/dao/BloodDaoImpl.java
+8
-0
BloodService.java
src/main/java/com/qiankun/service/BloodService.java
+5
-0
UserUtils.java
src/main/java/com/qiankun/utils/UserUtils.java
+21
-14
No files found.
src/main/java/com/qiankun/controller/mdp/MdpController.java
View file @
9a6c9942
...
@@ -24,6 +24,7 @@ import com.qiankun.utils.UserUtils;
...
@@ -24,6 +24,7 @@ import com.qiankun.utils.UserUtils;
import
com.qiankun.vo.*
;
import
com.qiankun.vo.*
;
import
com.sun.mail.imap.ResyncData
;
import
com.sun.mail.imap.ResyncData
;
import
me.chanjar.weixin.common.error.WxErrorException
;
import
me.chanjar.weixin.common.error.WxErrorException
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.commons.io.FileUtils
;
import
org.apache.commons.io.FileUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.omg.PortableInterceptor.ServerRequestInfo
;
import
org.omg.PortableInterceptor.ServerRequestInfo
;
...
@@ -458,9 +459,15 @@ public class MdpController extends BaseController<Object> {
...
@@ -458,9 +459,15 @@ public class MdpController extends BaseController<Object> {
result
.
put
(
"errorMsg"
,
"您还未采血,不能生成证书"
);
result
.
put
(
"errorMsg"
,
"您还未采血,不能生成证书"
);
return
result
;
return
result
;
}
}
String
code
=
getCollectBloodCode
(
user
);
if
(
Strings
.
isNullOrEmpty
(
code
)){
result
.
put
(
"status"
,
"error"
);
result
.
put
(
"errorMsg"
,
"采血编号不存在"
);
return
result
;
}
if
(
Strings
.
isNullOrEmpty
(
user
.
getCerfificatePath
())){
if
(
Strings
.
isNullOrEmpty
(
user
.
getCerfificatePath
())){
try
{
try
{
generateCertificate
(
user
);
generateCertificate
(
user
,
code
);
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
logger
.
error
(
e
.
getMessage
(),
e
);
logger
.
error
(
e
.
getMessage
(),
e
);
result
.
put
(
"status"
,
"error"
);
result
.
put
(
"status"
,
"error"
);
...
@@ -473,16 +480,27 @@ public class MdpController extends BaseController<Object> {
...
@@ -473,16 +480,27 @@ public class MdpController extends BaseController<Object> {
result
.
put
(
"certificateImage"
,
user
.
getCerfificatePath
());
result
.
put
(
"certificateImage"
,
user
.
getCerfificatePath
());
return
result
;
return
result
;
}
}
private
void
generateCertificate
(
User
user
)
throws
IOException
{
private
void
generateCertificate
(
User
user
,
String
code
)
throws
IOException
{
List
<
CertificateVo
>
addTexts
=
Lists
.
newArrayList
();
List
<
CertificateVo
>
addTexts
=
Lists
.
newArrayList
();
Calendar
now
=
Calendar
.
getInstance
();
Calendar
now
=
Calendar
.
getInstance
();
addTexts
.
add
(
new
CertificateVo
(
user
.
getName
(),
new
Font
(
"微软雅黑"
,
Font
.
BOLD
,
50
),
250
,
1100
));
addTexts
.
add
(
new
CertificateVo
(
user
.
getName
(),
new
Font
(
"宋体"
,
Font
.
BOLD
,
50
),
200
,
600
));
addTexts
.
add
(
new
CertificateVo
(
now
.
get
(
Calendar
.
YEAR
)+
""
,
new
Font
(
"微软雅黑"
,
Font
.
PLAIN
,
30
),
550
,
1245
));
addTexts
.
add
(
new
CertificateVo
(
code
,
new
Font
(
"宋体"
,
Font
.
BOLD
,
30
),
280
,
1310
));
addTexts
.
add
(
new
CertificateVo
(
now
.
get
(
Calendar
.
MONTH
)
+
1
+
""
,
new
Font
(
"微软雅黑"
,
Font
.
PLAIN
,
30
),
680
,
1245
));
addTexts
.
add
(
new
CertificateVo
(
now
.
get
(
Calendar
.
YEAR
)+
""
,
new
Font
(
"宋体"
,
Font
.
PLAIN
,
30
),
550
,
1245
));
addTexts
.
add
(
new
CertificateVo
(
now
.
get
(
Calendar
.
DATE
)+
""
,
new
Font
(
"微软雅黑"
,
Font
.
PLAIN
,
30
),
790
,
1245
));
addTexts
.
add
(
new
CertificateVo
(
now
.
get
(
Calendar
.
MONTH
)
+
1
+
""
,
new
Font
(
"宋体"
,
Font
.
PLAIN
,
30
),
680
,
1245
));
addTexts
.
add
(
new
CertificateVo
(
now
.
get
(
Calendar
.
DATE
)+
""
,
new
Font
(
"宋体"
,
Font
.
PLAIN
,
30
),
790
,
1245
));
String
outputFilePath
=
rb
.
getString
(
"file_path"
)
+
this
.
userCertificatePath
+
File
.
separator
+
user
.
getId
()
+
".jpeg"
;
String
outputFilePath
=
rb
.
getString
(
"file_path"
)
+
this
.
userCertificatePath
+
File
.
separator
+
user
.
getId
()
+
".jpeg"
;
UserUtils
.
generateCertificate
(
this
.
certificateTemplate
,
outputFilePath
,
addTexts
);
UserUtils
.
generateCertificate
(
this
.
certificateTemplate
,
outputFilePath
,
addTexts
);
user
.
setCerfificatePath
(
this
.
userCertificatePath
+
File
.
separator
+
user
.
getId
()
+
".jpeg"
);
user
.
setCerfificatePath
(
this
.
userCertificatePath
+
File
.
separator
+
user
.
getId
()
+
".jpeg"
);
}
}
private
String
getCollectBloodCode
(
User
user
)
{
String
code
=
""
;
List
<
Blood
>
collectionBloods
=
bloodService
.
findByUserId
(
user
);
if
(!
CollectionUtils
.
isEmpty
(
collectionBloods
)){
Blood
b
=
collectionBloods
.
get
(
0
);
code
=
b
.
getBloodId
();
}
return
code
;
}
}
}
src/main/java/com/qiankun/dao/BloodDao.java
View file @
9a6c9942
package
com
.
qiankun
.
dao
;
package
com
.
qiankun
.
dao
;
import
com.qiankun.dao.core.IDao
;
import
com.qiankun.dao.core.IDao
;
import
com.qiankun.entity.Activity
;
import
com.qiankun.entity.Blood
;
import
com.qiankun.entity.Blood
;
import
com.qiankun.entity.User
;
import
java.util.List
;
public
interface
BloodDao
extends
IDao
<
Blood
,
String
>
{
public
interface
BloodDao
extends
IDao
<
Blood
,
String
>
{
long
findCountByUserAndActivity
(
String
userId
,
String
activityId
);
long
findCountByUserAndActivity
(
String
userId
,
String
activityId
);
List
<
Blood
>
findByUserOrderByCreateTime
(
String
userId
);
}
}
src/main/java/com/qiankun/dao/BloodDaoImpl.java
View file @
9a6c9942
package
com
.
qiankun
.
dao
;
package
com
.
qiankun
.
dao
;
import
com.qiankun.dao.core.AbsDao
;
import
com.qiankun.dao.core.AbsDao
;
import
com.qiankun.dao.core.Hints
;
import
com.qiankun.entity.Activity
;
import
com.qiankun.entity.Activity
;
import
com.qiankun.entity.Blood
;
import
com.qiankun.entity.Blood
;
import
com.qiankun.entity.User
;
import
com.qiankun.entity.User
;
import
org.springframework.stereotype.Repository
;
import
org.springframework.stereotype.Repository
;
import
java.util.List
;
@Repository
@Repository
public
class
BloodDaoImpl
extends
AbsDao
<
Blood
,
String
>
implements
BloodDao
{
public
class
BloodDaoImpl
extends
AbsDao
<
Blood
,
String
>
implements
BloodDao
{
@Override
@Override
public
long
findCountByUserAndActivity
(
String
userId
,
String
activityId
)
{
public
long
findCountByUserAndActivity
(
String
userId
,
String
activityId
)
{
return
findCount
(
"select count(*) from Blood where user.id = ? and activity.id = ?"
,
userId
,
activityId
);
return
findCount
(
"select count(*) from Blood where user.id = ? and activity.id = ?"
,
userId
,
activityId
);
}
}
@Override
public
List
<
Blood
>
findByUserOrderByCreateTime
(
String
userId
)
{
return
find
(
" from Blood where user.id = ? order by updateTime desc"
,
new
Hints
(),
userId
);
}
}
}
src/main/java/com/qiankun/service/BloodService.java
View file @
9a6c9942
...
@@ -8,6 +8,8 @@ import org.springframework.beans.factory.annotation.Autowired;
...
@@ -8,6 +8,8 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.transaction.annotation.Transactional
;
import
java.util.List
;
@Service
@Service
public
class
BloodService
{
public
class
BloodService
{
@Autowired
@Autowired
...
@@ -25,4 +27,7 @@ public class BloodService {
...
@@ -25,4 +27,7 @@ public class BloodService {
return
false
;
return
false
;
}
}
}
}
public
List
<
Blood
>
findByUserId
(
User
user
){
return
bloodDao
.
findByUserOrderByCreateTime
(
user
.
getId
());
}
}
}
src/main/java/com/qiankun/utils/UserUtils.java
View file @
9a6c9942
...
@@ -101,19 +101,26 @@ public class UserUtils {
...
@@ -101,19 +101,26 @@ public class UserUtils {
return
url
.
openStream
();
return
url
.
openStream
();
}
}
/*
public static void main(String[] args){
try {
// GraphicsEnvironment ge=GraphicsEnvironment.getLocalGraphicsEnvironment();
// String[] fa=ge.getAvailableFontFamilyNames();
// for (String s:fa) {
// System.out.println(s);
// }
List<CertificateVo> addTexts = Lists.newArrayList();
Calendar now = Calendar.getInstance();
addTexts.add(new CertificateVo("刘扬",new Font("宋体",Font.PLAIN,50),200,600));
addTexts.add(new CertificateVo("0222189765",new Font("宋体",Font.PLAIN,30),280,1310));
addTexts.add(new CertificateVo(now.get(Calendar.YEAR)+"",new Font("宋体",Font.PLAIN,30),550,1245));
addTexts.add(new CertificateVo(now.get(Calendar.MONTH) +1+"",new Font("宋体",Font.PLAIN,30),690,1245));
addTexts.add(new CertificateVo(now.get(Calendar.DATE)+"",new Font("宋体",Font.PLAIN,30),790,1245));
UserUtils.generateCertificate("classpath:certificate.jpeg","/Users/liuyang/Pictures/certificate.jpeg",addTexts);
}catch (IOException e){
e.printStackTrace();;
}
// public static void main(String[] args){
}
// try {
*/
// List<CertificateVo> addTexts = Lists.newArrayList();
// Calendar now = Calendar.getInstance();
// addTexts.add(new CertificateVo("刘扬",new Font("微软雅黑",Font.BOLD,50),250,1100));
// addTexts.add(new CertificateVo(now.get(Calendar.YEAR)+"",new Font("微软雅黑",Font.PLAIN,30),550,1245));
// addTexts.add(new CertificateVo(now.get(Calendar.MONTH) +1+"",new Font("微软雅黑",Font.PLAIN,30),680,1245));
// addTexts.add(new CertificateVo(now.get(Calendar.DATE)+"",new Font("微软雅黑",Font.PLAIN,30),790,1245));
// UserUtils.generateCertificate("classpath:certificate.jpeg","/Users/liuyang/Pictures/certificate.jpeg",addTexts);
// }catch (IOException e){
// e.printStackTrace();;
// }
//
// }
}
}
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