优化
This commit is contained in:
@ -47,6 +47,11 @@
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-generator</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- demo模块 -->
|
||||
<!-- <dependency>-->
|
||||
|
@ -17,7 +17,13 @@
|
||||
|
||||
<dependencies>
|
||||
|
||||
|
||||
<!-- https://mvnrepository.com/artifact/com.itextpdf/itext7-core -->
|
||||
<dependency>
|
||||
<groupId>com.itextpdf</groupId>
|
||||
<artifactId>itext7-core</artifactId>
|
||||
<version>7.2.0</version>
|
||||
<type>pom</type>
|
||||
</dependency>
|
||||
|
||||
<!-- Spring框架基本的核心工具 -->
|
||||
<dependency>
|
||||
@ -158,6 +164,11 @@
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>lock4j-redisson-spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
|
@ -77,6 +77,11 @@
|
||||
<artifactId>commons-codec</artifactId>
|
||||
<version>1.15</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
|
@ -28,6 +28,11 @@
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-common</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
|
@ -34,6 +34,11 @@
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-common</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
|
@ -11,6 +11,8 @@ import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.Size;
|
||||
import java.io.Serializable;
|
||||
|
@ -28,6 +28,11 @@
|
||||
<version>5.5.12</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
|
@ -82,11 +82,11 @@ public class WgzAppCheckDailyNewspaperRes implements Serializable {
|
||||
@ApiModelProperty("备注")
|
||||
private String remark;
|
||||
|
||||
@ApiModelProperty("姓名")
|
||||
private String username;
|
||||
@ApiModelProperty("审核人姓名")
|
||||
private String auditorUserName;
|
||||
|
||||
@ApiModelProperty("头像地址")
|
||||
private String avatarName;
|
||||
private String auditorUserHead;
|
||||
|
||||
@ApiModelProperty("日报状态(0正常 1补卡)")
|
||||
private String status;
|
||||
|
@ -51,6 +51,12 @@ public class WgzReissueacard implements Serializable {
|
||||
@ApiModelProperty("打卡ID")
|
||||
private Long attendanceId;
|
||||
|
||||
/** 考勤招工申请Id */
|
||||
@Excel(name = "考勤招工申请Id")
|
||||
@ApiModelProperty("考勤招工申请Id")
|
||||
private Long applyKey;
|
||||
|
||||
|
||||
/** 状态(0上班补卡 1下班补卡) */
|
||||
@Excel(name = "状态" , readConverterExp = "0=上班补卡,1=下班补卡")
|
||||
@ApiModelProperty("状态(0上班补卡 1下班补卡)")
|
||||
|
@ -327,7 +327,7 @@ public class WgzDailyClockServiceImpl extends ServicePlusImpl<WgzDailyClockMappe
|
||||
BeanUtils.copyProperties(byId,res);
|
||||
//2、获取日报的审核人信息
|
||||
BgtUser by = userService.selectUserByUserId(byId.getAuditorUserId());
|
||||
res.setAvatarName(by.getAvatarName()).setUsername(by.getUsername());
|
||||
res.setAuditorUserHead(by.getAvatarName()).setAuditorUserName(by.getUsername());
|
||||
//3、获取招工主题
|
||||
BgtProjectRecruit byId1 = recruitService.getById(byId.getRecruitId());
|
||||
res.setRecruitName(byId1.getRecruitName());
|
||||
|
@ -4,6 +4,17 @@ import cn.hutool.core.bean.BeanUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.itextpdf.io.font.PdfEncodings;
|
||||
import com.itextpdf.io.image.ImageData;
|
||||
import com.itextpdf.io.image.ImageDataFactory;
|
||||
import com.itextpdf.kernel.colors.DeviceRgb;
|
||||
import com.itextpdf.kernel.font.PdfFont;
|
||||
import com.itextpdf.kernel.font.PdfFontFactory;
|
||||
import com.itextpdf.kernel.geom.PageSize;
|
||||
import com.itextpdf.kernel.pdf.PdfDocument;
|
||||
import com.itextpdf.kernel.pdf.PdfWriter;
|
||||
import com.itextpdf.layout.Document;
|
||||
import com.itextpdf.layout.element.Image;
|
||||
import com.ruoyi.bgt.domain.vo.BgtQuestionResult;
|
||||
import com.ruoyi.common.core.mybatisplus.core.ServicePlusImpl;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
@ -23,20 +34,23 @@ import com.ruoyi.wgz.service.IWgzQuestionBankService;
|
||||
import com.ruoyi.wgz.service.IWgzQuestionSaveService;
|
||||
import com.ruoyi.wgz.service.IWgzQuestionsConfigurationService;
|
||||
import com.ruoyi.wgz.service.IWgzUserService;
|
||||
import com.sun.scenario.effect.ImageData;
|
||||
import org.apache.poi.ss.usermodel.HorizontalAlignment;
|
||||
import org.apache.poi.wp.usermodel.Paragraph;
|
||||
import com.itextpdf.layout.properties.TextAlignment;
|
||||
import com.itextpdf.layout.element.Paragraph;
|
||||
import org.aspectj.weaver.patterns.TypePatternQuestions;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* 用户试卷存储Service业务层处理
|
||||
@ -209,13 +223,15 @@ public class WgzQuestionSaveServiceImpl extends ServicePlusImpl<WgzQuestionSaveM
|
||||
/**
|
||||
* 第二部分:分离出试卷信息
|
||||
*/
|
||||
|
||||
|
||||
// String two = two(req.getUserId(), configuration);
|
||||
// System.out.println("????????? "+two);
|
||||
// System.out.println("????????? "+two);
|
||||
// System.out.println("????????? "+two);
|
||||
return res;
|
||||
}
|
||||
|
||||
// 分离试卷信息
|
||||
public void two(Long userId,WgzQuestionsConfiguration configurationEntity) throws IOException {
|
||||
public String two(Long userId,WgzQuestionsConfiguration configurationEntity) {
|
||||
//1、组装数据
|
||||
List<PdfEntity> we = baseMapper.pdfSc(userId);
|
||||
if (!we.isEmpty()) {
|
||||
@ -262,69 +278,106 @@ public class WgzQuestionSaveServiceImpl extends ServicePlusImpl<WgzQuestionSaveM
|
||||
rs.setMultiple(two);
|
||||
rs.setEstimate(three);
|
||||
//2、生成pdf
|
||||
// generatePdf(rs);
|
||||
try {
|
||||
return generateExamPaper(rs);
|
||||
}catch (Exception e1){
|
||||
throw new RuntimeException("生成PDF试卷出现了意外,请重新提交!");
|
||||
}
|
||||
// if len(we) > 0 {
|
||||
// value, _ := dao.BusQuestionSave.Ctx(ctx).Where("openid", req.Openid).Where("correct", "1").Fields("sum(score)").Value()
|
||||
// s := configurationEntity.SingleChoice
|
||||
// m := configurationEntity.MultipleChoice
|
||||
// e := configurationEntity.Estimate
|
||||
// var rs *model.ExaminationPaperRes
|
||||
// rs = &model.ExaminationPaperRes{
|
||||
// UserName: we[0].UserName,
|
||||
// Pass: we[0].Pass,
|
||||
// SumScore: value.String(),
|
||||
// Sign: signature.Signature,
|
||||
// Openid: req.Openid,
|
||||
// }
|
||||
// var one = new(model.ExaminationPaperOne)
|
||||
// var two = new(model.ExaminationPaperOne)
|
||||
// var three = new(model.ExaminationPaperOne)
|
||||
// one.Topic = "一、单选题,共" + strconv.Itoa(s) + "道题,每小题" + strconv.FormatFloat(configurationEntity.SingleScore, 'f', -1, 64) + "分,共计" + strconv.FormatFloat(float64(s)*configurationEntity.SingleScore, 'f', -1, 64) + "分"
|
||||
// two.Topic = "二、多选题,共" + strconv.Itoa(m) + "道题,每小题" + strconv.FormatFloat(configurationEntity.MultipleScore, 'f', -1, 64) + "分,共计" + strconv.FormatFloat(float64(m)*configurationEntity.MultipleScore, 'f', -1, 64) + "分"
|
||||
// three.Topic = "三、判断题,共" + strconv.Itoa(e) + "道题,每小题" + strconv.FormatFloat(configurationEntity.EstimateScore, 'f', -1, 64) + "分,共计" + strconv.FormatFloat(float64(e)*configurationEntity.EstimateScore, 'f', -1, 64) + "分"
|
||||
// var sEntity []*model.ExaminationPaperTwo
|
||||
// var mEntity []*model.ExaminationPaperTwo
|
||||
// var eEntity []*model.ExaminationPaperTwo
|
||||
// for _, data := range we {
|
||||
// var sy *model.ExaminationPaperTwo
|
||||
// sy = &model.ExaminationPaperTwo{
|
||||
// QuestionText: data.QuestionText,
|
||||
// Options: data.Options,
|
||||
// Answer: data.Answer,
|
||||
// CorrectAnswer: data.CorrectAnswer,
|
||||
// Correct: data.Correct,
|
||||
// Score: data.Score,
|
||||
// }
|
||||
// if data.QuestionType == "1" {
|
||||
// sEntity = append(sEntity, sy)
|
||||
// } else if data.QuestionType == "2" {
|
||||
// mEntity = append(mEntity, sy)
|
||||
// } else if data.QuestionType == "3" {
|
||||
// eEntity = append(eEntity, sy)
|
||||
}
|
||||
throw new RuntimeException("未获取到试卷信息!");
|
||||
}
|
||||
|
||||
public String generateExamPaper(ExaminationPaper rs) throws IOException {
|
||||
String fileName = "exam_paper_" + System.currentTimeMillis() + ".pdf";
|
||||
String outputPath = Paths.get(System.getProperty("user.dir"), fileName).toString();
|
||||
|
||||
PdfWriter writer = new PdfWriter(outputPath);
|
||||
PdfDocument pdfDoc = new PdfDocument(writer);
|
||||
Document document = new Document(pdfDoc, PageSize.A4);
|
||||
|
||||
// 加载字体(确保 simhei.ttf 可用)
|
||||
String fontPath = "ruoyi/uploadPath/appResource/font/simhei.ttf";
|
||||
PdfFont simhei = PdfFontFactory.createFont(fontPath, PdfEncodings.IDENTITY_H);
|
||||
PdfFont simheiBold = PdfFontFactory.createFont(fontPath, PdfEncodings.IDENTITY_H);
|
||||
|
||||
// 标题
|
||||
document.setFont(simheiBold).setFontSize(36);
|
||||
|
||||
document.add(new Paragraph("《灵活用工岗前培训》")
|
||||
.setTextAlignment(TextAlignment.CENTER));
|
||||
|
||||
document.add(new Paragraph("\n"));
|
||||
|
||||
// 考生信息
|
||||
document.setFont(simhei).setFontSize(16);
|
||||
document.add(new Paragraph("姓名: " + rs.getUserName()));
|
||||
document.add(new Paragraph("及格线/总分: " + rs.getPass()));
|
||||
document.add(new Paragraph("实际得分: " + rs.getSumScore()));
|
||||
document.add(new Paragraph("\n"));
|
||||
|
||||
// 处理单选、多选、判断题
|
||||
for (int i = 1; i <= 3; i++) {
|
||||
ExaminationPaperOne ep;
|
||||
if (i == 1) {
|
||||
ep = rs.getSingle();
|
||||
} else if (i == 2) {
|
||||
ep = rs.getMultiple();
|
||||
} else {
|
||||
ep = rs.getEstimate();
|
||||
}
|
||||
|
||||
document.setFont(simhei).setFontSize(20);
|
||||
document.add(new Paragraph(ep.getTopic()));
|
||||
|
||||
document.setFont(simhei).setFontSize(12);
|
||||
List<ExaminationPaperTwo> questionList = ep.getList();
|
||||
for (int qIndex = 0; qIndex < questionList.size(); qIndex++) {
|
||||
ExaminationPaperTwo data = questionList.get(qIndex);
|
||||
String questionText = (i == 3) ?
|
||||
(qIndex + 1) + "、" + data.getQuestionText() + "( " + data.getAnswer() + " )"
|
||||
: (qIndex + 1) + "、" + replaceBrackets(data.getQuestionText(), data.getAnswer());
|
||||
|
||||
document.add(new Paragraph(questionText));
|
||||
|
||||
// 选项
|
||||
String[] options = data.getOptions().split("@");
|
||||
for (String option : options) {
|
||||
document.add(new Paragraph(" " + option));
|
||||
}
|
||||
|
||||
// 标记错误答案
|
||||
if ("2".equals(data.getCorrect())) {
|
||||
document.add(new Paragraph("正确答案为:" + data.getCorrectAnswer())
|
||||
.setFontColor(com.itextpdf.kernel.colors.ColorConstants.RED));
|
||||
}
|
||||
|
||||
document.add(new Paragraph("\n"));
|
||||
}
|
||||
}
|
||||
|
||||
// // 签名部分
|
||||
// document.add(new Paragraph("\n\n\n"));
|
||||
// document.setFont(simheiBold).setFontSize(16);
|
||||
// document.add(new Paragraph("签字:").setTextAlignment(TextAlignment.RIGHT));
|
||||
// // 嵌入签名图片
|
||||
// if (rs.getSign() != null && !rs.getSign().isEmpty()) {
|
||||
// String signPath = Paths.get(System.getProperty("user.dir"), rs.getSign()).toString();
|
||||
// File signFile = new File(signPath);
|
||||
// if (signFile.exists()) {
|
||||
// ImageData imageData = ImageDataFactory.create(signPath);
|
||||
// Image image = new Image(imageData).scaleToFit(100, 50);
|
||||
// document.add(image.setRotationAngle(Math.PI / 2));
|
||||
// }
|
||||
// }
|
||||
// one.List = sEntity
|
||||
// two.List = mEntity
|
||||
// three.List = eEntity
|
||||
// rs.Single = one
|
||||
// rs.Multiple = two
|
||||
// rs.Estimate = three
|
||||
// path, errPath := Wo(rs)
|
||||
// if errPath != nil {
|
||||
// errPath = errors.New("生成PDF试卷出现了意外,请重新提交!")
|
||||
// liberr.ErrIsNil(ctx, errPath)
|
||||
// return
|
||||
// } else {
|
||||
// path = strings.Replace(path, "resource/public", "/wxfile", 1)
|
||||
// _, err = g.DB().Insert(ctx, "bus_question_save_pdf", gdb.Map{
|
||||
// "openid": req.Openid,
|
||||
// "path": path,
|
||||
// })
|
||||
// res.PdfStr = path
|
||||
// }
|
||||
// }
|
||||
// liberr.ErrIsNil(ctx, err, "添加失败")
|
||||
|
||||
document.close();
|
||||
return outputPath;
|
||||
}
|
||||
|
||||
private static String replaceBrackets(String text, String replacement) {
|
||||
Pattern pattern = Pattern.compile("\\s*(\\s*)\\s*");
|
||||
Matcher matcher = pattern.matcher(text);
|
||||
return matcher.replaceAll("( " + replacement + " )");
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -402,4 +455,5 @@ public class WgzQuestionSaveServiceImpl extends ServicePlusImpl<WgzQuestionSaveM
|
||||
bgtQuestionResult.setTime(time);
|
||||
return bgtQuestionResult;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -174,6 +174,7 @@ public class WgzReissueacardServiceImpl extends ServicePlusImpl<WgzReissueacardM
|
||||
//5、组装补卡申请数据
|
||||
WgzReissueacard wgzReissueacard = new WgzReissueacard().
|
||||
setRecruitId(recruitApply.getRecruitId()).
|
||||
setApplyKey(recruitApply.getId()).
|
||||
setUserId(appUserId).
|
||||
setAttendanceId(attendanceInfo.getId()).
|
||||
setType(req.getType()).
|
||||
|
@ -34,7 +34,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
c.username as userName,
|
||||
c.avatar_name
|
||||
FROM
|
||||
wgz_reissueacard a
|
||||
wgz_reissueacard as a
|
||||
LEFT JOIN bgt_user b ON (a.auditor_user_id = b.user_id and b.del_flag = 0)
|
||||
LEFT JOIN wgz_user c ON (a.user_id = c.user_id and c.del_flag = 0)
|
||||
WHERE
|
||||
@ -49,11 +49,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
b.username as auditorname,
|
||||
b.avatar_name as auditorHead,
|
||||
c.username as userName,
|
||||
c.avatar_name
|
||||
c.avatar_name,
|
||||
d.recruit_name as recruitName
|
||||
FROM
|
||||
wgz_reissueacard a
|
||||
LEFT JOIN bgt_user b ON (a.auditor_user_id = b.user_id and b.del_flag = 0)
|
||||
LEFT JOIN wgz_user c ON (a.user_id = c.user_id and c.del_flag = 0)
|
||||
LEFT JOIN bgt_user b ON (a.auditor_user_id = b.user_id)
|
||||
LEFT JOIN wgz_user c ON (a.user_id = c.user_id)
|
||||
LEFT JOIN bgt_project_recruit d ON (d.id = a.recruit_id )
|
||||
WHERE
|
||||
a.id = #{id} and a.del_flag = 0
|
||||
ORDER BY
|
||||
|
BIN
ruoyi/uploadPath/appResource/font/simhei.ttf
Normal file
BIN
ruoyi/uploadPath/appResource/font/simhei.ttf
Normal file
Binary file not shown.
Reference in New Issue
Block a user