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
31d58e72
Commit
31d58e72
authored
Apr 30, 2019
by
liuchao
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
http://fywlsoft.cn:50379/other-project/tjmdp
parents
0be32ad9
237ee3b6
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
74 additions
and
26 deletions
+74
-26
MdpController.java
src/main/java/com/qiankun/controller/mdp/MdpController.java
+34
-10
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
+24
-14
certificate.jpeg
src/main/resources/certificate.jpeg
+0
-0
certificate.png
src/main/resources/certificate.png
+0
-0
No files found.
src/main/java/com/qiankun/controller/mdp/MdpController.java
View file @
31d58e72
...
...
@@ -24,6 +24,7 @@ import com.qiankun.utils.UserUtils;
import
com.qiankun.vo.*
;
import
com.sun.mail.imap.ResyncData
;
import
me.chanjar.weixin.common.error.WxErrorException
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.commons.io.FileUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.omg.PortableInterceptor.ServerRequestInfo
;
...
...
@@ -64,7 +65,7 @@ public class MdpController extends BaseController<Object> {
return
propertis
.
getConfigs
().
get
(
1
).
getAppid
();
}
private
String
uploadAvatarPath
=
File
.
separator
+
"mdp"
+
File
.
separator
+
"uploadAvatar"
;
private
String
certificateTemplate
=
"classpath:certificate.
jpe
g"
;
private
String
certificateTemplate
=
"classpath:certificate.
pn
g"
;
private
String
userCertificatePath
=
File
.
separator
+
"mdp"
+
File
.
separator
+
"certificate"
;
@Auth
(
verifyLogin
=
false
,
verifyURL
=
false
)
...
...
@@ -390,6 +391,9 @@ public class MdpController extends BaseController<Object> {
blood
.
setUser
(
user
);
blood
.
setActivity
(
activity
);
bloodService
.
save
(
blood
);
//修改用户状态
user
.
setStatus
(
"2"
);
userService
.
save
(
user
);
result
.
put
(
"status"
,
"ok"
);
return
result
;
}
...
...
@@ -449,15 +453,21 @@ public class MdpController extends BaseController<Object> {
result
.
put
(
"errorMsg"
,
"用户不存在"
);
return
result
;
}
if
(
user
.
getStatus
().
equals
(
"1"
)
||
user
.
getStatus
().
equals
(
""
)){
if
(
"1"
.
equals
(
user
.
getStatus
())
||
"3"
.
equals
(
user
.
getStatus
()
)){
//未采血或退库的没有证书
result
.
put
(
"status"
,
"error"
);
result
.
put
(
"errorMsg"
,
"您还未采血,不能生成证书"
);
return
result
;
}
String
code
=
getCollectBloodCode
(
user
);
if
(
Strings
.
isNullOrEmpty
(
code
)){
result
.
put
(
"status"
,
"error"
);
result
.
put
(
"errorMsg"
,
"采血编号不存在"
);
return
result
;
}
if
(
Strings
.
isNullOrEmpty
(
user
.
getCerfificatePath
())){
try
{
generateCertificate
(
user
);
generateCertificate
(
user
,
code
);
}
catch
(
IOException
e
)
{
logger
.
error
(
e
.
getMessage
(),
e
);
result
.
put
(
"status"
,
"error"
);
...
...
@@ -470,16 +480,30 @@ public class MdpController extends BaseController<Object> {
result
.
put
(
"certificateImage"
,
user
.
getCerfificatePath
());
return
result
;
}
private
void
generateCertificate
(
User
user
)
throws
IOException
{
private
void
generateCertificate
(
User
user
,
String
code
)
throws
IOException
{
List
<
CertificateVo
>
addTexts
=
Lists
.
newArrayList
();
Calendar
now
=
Calendar
.
getInstance
();
addTexts
.
add
(
new
CertificateVo
(
user
.
getName
(),
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
));
String
outputFilePath
=
rb
.
getString
(
"file_path"
)
+
this
.
userCertificatePath
+
File
.
separator
+
user
.
getId
()
+
".jpeg"
;
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
);
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
(
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
));
String
outputFilePath
=
rb
.
getString
(
"file_path"
)
+
this
.
userCertificatePath
+
File
.
separator
+
user
.
getId
()
+
".png"
;
UserUtils
.
generateCertificate
(
this
.
certificateTemplate
,
outputFilePath
,
addTexts
);
user
.
setCerfificatePath
(
this
.
userCertificatePath
+
File
.
separator
+
user
.
getId
()
+
".jpeg"
);
user
.
setCerfificatePath
(
this
.
userCertificatePath
+
File
.
separator
+
user
.
getId
()
+
".png"
);
}
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 @
31d58e72
package
com
.
qiankun
.
dao
;
import
com.qiankun.dao.core.IDao
;
import
com.qiankun.entity.Activity
;
import
com.qiankun.entity.Blood
;
import
com.qiankun.entity.User
;
import
java.util.List
;
public
interface
BloodDao
extends
IDao
<
Blood
,
String
>
{
long
findCountByUserAndActivity
(
String
userId
,
String
activityId
);
List
<
Blood
>
findByUserOrderByCreateTime
(
String
userId
);
}
src/main/java/com/qiankun/dao/BloodDaoImpl.java
View file @
31d58e72
package
com
.
qiankun
.
dao
;
import
com.qiankun.dao.core.AbsDao
;
import
com.qiankun.dao.core.Hints
;
import
com.qiankun.entity.Activity
;
import
com.qiankun.entity.Blood
;
import
com.qiankun.entity.User
;
import
org.springframework.stereotype.Repository
;
import
java.util.List
;
@Repository
public
class
BloodDaoImpl
extends
AbsDao
<
Blood
,
String
>
implements
BloodDao
{
@Override
public
long
findCountByUserAndActivity
(
String
userId
,
String
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 @
31d58e72
...
...
@@ -8,6 +8,8 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
java.util.List
;
@Service
public
class
BloodService
{
@Autowired
...
...
@@ -25,4 +27,7 @@ public class BloodService {
return
false
;
}
}
public
List
<
Blood
>
findByUserId
(
User
user
){
return
bloodDao
.
findByUserOrderByCreateTime
(
user
.
getId
());
}
}
src/main/java/com/qiankun/utils/UserUtils.java
View file @
31d58e72
...
...
@@ -101,19 +101,29 @@ public class UserUtils {
return
url
.
openStream
();
}
// 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();;
// }
//
/*
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();
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);
addTexts.add(new CertificateVo("刘扬",new Font("宋体",Font.BOLD,50),190,570));
addTexts.add(new CertificateVo("02223456",new Font("宋体",Font.BOLD,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));
UserUtils.generateCertificate("classpath:certificate.png","/Users/liuyang/Pictures/certificate.png",addTexts);
}catch (IOException e){
e.printStackTrace();;
}
}
*/
}
src/main/resources/certificate.jpeg
deleted
100644 → 0
View file @
0be32ad9
424 KB
src/main/resources/certificate.png
0 → 100644
View file @
31d58e72
506 KB
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