|
@@ -3,6 +3,13 @@ package org.springblade.archive.service.impl;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
+import com.itextpdf.text.Document;
|
|
|
+import com.itextpdf.text.Font;
|
|
|
+import com.itextpdf.text.PageSize;
|
|
|
+import com.itextpdf.text.pdf.BaseFont;
|
|
|
+import com.itextpdf.text.pdf.PdfPCell;
|
|
|
+import com.itextpdf.text.pdf.PdfPTable;
|
|
|
+import com.itextpdf.text.pdf.PdfWriter;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
import org.springblade.archive.entity.ArchiveExpertConclusion;
|
|
@@ -11,17 +18,29 @@ import org.springblade.archive.mapper.ArchiveExpertConclusionMapper;
|
|
|
import org.springblade.archive.mapper.ArchiveExpertScoreMapper;
|
|
|
import org.springblade.archive.service.IArchiveExpertConclusionService;
|
|
|
import org.springblade.archive.service.IArchiveExpertScoreService;
|
|
|
+import org.springblade.archive.utils.ItextPdfUtils;
|
|
|
+import org.springblade.archive.utils.MyPdfPageHelper;
|
|
|
import org.springblade.common.utils.SnowFlakeUtil;
|
|
|
import org.springblade.core.log.exception.ServiceException;
|
|
|
import org.springblade.core.mp.base.BaseServiceImpl;
|
|
|
+import org.springblade.core.oss.model.BladeFile;
|
|
|
import org.springblade.core.secure.utils.AuthUtil;
|
|
|
import org.springblade.core.tool.api.R;
|
|
|
+import org.springblade.core.tool.utils.Func;
|
|
|
import org.springblade.manager.entity.ProjectInfo;
|
|
|
import org.springblade.manager.feign.ProjectClient;
|
|
|
+import org.springblade.resource.feign.NewIOSSClient;
|
|
|
+import org.springblade.system.user.entity.User;
|
|
|
+import org.springblade.system.user.feign.IUserClient;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
+import java.io.FileOutputStream;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
+import java.util.Date;
|
|
|
import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
@Service
|
|
|
@AllArgsConstructor
|
|
@@ -31,9 +50,18 @@ public class ArchiveExpertConclusionServiceImpl extends BaseServiceImpl<ArchiveE
|
|
|
|
|
|
private final ProjectClient projectClient;
|
|
|
|
|
|
+ private final IUserClient userClient;
|
|
|
+
|
|
|
+ private final NewIOSSClient newIOSSClient;
|
|
|
+ //表格高度
|
|
|
+ private static int high = 20;
|
|
|
+ //表格宽度
|
|
|
+ private static int widthPercentage = 80;
|
|
|
+
|
|
|
+
|
|
|
@Override
|
|
|
@Transactional
|
|
|
- public R saveBaseTableInfo(Long projectId, String appUrl,Long taskId) {
|
|
|
+ public R saveBaseTableInfo(Long projectId, String appUrl,Long taskId,String expertIds) {
|
|
|
//判断当前项目下是否存在抽检中的数据
|
|
|
long count = this.count(new LambdaUpdateWrapper<ArchiveExpertConclusion>()
|
|
|
.eq(ArchiveExpertConclusion::getProjectId, projectId)
|
|
@@ -191,26 +219,228 @@ public class ArchiveExpertConclusionServiceImpl extends BaseServiceImpl<ArchiveE
|
|
|
@Override
|
|
|
@Transactional
|
|
|
public void submitTable(ArchiveExpertConclusion conclusion) {
|
|
|
- //生成结论pdf
|
|
|
- //判断是否追加
|
|
|
- if (conclusion.getIsBuildScore() == 1) {
|
|
|
- String scoreUrl;
|
|
|
- //调用生成
|
|
|
- try {
|
|
|
- scoreUrl = scoreService.buildScorePdf(conclusion.getProjectId(), conclusion.getId());
|
|
|
- }catch (Exception e){
|
|
|
- throw new ServiceException("创建专家评分表PDF失败");
|
|
|
- }
|
|
|
- if (StringUtils.isNotBlank(scoreUrl)){
|
|
|
- //合并PDF
|
|
|
+ String pdfUrl = "";
|
|
|
+ try {
|
|
|
+ //生成结论pdf
|
|
|
+ pdfUrl = buildPdf(conclusion);
|
|
|
+ if (StringUtils.isBlank(pdfUrl)){
|
|
|
+ throw new ServiceException("");
|
|
|
}
|
|
|
+ }catch (Exception e){
|
|
|
+ throw new ServiceException("生成PDF失败");
|
|
|
}
|
|
|
//PDF电签
|
|
|
+ try {
|
|
|
+// pdfUrl = ;
|
|
|
+ }catch (Exception e){
|
|
|
+ throw new ServiceException("PDF电签失败");
|
|
|
+ }
|
|
|
//修改状态,插入结论PDF
|
|
|
+ conclusion.setTableUrl(pdfUrl);
|
|
|
conclusion.setStatus(2);
|
|
|
this.updateById(conclusion);
|
|
|
}
|
|
|
|
|
|
+ private String buildPdf(ArchiveExpertConclusion conclusion) throws Exception {
|
|
|
+ //获取评分基础数据
|
|
|
+ List<ArchiveExpertScore> list1 = scoreService.list(new LambdaQueryWrapper<ArchiveExpertScore>()
|
|
|
+ .eq(ArchiveExpertScore::getProjectId, conclusion.getProjectId())
|
|
|
+ .eq(ArchiveExpertScore::getConclusionId, conclusion.getId()));
|
|
|
+ Map<Integer, List<ArchiveExpertScore>> map = list1.stream().collect(Collectors.groupingBy(ArchiveExpertScore::getUnitType));
|
|
|
+ //根据专家信息获取到具体的user
|
|
|
+ String expertIds = conclusion.getExpertIds();
|
|
|
+ if (StringUtils.isBlank(expertIds)){
|
|
|
+ throw new ServiceException("获取专家账号失败");
|
|
|
+ }
|
|
|
+ List<Long> userIds = Func.toLongList(expertIds);
|
|
|
+ List<User> users = userClient.userInfoByIds(userIds);
|
|
|
+ //获取专家组长
|
|
|
+ User us = null;
|
|
|
+ for (User user : users) {
|
|
|
+ if ("1656191696348082177".equals(user.getRoleId())){
|
|
|
+ us = user;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (us == null){
|
|
|
+ throw new ServiceException("未获取到专家组长");
|
|
|
+ }
|
|
|
+ //新建一个pdf文档对象,前一个参数是纸张大小,后四个为边距
|
|
|
+ Document document = new Document(PageSize.A4, 10, 10, 80, 85);
|
|
|
+ //文件地址
|
|
|
+ String localFile = "C:\\Users\\泓创研发01\\Desktop\\"+conclusion.getId()+".pdf";
|
|
|
+ //建立一个书写器
|
|
|
+ PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(localFile));
|
|
|
+ //页尾
|
|
|
+ MyPdfPageHelper helper = new MyPdfPageHelper();
|
|
|
+ writer.setPageEvent(helper);
|
|
|
+ document.open();
|
|
|
+ //创建字体
|
|
|
+ BaseFont baseFont2 =BaseFont.createFont("C:/WINDOWS/Fonts/simsun.ttc,0", BaseFont.IDENTITY_H,BaseFont.NOT_EMBEDDED);
|
|
|
+ //字体对象,这里可以创建一个方法
|
|
|
+ Font sigFont = new Font(baseFont2, 0.1F, Font.NORMAL); //大小为0.1的正常字体
|
|
|
+ Font size13font = new Font(baseFont2, 13, Font.NORMAL); //大小为13的正常字体
|
|
|
+ Font size13bold = new Font(baseFont2, 13, Font.BOLD); //大小为13的粗字体
|
|
|
+ Font size14bold = new Font(baseFont2, 14, Font.BOLD); //大小为14的粗字体
|
|
|
+ Font size17bold = new Font(baseFont2, 17, Font.BOLD); //大小为17的正常字体
|
|
|
+
|
|
|
+ String firstText = "重庆渝北至长寿高速公路(渝长高速公路扩能)";
|
|
|
+ String secondText = "档案专项验收意见";
|
|
|
+ ItextPdfUtils.tableHeader(document,size17bold,firstText);
|
|
|
+ ItextPdfUtils.tableHeader(document,size17bold,secondText);
|
|
|
+ ItextPdfUtils.blankRow(document,size13font,20);
|
|
|
+ //创建第二行
|
|
|
+ ItextPdfUtils.tableText(document,size13font,conclusion.getForeword());
|
|
|
+ String ss ="一、项目概况";
|
|
|
+ ItextPdfUtils.rowHeader(document,ss,size14bold,83,20);
|
|
|
+ ItextPdfUtils.tableText(document,size13font,conclusion.getGeneralSituation());
|
|
|
+ String ss2 ="二、项目档案管理情况";
|
|
|
+ ItextPdfUtils.rowHeader(document,ss2,size14bold,83,20);
|
|
|
+ ItextPdfUtils.tableText(document,size13font,conclusion.getAdminCondition());
|
|
|
+ String ss3 ="三、存在问题及建议";
|
|
|
+ ItextPdfUtils.rowHeader(document,ss3,size14bold,83,20);
|
|
|
+ ItextPdfUtils.tableText(document,size13font,conclusion.getQuestionSuggest());
|
|
|
+ ItextPdfUtils.blankRow(document,size13font,60);
|
|
|
+ //落款项目
|
|
|
+ ItextPdfUtils.endRight(document,size13font,"重庆渝北至长寿高速公路(渝长高速公路扩能)",widthPercentage);
|
|
|
+ //落款档案验收组
|
|
|
+ ItextPdfUtils.endRight(document,size13font,"档案验收组",60);
|
|
|
+ //落款日期
|
|
|
+ ItextPdfUtils.endRight(document,size13font,new SimpleDateFormat("yyyy年M月dd日").format(new Date()),63);
|
|
|
+ if (conclusion.getIsBuildScore() == 1) {
|
|
|
+ //评分表
|
|
|
+ //该数组是每个表格的宽度
|
|
|
+ float[] floats = new float[5];
|
|
|
+ floats[0] = 0.48f;
|
|
|
+ floats[1] = 0.13f;
|
|
|
+ floats[2] = 0.13f;
|
|
|
+ floats[3] = 0.13f;
|
|
|
+ floats[4] = 0.13f;
|
|
|
+ //末尾表格
|
|
|
+ float[] floats2 = new float[2];
|
|
|
+ floats2[0] = 0.48f;
|
|
|
+ floats2[1] = 0.52f;
|
|
|
+ //为每个单位生成评分表,
|
|
|
+ for (int i = 1; i <= 3; i++) {
|
|
|
+ //如果当前单位没有扣分项,则跳过生成当前单位评分表
|
|
|
+ List<ArchiveExpertScore> list = map.get(i);
|
|
|
+ Boolean isMark = false;
|
|
|
+ for (ArchiveExpertScore score : list) {
|
|
|
+ if (score.getIntegralityDeduction() != 0 || score.getNormativeDeduction() != 0) {
|
|
|
+ isMark = true;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!isMark) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ //换页生成
|
|
|
+ document.newPage();
|
|
|
+ ItextPdfUtils.startLeft(document, size13font, "附件", 80);
|
|
|
+ ItextPdfUtils.blankRow(document, size13font, 10);
|
|
|
+ String title = "项目档案验收评分表";
|
|
|
+ ItextPdfUtils.tableHeader(document, size17bold, title);
|
|
|
+ //设置单位
|
|
|
+ String unitName = "";
|
|
|
+ if (i == 1) {
|
|
|
+ unitName = "总承包单位";
|
|
|
+ } else if (i == 2) {
|
|
|
+ unitName = "监理单位";
|
|
|
+ } else {
|
|
|
+ unitName = "施工单位";
|
|
|
+ }
|
|
|
+ ItextPdfUtils.rowHeader(document, unitName + ":", size13bold, 85, 30);
|
|
|
+ ItextPdfUtils.tableUnit(document, size13bold, unitName, 30);
|
|
|
+ //表头文字
|
|
|
+ String[] name = new String[]{"项目", "完整性", "扣分", "规范性", "扣分"};
|
|
|
+ //创建第二行,并设置第二行中的表格数
|
|
|
+ PdfPTable twoTable = new PdfPTable(name.length);
|
|
|
+ twoTable.setWidthPercentage(widthPercentage);
|
|
|
+ //设置表格的宽度
|
|
|
+ twoTable.setTotalWidth(floats);
|
|
|
+ //循环将表头数据添加到第二行表格中
|
|
|
+ for (int j = 0; j < name.length; j++) {
|
|
|
+ PdfPCell pdfPCell = ItextPdfUtils.pdfTableStyle7(name[j], size13font, 30);
|
|
|
+ twoTable.addCell(pdfPCell);
|
|
|
+ }
|
|
|
+ document.add(twoTable);
|
|
|
+ //将数据放入表格中
|
|
|
+
|
|
|
+ int allScore = 0;
|
|
|
+ int allPoints = 0;
|
|
|
+ for (int j = 0; j < list.size(); j++) {
|
|
|
+ PdfPTable dataTable = new PdfPTable(5);
|
|
|
+ dataTable.setWidths(floats);
|
|
|
+ dataTable.setWidthPercentage(widthPercentage);
|
|
|
+ ArchiveExpertScore score = list.get(j);
|
|
|
+ dataTable.addCell(ItextPdfUtils.pdfTableStyle7(score.getScoreItem(), size13font, 25));
|
|
|
+ dataTable.addCell(ItextPdfUtils.pdfTableStyle7(score.getIntegrality() + "", size13font, 25));
|
|
|
+ dataTable.addCell(ItextPdfUtils.pdfTableStyle7(score.getIntegralityDeduction() + "", size13font, 25));
|
|
|
+ dataTable.addCell(ItextPdfUtils.pdfTableStyle7(score.getNormative() + "", size13font, 25));
|
|
|
+ dataTable.addCell(ItextPdfUtils.pdfTableStyle7(score.getNormativeDeduction() + "", size13font, 25));
|
|
|
+ document.add(dataTable);
|
|
|
+ allScore += score.getIntegrality() + score.getNormative();
|
|
|
+ allPoints += score.getIntegralityDeduction() + score.getNormativeDeduction();
|
|
|
+ }
|
|
|
+ //末尾统计行
|
|
|
+ PdfPTable statRow = new PdfPTable(2);
|
|
|
+ statRow.setWidths(floats2);
|
|
|
+ statRow.setWidthPercentage(widthPercentage);
|
|
|
+ PdfPCell leftCell = ItextPdfUtils.pdfTableStyle7("总得分", size13font, 25);
|
|
|
+ statRow.addCell(leftCell);
|
|
|
+ PdfPCell rightCell = ItextPdfUtils.pdfTableStyle7(allScore - allPoints + "", size13font, 25);
|
|
|
+ statRow.addCell(rightCell);
|
|
|
+ document.add(statRow);
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //生成签名表
|
|
|
+ document.newPage();
|
|
|
+ ItextPdfUtils.startLeft(document,size13font,"附件",80);
|
|
|
+ ItextPdfUtils.blankRow(document,size13font,10);
|
|
|
+ ItextPdfUtils.tableHeader(document,size17bold,firstText);
|
|
|
+ ItextPdfUtils.tableHeader(document,size17bold,"工程档案验收组成员签字表");
|
|
|
+ ItextPdfUtils.blankRow(document,size13font,30);
|
|
|
+ ItextPdfUtils.rowHeader2(document,"组 长:",size13font,us.getName()+us.getPhone().substring(0,3),sigFont);
|
|
|
+ ItextPdfUtils.blankRow(document,size13font,10);
|
|
|
+ //该数组是每个表格的宽度
|
|
|
+ float[] floats5 = new float[4];
|
|
|
+ floats5[0] = 0.1f;
|
|
|
+ floats5[1] = 0.4f;
|
|
|
+ floats5[2] = 0.25f;
|
|
|
+ floats5[3] = 0.25f;
|
|
|
+ //表头文字
|
|
|
+ String[] name2 = new String[]{"姓名", "单位", "职务职称", "签名"};
|
|
|
+ //创建第二行,并设置第二行中的表格数
|
|
|
+ PdfPTable twoTable2 = new PdfPTable(name2.length);
|
|
|
+ twoTable2.setWidthPercentage(widthPercentage);
|
|
|
+ twoTable2.setTotalWidth(floats5);
|
|
|
+ //循环将表头数据添加到第二行表格中
|
|
|
+ for (int i = 0; i < name2.length; i++) {
|
|
|
+ PdfPCell pdfPCell = ItextPdfUtils.pdfTableStyle6(name2[i], size13font, 35, true, true);
|
|
|
+ twoTable2.addCell(pdfPCell);
|
|
|
+ }
|
|
|
+ document.add(twoTable2);
|
|
|
+ //将数据放入表格中
|
|
|
+ for (int i = 0; i < users.size(); i++) {
|
|
|
+ User user = users.get(i);
|
|
|
+ PdfPTable dataTable = new PdfPTable(4);
|
|
|
+ dataTable.setWidths(floats5);
|
|
|
+ dataTable.setWidthPercentage(80);
|
|
|
+ dataTable.addCell(ItextPdfUtils.pdfTableStyle6(user.getName(), size13font, 50, true, true));
|
|
|
+ dataTable.addCell(ItextPdfUtils.pdfTableStyle6(user.getCompanyName(), size13font, 50, true, true));
|
|
|
+ dataTable.addCell(ItextPdfUtils.pdfTableStyle6(user.getPosition(), size13font, 50, true, true));
|
|
|
+ dataTable.addCell(ItextPdfUtils.pdfTableStyle6(user.getName()+user.getPhone().substring(0,3), sigFont, 50, true, true));
|
|
|
+ document.add(dataTable);
|
|
|
+ }
|
|
|
+ document.close();
|
|
|
+ writer.close();
|
|
|
+ BladeFile bladeFile = newIOSSClient.uploadFile("file.pdf", localFile);
|
|
|
+ if (bladeFile == null || StringUtils.isBlank(bladeFile.getLink())){
|
|
|
+ throw new ServiceException("文件上传失败");
|
|
|
+ }
|
|
|
+ return bladeFile.getLink();
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public Boolean checkSubmit(Long projectId) {
|
|
|
//判断当前用户职位是否为专家组长,专家组长允许提交
|