change преди 3 години
родител
ревизия
d848c2508b

+ 24 - 22
zhongzheng-system/src/main/java/com/zhongzheng/modules/base/service/impl/UserProfileServiceImpl.java

@@ -14,6 +14,7 @@ import com.zhongzheng.common.utils.SecurityUtils;
 import com.zhongzheng.modules.base.bo.UserProfileFit;
 import org.apache.poi.xwpf.usermodel.BreakType;
 import org.apache.poi.xwpf.usermodel.ParagraphAlignment;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
@@ -29,10 +30,7 @@ import com.zhongzheng.modules.base.service.IUserProfileService;
 import sun.misc.BASE64Encoder;
 
 import java.awt.*;
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
+import java.io.*;
 import java.net.HttpURLConnection;
 import java.net.URL;
 import java.util.*;
@@ -48,6 +46,9 @@ import java.util.stream.Collectors;
 @Service
 public class UserProfileServiceImpl extends ServiceImpl<UserProfileMapper, UserProfile> implements IUserProfileService {
 
+    @Value("${aliyun.oss.endpoint}")
+    private String ALIYUN_OSS_ENDPOINT;
+
     @Override
     public UserProfileVo queryById(Long id){
         UserProfileQueryBo userProfileQueryBo = new UserProfileQueryBo();
@@ -138,33 +139,34 @@ public class UserProfileServiceImpl extends ServiceImpl<UserProfileMapper, UserP
         UserProfileQueryBo userProfileQueryBo = new UserProfileQueryBo();
         userProfileQueryBo.setUserId(bo.getUserId());
         userProfileQueryBo.setGoodsId(bo.getGoodsId());
+        userProfileQueryBo.setTypeStatus(1L);
         UserProfileVo info = baseMapper.getInfo(userProfileQueryBo);
         //第一种方式
         Map<String, String> maps = JSONObject.parseObject(info.getKeyValue(),Map.class);
-        String s = String.valueOf(maps.get("data"));
         //默认配置就够用了
         TemplateEngine engine = TemplateUtil.createEngine(new TemplateConfig("templates", TemplateConfig.ResourceMode.CLASSPATH));
         Template template = engine.getTemplate("word.ftl");
         //给STRING_TEMPLATE绑定数据
         Map<String, Object> bindingMap = new HashMap<>();
-/*        bindingMap.put("name", maps.get("name").getValue());
-        bindingMap.put("s", maps.get("sex").getValue());
-        bindingMap.put("post", maps.get("apply_post").getValue());
-        bindingMap.put("idcard", maps.get("idcard").getValue());
-        bindingMap.put("phone", maps.get("telphone").getValue());
-        bindingMap.put("school", maps.get("school").getValue());
-        bindingMap.put("edu", maps.get("education").getValue());
-        bindingMap.put("major", maps.get("major").getValue());
-        bindingMap.put("cname", maps.get("unit_contact").getValue());
-        bindingMap.put("cphone", maps.get("unit_tel").getValue());
-        bindingMap.put("image",  Image2Base64("https://file-dev.xyyxt.net/oss/images/avatar/20211220/1639989015718_1121154924"));
-        bindingMap.put("y", maps.get("education").getValue());
-        bindingMap.put("m", maps.get("education").getValue());
-        bindingMap.put("d", maps.get("education").getValue());
-        bindingMap.put("time", maps.get("graduation_time").getValue());
-        bindingMap.put("year", maps.get("working_years").getValue());*/
+        bindingMap.put("name", 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",  Image2Base64(ALIYUN_OSS_ENDPOINT+"/"+JSONObject.parseObject(String.valueOf(maps.get("commitment_electr_signature")), UserProfileFit.class).getValue()));
+        bindingMap.put("y", 1);
+        bindingMap.put("m", 1);
+        bindingMap.put("d", 1);
+        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());
         //最终渲染出来的样子
-        template.render(bindingMap,new File("D:\\Download/20211214.docx"));
+        template.render(bindingMap);
+
         return "11";
     }
 

+ 1 - 0
zhongzheng-system/src/main/resources/mapper/modules/base/UserProfileMapper.xml

@@ -153,6 +153,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         FROM
         user_profile up
         where 1=1
+        and up.current_status = 0
         <if test="typeStatus != null and typeStatus !='' ">
             and up.type_status = #{typeStatus}
         </if>