|
@@ -223,6 +223,70 @@ public class UserProfileServiceImpl extends ServiceImpl<UserProfileMapper, UserP
|
|
return this.removeByIds(ids);
|
|
return this.removeByIds(ids);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
+ public String addWordV2(UserProfileAddBo bo) throws IOException {
|
|
|
|
+ if(Validator.isEmpty(bo.getKeyValue())){
|
|
|
|
+ throw new CustomException("参数错误");
|
|
|
|
+ }
|
|
|
|
+ int imgIndex=(int)(Math.random() * 10 );
|
|
|
|
+ //第一种方式
|
|
|
|
+ Map<String, String> maps = JSONObject.parseObject(bo.getKeyValue(), Map.class);
|
|
|
|
+
|
|
|
|
+ /* TemplateEngine engine = TemplateUtil.createEngine(new TemplateConfig("templates", TemplateConfig.ResourceMode.CLASSPATH));
|
|
|
|
+ Template template = engine.getTemplate("word.ftl");*/
|
|
|
|
+ //给模板绑定数据
|
|
|
|
+ Calendar rightNow = Calendar.getInstance();
|
|
|
|
+ Map<String, Object> bindingMap = new HashMap<>();
|
|
|
|
+ bindingMap.put("username", JSONObject.parseObject(String.valueOf(maps.get("name")), UserProfileFit.class).getValue());
|
|
|
|
+ bindingMap.put("s", JSONObject.parseObject(String.valueOf(maps.get("sex")), UserProfileFit.class).getValue());
|
|
|
|
+ bindingMap.put("post", JSONObject.parseObject(String.valueOf(maps.get("apply_post")), UserProfileFit.class).getValue());
|
|
|
|
+ bindingMap.put("idcard", JSONObject.parseObject(String.valueOf(maps.get("idcard")), UserProfileFit.class).getValue());
|
|
|
|
+ bindingMap.put("phone", JSONObject.parseObject(String.valueOf(maps.get("telphone")), UserProfileFit.class).getValue());
|
|
|
|
+ bindingMap.put("school", JSONObject.parseObject(String.valueOf(maps.get("school")), UserProfileFit.class).getValue());
|
|
|
|
+ bindingMap.put("edu", JSONObject.parseObject(String.valueOf(maps.get("education")), UserProfileFit.class).getValue());
|
|
|
|
+ bindingMap.put("major", JSONObject.parseObject(String.valueOf(maps.get("major")), UserProfileFit.class).getValue());
|
|
|
|
+ bindingMap.put("cname", JSONObject.parseObject(String.valueOf(maps.get("unit_contact")), UserProfileFit.class).getValue());
|
|
|
|
+ bindingMap.put("cphone", JSONObject.parseObject(String.valueOf(maps.get("unit_tel")), UserProfileFit.class).getValue());
|
|
|
|
+ bindingMap.put("image", ALIYUN_OSS_ENDPOINT + "/" + JSONObject.parseObject(String.valueOf(maps.get("commitment_electr_signature")), UserProfileFit.class).getValue());
|
|
|
|
+ bindingMap.put("y", Convert.toStr(rightNow.get(Calendar.YEAR)));
|
|
|
|
+ bindingMap.put("m", rightNow.get(Calendar.MONTH) + 1);
|
|
|
|
+ bindingMap.put("d", rightNow.get(Calendar.DAY_OF_MONTH));
|
|
|
|
+ bindingMap.put("time", JSONObject.parseObject(String.valueOf(maps.get("graduation_time")), UserProfileFit.class).getValue());
|
|
|
|
+ bindingMap.put("year", JSONObject.parseObject(String.valueOf(maps.get("working_years")), UserProfileFit.class).getValue());
|
|
|
|
+ File touch = FileUtil.touch(ZHONGZHENG_PROFILE + imgIndex+"word.html");
|
|
|
|
+ //默认freemake配置
|
|
|
|
+ Configuration configuration = new Configuration();
|
|
|
|
+ configuration.setDefaultEncoding("UTF-8");
|
|
|
|
+ configuration.setClassForTemplateLoading(this.getClass(), "/templates");
|
|
|
|
+ Template template = configuration.getTemplate("wordPhone.ftl");
|
|
|
|
+ Writer out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(touch), "UTF-8"));
|
|
|
|
+ try {
|
|
|
|
+ //写入数据
|
|
|
|
+ template.process(bindingMap, out);
|
|
|
|
+ out.flush();
|
|
|
|
+ out.close();
|
|
|
|
+
|
|
|
|
+ } catch (TemplateException | freemarker.template.TemplateException e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ }
|
|
|
|
+ //将模板输出为图片
|
|
|
|
+ final Java2DRenderer renderer = new Java2DRenderer(touch, 1000, 1000);
|
|
|
|
+ final BufferedImage img = renderer.getImage();
|
|
|
|
+ final FSImageWriter imageWriter = new FSImageWriter();
|
|
|
|
+ imageWriter.setWriteCompressionQuality(1.0f);
|
|
|
|
+ imageWriter.write(img, ZHONGZHENG_PROFILE + imgIndex+ "wordJpg.jpg");//输出路径
|
|
|
|
+
|
|
|
|
+ OssRequest ossRequest = new OssRequest();
|
|
|
|
+ FileInputStream fileInputStream = new FileInputStream(ZHONGZHENG_PROFILE + imgIndex+ "wordJpg.jpg");
|
|
|
|
+ MultipartFile multipartFile = new MockMultipartFile(ZHONGZHENG_PROFILE + imgIndex+ "wordJpg.jpg", ZHONGZHENG_PROFILE+ imgIndex + "wordJpg.jpg",
|
|
|
|
+ ContentType.APPLICATION_OCTET_STREAM.toString(), fileInputStream);
|
|
|
|
+ ossRequest.setFile(multipartFile);
|
|
|
|
+ ossRequest.setImageStatus(6);
|
|
|
|
+ //上传阿里云
|
|
|
|
+ String upload = ossService.upload(ossRequest);
|
|
|
|
+ return upload;
|
|
|
|
+ }
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
public String addWord(UserProfileAddBo bo) throws IOException {
|
|
public String addWord(UserProfileAddBo bo) throws IOException {
|
|
UserProfileQueryBo userProfileQueryBo = new UserProfileQueryBo();
|
|
UserProfileQueryBo userProfileQueryBo = new UserProfileQueryBo();
|