Commit 237ee3b6 authored by liuyang's avatar liuyang

修改证书模板

parent 9a6c9942
...@@ -65,7 +65,7 @@ public class MdpController extends BaseController<Object> { ...@@ -65,7 +65,7 @@ public class MdpController extends BaseController<Object> {
return propertis.getConfigs().get(1).getAppid(); return propertis.getConfigs().get(1).getAppid();
} }
private String uploadAvatarPath = File.separator + "mdp" + File.separator + "uploadAvatar"; private String uploadAvatarPath = File.separator + "mdp" + File.separator + "uploadAvatar";
private String certificateTemplate = "classpath:certificate.jpeg"; private String certificateTemplate = "classpath:certificate.png";
private String userCertificatePath = File.separator + "mdp" + File.separator + "certificate"; private String userCertificatePath = File.separator + "mdp" + File.separator + "certificate";
@Auth(verifyLogin = false,verifyURL = false) @Auth(verifyLogin = false,verifyURL = false)
...@@ -484,14 +484,17 @@ public class MdpController extends BaseController<Object> { ...@@ -484,14 +484,17 @@ public class MdpController extends BaseController<Object> {
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),200,600)); String year = now.get(Calendar.YEAR) + "";
addTexts.add(new CertificateVo(code,new Font("宋体",Font.BOLD,30),280,1310)); String month = now.get(Calendar.MONTH) + 1 >=10 ? "" + (now.get(Calendar.MONTH) + 1) : "0" + (now.get(Calendar.MONTH) + 1);
addTexts.add(new CertificateVo(now.get(Calendar.YEAR)+"",new Font("宋体",Font.PLAIN,30),550,1245)); String day = now.get(Calendar.DATE) >=10 ? "" + now.get(Calendar.DATE) : "0" + now.get(Calendar.DATE);
addTexts.add(new CertificateVo(now.get(Calendar.MONTH) +1+"",new Font("宋体",Font.PLAIN,30),680,1245)); addTexts.add(new CertificateVo(user.getName(),new Font("宋体",Font.BOLD,50),190,570));
addTexts.add(new CertificateVo(now.get(Calendar.DATE)+"",new Font("宋体",Font.PLAIN,30),790,1245)); addTexts.add(new CertificateVo(code,new Font("宋体",Font.BOLD,30),270,1265));
String outputFilePath = rb.getString("file_path") + this.userCertificatePath + File.separator + user.getId() + ".jpeg"; 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); 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) { private String getCollectBloodCode(User user) {
......
...@@ -111,16 +111,19 @@ public class UserUtils { ...@@ -111,16 +111,19 @@ public class UserUtils {
// } // }
List<CertificateVo> addTexts = Lists.newArrayList(); List<CertificateVo> addTexts = Lists.newArrayList();
Calendar now = Calendar.getInstance(); Calendar now = Calendar.getInstance();
addTexts.add(new CertificateVo("刘扬",new Font("宋体",Font.PLAIN,50),200,600)); String year = now.get(Calendar.YEAR) + "";
addTexts.add(new CertificateVo("0222189765",new Font("宋体",Font.PLAIN,30),280,1310)); String month = now.get(Calendar.MONTH) + 1 >=10 ? "" + (now.get(Calendar.MONTH) + 1) : "0" + (now.get(Calendar.MONTH) + 1);
addTexts.add(new CertificateVo(now.get(Calendar.YEAR)+"",new Font("宋体",Font.PLAIN,30),550,1245)); String day = now.get(Calendar.DATE) >=10 ? "" + now.get(Calendar.DATE) : "0" + now.get(Calendar.DATE);
addTexts.add(new CertificateVo(now.get(Calendar.MONTH) +1+"",new Font("宋体",Font.PLAIN,30),690,1245)); addTexts.add(new CertificateVo("刘扬",new Font("宋体",Font.BOLD,50),190,570));
addTexts.add(new CertificateVo(now.get(Calendar.DATE)+"",new Font("宋体",Font.PLAIN,30),790,1245)); addTexts.add(new CertificateVo("02223456",new Font("宋体",Font.BOLD,30),270,1265));
UserUtils.generateCertificate("classpath:certificate.jpeg","/Users/liuyang/Pictures/certificate.jpeg",addTexts); 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){ }catch (IOException e){
e.printStackTrace();; e.printStackTrace();;
} }
} }
*/ */
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment