|
@@ -1,7 +1,10 @@
|
|
|
package com.zhongzheng.modules.exam.service.impl;
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
+import cn.hutool.core.convert.Convert;
|
|
|
+import cn.hutool.core.io.FileUtil;
|
|
|
import cn.hutool.core.lang.Validator;
|
|
|
+import cn.hutool.extra.template.TemplateException;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
@@ -11,6 +14,8 @@ import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.github.pagehelper.Page;
|
|
|
+import com.openhtmltopdf.swing.Java2DRenderer;
|
|
|
+import com.openhtmltopdf.util.FSImageWriter;
|
|
|
import com.zhongzheng.common.core.page.TableDataInfo;
|
|
|
import com.zhongzheng.common.exception.CustomException;
|
|
|
import com.zhongzheng.common.type.EncryptHandler;
|
|
@@ -31,6 +36,7 @@ import com.zhongzheng.modules.bank.domain.Exam;
|
|
|
import com.zhongzheng.modules.bank.domain.QuestionBusiness;
|
|
|
import com.zhongzheng.modules.bank.service.IExamService;
|
|
|
import com.zhongzheng.modules.bank.service.IQuestionBusinessService;
|
|
|
+import com.zhongzheng.modules.base.bo.UserProfileFit;
|
|
|
import com.zhongzheng.modules.base.bo.UserProfileQueryBo;
|
|
|
import com.zhongzheng.modules.base.domain.UserProfile;
|
|
|
import com.zhongzheng.modules.base.service.IUserProfileService;
|
|
@@ -55,6 +61,8 @@ import com.zhongzheng.modules.user.service.IUserService;
|
|
|
import com.zhongzheng.modules.user.service.IUserSubscribeService;
|
|
|
import com.zhongzheng.modules.user.vo.UserStudyRecordExport;
|
|
|
import com.zhongzheng.modules.user.vo.UserVo;
|
|
|
+import freemarker.template.Configuration;
|
|
|
+import freemarker.template.Template;
|
|
|
import org.apache.commons.io.IOUtils;
|
|
|
import org.apache.http.entity.ContentType;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -68,6 +76,7 @@ import javax.activation.DataHandler;
|
|
|
import javax.mail.*;
|
|
|
import javax.mail.internet.*;
|
|
|
import javax.mail.util.ByteArrayDataSource;
|
|
|
+import java.awt.image.BufferedImage;
|
|
|
import java.io.*;
|
|
|
import java.nio.file.Files;
|
|
|
import java.nio.file.Path;
|
|
@@ -119,6 +128,11 @@ public class ExamApplyServiceImpl extends ServiceImpl<ExamApplyMapper, ExamApply
|
|
|
private IUserProfileService iUserProfileService;
|
|
|
@Value("${exam.applyDelete}")
|
|
|
private String EXAM_APPLY_DELETE;
|
|
|
+ @Value("${aliyun.oss.endpoint}")
|
|
|
+ private String ALIYUN_OSS_ENDPOINT;
|
|
|
+
|
|
|
+ @Value("${zhongzheng.profile}")
|
|
|
+ private String ZHONGZHENG_PROFILE;
|
|
|
|
|
|
@Override
|
|
|
public ExamApplyVo queryById(Long applyId) {
|
|
@@ -407,6 +421,26 @@ public class ExamApplyServiceImpl extends ServiceImpl<ExamApplyMapper, ExamApply
|
|
|
|
|
|
@Override
|
|
|
public ExamUserApplyVo subscribe(ExamApplyQueryBo bo) {
|
|
|
+ //校验预约学员资料信息
|
|
|
+ UserProfile userProfile = iUserProfileService.getOne(new LambdaQueryWrapper<UserProfile>()
|
|
|
+ .eq(UserProfile::getUserId, bo.getUserId())
|
|
|
+ .eq(UserProfile::getOrderGoodsId, bo.getOrderGoodsId())
|
|
|
+ .eq(UserProfile::getGoodsId, bo.getGoodsId())
|
|
|
+ .eq(UserProfile::getStatus, 1)
|
|
|
+ .eq(UserProfile::getChangeStatus, 1)
|
|
|
+ .last("limit 1"));
|
|
|
+ if (ObjectUtils.isNull(userProfile) || ObjectUtils.isNull(userProfile.getKeyValue())){
|
|
|
+ throw new CustomException("学员资料不完善,请先完善学员资料");
|
|
|
+ }
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(userProfile.getKeyValue());
|
|
|
+ if (ObjectUtils.isNull(jsonObject.get("commitment_seal"))){
|
|
|
+ throw new CustomException("缺少带有公司印章的承诺书,请先上传!");
|
|
|
+ }
|
|
|
+ JSONObject commitmentSeal = JSONObject.parseObject(JSONObject.toJSONString(jsonObject.get("commitment_seal")));
|
|
|
+ if (ObjectUtils.isNull(commitmentSeal.get("value"))){
|
|
|
+ throw new CustomException("缺少带有公司印章的承诺书,请先上传!");
|
|
|
+ }
|
|
|
+
|
|
|
//查询学时通过情况
|
|
|
Integer countGradePeriod = baseMapper.countGradePeriod(bo);
|
|
|
if (countGradePeriod < 1) {
|
|
@@ -440,7 +474,7 @@ public class ExamApplyServiceImpl extends ServiceImpl<ExamApplyMapper, ExamApply
|
|
|
if (ObjectUtils.isNotNull(subscribe)) {
|
|
|
Long examTime = subscribe.getApplySiteExamTime();
|
|
|
//向后推15个工作日
|
|
|
- Long applyEndTime = getApplyEndTime(examTime, 20);
|
|
|
+ Long applyEndTime = getApplyEndTime(examTime, 15);
|
|
|
if (DateUtils.getNowTime() < applyEndTime){
|
|
|
throw new CustomException("成绩审核中,请等待15个工作日后再预约!");
|
|
|
}
|
|
@@ -1153,9 +1187,12 @@ public class ExamApplyServiceImpl extends ServiceImpl<ExamApplyMapper, ExamApply
|
|
|
Goods goods = iGoodsService.getById(userProfile.getGoodsId());
|
|
|
Major major = iMajorService.getById(goods.getMajorId());
|
|
|
if (ObjectUtils.isNotNull(major)){
|
|
|
- JSONObject json = JSONObject.parseObject(userProfile.getKeyValue());
|
|
|
- JSONObject sign = JSONObject.parseObject(JSONObject.toJSONString(json.get("commitment_electr_signature")));
|
|
|
- handleFile(sign,idCard,toPath,"commitment_electr_signature",major.getCategoryName());
|
|
|
+ try {
|
|
|
+ generateCommitment(userProfile.getKeyValue(),toPath,idCard,major.getCategoryName());
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ throw new CustomException("承诺书生成失败");
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
});
|
|
@@ -1185,6 +1222,57 @@ public class ExamApplyServiceImpl extends ServiceImpl<ExamApplyMapper, ExamApply
|
|
|
return content;
|
|
|
}
|
|
|
|
|
|
+ //生成承诺书
|
|
|
+ private void generateCommitment(String keyValue,String toPath,String idCard,String major)throws IOException {
|
|
|
+ int imgIndex=(int)(Math.random() * 10 );
|
|
|
+ //第一种方式
|
|
|
+ Map<String, String> maps = JSONObject.parseObject(keyValue, Map.class);
|
|
|
+
|
|
|
+ //给模板绑定数据
|
|
|
+ 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);
|
|
|
+ String fileName = idCard+"$承诺书$"+major+".jpg";
|
|
|
+ String filePath = toPath+"/"+fileName;
|
|
|
+ imageWriter.write(img, filePath);//输出路径
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
private void handleFile(JSONObject recentPhotos,String idCard,String toPath,String key,String major){
|
|
|
try {
|
|
|
if (ObjectUtils.isNotNull(recentPhotos.get("value"))){
|