生成证书
This commit is contained in:
@@ -411,8 +411,8 @@ public class ClassController {
|
||||
String endYear = DateUtil.year(classExamUser.getEndTime())+"";
|
||||
String endMonth = DateUtil.month(classExamUser.getEndTime())+1+"";
|
||||
String endDay = DateUtil.dayOfMonth(classExamUser.getEndTime())+"";
|
||||
String description = endYear+"年"+endMonth+"月"+endDay+"日自考通过太湖学堂"+courseEntity.getTitle()+"课程考试,确认合格。";
|
||||
String edes = "has past the online-examination study of "+courseEntity.getEtitle()+" Courses in Tai Hu Education online.";
|
||||
String[] description= {endYear,endMonth,endDay,courseEntity.getTitle()};
|
||||
String[] edes = {courseEntity.getEtitle()};
|
||||
String url = userCertificateService.generateCertificate(type,certificateNo,photoUrl,realName, description, edes, endYear,endMonth,endDay);
|
||||
userCertificate.setCertificateNo(certificateNo);
|
||||
userCertificate.setCertificateUrl(url);
|
||||
@@ -433,10 +433,10 @@ public class ClassController {
|
||||
userCertificate.setCertificateNo(certificateNo);
|
||||
double keshiTotal = (double)map.get("keshi");
|
||||
String keshi = (keshiTotal+"").replace(".0","");
|
||||
String description = "自"+startYear+"年"+startMonth+"月"+startDay+"日至"+endYear+"年"+endMonth+"月"+endDay+"日" +
|
||||
"在太湖学堂"+classEntity.getTitle()+"学习,修完"+map.get("courseTitle")+"课程,共计"+keshi+"学时,确认合格。";
|
||||
String edes = "Has satisfactorily completed an online courseTCM on "+map.get("courseETitle")+" with "+keshi+" course hours intotal, and has been recongnized eligibility without assessment.";
|
||||
String url = userCertificateService.generateCertificate(type,certificateNo,photoUrl,realName, description, edes, endYear,endMonth,endDay);
|
||||
String[] des = {startYear,startMonth,startDay,endYear,endMonth,endDay,
|
||||
classEntity.getTitle(),map.get("courseTitle").toString(),keshi};
|
||||
String[] edes = {map.get("courseETitle").toString(),keshi};
|
||||
String url = userCertificateService.generateCertificate(type,certificateNo,photoUrl,realName,des, edes, endYear,endMonth,endDay);
|
||||
userCertificate.setTitle(classEntity.getTitle());
|
||||
userCertificate.setCertificateUrl(url);
|
||||
userCertificate.setClassId(classEntity.getId());
|
||||
@@ -464,19 +464,19 @@ public class ClassController {
|
||||
String certificateNo = u0.getCertificateNo();
|
||||
int no = Integer.parseInt(certificateNo.substring(certificateNo.indexOf("1")+1,certificateNo.indexOf("1")+7))+1;
|
||||
if ("A".equals(type)){
|
||||
res = "NO.A1"+String.format("%06d", no);
|
||||
res = "NO."+String.format("%06d", no);
|
||||
}else if ("B".equals(type)){
|
||||
res = "NO.B1"+String.format("%06d", no);
|
||||
res = "NO."+String.format("%06d", no);
|
||||
}else if ("ZK".equals(type)){
|
||||
res = "NO.ZK1"+String.format("%06d", no);
|
||||
res = "NO.ZK"+String.format("%06d", no);
|
||||
}
|
||||
}else {
|
||||
if ("A".equals(type)){
|
||||
res = "NO.A1000001";
|
||||
res = "NO.000001";
|
||||
}else if ("B".equals(type)){
|
||||
res = "NO.B1000001";
|
||||
res = "NO.000001";
|
||||
}else if ("ZK".equals(type)){
|
||||
res = "NO.ZK1000001";
|
||||
res = "NO.ZK000001";
|
||||
}
|
||||
}
|
||||
return res+courseNamePinyin;
|
||||
|
||||
@@ -58,11 +58,13 @@ public class UserCertificateController {
|
||||
String iconUrl = params.get("iconUrl").toString();
|
||||
String realName = params.get("realName").toString();
|
||||
String description = params.get("description").toString();
|
||||
String edes = params.get("edes").toString();
|
||||
String edescription = params.get("edes").toString();
|
||||
String endYear = params.get("endYear").toString();
|
||||
String endMonth = params.get("endMonth").toString();
|
||||
String endDay = params.get("endDay").toString();
|
||||
String url = userCertificateService.generateCertificate(type,certificateNo,iconUrl,realName, description, edes, endYear,endMonth,endDay);
|
||||
String[] des = description.split(",");
|
||||
String[] edes = edescription.split(",");
|
||||
String url = userCertificateService.generateCertificate(type,certificateNo,iconUrl,realName, des, edes, endYear,endMonth,endDay);
|
||||
return R.ok().put("url",url);
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,6 @@ import com.peanut.modules.common.entity.UserCertificate;
|
||||
public interface UserCertificateService extends IService<UserCertificate> {
|
||||
|
||||
|
||||
String generateCertificate(String type,String no,String iconUrl,String name,String des,String edes,String endy,String endm,String endd);
|
||||
String generateCertificate(String type,String no,String iconUrl,String name,String[] des,String[] edes,String endy,String endm,String endd);
|
||||
|
||||
}
|
||||
|
||||
@@ -23,15 +23,8 @@ import java.util.UUID;
|
||||
@Service("commonUserCertificateService")
|
||||
public class UserCertificateServiceImpl extends ServiceImpl<UserCertificateDao, UserCertificate> implements UserCertificateService {
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
System.out.println(" ");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String generateCertificate(String type,String certificateNo,String iconUrl,String realName,String des,String edes,
|
||||
public String generateCertificate(String type,String certificateNo,String iconUrl,String realName,String[] des,String[] edes,
|
||||
String endYear,String endMonth,String endDay) {
|
||||
String url = "";
|
||||
if ("A".equals(type)){
|
||||
@@ -41,14 +34,11 @@ public class UserCertificateServiceImpl extends ServiceImpl<UserCertificateDao,
|
||||
}else if ("ZK".equals(type)){
|
||||
url = generateZKCertificate(certificateNo, iconUrl, realName, des, endYear, endMonth, endDay);
|
||||
}
|
||||
String eurl = generateECertificate(certificateNo,realName, edes);
|
||||
String eurl = generateECertificate(type,certificateNo,realName, edes);
|
||||
return url+","+eurl;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public String generateZKCertificate(String no,String iconUrl,String name,String des,String endy,String endm,String endd) {
|
||||
public String generateZKCertificate(String no,String iconUrl,String name,String[] des,String endy,String endm,String endd) {
|
||||
try {
|
||||
Image src = ImageIO.read(new URL("https://ehh-private-01.oss-cn-beijing.aliyuncs.com/certificate/ZK.png"));
|
||||
// 获取图片的高和宽
|
||||
@@ -80,32 +70,34 @@ public class UserCertificateServiceImpl extends ServiceImpl<UserCertificateDao,
|
||||
int namey = 765;
|
||||
g.drawString(name, namex, namey);
|
||||
|
||||
String[] str = {"年","月","日自考通过太湖学堂","课程考试,确认合格。"};
|
||||
g.setColor(Color.BLACK);
|
||||
g.setFont(new Font("黑体", Font.BOLD, 30));
|
||||
FontMetrics dess = g.getFontMetrics();
|
||||
int alreadyWriteLine = 0; //已经写了多少行
|
||||
int nowWidth = 0; //目前一行的长度
|
||||
boolean space = true; //第一行空两格
|
||||
for (int i = 0; i < des.length(); i++) {
|
||||
int oneWordWidth = dess.charWidth(des.charAt(i)); //获取单个字符的长度
|
||||
if (nowWidth+oneWordWidth>650){
|
||||
int desTotalWidth = 50; //目前一行的长度
|
||||
for (int j = 0; j < 4; j++) {//可画字区域宽650,x 180,y 820高开始+10行间距
|
||||
for (int k=0;k<des[j].length(); k++){
|
||||
int oneWordWidth = dess.charWidth(des[j].charAt(k));//获取单个字符的长度
|
||||
desTotalWidth += oneWordWidth;
|
||||
if (desTotalWidth>650){
|
||||
alreadyWriteLine++;
|
||||
int writeY = 850 + alreadyWriteLine * (dess.getHeight()+10);//10是行间距
|
||||
g.drawString(des.charAt(i) + "", 180, writeY);
|
||||
nowWidth = 0;
|
||||
space = false;
|
||||
nowWidth += oneWordWidth;
|
||||
}else {
|
||||
int writeY = 850 + alreadyWriteLine * (dess.getHeight()+10);//10是行间距
|
||||
if (nowWidth==0&&space){//换行画
|
||||
g.drawString(des.charAt(i)+"", 180+oneWordWidth, writeY);
|
||||
nowWidth += oneWordWidth*2;
|
||||
}else {//一字一字画
|
||||
g.drawString(des.charAt(i)+"", 180+nowWidth, writeY);
|
||||
nowWidth += oneWordWidth;
|
||||
}
|
||||
desTotalWidth = oneWordWidth;
|
||||
}
|
||||
g.setFont(new Font("黑体", Font.BOLD, 30));
|
||||
g.drawString(des[j].charAt(k)+"",180+desTotalWidth-oneWordWidth,820+alreadyWriteLine*(dess.getHeight()+10));
|
||||
}
|
||||
for (int k=0;k<str[j].length(); k++){
|
||||
int oneWordWidth = dess.charWidth(str[j].charAt(k));//获取单个字符的长度
|
||||
desTotalWidth += oneWordWidth;
|
||||
if (desTotalWidth>650){
|
||||
alreadyWriteLine++;
|
||||
desTotalWidth = oneWordWidth;
|
||||
}
|
||||
g.setFont(new Font("宋体", Font.PLAIN, 30));
|
||||
g.drawString(str[j].charAt(k)+"",180+desTotalWidth-oneWordWidth,820+alreadyWriteLine*(dess.getHeight()+10));
|
||||
}
|
||||
}
|
||||
|
||||
g.setColor(new Color(0,75,63));
|
||||
g.setFont(new Font("黑体", Font.BOLD, 28));
|
||||
g.drawString(endy,595,1123);
|
||||
@@ -123,7 +115,7 @@ public class UserCertificateServiceImpl extends ServiceImpl<UserCertificateDao,
|
||||
}
|
||||
}
|
||||
|
||||
public String generateBCertificate(String no,String iconUrl,String name,String des,String endy,String endm,String endd) {
|
||||
public String generateBCertificate(String no,String iconUrl,String name,String[] des,String endy,String endm,String endd) {
|
||||
try {
|
||||
Image src = ImageIO.read(new URL("https://ehh-private-01.oss-cn-beijing.aliyuncs.com/certificate/B.png"));
|
||||
// 获取图片的高和宽
|
||||
@@ -155,31 +147,36 @@ public class UserCertificateServiceImpl extends ServiceImpl<UserCertificateDao,
|
||||
int namey = 730;
|
||||
g.drawString(name, namex, namey);
|
||||
|
||||
g.setFont(new Font("黑体", Font.BOLD, 30));
|
||||
String[] str = {"自","年","月","日至","年","月","日在太湖学堂","学习,修完","课程,共计","学时,确认合格。"};
|
||||
g.setColor(Color.BLACK);
|
||||
FontMetrics dess = g.getFontMetrics();
|
||||
int alreadyWriteLine = 0; //已经写了多少行
|
||||
int nowWidth = 0; //目前一行的长度
|
||||
boolean space = true; //第一行空两格
|
||||
for (int i = 0; i < des.length(); i++) {
|
||||
int oneWordWidth = dess.charWidth(des.charAt(i)); //获取单个字符的长度
|
||||
if (nowWidth+oneWordWidth>650){
|
||||
int desTotalWidth = 50; //目前一行的长度
|
||||
for (int j = 0; j < 10; j++) {//可画字区域宽650,x 180,y 820高开始+10行间距
|
||||
for (int k=0;k<str[j].length(); k++){
|
||||
int oneWordWidth = dess.charWidth(str[j].charAt(k));//获取单个字符的长度
|
||||
desTotalWidth += oneWordWidth;
|
||||
if (desTotalWidth>650){
|
||||
alreadyWriteLine++;
|
||||
int writeY = 850 + alreadyWriteLine * (dess.getHeight()+10);//10是行间距
|
||||
g.drawString(des.charAt(i) + "", 180, writeY);
|
||||
nowWidth = 0;
|
||||
space = false;
|
||||
nowWidth += oneWordWidth;
|
||||
}else {
|
||||
int writeY = 850 + alreadyWriteLine * (dess.getHeight()+10);//10是行间距
|
||||
if (nowWidth==0&&space){//换行画
|
||||
g.drawString(des.charAt(i)+"", 180+oneWordWidth, writeY);
|
||||
nowWidth += oneWordWidth*2;
|
||||
}else {//一字一字画
|
||||
g.drawString(des.charAt(i)+"", 180+nowWidth, writeY);
|
||||
nowWidth += oneWordWidth;
|
||||
desTotalWidth = oneWordWidth;
|
||||
}
|
||||
g.setFont(new Font("宋体", Font.PLAIN, 30));
|
||||
g.drawString(str[j].charAt(k)+"",180+desTotalWidth-oneWordWidth,820+alreadyWriteLine*(dess.getHeight()+10));
|
||||
}
|
||||
if (j<=des.length){
|
||||
for (int k=0;k<des[j].length(); k++){
|
||||
int oneWordWidth = dess.charWidth(des[j].charAt(k));//获取单个字符的长度
|
||||
desTotalWidth += oneWordWidth;
|
||||
if (desTotalWidth>650){
|
||||
alreadyWriteLine++;
|
||||
desTotalWidth = oneWordWidth;
|
||||
}
|
||||
g.setFont(new Font("黑体", Font.BOLD, 30));
|
||||
g.drawString(des[j].charAt(k)+"",180+desTotalWidth-oneWordWidth,820+alreadyWriteLine*(dess.getHeight()+10));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
g.setFont(new Font("黑体", Font.BOLD, 28));
|
||||
g.drawString(endy,600,1158);
|
||||
g.drawString(endm,695,1158);
|
||||
@@ -196,7 +193,7 @@ public class UserCertificateServiceImpl extends ServiceImpl<UserCertificateDao,
|
||||
}
|
||||
}
|
||||
|
||||
public String generateACertificate(String no,String iconUrl,String name,String des,String endy,String endm,String endd) {
|
||||
public String generateACertificate(String no,String iconUrl,String name,String[] des,String endy,String endm,String endd) {
|
||||
try {
|
||||
Image src = ImageIO.read(new URL("https://ehh-private-01.oss-cn-beijing.aliyuncs.com/certificate/A.png"));
|
||||
// 获取图片的高和宽
|
||||
@@ -228,28 +225,33 @@ public class UserCertificateServiceImpl extends ServiceImpl<UserCertificateDao,
|
||||
int namey = 815;
|
||||
g.drawString(name, namex, namey);
|
||||
|
||||
g.setFont(new Font("黑体", Font.BOLD, 30));
|
||||
String[] str = {"自","年","月","日至","年","月","日在太湖学堂","学习,修完","课程,共计","学时,确认合格。"};
|
||||
g.setColor(Color.BLACK);
|
||||
g.setFont(new Font("宋体", Font.PLAIN, 32));
|
||||
FontMetrics dess = g.getFontMetrics();
|
||||
int alreadyWriteLine = 0; //已经写了多少行
|
||||
int nowWidth = 0; //目前一行的长度
|
||||
boolean space = true; //第一行空两格
|
||||
for (int i = 0; i < des.length(); i++) {
|
||||
int oneWordWidth = dess.charWidth(des.charAt(i)); //获取单个字符的长度
|
||||
if (nowWidth+oneWordWidth>650){
|
||||
int desTotalWidth = 50; //目前一行的长度
|
||||
for (int j = 0; j < 10; j++) {//可画字区域宽650,x 180,y 820高开始+10行间距
|
||||
for (int k=0;k<str[j].length(); k++){
|
||||
int oneWordWidth = dess.charWidth(str[j].charAt(k));//获取单个字符的长度
|
||||
desTotalWidth += oneWordWidth;
|
||||
if (desTotalWidth>650){
|
||||
alreadyWriteLine++;
|
||||
int writeY = 865 + alreadyWriteLine * (dess.getHeight()+10);//10是行间距
|
||||
g.drawString(des.charAt(i) + "", 180, writeY);
|
||||
nowWidth = 0;
|
||||
space = false;
|
||||
nowWidth += oneWordWidth;
|
||||
}else {
|
||||
int writeY = 865 + alreadyWriteLine * (dess.getHeight()+10);//10是行间距
|
||||
if (nowWidth==0&&space){//换行画
|
||||
g.drawString(des.charAt(i)+"", 180+oneWordWidth, writeY);
|
||||
nowWidth += oneWordWidth*2;
|
||||
}else {//一字一字画
|
||||
g.drawString(des.charAt(i)+"", 180+nowWidth, writeY);
|
||||
nowWidth += oneWordWidth;
|
||||
desTotalWidth = oneWordWidth;
|
||||
}
|
||||
g.setFont(new Font("宋体", Font.PLAIN, 32));
|
||||
g.drawString(str[j].charAt(k)+"",180+desTotalWidth-oneWordWidth,860+alreadyWriteLine*(dess.getHeight()+20));
|
||||
}
|
||||
if (j<des.length){
|
||||
for (int k=0;k<des[j].length(); k++){
|
||||
int oneWordWidth = dess.charWidth(des[j].charAt(k));//获取单个字符的长度
|
||||
desTotalWidth += oneWordWidth;
|
||||
if (desTotalWidth>650){
|
||||
alreadyWriteLine++;
|
||||
desTotalWidth = oneWordWidth;
|
||||
}
|
||||
g.setFont(new Font("黑体", Font.BOLD, 32));
|
||||
g.drawString(des[j].charAt(k)+"",180+desTotalWidth-oneWordWidth,860+alreadyWriteLine*(dess.getHeight()+20));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -270,7 +272,7 @@ public class UserCertificateServiceImpl extends ServiceImpl<UserCertificateDao,
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
public String generateECertificate(String no,String name,String des) {
|
||||
public String generateECertificate(String type,String no,String name,String[] edes) {
|
||||
try {
|
||||
Image src = ImageIO.read(new URL("https://ehh-private-01.oss-cn-beijing.aliyuncs.com/certificate/E.png"));
|
||||
String filename = "eee";
|
||||
@@ -305,6 +307,12 @@ public class UserCertificateServiceImpl extends ServiceImpl<UserCertificateDao,
|
||||
int alreadyWriteLine = 0; //已经写了多少行
|
||||
int nowWidth = 0; //目前一行的长度
|
||||
boolean space = true; //第一行空两格
|
||||
String des = "";
|
||||
if ("ZK".equals(type)){
|
||||
des = "has past the online-examination study of "+edes[0]+" Courses in Tai Hu Education online.";
|
||||
}else {
|
||||
des = "Has satisfactorily completed an online courseTCM on "+edes[0]+" with "+edes[1]+" course hours intotal, and has been recongnized eligibility without assessment.";
|
||||
}
|
||||
for (int i = 0; i < des.length(); i++) {
|
||||
int oneWordWidth = dess.charWidth(des.charAt(i)); //获取单个字符的长度
|
||||
if (nowWidth+oneWordWidth>700){//换行画
|
||||
@@ -343,6 +351,7 @@ public class UserCertificateServiceImpl extends ServiceImpl<UserCertificateDao,
|
||||
String name = "";
|
||||
for (int i = 0; i < sss.length; i++) {
|
||||
String ss = sss[i];
|
||||
if (!" ".equals(ss)){
|
||||
ss = ss.replace(ss.charAt(0),Character.toUpperCase(ss.charAt(0)));
|
||||
if (i==0){
|
||||
nick = ss;
|
||||
@@ -350,6 +359,7 @@ public class UserCertificateServiceImpl extends ServiceImpl<UserCertificateDao,
|
||||
name = name+" "+ss;
|
||||
}
|
||||
}
|
||||
}
|
||||
return name+" "+nick;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user