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
1638949f
Commit
1638949f
authored
Apr 02, 2019
by
liuchao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
no message
parent
8ff5707b
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
808 additions
and
146 deletions
+808
-146
pom.xml
pom.xml
+6
-0
UserController.java
src/main/java/com/qiankun/controller/UserController.java
+21
-49
Activity.java
src/main/java/com/qiankun/entity/Activity.java
+183
-0
Blood.java
src/main/java/com/qiankun/entity/Blood.java
+101
-0
Contacts.java
src/main/java/com/qiankun/entity/Contacts.java
+34
-75
User.java
src/main/java/com/qiankun/entity/User.java
+199
-22
QRCodeUtil.java
src/main/java/com/qiankun/utils/QRCodeUtil.java
+264
-0
No files found.
pom.xml
View file @
1638949f
...
...
@@ -240,6 +240,12 @@
<artifactId>
fastjson
</artifactId>
<version>
1.2.20
</version>
</dependency>
<dependency>
<groupId>
com.google.zxing
</groupId>
<artifactId>
core
</artifactId>
<version>
3.3.0
</version>
</dependency>
<dependency>
<groupId>
net.sourceforge.jexcelapi
</groupId>
...
...
src/main/java/com/qiankun/controller/UserController.java
View file @
1638949f
...
...
@@ -26,7 +26,7 @@ import org.springframework.web.servlet.ModelAndView;
import
com.qiankun.annotation.Auth
;
import
com.qiankun.controller.base.BaseController
;
import
com.qiankun.dao.core.Hints
;
import
com.qiankun.entity.
Product
;
import
com.qiankun.entity.
Contacts
;
import
com.qiankun.entity.User
;
import
com.qiankun.pages.IPageList
;
import
com.qiankun.service.UserService
;
...
...
@@ -90,22 +90,11 @@ public class UserController extends BaseController<Object>{
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"yyyy"
);
String
year
=
sdf
.
format
(
date
);
Long
code
=
null
;
User
last
=
userService
.
findLastUserByGroup
(
userVo
.
getGroups
());
if
(
last
!=
null
)
{
code
=
Long
.
valueOf
(
last
.
getUserId
().
substring
(
6
))+
1
;
}
else
{
code
=
Long
.
valueOf
(
userVo
.
getGroups
()
+
"000001"
);
}
String
userId
=
"IE"
+
year
+
code
;
user
.
setUserId
(
userId
);
Product
product
=
new
Product
();
Contacts
product
=
new
Contacts
();
product
.
setUser
(
user
);
product
.
setCreateTime
(
date
);
user
.
getProduct
().
add
(
product
);
user
.
getContacts
().
add
(
product
);
view
.
getModelMap
().
put
(
"status"
,
1
);
}
else
{
...
...
@@ -117,7 +106,7 @@ public class UserController extends BaseController<Object>{
}
}
user
=
userService
.
findById
(
userVo
.
getId
());
if
(
StringUtils
.
isNotBlank
(
userVo
.
getTeamName
())
&&
!
userVo
.
getTeamName
().
equals
(
user
.
getTeamName
())
)
{
if
(
StringUtils
.
isNotBlank
(
userVo
.
getTeamName
()))
{
Boolean
userIsExistUserName
=
userService
.
validateUserExistByTeamName
(
userVo
.
getTeamName
());
if
(
userIsExistUserName
)
{
view
.
getModel
().
put
(
"message"
,
"userIsExist_teamName"
);
...
...
@@ -129,7 +118,6 @@ public class UserController extends BaseController<Object>{
user
.
setPwd
(
MD5
.
digest
(
userVo
.
getPwd
()));
}
user
.
setUserName
(
userVo
.
getUserName
());
user
.
setTeamName
(
userVo
.
getTeamName
());
user
.
setEmail
(
userVo
.
getEmail
());
...
...
@@ -223,19 +211,16 @@ public class UserController extends BaseController<Object>{
ModelAndView
view
=
new
ModelAndView
();
User
userSession
=
SessionUtils
.
getUser
(
request
);
User
user
=
userService
.
findById
(
userSession
.
getId
());
Product
product
=
new
Product
();
Set
<
Product
>
productSet
=
user
.
getProduct
();
Iterator
<
Product
>
its
=
productSet
.
iterator
();
Contacts
product
=
new
Contacts
();
Set
<
Contacts
>
productSet
=
user
.
getContacts
();
Iterator
<
Contacts
>
its
=
productSet
.
iterator
();
if
(
its
.
hasNext
())
{
product
=
its
.
next
();
}
product
.
setName
(
productVo
.
getName
());
product
.
setContent1
(
productVo
.
getContent1
());
product
.
setContent2
(
productVo
.
getContent2
());
product
.
setContent3
(
productVo
.
getContent3
());
product
.
setUpdateTime
(
new
Date
());
user
.
get
Product
().
clear
();
user
.
get
Product
().
add
(
product
);
user
.
get
Contacts
().
clear
();
user
.
get
Contacts
().
add
(
product
);
userService
.
save
(
user
);
view
.
getModelMap
().
put
(
"message"
,
"success"
);
return
view
;
...
...
@@ -255,9 +240,9 @@ public class UserController extends BaseController<Object>{
ModelAndView
view
=
new
ModelAndView
();
User
userSession
=
SessionUtils
.
getUser
(
request
);
User
user
=
userService
.
findById
(
userSession
.
getId
());
Product
product
=
new
Product
();
Set
<
Product
>
productSet
=
user
.
getProduct
();
Iterator
<
Product
>
its
=
productSet
.
iterator
();
Contacts
product
=
new
Contacts
();
Set
<
Contacts
>
productSet
=
user
.
getContacts
();
Iterator
<
Contacts
>
its
=
productSet
.
iterator
();
if
(
its
.
hasNext
())
{
product
=
its
.
next
();
}
...
...
@@ -328,7 +313,7 @@ public class UserController extends BaseController<Object>{
User
userSession
=
SessionUtils
.
getUser
(
request
);
ResourceBundle
rb
=
ResourceBundle
.
getBundle
(
"system"
);
String
path
=
rb
.
getString
(
"file_path"
)
+
userSession
.
getUserId
()
+
"/"
;
String
path
=
rb
.
getString
(
"file_path"
)
+
"/"
;
File
f
=
new
File
(
path
);
if
(!
f
.
exists
()
&&
!
f
.
isDirectory
())
{
f
.
mkdir
();
...
...
@@ -380,27 +365,16 @@ public class UserController extends BaseController<Object>{
User
user
=
userService
.
findById
(
userSession
.
getId
());
Product
product
=
new
Product
();
Set
<
Product
>
productSet
=
user
.
getProduct
();
Iterator
<
Product
>
its
=
productSet
.
iterator
();
Contacts
product
=
new
Contacts
();
Set
<
Contacts
>
productSet
=
user
.
getContacts
();
Iterator
<
Contacts
>
its
=
productSet
.
iterator
();
if
(
its
.
hasNext
())
{
product
=
its
.
next
();
}
if
(
"enroll"
.
equals
(
type
))
{
product
.
setEnroll
(
fileFullName
);
}
if
(
"report"
.
equals
(
type
))
{
product
.
setReport
(
fileFullName
);
}
if
(
"ppt"
.
equals
(
type
))
{
product
.
setPpt
(
fileFullName
);
}
if
(
"attachment"
.
equals
(
type
))
{
product
.
setAttachment
(
fileFullName
);
}
product
.
setUpdateTime
(
new
Date
());
user
.
get
Product
().
clear
();
user
.
get
Product
().
add
(
product
);
user
.
get
Contacts
().
clear
();
user
.
get
Contacts
().
add
(
product
);
userService
.
save
(
user
);
return
view
;
...
...
@@ -415,9 +389,7 @@ public class UserController extends BaseController<Object>{
try
{
User
userSession
=
SessionUtils
.
getUser
(
request
);
ResourceBundle
rb
=
ResourceBundle
.
getBundle
(
"system"
);
if
(
StringUtils
.
isBlank
(
userId
))
{
userId
=
userSession
.
getUserId
();
}
String
path
=
rb
.
getString
(
"file_path"
)
+
userId
+
"/"
+
type
+
"/"
+
fileName
;
response
.
setContentType
(
"application/octet-stream"
);
...
...
src/main/java/com/qiankun/entity/Activity.java
0 → 100644
View file @
1638949f
package
com
.
qiankun
.
entity
;
import
java.util.Date
;
import
java.util.HashSet
;
import
java.util.Set
;
import
javax.persistence.CascadeType
;
import
javax.persistence.Entity
;
import
javax.persistence.FetchType
;
import
javax.persistence.GeneratedValue
;
import
javax.persistence.Id
;
import
javax.persistence.Inheritance
;
import
javax.persistence.InheritanceType
;
import
javax.persistence.Lob
;
import
javax.persistence.ManyToMany
;
import
javax.persistence.ManyToOne
;
import
org.hibernate.annotations.Cache
;
import
org.hibernate.annotations.CacheConcurrencyStrategy
;
import
org.hibernate.annotations.GenericGenerator
;
import
com.fasterxml.jackson.annotation.JsonIgnore
;
@Entity
@Cache
(
usage
=
CacheConcurrencyStrategy
.
READ_WRITE
)
@Inheritance
(
strategy
=
InheritanceType
.
TABLE_PER_CLASS
)
public
class
Activity
{
@Id
@GenericGenerator
(
name
=
"systemUUID"
,
strategy
=
"uuid2"
)
@GeneratedValue
(
generator
=
"systemUUID"
)
private
String
id
;
private
String
name
;
//活动名称
private
String
type
;
//采样编号
@Lob
private
String
addr
;
//地点
@Lob
private
String
content
;
//详细信息
@ManyToOne
private
User
review
;
//数据初审者;
private
Date
day
;
//活动时间
private
long
max
;
//最大人数;
private
String
crowd
;
//适用人群
private
boolean
available
;
//活动是否可用
private
String
contacts
;
//联系人
private
String
tel
;
//联系电话
@ManyToMany
(
fetch
=
FetchType
.
LAZY
,
cascade
=
{
CascadeType
.
MERGE
})
@JsonIgnore
private
Set
<
User
>
user
=
new
HashSet
<
User
>();
private
Date
updateTime
=
new
Date
();
public
String
getId
()
{
return
id
;
}
public
void
setId
(
String
id
)
{
this
.
id
=
id
;
}
public
String
getName
()
{
return
name
;
}
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
public
String
getType
()
{
return
type
;
}
public
void
setType
(
String
type
)
{
this
.
type
=
type
;
}
public
String
getAddr
()
{
return
addr
;
}
public
void
setAddr
(
String
addr
)
{
this
.
addr
=
addr
;
}
public
String
getContent
()
{
return
content
;
}
public
void
setContent
(
String
content
)
{
this
.
content
=
content
;
}
public
User
getReview
()
{
return
review
;
}
public
void
setReview
(
User
review
)
{
this
.
review
=
review
;
}
public
Date
getDay
()
{
return
day
;
}
public
void
setDay
(
Date
day
)
{
this
.
day
=
day
;
}
public
long
getMax
()
{
return
max
;
}
public
void
setMax
(
long
max
)
{
this
.
max
=
max
;
}
public
String
getCrowd
()
{
return
crowd
;
}
public
void
setCrowd
(
String
crowd
)
{
this
.
crowd
=
crowd
;
}
public
boolean
isAvailable
()
{
return
available
;
}
public
void
setAvailable
(
boolean
available
)
{
this
.
available
=
available
;
}
public
String
getContacts
()
{
return
contacts
;
}
public
void
setContacts
(
String
contacts
)
{
this
.
contacts
=
contacts
;
}
public
String
getTel
()
{
return
tel
;
}
public
void
setTel
(
String
tel
)
{
this
.
tel
=
tel
;
}
public
Set
<
User
>
getUser
()
{
return
user
;
}
public
void
setUser
(
Set
<
User
>
user
)
{
this
.
user
=
user
;
}
public
Date
getUpdateTime
()
{
return
updateTime
;
}
public
void
setUpdateTime
(
Date
updateTime
)
{
this
.
updateTime
=
updateTime
;
}
}
src/main/java/com/qiankun/entity/Blood.java
0 → 100644
View file @
1638949f
package
com
.
qiankun
.
entity
;
import
java.util.Date
;
import
java.util.HashSet
;
import
java.util.Set
;
import
javax.persistence.CascadeType
;
import
javax.persistence.Entity
;
import
javax.persistence.FetchType
;
import
javax.persistence.GeneratedValue
;
import
javax.persistence.Id
;
import
javax.persistence.Inheritance
;
import
javax.persistence.InheritanceType
;
import
javax.persistence.Lob
;
import
javax.persistence.ManyToOne
;
import
javax.persistence.OneToMany
;
import
org.hibernate.annotations.Cache
;
import
org.hibernate.annotations.CacheConcurrencyStrategy
;
import
org.hibernate.annotations.GenericGenerator
;
import
com.fasterxml.jackson.annotation.JsonIgnore
;
@Entity
@Cache
(
usage
=
CacheConcurrencyStrategy
.
READ_WRITE
)
@Inheritance
(
strategy
=
InheritanceType
.
TABLE_PER_CLASS
)
public
class
Blood
{
@Id
@GenericGenerator
(
name
=
"systemUUID"
,
strategy
=
"uuid2"
)
@GeneratedValue
(
generator
=
"systemUUID"
)
private
String
id
;
private
String
bloodId
;
//采样编号
@Lob
private
String
bloodAddr
;
//采血地点
@ManyToOne
private
User
review
;
//数据初审者;
@ManyToOne
private
User
user
=
new
User
();
private
Date
updateTime
=
new
Date
();
public
String
getId
()
{
return
id
;
}
public
void
setId
(
String
id
)
{
this
.
id
=
id
;
}
public
String
getBloodId
()
{
return
bloodId
;
}
public
void
setBloodId
(
String
bloodId
)
{
this
.
bloodId
=
bloodId
;
}
public
String
getBloodAddr
()
{
return
bloodAddr
;
}
public
void
setBloodAddr
(
String
bloodAddr
)
{
this
.
bloodAddr
=
bloodAddr
;
}
public
User
getReview
()
{
return
review
;
}
public
void
setReview
(
User
review
)
{
this
.
review
=
review
;
}
public
User
getUser
()
{
return
user
;
}
public
void
setUser
(
User
user
)
{
this
.
user
=
user
;
}
public
Date
getUpdateTime
()
{
return
updateTime
;
}
public
void
setUpdateTime
(
Date
updateTime
)
{
this
.
updateTime
=
updateTime
;
}
}
src/main/java/com/qiankun/entity/
Product
.java
→
src/main/java/com/qiankun/entity/
Contacts
.java
View file @
1638949f
package
com
.
qiankun
.
entity
;
import
java.util.Date
;
import
java.util.Set
;
import
javax.persistence.Entity
;
import
javax.persistence.GeneratedValue
;
...
...
@@ -18,7 +17,7 @@ import org.hibernate.annotations.GenericGenerator;
@Entity
@Cache
(
usage
=
CacheConcurrencyStrategy
.
READ_WRITE
)
@Inheritance
(
strategy
=
InheritanceType
.
TABLE_PER_CLASS
)
public
class
Product
{
public
class
Contacts
{
@Id
@GenericGenerator
(
name
=
"systemUUID"
,
strategy
=
"uuid2"
)
...
...
@@ -27,31 +26,22 @@ public class Product {
private
String
name
;
@Lob
private
String
content1
;
//摘要
@Lob
private
String
content2
;
//作品思路和应用的理论方法
@Lob
private
String
content3
;
//作品的创新性
private
String
relation
;
//关系
private
String
enroll
;
//报名表上传
private
String
mobile
;
//手机
private
String
report
;
//报告上传
private
String
qq
;
private
String
ppt
;
//ppt上传
private
String
attachment
;
//附件上传
private
String
weixin
;
@Lob
private
String
addr
;
//地址
@ManyToOne
private
User
user
=
new
User
();
private
Date
createTime
=
new
Date
();
private
Date
updateTime
=
new
Date
();
private
Boolean
isSubmit
=
false
;
//是否提交
public
String
getId
()
{
return
id
;
...
...
@@ -69,68 +59,52 @@ public class Product {
this
.
name
=
name
;
}
public
String
getContent1
()
{
return
content1
;
}
public
void
setContent1
(
String
content1
)
{
this
.
content1
=
content1
;
}
public
String
getContent2
()
{
return
content2
;
}
public
void
setContent2
(
String
content2
)
{
this
.
content2
=
content2
;
}
public
String
getContent3
()
{
return
content3
;
public
String
getRelation
()
{
return
relation
;
}
public
void
set
Content3
(
String
content3
)
{
this
.
content3
=
content3
;
public
void
set
Relation
(
String
relation
)
{
this
.
relation
=
relation
;
}
public
String
get
Enroll
()
{
return
enroll
;
public
String
get
Mobile
()
{
return
mobile
;
}
public
void
set
Enroll
(
String
enroll
)
{
this
.
enroll
=
enroll
;
public
void
set
Mobile
(
String
mobile
)
{
this
.
mobile
=
mobile
;
}
public
String
get
Report
()
{
return
report
;
public
String
get
Qq
()
{
return
qq
;
}
public
void
set
Report
(
String
report
)
{
this
.
report
=
report
;
public
void
set
Qq
(
String
qq
)
{
this
.
qq
=
qq
;
}
public
String
get
Ppt
()
{
return
ppt
;
public
String
get
Weixin
()
{
return
weixin
;
}
public
void
set
Ppt
(
String
ppt
)
{
this
.
ppt
=
ppt
;
public
void
set
Weixin
(
String
weixin
)
{
this
.
weixin
=
weixin
;
}
public
String
getA
ttachment
()
{
return
a
ttachment
;
public
String
getA
ddr
()
{
return
a
ddr
;
}
public
void
setA
ttachment
(
String
attachment
)
{
this
.
a
ttachment
=
attachment
;
public
void
setA
ddr
(
String
addr
)
{
this
.
a
ddr
=
addr
;
}
public
Date
getCreateTime
()
{
return
createTime
;
public
User
getUser
()
{
return
user
;
}
public
void
set
CreateTime
(
Date
createTime
)
{
this
.
createTime
=
createTime
;
public
void
set
User
(
User
user
)
{
this
.
user
=
user
;
}
public
Date
getUpdateTime
()
{
...
...
@@ -140,22 +114,7 @@ public class Product {
public
void
setUpdateTime
(
Date
updateTime
)
{
this
.
updateTime
=
updateTime
;
}
public
Boolean
getIsSubmit
()
{
return
isSubmit
;
}
public
void
setIsSubmit
(
Boolean
isSubmit
)
{
this
.
isSubmit
=
isSubmit
;
}
public
User
getUser
()
{
return
user
;
}
public
void
setUser
(
User
user
)
{
this
.
user
=
user
;
}
...
...
src/main/java/com/qiankun/entity/User.java
View file @
1638949f
...
...
@@ -11,6 +11,7 @@ import javax.persistence.GeneratedValue;
import
javax.persistence.Id
;
import
javax.persistence.Inheritance
;
import
javax.persistence.InheritanceType
;
import
javax.persistence.Lob
;
import
javax.persistence.OneToMany
;
import
org.hibernate.annotations.Cache
;
...
...
@@ -29,12 +30,38 @@ public class User {
@GeneratedValue
(
generator
=
"systemUUID"
)
private
String
id
;
private
String
userId
;
//编号
private
String
userName
;
//单位名称
private
String
teamName
;
//团队名称
private
String
mobile
;
//手机
private
String
userName
;
//用户名
private
String
name
;
//姓名
private
String
gender
;
//性别
private
String
birthdate
;
//出生年月
private
String
paperType
;
//证件类型
private
String
paperId
;
//证件号
private
String
nation
;
//民族
private
String
nativePlace
;
//籍贯
private
String
nationality
;
//国籍
private
String
education
;
//学历
private
String
domicilePlace
;
//户籍所在地
private
String
addr
;
//经常居住地
private
String
unit
;
//单位、学校
private
String
unitAddr
;
//单位、学校地址
private
String
unitTel
;
//单位、学校电话
private
String
profession
;
//职业
private
String
mobile
;
//本人手机
private
String
email
;
//电话
private
String
tel
;
//固定电话
private
String
qq
;
private
String
weixin
;
//微信号
private
Integer
donateBloodCount
;
//无偿献血次数
private
String
bloodType
;
//血型
private
Integer
height
;
//身高
private
Integer
weight
;
//体重
@Lob
private
String
remark
;
//备注
private
String
pwd
;
//密码
private
String
email
;
private
String
role
;
//角色 1.管理员 2.志愿者 3.预注册用户
...
...
@@ -42,7 +69,17 @@ public class User {
@OneToMany
(
fetch
=
FetchType
.
LAZY
,
cascade
=
{
CascadeType
.
ALL
},
orphanRemoval
=
true
,
mappedBy
=
"user"
)
@JsonIgnore
private
Set
<
Product
>
product
=
new
HashSet
<
Product
>();
private
Set
<
Contacts
>
contacts
=
new
HashSet
<
Contacts
>();
@OneToMany
(
fetch
=
FetchType
.
LAZY
,
cascade
=
{
CascadeType
.
ALL
},
orphanRemoval
=
true
,
mappedBy
=
"user"
)
@JsonIgnore
private
Set
<
Blood
>
blood
=
new
HashSet
<
Blood
>();
@OneToMany
(
fetch
=
FetchType
.
LAZY
,
cascade
=
{
CascadeType
.
ALL
},
orphanRemoval
=
true
,
mappedBy
=
"review"
)
@JsonIgnore
private
Set
<
Blood
>
review
=
new
HashSet
<
Blood
>();
private
Boolean
isRemove
=
false
;
//是否删除用户,默认false
...
...
@@ -52,12 +89,7 @@ public class User {
public
void
setId
(
String
id
)
{
this
.
id
=
id
;
}
public
String
getUserId
()
{
return
userId
;
}
public
void
setUserId
(
String
userId
)
{
this
.
userId
=
userId
;
}
public
String
getUserName
()
{
return
userName
;
}
...
...
@@ -76,12 +108,7 @@ public class User {
public
void
setPwd
(
String
pwd
)
{
this
.
pwd
=
pwd
;
}
public
String
getTeamName
()
{
return
teamName
;
}
public
void
setTeamName
(
String
teamName
)
{
this
.
teamName
=
teamName
;
}
public
String
getEmail
()
{
return
email
;
}
...
...
@@ -100,11 +127,11 @@ public class User {
public
void
setCreateTime
(
Date
createTime
)
{
this
.
createTime
=
createTime
;
}
public
Set
<
Product
>
getProduct
()
{
return
product
;
public
Set
<
Contacts
>
getContacts
()
{
return
contacts
;
}
public
void
set
Product
(
Set
<
Product
>
product
)
{
this
.
product
=
product
;
public
void
set
Contacts
(
Set
<
Contacts
>
Contacts
)
{
this
.
contacts
=
Contacts
;
}
public
Boolean
getIsRemove
()
{
return
isRemove
;
...
...
@@ -112,6 +139,156 @@ public class User {
public
void
setIsRemove
(
Boolean
isRemove
)
{
this
.
isRemove
=
isRemove
;
}
public
String
getName
()
{
return
name
;
}
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
public
String
getGender
()
{
return
gender
;
}
public
void
setGender
(
String
gender
)
{
this
.
gender
=
gender
;
}
public
String
getBirthdate
()
{
return
birthdate
;
}
public
void
setBirthdate
(
String
birthdate
)
{
this
.
birthdate
=
birthdate
;
}
public
String
getPaperType
()
{
return
paperType
;
}
public
void
setPaperType
(
String
paperType
)
{
this
.
paperType
=
paperType
;
}
public
String
getPaperId
()
{
return
paperId
;
}
public
void
setPaperId
(
String
paperId
)
{
this
.
paperId
=
paperId
;
}
public
String
getNation
()
{
return
nation
;
}
public
void
setNation
(
String
nation
)
{
this
.
nation
=
nation
;
}
public
String
getNativePlace
()
{
return
nativePlace
;
}
public
void
setNativePlace
(
String
nativePlace
)
{
this
.
nativePlace
=
nativePlace
;
}
public
String
getNationality
()
{
return
nationality
;
}
public
void
setNationality
(
String
nationality
)
{
this
.
nationality
=
nationality
;
}
public
String
getEducation
()
{
return
education
;
}
public
void
setEducation
(
String
education
)
{
this
.
education
=
education
;
}
public
String
getDomicilePlace
()
{
return
domicilePlace
;
}
public
void
setDomicilePlace
(
String
domicilePlace
)
{
this
.
domicilePlace
=
domicilePlace
;
}
public
String
getAddr
()
{
return
addr
;
}
public
void
setAddr
(
String
addr
)
{
this
.
addr
=
addr
;
}
public
String
getUnit
()
{
return
unit
;
}
public
void
setUnit
(
String
unit
)
{
this
.
unit
=
unit
;
}
public
String
getUnitAddr
()
{
return
unitAddr
;
}
public
void
setUnitAddr
(
String
unitAddr
)
{
this
.
unitAddr
=
unitAddr
;
}
public
String
getUnitTel
()
{
return
unitTel
;
}
public
void
setUnitTel
(
String
unitTel
)
{
this
.
unitTel
=
unitTel
;
}
public
String
getProfession
()
{
return
profession
;
}
public
void
setProfession
(
String
profession
)
{
this
.
profession
=
profession
;
}
public
String
getTel
()
{
return
tel
;
}
public
void
setTel
(
String
tel
)
{
this
.
tel
=
tel
;
}
public
String
getQq
()
{
return
qq
;
}
public
void
setQq
(
String
qq
)
{
this
.
qq
=
qq
;
}
public
String
getWeixin
()
{
return
weixin
;
}
public
void
setWeixin
(
String
weixin
)
{
this
.
weixin
=
weixin
;
}
public
Integer
getDonateBloodCount
()
{
return
donateBloodCount
;
}
public
void
setDonateBloodCount
(
Integer
donateBloodCount
)
{
this
.
donateBloodCount
=
donateBloodCount
;
}
public
String
getBloodType
()
{
return
bloodType
;
}
public
void
setBloodType
(
String
bloodType
)
{
this
.
bloodType
=
bloodType
;
}
public
Integer
getHeight
()
{
return
height
;
}
public
void
setHeight
(
Integer
height
)
{
this
.
height
=
height
;
}
public
Integer
getWeight
()
{
return
weight
;
}
public
void
setWeight
(
Integer
weight
)
{
this
.
weight
=
weight
;
}
public
String
getRemark
()
{
return
remark
;
}
public
void
setRemark
(
String
remark
)
{
this
.
remark
=
remark
;
}
public
Set
<
Blood
>
getBlood
()
{
return
blood
;
}
public
void
setBlood
(
Set
<
Blood
>
blood
)
{
this
.
blood
=
blood
;
}
public
Set
<
Blood
>
getReview
()
{
return
review
;
}
public
void
setReview
(
Set
<
Blood
>
review
)
{
this
.
review
=
review
;
}
...
...
src/main/java/com/qiankun/utils/QRCodeUtil.java
0 → 100644
View file @
1638949f
package
com
.
qiankun
.
utils
;
import
java.awt.Graphics2D
;
import
java.awt.geom.AffineTransform
;
import
java.awt.image.BufferedImage
;
import
java.io.File
;
import
java.io.IOException
;
import
java.io.OutputStream
;
import
java.util.HashMap
;
import
java.util.Hashtable
;
import
java.util.Map
;
import
javax.imageio.ImageIO
;
import
javax.servlet.http.HttpServletResponse
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
com.google.zxing.BarcodeFormat
;
import
com.google.zxing.Binarizer
;
import
com.google.zxing.BinaryBitmap
;
import
com.google.zxing.DecodeHintType
;
import
com.google.zxing.EncodeHintType
;
import
com.google.zxing.LuminanceSource
;
import
com.google.zxing.MultiFormatReader
;
import
com.google.zxing.MultiFormatWriter
;
import
com.google.zxing.Result
;
import
com.google.zxing.common.BitMatrix
;
import
com.google.zxing.common.HybridBinarizer
;
import
com.google.zxing.qrcode.decoder.ErrorCorrectionLevel
;
/**
* <p>Title:QRCodeUtil </p>
* <p>Description: 二维码生成工具类</p>
* @author Administrator
* @version
* @since
*/
public
final
class
QRCodeUtil
extends
LuminanceSource
{
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
QRCodeUtil
.
class
);
// 二维码颜色
private
static
final
int
BLACK
=
0xFF000000
;
// 二维码颜色
private
static
final
int
WHITE
=
0xFFFFFFFF
;
private
final
BufferedImage
image
;
private
final
int
left
;
private
final
int
top
;
public
QRCodeUtil
(
BufferedImage
image
)
{
this
(
image
,
0
,
0
,
image
.
getWidth
(),
image
.
getHeight
());
}
public
QRCodeUtil
(
BufferedImage
image
,
int
left
,
int
top
,
int
width
,
int
height
)
{
super
(
width
,
height
);
int
sourceWidth
=
image
.
getWidth
();
int
sourceHeight
=
image
.
getHeight
();
if
(
left
+
width
>
sourceWidth
||
top
+
height
>
sourceHeight
)
{
throw
new
IllegalArgumentException
(
"Crop rectangle does not fit within image data."
);
}
for
(
int
y
=
top
;
y
<
top
+
height
;
y
++)
{
for
(
int
x
=
left
;
x
<
left
+
width
;
x
++)
{
if
((
image
.
getRGB
(
x
,
y
)
&
0xFF000000
)
==
0
)
{
image
.
setRGB
(
x
,
y
,
0xFFFFFFFF
);
// = white
}
}
}
this
.
image
=
new
BufferedImage
(
sourceWidth
,
sourceHeight
,
BufferedImage
.
TYPE_BYTE_GRAY
);
this
.
image
.
getGraphics
().
drawImage
(
image
,
0
,
0
,
null
);
this
.
left
=
left
;
this
.
top
=
top
;
}
@Override
public
byte
[]
getRow
(
int
y
,
byte
[]
row
)
{
if
(
y
<
0
||
y
>=
getHeight
())
{
throw
new
IllegalArgumentException
(
"Requested row is outside the image: "
+
y
);
}
int
width
=
getWidth
();
if
(
row
==
null
||
row
.
length
<
width
)
{
row
=
new
byte
[
width
];
}
image
.
getRaster
().
getDataElements
(
left
,
top
+
y
,
width
,
1
,
row
);
return
row
;
}
@Override
public
byte
[]
getMatrix
()
{
int
width
=
getWidth
();
int
height
=
getHeight
();
int
area
=
width
*
height
;
byte
[]
matrix
=
new
byte
[
area
];
image
.
getRaster
().
getDataElements
(
left
,
top
,
width
,
height
,
matrix
);
return
matrix
;
}
@Override
public
boolean
isCropSupported
()
{
return
true
;
}
@Override
public
LuminanceSource
crop
(
int
left
,
int
top
,
int
width
,
int
height
)
{
return
new
QRCodeUtil
(
image
,
this
.
left
+
left
,
this
.
top
+
top
,
width
,
height
);
}
@Override
public
boolean
isRotateSupported
()
{
return
true
;
}
@Override
public
LuminanceSource
rotateCounterClockwise
()
{
int
sourceWidth
=
image
.
getWidth
();
int
sourceHeight
=
image
.
getHeight
();
AffineTransform
transform
=
new
AffineTransform
(
0.0
,
-
1.0
,
1.0
,
0.0
,
0.0
,
sourceWidth
);
BufferedImage
rotatedImage
=
new
BufferedImage
(
sourceHeight
,
sourceWidth
,
BufferedImage
.
TYPE_BYTE_GRAY
);
Graphics2D
g
=
rotatedImage
.
createGraphics
();
g
.
drawImage
(
image
,
transform
,
null
);
g
.
dispose
();
int
width
=
getWidth
();
return
new
QRCodeUtil
(
rotatedImage
,
top
,
sourceWidth
-
(
left
+
width
),
getHeight
(),
width
);
}
/**
* @param matrix
* @return
*/
private
static
BufferedImage
toBufferedImage
(
BitMatrix
matrix
)
{
int
width
=
matrix
.
getWidth
();
int
height
=
matrix
.
getHeight
();
BufferedImage
image
=
new
BufferedImage
(
width
,
height
,
BufferedImage
.
TYPE_INT_RGB
);
for
(
int
x
=
0
;
x
<
width
;
x
++)
{
for
(
int
y
=
0
;
y
<
height
;
y
++)
{
image
.
setRGB
(
x
,
y
,
matrix
.
get
(
x
,
y
)
?
BLACK
:
WHITE
);
}
}
return
image
;
}
/**
* 生成二维码图片
*
* @param matrix
* @param format
* @param file
* @throws IOException
*/
public
static
void
writeToFile
(
BitMatrix
matrix
,
String
format
,
File
file
)
throws
IOException
{
BufferedImage
image
=
toBufferedImage
(
matrix
);
if
(!
ImageIO
.
write
(
image
,
format
,
file
))
{
throw
new
IOException
(
"Could not write an image of format "
+
format
+
" to "
+
file
);
}
}
/**
* 生成二维码图片流
*
* @param matrix
* @param format
* @param stream
* @throws IOException
*/
public
static
void
writeToStream
(
BitMatrix
matrix
,
String
format
,
OutputStream
stream
)
throws
IOException
{
BufferedImage
image
=
toBufferedImage
(
matrix
);
if
(!
ImageIO
.
write
(
image
,
format
,
stream
))
{
throw
new
IOException
(
"Could not write an image of format "
+
format
);
}
}
/**
* 根据内容,生成指定宽高、指定格式的二维码图片
*
* @param text 内容
* @param width 宽
* @param height 高
* @param format 图片格式
* @return 生成的二维码图片路径
* @throws Exception
*/
private
static
String
generateQRCode
(
String
text
,
int
width
,
int
height
,
String
format
,
String
pathName
)
throws
Exception
{
Hashtable
<
EncodeHintType
,
Object
>
hints
=
new
Hashtable
<
EncodeHintType
,
Object
>();
hints
.
put
(
EncodeHintType
.
CHARACTER_SET
,
"utf-8"
);
// 指定编码格式
hints
.
put
(
EncodeHintType
.
ERROR_CORRECTION
,
ErrorCorrectionLevel
.
L
);
// 指定纠错等级
hints
.
put
(
EncodeHintType
.
MARGIN
,
1
);
// 白边大小,取值范围0~4
BitMatrix
bitMatrix
=
new
MultiFormatWriter
().
encode
(
text
,
BarcodeFormat
.
QR_CODE
,
width
,
height
,
hints
);
File
outputFile
=
new
File
(
pathName
);
writeToFile
(
bitMatrix
,
format
,
outputFile
);
return
pathName
;
}
/**
* 输出二维码图片流
*
* @param text 二维码内容
* @param width 二维码宽
* @param height 二维码高
* @param format 图片格式eg: png, jpg, gif
* @param response HttpServletResponse
* @throws Exception
*/
public
static
void
generateQRCode
(
String
text
,
int
width
,
int
height
,
String
format
,
HttpServletResponse
response
)
throws
Exception
{
Hashtable
<
EncodeHintType
,
Object
>
hints
=
new
Hashtable
<
EncodeHintType
,
Object
>();
hints
.
put
(
EncodeHintType
.
CHARACTER_SET
,
"utf-8"
);
// 指定编码格式
hints
.
put
(
EncodeHintType
.
ERROR_CORRECTION
,
ErrorCorrectionLevel
.
L
);
// 指定纠错等级
hints
.
put
(
EncodeHintType
.
MARGIN
,
1
);
// 白边大小,取值范围0~4
BitMatrix
bitMatrix
=
new
MultiFormatWriter
().
encode
(
text
,
BarcodeFormat
.
QR_CODE
,
width
,
height
,
hints
);
writeToStream
(
bitMatrix
,
format
,
response
.
getOutputStream
());
}
/**
* 解析指定路径下的二维码图片
*
* @param filePath 二维码图片路径
* @return
*/
public
static
String
parseQRCode
(
String
filePath
)
{
String
content
=
""
;
try
{
File
file
=
new
File
(
filePath
);
BufferedImage
image
=
ImageIO
.
read
(
file
);
LuminanceSource
source
=
new
QRCodeUtil
(
image
);
Binarizer
binarizer
=
new
HybridBinarizer
(
source
);
BinaryBitmap
binaryBitmap
=
new
BinaryBitmap
(
binarizer
);
Map
<
DecodeHintType
,
Object
>
hints
=
new
HashMap
<
DecodeHintType
,
Object
>();
hints
.
put
(
DecodeHintType
.
CHARACTER_SET
,
"UTF-8"
);
MultiFormatReader
formatReader
=
new
MultiFormatReader
();
Result
result
=
formatReader
.
decode
(
binaryBitmap
,
hints
);
logger
.
info
(
"result 为:"
+
result
.
toString
());
logger
.
info
(
"resultFormat 为:"
+
result
.
getBarcodeFormat
());
logger
.
info
(
"resultText 为:"
+
result
.
getText
());
// 设置返回值
content
=
result
.
getText
();
}
catch
(
Exception
e
)
{
logger
.
error
(
e
.
getMessage
());
}
return
content
;
}
public
static
void
main
(
String
[]
args
)
{
String
text
=
"cd64a479-5c2d-494a-8a86-4bcf0647a596"
;
// 随机生成验证码
System
.
out
.
println
(
"随机码: "
+
text
);
int
width
=
100
;
// 二维码图片的宽
int
height
=
100
;
// 二维码图片的高
String
format
=
"png"
;
// 二维码图片的格式
try
{
// 生成二维码图片,并返回图片路径
String
pathName
=
generateQRCode
(
text
,
width
,
height
,
format
,
"D:/new.png"
);
System
.
out
.
println
(
"生成二维码的图片路径: "
+
pathName
);
String
content
=
parseQRCode
(
pathName
);
System
.
out
.
println
(
"解析出二维码的图片的内容为: "
+
content
);
}
catch
(
Exception
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