|
@@ -18,11 +18,14 @@ import com.ruoyi.framework.web.controller.BaseController;
|
|
|
import com.ruoyi.framework.web.domain.AjaxResult;
|
|
|
import com.ruoyi.framework.web.page.TableDataInfo;
|
|
|
import com.ruoyi.project.officeConvert.OfficeConvertController;
|
|
|
+import com.ruoyi.project.sems.domain.TMeasureLoop;
|
|
|
import com.ruoyi.project.sems.domain.TMeasureRecord;
|
|
|
import com.ruoyi.project.sems.domain.TMeasureStress;
|
|
|
import com.ruoyi.project.sems.domain.TMeasureThickness;
|
|
|
import com.ruoyi.project.sems.mapper.TMeasureStressMapper;
|
|
|
+import com.ruoyi.project.sems.service.ITMeasureLoopService;
|
|
|
import com.ruoyi.project.sems.service.ITMeasureRecordService;
|
|
|
+import com.ruoyi.project.sems.service.ITMeasureStressService;
|
|
|
import com.ruoyi.project.sems.service.ITMeasureThicknessService;
|
|
|
import freemarker.template.Template;
|
|
|
import io.jsonwebtoken.lang.Assert;
|
|
@@ -71,6 +74,11 @@ public class TMeasureThicknessController extends BaseController {
|
|
|
private OfficeConvertController officeConvertController;
|
|
|
@Resource
|
|
|
private TMeasureStressMapper tMeasureStressMapper;
|
|
|
+ @Autowired
|
|
|
+ private ITMeasureStressService tMeasureStressService;
|
|
|
+ @Autowired
|
|
|
+ private ITMeasureLoopService tMeasureLoopService;
|
|
|
+
|
|
|
|
|
|
// 美标(ASME)与国标B系列外径对照表(单位:mm)
|
|
|
private static final Map<Double, Double> INCH_TO_MM_MAP = new HashMap<>();
|
|
@@ -225,30 +233,39 @@ public class TMeasureThicknessController extends BaseController {
|
|
|
} else if (j == 22) {
|
|
|
//温度(℃)
|
|
|
entity.setTemperature(cellValue);
|
|
|
- } else if (j == 23) {
|
|
|
+ }else if (j == 23) {
|
|
|
+ //设备类型
|
|
|
+ entity.setDevType(cellValue);
|
|
|
+ }else if (j == 24) {
|
|
|
+ //设计温度(℃)
|
|
|
+ entity.setDesTemp(cellValue);
|
|
|
+ }else if (j == 25) {
|
|
|
+ //设计压力
|
|
|
+ entity.setDesPressure(cellValue);
|
|
|
+ } else if (j == 26) {
|
|
|
//腐蚀类型
|
|
|
entity.setCorrosionType(cellValue);
|
|
|
- } else if (j == 24) {
|
|
|
+ } else if (j == 27) {
|
|
|
entity.setAnalysis(cellValue);//原因分析
|
|
|
- } else if (j == 25) {
|
|
|
+ } else if (j == 28) {
|
|
|
entity.setMethodCause(cellValue);//治理方法及依据
|
|
|
- } else if (j == 26) {
|
|
|
+ } else if (j == 29) {
|
|
|
entity.setEffectTracing(cellValue); //效果跟踪
|
|
|
- } else if (j == 27) {
|
|
|
+ } else if (j == 30) {
|
|
|
entity.setRaiser(cellValue);//提出人
|
|
|
- } else if (j == 28) {
|
|
|
+ } else if (j == 31) {
|
|
|
if (cellValue.length() > 3) {//提出时间
|
|
|
entity.setRaiserDate(new SimpleDateFormat(DateUtils.getDateFormat(cellValue)).parse(cellValue));
|
|
|
}
|
|
|
- } else if (j == 29) {
|
|
|
+ } else if (j == 32) {
|
|
|
entity.setOtherContent(cellValue);//其他检测方法内容
|
|
|
- } else if (j == 30) {
|
|
|
+ } else if (j == 33) {
|
|
|
entity.setRecorder(cellValue);//记录人
|
|
|
- } else if (j == 31) {
|
|
|
+ } else if (j == 34) {
|
|
|
if (cellValue.length() > 3) {//记录时间
|
|
|
entity.setRecorderDate(new SimpleDateFormat(DateUtils.getDateFormat(cellValue)).parse(cellValue));
|
|
|
}
|
|
|
- } else if (j == 32) {
|
|
|
+ } else if (j == 35) {
|
|
|
entity.setRemarks(cellValue);//备注
|
|
|
}
|
|
|
}
|
|
@@ -518,33 +535,66 @@ public class TMeasureThicknessController extends BaseController {
|
|
|
|
|
|
/**
|
|
|
* @param id 生成文件名
|
|
|
- * @return
|
|
|
- * @throws IOException
|
|
|
+ * @return 合并后的 PDF 访问路径
|
|
|
+ * @throws IOException 如果生成或合并过程出错
|
|
|
*/
|
|
|
public String PreView(Long id) throws IOException {
|
|
|
- //根据ID查询并生成
|
|
|
+ // 根据ID查询并生成
|
|
|
TMeasureThickness t = tMeasureThicknessService.selectTMeasureThicknessById(id);
|
|
|
String url = this.createcheck(t);
|
|
|
+
|
|
|
if (StringUtils.isNotEmpty(t.getCheckUrl())) {
|
|
|
- //合并PDF
|
|
|
- logger.info("url:" + url);
|
|
|
- // 将路径字符串转换为Path对象
|
|
|
+ logger.info("url: " + url);
|
|
|
+
|
|
|
+ // 生成第1个 PDF 文件(word 转 pdf)
|
|
|
Path path = Paths.get(url);
|
|
|
- // 获取文件名
|
|
|
String fileName = path.getFileName().toString();
|
|
|
fileName = officeConvertController.wordTransPdf(url);
|
|
|
String filePathOne = RuoYiConfig.getProfile() + "/" + fileName.replace("/profile", "");
|
|
|
+
|
|
|
+ // 第2个 PDF 文件(测厚位置)
|
|
|
String filePathTwo = RuoYiConfig.getProfile() + "/" + t.getCheckUrl().replace("/profile", "");
|
|
|
+ // 第3个 PDF 文件(腐蚀置)
|
|
|
+ String filePathThree = RuoYiConfig.getProfile() + "/" + t.getLocationUrl().replace("/profile", "");
|
|
|
+
|
|
|
+ // 第3.5个 PDF 文件(原因附近)
|
|
|
+ String filePathAnalysis = RuoYiConfig.getProfile() + "/" + t.getAnalysisUrl().replace("/profile", "");
|
|
|
+
|
|
|
+
|
|
|
+ // 合并多个 PDF
|
|
|
+ List<String> pdfList = new ArrayList<>();
|
|
|
+ pdfList.add(filePathOne);
|
|
|
+ pdfList.add(filePathTwo);
|
|
|
+ pdfList.add(filePathThree);
|
|
|
+ pdfList.add(filePathAnalysis);
|
|
|
+ // 第4个 PDF 文件(回路图)
|
|
|
+ TMeasureLoop tMeasureLoop = new TMeasureLoop();
|
|
|
+ tMeasureLoop.setLoopNo(t.getLoopNo());
|
|
|
+ tMeasureLoop.setPlantCode(t.getPlantCode());
|
|
|
+ List<TMeasureLoop> list = tMeasureLoopService.selectTMeasureLoopUrl(tMeasureLoop);
|
|
|
+ if (list.size() > 0) {
|
|
|
+ String filePathFour = RuoYiConfig.getProfile() + "/" + list.get(0).getLoopUrl().replace("/profile", "");
|
|
|
+ // 合并多个 PDF
|
|
|
+ pdfList.add(filePathFour);
|
|
|
+ }
|
|
|
+ // 合并文件输出路径
|
|
|
String newPdfPath = "sems/measure/" + t.getId() + ".pdf";
|
|
|
- logger.info("newPdfPath:" + newPdfPath);
|
|
|
- logger.info("filePathOne:" + filePathOne);
|
|
|
- logger.info("filePathTwo:" + filePathTwo);
|
|
|
- PDFUtil.mergeTwoPdfs(filePathOne, filePathTwo, RuoYiConfig.getProfile() + "/" + newPdfPath);
|
|
|
+ String outputFullPath = RuoYiConfig.getProfile() + "/" + newPdfPath;
|
|
|
+
|
|
|
+ logger.info("filePathOne: " + filePathOne);
|
|
|
+ logger.info("filePathTwo: " + filePathTwo);
|
|
|
+ logger.info("outputPath: " + outputFullPath);
|
|
|
+
|
|
|
+
|
|
|
+ PDFUtil.mergeMultiplePdfs(pdfList, outputFullPath);
|
|
|
+
|
|
|
return "/profile/" + newPdfPath;
|
|
|
}
|
|
|
+
|
|
|
return url;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
/**
|
|
|
* 生成wordt
|
|
|
*/
|
|
@@ -578,6 +628,11 @@ public class TMeasureThicknessController extends BaseController {
|
|
|
params.put("installDate", Texts.of(DateUtils.dateTime(thickness.getInstallDate())).fontSize(10).create());
|
|
|
params.put("equipmentName", Texts.of(thickness.getEquipmentName()).fontSize(10).create());
|
|
|
params.put("material", Texts.of(thickness.getMaterial()).fontSize(10).create());
|
|
|
+ params.put("tagno ", Texts.of(thickness.getTagno()).fontSize(10).create());
|
|
|
+ params.put("measureNo", Texts.of(thickness.getMeasureNo()).fontSize(10).create());
|
|
|
+ params.put("devType", Texts.of(thickness.getDevType()).fontSize(10).create());
|
|
|
+ params.put("desPressure", Texts.of(thickness.getDesPressure()).fontSize(10).create());
|
|
|
+ params.put("desTemp", Texts.of(thickness.getDesTemp()).fontSize(10).create());
|
|
|
|
|
|
params.put("corAllowance", Texts.of(thickness.getCorAllowance()).fontSize(10).create());
|
|
|
params.put("originalThickness", Texts.of(thickness.getOriginalThickness()).fontSize(10).create());
|
|
@@ -602,14 +657,20 @@ public class TMeasureThicknessController extends BaseController {
|
|
|
if (StringUtils.isNotEmpty(thickness.getLocationUrl())) {
|
|
|
String[] urlArr = thickness.getLocationUrl().split(",");
|
|
|
if (urlArr.length > 0) {
|
|
|
- params.put("location1", Pictures.ofLocal(fileName(urlArr[0])).size(240, 240).create());
|
|
|
- }
|
|
|
- if (urlArr.length > 1) {
|
|
|
- params.put("location2", Pictures.ofLocal(fileName(urlArr[1])).size(240, 240).create());
|
|
|
- }
|
|
|
- if (urlArr.length > 2) {
|
|
|
- params.put("location3", Pictures.ofLocal(fileName(urlArr[2])).size(240, 240).create());
|
|
|
+ String firstUrl = urlArr[0].trim();
|
|
|
+ if (isImageFile(firstUrl)) {
|
|
|
+ params.put("location1", Pictures.ofLocal(fileName(firstUrl)).size(240, 240).create());
|
|
|
+ } else {
|
|
|
+ params.put("locationText", Texts.of("见附件").fontSize(10).create());
|
|
|
+
|
|
|
+ }
|
|
|
}
|
|
|
+// if (urlArr.length > 1) {
|
|
|
+// params.put("location2", Pictures.ofLocal(fileName(urlArr[1])).size(240, 240).create());
|
|
|
+// }
|
|
|
+// if (urlArr.length > 2) {
|
|
|
+// params.put("location3", Pictures.ofLocal(fileName(urlArr[2])).size(240, 240).create());
|
|
|
+// }
|
|
|
}
|
|
|
if (StringUtils.isNotEmpty(thickness.getPhoto())) {
|
|
|
String[] pArr = thickness.getPhoto().split(",");
|
|
@@ -645,6 +706,20 @@ public class TMeasureThicknessController extends BaseController {
|
|
|
return params;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 判断文件是否为常见图片格式
|
|
|
+ */
|
|
|
+ private boolean isImageFile(String filePath) {
|
|
|
+ if (filePath == null) return false;
|
|
|
+ String lower = filePath.toLowerCase();
|
|
|
+ return lower.endsWith(".png") ||
|
|
|
+ lower.endsWith(".jpg") ||
|
|
|
+ lower.endsWith(".jpeg") ||
|
|
|
+ lower.endsWith(".bmp") ||
|
|
|
+ lower.endsWith(".gif") ||
|
|
|
+ lower.endsWith(".webp");
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* @param templatePath word模板文件路径
|
|
|
* @param fileDir 生成的文件存放地址
|