|
@@ -8,16 +8,23 @@ import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
|
|
+import com.google.zxing.BarcodeFormat;
|
|
|
+import com.google.zxing.common.BitMatrix;
|
|
|
+import com.google.zxing.qrcode.QRCodeWriter;
|
|
|
import com.zhongzheng.common.annotation.DataScope;
|
|
|
import com.zhongzheng.common.core.redis.RedisCache;
|
|
|
import com.zhongzheng.common.exception.CustomException;
|
|
|
import com.zhongzheng.common.utils.DateUtils;
|
|
|
import com.zhongzheng.common.utils.ServletUtils;
|
|
|
+import com.zhongzheng.modules.alioss.service.OssService;
|
|
|
import com.zhongzheng.modules.alisms.service.IAliSmsService;
|
|
|
import com.zhongzheng.modules.base.bo.ConsoleQueryBo;
|
|
|
import com.zhongzheng.modules.course.domain.CourseBusiness;
|
|
|
+import com.zhongzheng.modules.course.domain.Major;
|
|
|
import com.zhongzheng.modules.course.mapper.CourseMapper;
|
|
|
import com.zhongzheng.modules.course.service.ICourseService;
|
|
|
+import com.zhongzheng.modules.course.service.IMajorService;
|
|
|
import com.zhongzheng.modules.exam.bo.ExamApplyQueryBo;
|
|
|
import com.zhongzheng.modules.exam.bo.ExamApplySiteTimeJson;
|
|
|
import com.zhongzheng.modules.exam.mapper.ExamApplyMapper;
|
|
@@ -25,6 +32,7 @@ import com.zhongzheng.modules.exam.vo.ExamApplySiteTimeVo;
|
|
|
import com.zhongzheng.modules.exam.vo.ExamApplySiteVo;
|
|
|
import com.zhongzheng.modules.exam.vo.ExamApplyVo;
|
|
|
import com.zhongzheng.modules.exam.vo.ExamUserApplyVo;
|
|
|
+import com.zhongzheng.modules.goods.domain.Goods;
|
|
|
import com.zhongzheng.modules.goods.service.IGoodsService;
|
|
|
import com.zhongzheng.modules.goods.vo.GoodsVo;
|
|
|
import com.zhongzheng.modules.grade.vo.ClassGradeVo;
|
|
@@ -39,6 +47,7 @@ import com.zhongzheng.modules.user.domain.UserExamGoods;
|
|
|
import com.zhongzheng.modules.user.service.IUserExamGoodsService;
|
|
|
import com.zhongzheng.modules.user.service.IUserService;
|
|
|
import com.zhongzheng.modules.user.vo.*;
|
|
|
+import org.apache.poi.hpsf.Thumbnail;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
@@ -50,11 +59,18 @@ import com.zhongzheng.modules.user.domain.UserSubscribe;
|
|
|
import com.zhongzheng.modules.user.mapper.UserSubscribeMapper;
|
|
|
import com.zhongzheng.modules.user.service.IUserSubscribeService;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
+import org.springframework.web.multipart.MultipartFile;
|
|
|
import org.thymeleaf.util.StringUtils;
|
|
|
|
|
|
+import javax.imageio.ImageIO;
|
|
|
+import java.awt.*;
|
|
|
+import java.awt.image.BufferedImage;
|
|
|
+import java.io.*;
|
|
|
+import java.net.URL;
|
|
|
import java.text.ParseException;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.*;
|
|
|
+import java.util.List;
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
@@ -91,6 +107,9 @@ public class UserSubscribeServiceImpl extends ServiceImpl<UserSubscribeMapper, U
|
|
|
@Autowired
|
|
|
private IUserService iUserService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private IMajorService majorService;
|
|
|
+
|
|
|
@Value("${aliyun.sms.cancellationReminder}")
|
|
|
private String cancellationReminder;
|
|
|
|
|
@@ -103,6 +122,12 @@ public class UserSubscribeServiceImpl extends ServiceImpl<UserSubscribeMapper, U
|
|
|
@Value("${aliyun.sms.newExamFail}")
|
|
|
private String newExamFail;
|
|
|
|
|
|
+ @Value("${aliyun.oss.endpoint}")
|
|
|
+ private String ALIYUN_OSS_ENDPOINT;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private OssService ossService;
|
|
|
+
|
|
|
|
|
|
|
|
|
@Autowired
|
|
@@ -1597,4 +1622,80 @@ public class UserSubscribeServiceImpl extends ServiceImpl<UserSubscribeMapper, U
|
|
|
public Integer getConsoleTestSubscribeNum(ConsoleQueryBo bo) {
|
|
|
return baseMapper.getConsoleTestSubscribeNum(bo);
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Boolean signReport(MultipartFile image, UserSubscribeSignReportBo bo) {
|
|
|
+ //获取考试预约信息
|
|
|
+ UserSubscribe userSubscribe = getById(bo.getSubscribeId());
|
|
|
+ if (ObjectUtils.isNull(userSubscribe)){
|
|
|
+ throw new CustomException("预约考试信息获取失败");
|
|
|
+ }
|
|
|
+ //获取考试专业
|
|
|
+ Goods goods = iGoodsService.getById(userSubscribe.getGoodsId());
|
|
|
+ Major major = majorService.getById(goods.getMajorId());
|
|
|
+ bo.setMajor(major.getCategoryName());
|
|
|
+ String applyDate = DateUtils.timestampToDateFormat(Long.valueOf(userSubscribe.getApplySiteExamTime()), "yyyy-MM-dd");
|
|
|
+ bo.setApplySiteStartTime(String.format("%s %s",applyDate,userSubscribe.getApplySiteStartTime()));
|
|
|
+ bo.setSeatNumber(userSubscribe.getSeatNumber());
|
|
|
+ //获取承诺书模板
|
|
|
+ String reportUrl = drawReport(image, bo);
|
|
|
+ userSubscribe.setReportStatus(1);//已签署
|
|
|
+ userSubscribe.setReportFile(reportUrl);
|
|
|
+ updateById(userSubscribe);
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ private String drawReport(MultipartFile image, UserSubscribeSignReportBo bo){
|
|
|
+ Font font = new Font("宋体", Font.BOLD, 48);// 添加字体的属性设置 微软雅黑
|
|
|
+ String imgName = null;
|
|
|
+ try {
|
|
|
+ // 获取模板
|
|
|
+ String imageUrl = ALIYUN_OSS_ENDPOINT+"/oss/images/file/20220825/1661411743620.png";
|
|
|
+ URL url = new URL(imageUrl);
|
|
|
+ BufferedImage imageLocal = ImageIO.read(url);
|
|
|
+ // 以本地图片为模板
|
|
|
+ Graphics2D g = imageLocal.createGraphics();
|
|
|
+ g.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON);
|
|
|
+ // 设置文本样式
|
|
|
+ g.setFont(font);
|
|
|
+ g.setColor(Color.BLACK);
|
|
|
+
|
|
|
+ g.drawString(bo.getApplySiteStartTime(), 668, 3341);
|
|
|
+ g.drawString(bo.getMajor(), 673, 3464);
|
|
|
+ g.drawString(bo.getSeatNumber(), 615, 3603);
|
|
|
+ g.drawString(bo.getIdCard(), 730, 3732);
|
|
|
+ g.drawString(bo.getPhone(), 678, 3864);
|
|
|
+ g.drawString(DateUtils.getDate(), 682, 3988);
|
|
|
+
|
|
|
+ //用户签名
|
|
|
+ ByteArrayInputStream inputStream = new ByteArrayInputStream(image.getBytes());
|
|
|
+ BufferedImage qrImage = ImageIO.read(inputStream);
|
|
|
+ Image scaledInstance = qrImage.getScaledInstance(304, 251, Image.SCALE_AREA_AVERAGING);
|
|
|
+//
|
|
|
+ // 在模板上添加用户签名图片(地址,左边距,上边距,图片宽度,图片高度,未知)
|
|
|
+ g.drawImage(scaledInstance, 636, 4169, 304, 251, null);
|
|
|
+ // 完成模板修改
|
|
|
+ g.dispose();
|
|
|
+ //上传OSS
|
|
|
+ InputStream is = bufferedImageToInputStream(imageLocal);
|
|
|
+ String ossPath = ossService.uploadInputStream(is,7);
|
|
|
+ return ossPath;
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ return imgName;
|
|
|
+ }
|
|
|
+
|
|
|
+ private InputStream bufferedImageToInputStream(BufferedImage image){
|
|
|
+ ByteArrayOutputStream os = new ByteArrayOutputStream();
|
|
|
+ try {
|
|
|
+ ImageIO.write(image, "jpg", os);
|
|
|
+ InputStream input = new ByteArrayInputStream(os.toByteArray());
|
|
|
+ return input;
|
|
|
+ } catch (IOException e) {
|
|
|
+
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
}
|