diff --git a/modules/i3plus-ext-mes-apiservice/pom.xml b/modules/i3plus-ext-mes-apiservice/pom.xml
index bb24de0..3794804 100644
--- a/modules/i3plus-ext-mes-apiservice/pom.xml
+++ b/modules/i3plus-ext-mes-apiservice/pom.xml
@@ -105,6 +105,12 @@
i3plus.platform
i3plus-platform-plugin
+
+
+ com.itextpdf
+ itextpdf
+
+
org.apache.cxf
diff --git a/modules/i3plus-ext-mes-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/apiservice/serviceimpl/report/MesYfReportServiceImpl.java b/modules/i3plus-ext-mes-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/apiservice/serviceimpl/report/MesYfReportServiceImpl.java
index 03f54bb..8235734 100644
--- a/modules/i3plus-ext-mes-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/apiservice/serviceimpl/report/MesYfReportServiceImpl.java
+++ b/modules/i3plus-ext-mes-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/apiservice/serviceimpl/report/MesYfReportServiceImpl.java
@@ -4,6 +4,8 @@ import cn.estsh.i3plus.ext.mes.api.base.IMesProduceSnService;
import cn.estsh.i3plus.ext.mes.api.base.IMesProductionRecordService;
import cn.estsh.i3plus.ext.mes.api.busi.report.IMesYfReportService;
import cn.estsh.i3plus.ext.mes.apiservice.dao.report.IMesYfReportDao;
+import cn.estsh.i3plus.ext.mes.apiservice.unit.exception.MesException;
+import cn.estsh.i3plus.ext.mes.apiservice.utils.MesTraceabilityTemp;
import cn.estsh.i3plus.ext.mes.pojo.model.report.MesDeviceDataQueryReportConditionModel;
import cn.estsh.i3plus.ext.mes.pojo.model.report.MesDeviceDataQueryReportResultModel;
import cn.estsh.i3plus.ext.mes.pojo.model.report.MesProdRuleReportConditionModel;
@@ -22,12 +24,14 @@ import cn.estsh.i3plus.pojo.mes.model.report.MesTraceabilityReportModel;
import cn.estsh.i3plus.pojo.mes.repository.*;
import cn.estsh.i3plus.pojo.mes.util.MesExtEnumUtil;
import cn.estsh.impp.framework.boot.util.ResultBean;
+import com.itextpdf.text.DocumentException;
import jodd.util.StringUtil;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
+import java.io.IOException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
@@ -129,10 +133,10 @@ public class MesYfReportServiceImpl implements IMesYfReportService {
public List findTraceabilityReport(MesProduceSn mesProduceSn) {
DdlPackBean packBean = getDdlPackBean(mesProduceSn);
//查询条码记录表
- List produceSnList = mesProduceSnService.findMesProduceSn(mesProduceSn.getOrganizeCode(), mesProduceSn.getOrganizeCode());
+ List produceSnList = mesProduceSnService.findMesProduceSn(mesProduceSn.getOrganizeCode(), mesProduceSn.getProductSn());
Map mesProduceSnMap = produceSnList.stream().collect(Collectors.toMap(MesProduceSn::getPartNo, t -> t));
//设备加工记录表
- List productionRecordList = mesProductionRecordService.findMesProductionRecord(mesProduceSn.getOrganizeCode(), mesProduceSn.getOrganizeCode());
+ List productionRecordList = mesProductionRecordService.findMesProductionRecord(mesProduceSn.getOrganizeCode(), mesProduceSn.getProductSn());
Map> productionRecordMap = productionRecordList.stream().collect(Collectors.groupingBy(MesProductionRecord::getPartNo));
//装配记录表
List productionAssemblyList = mesProductionAssemblyRepository.findByHqlWhere(packBean);
@@ -145,7 +149,7 @@ public class MesYfReportServiceImpl implements IMesYfReportService {
for (Map.Entry produceSnEntry : mesProduceSnMap.entrySet()) {
MesTraceabilityReportModel mesTraceabilityReportModel = new MesTraceabilityReportModel();
BeanUtils.copyProperties(produceSnEntry.getValue(), mesTraceabilityReportModel);
-
+ mesTraceabilityReportModel.setProdType(MesExtEnumUtil.TRACEABILITY_REPORT_PROD_TYPE.NO_SORT.getValue());
if (productionRecordMap.containsKey(produceSnEntry.getKey())) {
List mesProductionRecordList = productionRecordMap.get(produceSnEntry.getKey());
int duration = 0;
@@ -171,17 +175,27 @@ public class MesYfReportServiceImpl implements IMesYfReportService {
}
//开始时间
mesTraceabilityReportModel.setProduceBegin(mesProductionRecordList.iterator().next().getStartDateTime());
+ //生产状态
+ mesTraceabilityReportModel.setProdStatus(mesTraceabilityReportModel.getSnStatus());
//结束时间
if (mesTraceabilityReportModel.getSnStatus() >= MesExtEnumUtil.PRODUCE_SN_STATUS.OFFLINE.getValue()) {
+ mesTraceabilityReportModel.setProdStatus(MesExtEnumUtil.PRODUCE_SN_STATUS.OFFLINE.getValue());
mesTraceabilityReportModel.setProduceEnd(mesProductionRecordList.get(mesProductionRecordList.size() - 1).getCompleteDateTime());
}
mesTraceabilityReportModel.setDurationStr(dateFormat(duration));
mesTraceabilityReportModel.setDuration(duration);
}
+ //生成PDF文件并上传
+ try {
+ mesTraceabilityReportModel.setUrl(MesTraceabilityTemp.getMesTraceabilityTemp(mesTraceabilityReportModel));
+ } catch (IOException | DocumentException e) {
+ MesException.throwMesBusiException("生成PDF文件失败");
+ }
mesTraceabilityReportModelList.add(mesTraceabilityReportModel);
}
+
return mesTraceabilityReportModelList;
}
diff --git a/modules/i3plus-ext-mes-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/apiservice/utils/MesTraceabilityTemp.java b/modules/i3plus-ext-mes-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/apiservice/utils/MesTraceabilityTemp.java
new file mode 100644
index 0000000..0c879a9
--- /dev/null
+++ b/modules/i3plus-ext-mes-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/apiservice/utils/MesTraceabilityTemp.java
@@ -0,0 +1,617 @@
+package cn.estsh.i3plus.ext.mes.apiservice.utils;
+
+import cn.estsh.i3plus.ext.mes.pojo.constant.MesCommonConstant;
+import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
+import cn.estsh.i3plus.pojo.mes.bean.MesWorkCellScanMonitorLog;
+import cn.estsh.i3plus.pojo.mes.model.report.MesTraceabilityReportDataModel;
+import cn.estsh.i3plus.pojo.mes.model.report.MesTraceabilityReportModel;
+import cn.estsh.i3plus.pojo.mes.util.MesExtEnumUtil;
+import com.itextpdf.text.*;
+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 com.obs.services.model.PutObjectResult;
+import org.springframework.mock.web.MockMultipartFile;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+
+import static cn.estsh.i3plus.ext.mes.apiservice.dbinterface.WmsSAPDbQuery.lz;
+
+public class MesTraceabilityTemp {
+
+ public static String getMesTraceabilityTemp(MesTraceabilityReportModel mesTraceabilityReportModel) throws DocumentException, IOException {
+ Document document = new Document();
+ BaseFont bfChinese = BaseFont.createFont("C:\\Windows\\Fonts\\simhei.ttf", BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED);
+ Font whiteFont = new Font(bfChinese, 8, Font.NORMAL);
+ whiteFont.setColor(BaseColor.WHITE);
+ Font valueFont = new Font(bfChinese, 8, Font.NORMAL);
+ valueFont.setColor(new BaseColor(78, 103, 100));
+
+ Font equFont = new Font(bfChinese, 8, Font.NORMAL);
+ equFont.setColor(new BaseColor(196, 222, 249));
+
+ Font titleFont = new Font(bfChinese, 24, Font.NORMAL);
+ titleFont.setColor(new BaseColor(84, 132, 216));
+
+ BaseColor backgroundColor = new BaseColor(84, 132, 216);
+
+ File file = new File(System.getProperty("java.io.tmpdir") + File.separator + mesTraceabilityReportModel.getProductSn() + "-" + mesTraceabilityReportModel.getPartNo() + "追溯报表.PDF");
+ file.createNewFile();
+ PdfWriter.getInstance(document, new FileOutputStream(file));
+ document.open();
+ //最上面内容
+ PdfPTable table0 = new PdfPTable(20);
+ //设置间距
+ table0.setSpacingBefore(30);
+ table0.setWidths(new float[]{5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f});
+ table0.setWidthPercentage(100);
+ PdfPCell totalCell00 = new PdfPCell(new Paragraph("追溯报表", titleFont));
+ totalCell00.setColspan(20);
+ totalCell00.setBorderColor(BaseColor.WHITE);
+ totalCell00.setFixedHeight(50f);
+ table0.addCell(totalCell00);
+ //占9行,物料信息行
+ PdfPCell totalCell0 = new PdfPCell(new Paragraph(lz("工厂") + ":", whiteFont));
+ totalCell0.setHorizontalAlignment(Element.ALIGN_LEFT);
+ totalCell0.setVerticalAlignment(Element.ALIGN_MIDDLE);
+ totalCell0.setPaddingBottom(3);
+ totalCell0.setPaddingTop(1);
+ totalCell0.setPaddingLeft(5);
+ totalCell0.setColspan(5);
+ totalCell0.setBackgroundColor(backgroundColor);
+ totalCell0.setBorderColor(BaseColor.WHITE);
+ table0.addCell(totalCell0);
+
+ PdfPCell totalCell01 = new PdfPCell(new Paragraph(mesTraceabilityReportModel.getOrganizeCode(), valueFont));
+ totalCell01.setHorizontalAlignment(Element.ALIGN_LEFT);
+ totalCell01.setVerticalAlignment(Element.ALIGN_MIDDLE);
+ totalCell01.setPaddingBottom(3);
+ totalCell01.setPaddingTop(1);
+ totalCell01.setPaddingLeft(5);
+ totalCell01.setBorder(Rectangle.NO_BORDER);
+ totalCell01.setColspan(5);
+ table0.addCell(totalCell01);
+
+ PdfPCell totalCell02 = new PdfPCell(new Paragraph(lz("条码") + ":", whiteFont));
+ totalCell02.setHorizontalAlignment(Element.ALIGN_LEFT);
+ totalCell02.setVerticalAlignment(Element.ALIGN_MIDDLE);
+ totalCell02.setPaddingBottom(3);
+ totalCell02.setPaddingTop(1);
+ totalCell02.setPaddingLeft(5);
+ totalCell02.setBackgroundColor(backgroundColor);
+ totalCell02.setBorderColor(BaseColor.WHITE);
+ totalCell02.setColspan(5);
+ table0.addCell(totalCell02);
+
+ PdfPCell totalCell03 = new PdfPCell(new Paragraph(mesTraceabilityReportModel.getProductSn(), valueFont));
+ totalCell03.setHorizontalAlignment(Element.ALIGN_LEFT);
+ totalCell03.setVerticalAlignment(Element.ALIGN_MIDDLE);
+ totalCell03.setBorder(Rectangle.NO_BORDER);
+ totalCell03.setPaddingBottom(3);
+ totalCell03.setPaddingTop(1);
+ totalCell03.setPaddingLeft(5);
+ totalCell03.setColspan(5);
+ table0.addCell(totalCell03);
+
+ PdfPCell totalCell04 = new PdfPCell(new Paragraph(lz("产线") + ":", whiteFont));
+ totalCell04.setHorizontalAlignment(Element.ALIGN_LEFT);
+ totalCell04.setVerticalAlignment(Element.ALIGN_MIDDLE);
+ totalCell04.setPaddingBottom(3);
+ totalCell04.setPaddingTop(1);
+ totalCell04.setPaddingLeft(5);
+ totalCell04.setBackgroundColor(backgroundColor);
+ totalCell04.setBorderColor(BaseColor.WHITE);
+ totalCell04.setColspan(5);
+ table0.addCell(totalCell04);
+
+ PdfPCell totalCell05 = new PdfPCell(new Paragraph(mesTraceabilityReportModel.getWorkCenterCode(), valueFont));
+ totalCell05.setHorizontalAlignment(Element.ALIGN_LEFT);
+ totalCell05.setVerticalAlignment(Element.ALIGN_MIDDLE);
+ totalCell05.setBorder(Rectangle.NO_BORDER);
+ totalCell05.setPaddingBottom(3);
+ totalCell05.setPaddingTop(3);
+ totalCell05.setPaddingLeft(5);
+ totalCell05.setColspan(5);
+ table0.addCell(totalCell05);
+
+ PdfPCell totalCell06 = new PdfPCell(new Paragraph(lz("零件号") + ":", whiteFont));
+ totalCell06.setHorizontalAlignment(Element.ALIGN_LEFT);
+ totalCell06.setVerticalAlignment(Element.ALIGN_MIDDLE);
+ totalCell06.setPaddingBottom(3);
+ totalCell06.setPaddingTop(3);
+ totalCell06.setPaddingLeft(5);
+ totalCell06.setBackgroundColor(backgroundColor);
+ totalCell06.setBorderColor(BaseColor.WHITE);
+ totalCell06.setColspan(5);
+ table0.addCell(totalCell06);
+
+ PdfPCell totalCell07 = new PdfPCell(new Paragraph(mesTraceabilityReportModel.getPartNo(), valueFont));
+ totalCell07.setHorizontalAlignment(Element.ALIGN_LEFT);
+ totalCell07.setVerticalAlignment(Element.ALIGN_MIDDLE);
+ totalCell07.setBorder(Rectangle.NO_BORDER);
+ totalCell07.setPaddingBottom(3);
+ totalCell07.setPaddingTop(3);
+ totalCell07.setPaddingLeft(5);
+ totalCell07.setColspan(5);
+ table0.addCell(totalCell07);
+
+ document.add(table0);
+
+ //最上面内容
+ PdfPTable tableTop2 = new PdfPTable(20);
+ //设置间距
+ tableTop2.setSpacingBefore(10);
+ tableTop2.setWidths(new float[]{5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f});
+ tableTop2.setWidthPercentage(100);
+
+ //加工类型
+ PdfPCell tableTop2Cell00 = new PdfPCell(new Paragraph(lz("加工类型") + ":", whiteFont));
+ tableTop2Cell00.setHorizontalAlignment(Element.ALIGN_LEFT);
+ tableTop2Cell00.setVerticalAlignment(Element.ALIGN_MIDDLE);
+ tableTop2Cell00.setPaddingBottom(3);
+ tableTop2Cell00.setPaddingTop(1);
+ tableTop2Cell00.setPaddingLeft(5);
+ tableTop2Cell00.setBackgroundColor(backgroundColor);
+ tableTop2Cell00.setBorderColor(BaseColor.WHITE);
+ tableTop2Cell00.setColspan(5);
+ tableTop2.addCell(tableTop2Cell00);
+
+ PdfPCell tableTop2Cell01 = new PdfPCell(new Paragraph(MesExtEnumUtil.TRACEABILITY_REPORT_PROD_TYPE.valueOfDescription(mesTraceabilityReportModel.getProdType()), valueFont));
+ tableTop2Cell01.setHorizontalAlignment(Element.ALIGN_LEFT);
+ tableTop2Cell01.setVerticalAlignment(Element.ALIGN_MIDDLE);
+ tableTop2Cell01.setBorder(Rectangle.NO_BORDER);
+ tableTop2Cell01.setPaddingBottom(3);
+ tableTop2Cell01.setPaddingTop(1);
+ tableTop2Cell01.setPaddingLeft(5);
+ tableTop2Cell01.setColspan(5);
+ tableTop2.addCell(tableTop2Cell01);
+
+ PdfPCell tableTop2Cell02 = new PdfPCell(new Paragraph("", valueFont));
+ tableTop2Cell02.setHorizontalAlignment(Element.ALIGN_LEFT);
+ tableTop2Cell02.setVerticalAlignment(Element.ALIGN_MIDDLE);
+ tableTop2Cell02.setPaddingBottom(3);
+ tableTop2Cell02.setPaddingTop(1);
+ tableTop2Cell02.setPaddingLeft(5);
+ tableTop2Cell02.setBorderColor(BaseColor.WHITE);
+ tableTop2Cell02.setColspan(5);
+ tableTop2.addCell(tableTop2Cell02);
+
+ PdfPCell tableTop2Cell03 = new PdfPCell(new Paragraph("", valueFont));
+ tableTop2Cell03.setHorizontalAlignment(Element.ALIGN_LEFT);
+ tableTop2Cell03.setVerticalAlignment(Element.ALIGN_MIDDLE);
+ tableTop2Cell03.setBorder(Rectangle.NO_BORDER);
+ tableTop2Cell03.setPaddingBottom(3);
+ tableTop2Cell03.setPaddingTop(1);
+ tableTop2Cell03.setPaddingLeft(5);
+ tableTop2Cell03.setColspan(5);
+ tableTop2.addCell(tableTop2Cell03);
+
+ //零件状态
+ PdfPCell tableTop2Cell10 = new PdfPCell(new Paragraph(lz("零件状态") + ":", whiteFont));
+ tableTop2Cell10.setHorizontalAlignment(Element.ALIGN_LEFT);
+ tableTop2Cell10.setVerticalAlignment(Element.ALIGN_MIDDLE);
+ tableTop2Cell10.setBackgroundColor(backgroundColor);
+ tableTop2Cell10.setBorderColor(BaseColor.WHITE);
+ tableTop2Cell10.setPaddingBottom(3);
+ tableTop2Cell10.setPaddingTop(1);
+ tableTop2Cell10.setPaddingLeft(5);
+ tableTop2Cell10.setColspan(5);
+ tableTop2.addCell(tableTop2Cell10);
+
+ PdfPCell tableTop2Cell11 = new PdfPCell(new Paragraph(MesExtEnumUtil.PRODUCE_SN_STATUS.valueOfDescription(mesTraceabilityReportModel.getSnStatus()), valueFont));
+ tableTop2Cell11.setHorizontalAlignment(Element.ALIGN_LEFT);
+ tableTop2Cell11.setVerticalAlignment(Element.ALIGN_MIDDLE);
+ tableTop2Cell11.setBorder(Rectangle.NO_BORDER);
+ tableTop2Cell11.setPaddingBottom(3);
+ tableTop2Cell11.setPaddingTop(1);
+ tableTop2Cell11.setPaddingLeft(5);
+ tableTop2Cell11.setColspan(5);
+ tableTop2.addCell(tableTop2Cell11);
+
+ PdfPCell tableTop2Cell12 = new PdfPCell(new Paragraph("", valueFont));
+ tableTop2Cell12.setHorizontalAlignment(Element.ALIGN_LEFT);
+ tableTop2Cell12.setVerticalAlignment(Element.ALIGN_MIDDLE);
+ tableTop2Cell12.setPaddingBottom(3);
+ tableTop2Cell12.setPaddingTop(3);
+ tableTop2Cell12.setPaddingLeft(5);
+ tableTop2Cell12.setBorderColor(BaseColor.WHITE);
+ tableTop2Cell12.setColspan(5);
+ tableTop2.addCell(tableTop2Cell12);
+
+ PdfPCell tableTop2Cell14 = new PdfPCell(new Paragraph("", valueFont));
+ tableTop2Cell14.setHorizontalAlignment(Element.ALIGN_LEFT);
+ tableTop2Cell14.setVerticalAlignment(Element.ALIGN_MIDDLE);
+ tableTop2Cell14.setBorder(Rectangle.NO_BORDER);
+ tableTop2Cell14.setPaddingBottom(3);
+ tableTop2Cell14.setPaddingTop(3);
+ tableTop2Cell14.setPaddingLeft(5);
+ tableTop2Cell14.setColspan(5);
+ tableTop2.addCell(tableTop2Cell14);
+
+ //加工开始时间
+ PdfPCell tableTop2Cell20 = new PdfPCell(new Paragraph(lz("加工开始时间") + ":", whiteFont));
+ tableTop2Cell20.setHorizontalAlignment(Element.ALIGN_LEFT);
+ tableTop2Cell20.setVerticalAlignment(Element.ALIGN_MIDDLE);
+ tableTop2Cell20.setBackgroundColor(backgroundColor);
+ tableTop2Cell20.setBorderColor(BaseColor.WHITE);
+ tableTop2Cell20.setPaddingBottom(3);
+ tableTop2Cell20.setPaddingTop(1);
+ tableTop2Cell20.setPaddingLeft(5);
+ tableTop2Cell20.setColspan(5);
+ tableTop2.addCell(tableTop2Cell20);
+
+ PdfPCell tableTop2Cell21 = new PdfPCell(new Paragraph(mesTraceabilityReportModel.getProduceBegin(), valueFont));
+ tableTop2Cell21.setHorizontalAlignment(Element.ALIGN_LEFT);
+ tableTop2Cell21.setVerticalAlignment(Element.ALIGN_MIDDLE);
+ tableTop2Cell21.setBorder(Rectangle.NO_BORDER);
+ tableTop2Cell21.setPaddingBottom(3);
+ tableTop2Cell21.setPaddingTop(1);
+ tableTop2Cell21.setPaddingLeft(5);
+ tableTop2Cell21.setColspan(5);
+ tableTop2.addCell(tableTop2Cell21);
+
+ PdfPCell tableTop2Cell22 = new PdfPCell(new Paragraph("", valueFont));
+ tableTop2Cell22.setHorizontalAlignment(Element.ALIGN_LEFT);
+ tableTop2Cell22.setVerticalAlignment(Element.ALIGN_MIDDLE);
+ tableTop2Cell22.setPaddingBottom(3);
+ tableTop2Cell22.setPaddingTop(1);
+ tableTop2Cell22.setPaddingLeft(5);
+ tableTop2Cell22.setBorderColor(BaseColor.WHITE);
+ tableTop2Cell22.setColspan(5);
+ tableTop2.addCell(tableTop2Cell22);
+
+ PdfPCell tableTop2Cell24 = new PdfPCell(new Paragraph("", valueFont));
+ tableTop2Cell24.setHorizontalAlignment(Element.ALIGN_LEFT);
+ tableTop2Cell24.setVerticalAlignment(Element.ALIGN_MIDDLE);
+ tableTop2Cell24.setBorder(Rectangle.NO_BORDER);
+ tableTop2Cell24.setPaddingBottom(3);
+ tableTop2Cell24.setPaddingTop(1);
+ tableTop2Cell24.setPaddingLeft(5);
+ tableTop2Cell24.setColspan(5);
+ tableTop2.addCell(tableTop2Cell24);
+
+ //加工结束时间
+ PdfPCell tableTop2Cell30 = new PdfPCell(new Paragraph(lz("加工结束时间") + ":", whiteFont));
+ tableTop2Cell30.setHorizontalAlignment(Element.ALIGN_LEFT);
+ tableTop2Cell30.setVerticalAlignment(Element.ALIGN_MIDDLE);
+ tableTop2Cell30.setBackgroundColor(backgroundColor);
+ tableTop2Cell30.setBorderColor(BaseColor.WHITE);
+ tableTop2Cell30.setPaddingBottom(3);
+ tableTop2Cell30.setPaddingTop(1);
+ tableTop2Cell30.setPaddingLeft(5);
+ tableTop2Cell30.setColspan(5);
+ tableTop2.addCell(tableTop2Cell30);
+
+ PdfPCell tableTop2Cell31 = new PdfPCell(new Paragraph(mesTraceabilityReportModel.getProduceEnd(), valueFont));
+ tableTop2Cell31.setHorizontalAlignment(Element.ALIGN_LEFT);
+ tableTop2Cell31.setVerticalAlignment(Element.ALIGN_MIDDLE);
+ tableTop2Cell31.setBorder(Rectangle.NO_BORDER);
+ tableTop2Cell31.setPaddingBottom(3);
+ tableTop2Cell31.setPaddingTop(1);
+ tableTop2Cell31.setPaddingLeft(5);
+ tableTop2Cell31.setColspan(5);
+ tableTop2.addCell(tableTop2Cell31);
+
+ PdfPCell tableTop2Cell32 = new PdfPCell(new Paragraph("", valueFont));
+ tableTop2Cell32.setHorizontalAlignment(Element.ALIGN_LEFT);
+ tableTop2Cell32.setVerticalAlignment(Element.ALIGN_MIDDLE);
+ tableTop2Cell32.setPaddingBottom(3);
+ tableTop2Cell32.setPaddingTop(1);
+ tableTop2Cell32.setPaddingLeft(5);
+ tableTop2Cell32.setBorderColor(BaseColor.WHITE);
+ tableTop2Cell32.setColspan(5);
+ tableTop2.addCell(tableTop2Cell32);
+
+ PdfPCell tableTop2Cell34 = new PdfPCell(new Paragraph("", valueFont));
+ tableTop2Cell34.setHorizontalAlignment(Element.ALIGN_LEFT);
+ tableTop2Cell34.setVerticalAlignment(Element.ALIGN_MIDDLE);
+ tableTop2Cell34.setBorder(Rectangle.NO_BORDER);
+ tableTop2Cell34.setPaddingBottom(3);
+ tableTop2Cell34.setPaddingTop(1);
+ tableTop2Cell34.setPaddingLeft(5);
+ tableTop2Cell34.setColspan(5);
+ tableTop2.addCell(tableTop2Cell34);
+
+
+ //持续时间
+ PdfPCell tableTop2Cell40 = new PdfPCell(new Paragraph(lz("持续时间") + ":", whiteFont));
+ tableTop2Cell40.setHorizontalAlignment(Element.ALIGN_LEFT);
+ tableTop2Cell40.setVerticalAlignment(Element.ALIGN_MIDDLE);
+ tableTop2Cell40.setBackgroundColor(backgroundColor);
+ tableTop2Cell40.setBorderColor(BaseColor.WHITE);
+ tableTop2Cell40.setPaddingBottom(3);
+ tableTop2Cell40.setPaddingTop(1);
+ tableTop2Cell40.setPaddingLeft(5);
+ tableTop2Cell40.setColspan(5);
+ tableTop2.addCell(tableTop2Cell40);
+
+ PdfPCell tableTop2Cell41 = new PdfPCell(new Paragraph(mesTraceabilityReportModel.getDurationStr(), valueFont));
+ tableTop2Cell41.setHorizontalAlignment(Element.ALIGN_LEFT);
+ tableTop2Cell41.setVerticalAlignment(Element.ALIGN_MIDDLE);
+ tableTop2Cell41.setBorder(Rectangle.NO_BORDER);
+ tableTop2Cell41.setPaddingBottom(3);
+ tableTop2Cell41.setPaddingTop(1);
+ tableTop2Cell41.setPaddingLeft(5);
+ tableTop2Cell41.setColspan(5);
+ tableTop2.addCell(tableTop2Cell41);
+
+ PdfPCell tableTop2Cell42 = new PdfPCell(new Paragraph("", valueFont));
+ tableTop2Cell42.setHorizontalAlignment(Element.ALIGN_LEFT);
+ tableTop2Cell42.setVerticalAlignment(Element.ALIGN_MIDDLE);
+ tableTop2Cell42.setPaddingBottom(3);
+ tableTop2Cell42.setPaddingTop(1);
+ tableTop2Cell42.setPaddingLeft(5);
+ tableTop2Cell42.setBorderColor(BaseColor.WHITE);
+ tableTop2Cell42.setColspan(5);
+ tableTop2.addCell(tableTop2Cell42);
+
+ PdfPCell tableTop2Cell44 = new PdfPCell(new Paragraph("", valueFont));
+ tableTop2Cell44.setHorizontalAlignment(Element.ALIGN_LEFT);
+ tableTop2Cell44.setVerticalAlignment(Element.ALIGN_MIDDLE);
+ tableTop2Cell44.setBorder(Rectangle.NO_BORDER);
+ tableTop2Cell44.setPaddingBottom(3);
+ tableTop2Cell44.setPaddingTop(1);
+ tableTop2Cell44.setPaddingLeft(5);
+ tableTop2Cell44.setColspan(5);
+ tableTop2.addCell(tableTop2Cell44);
+
+
+ //生产状态
+ PdfPCell tableTop2Cell50 = new PdfPCell(new Paragraph(lz("生产状态") + ":", whiteFont));
+ tableTop2Cell50.setHorizontalAlignment(Element.ALIGN_LEFT);
+ tableTop2Cell50.setVerticalAlignment(Element.ALIGN_MIDDLE);
+ tableTop2Cell50.setBackgroundColor(backgroundColor);
+ tableTop2Cell50.setBorderColor(BaseColor.WHITE);
+ tableTop2Cell50.setPaddingBottom(3);
+ tableTop2Cell50.setPaddingTop(1);
+ tableTop2Cell50.setPaddingLeft(5);
+ tableTop2Cell50.setColspan(5);
+ tableTop2.addCell(tableTop2Cell50);
+
+ PdfPCell tableTop2Cell51 = new PdfPCell(new Paragraph(MesExtEnumUtil.PRODUCE_SN_STATUS.valueOfDescription(mesTraceabilityReportModel.getProdStatus()), valueFont));
+ tableTop2Cell51.setHorizontalAlignment(Element.ALIGN_LEFT);
+ tableTop2Cell51.setVerticalAlignment(Element.ALIGN_MIDDLE);
+ tableTop2Cell51.setBorder(Rectangle.NO_BORDER);
+ tableTop2Cell51.setPaddingBottom(3);
+ tableTop2Cell51.setPaddingTop(1);
+ tableTop2Cell51.setPaddingLeft(5);
+ tableTop2Cell51.setColspan(5);
+ tableTop2.addCell(tableTop2Cell51);
+
+ PdfPCell tableTop2Cell52 = new PdfPCell(new Paragraph("", valueFont));
+ tableTop2Cell52.setHorizontalAlignment(Element.ALIGN_LEFT);
+ tableTop2Cell52.setVerticalAlignment(Element.ALIGN_MIDDLE);
+ tableTop2Cell52.setPaddingBottom(3);
+ tableTop2Cell52.setPaddingTop(1);
+ tableTop2Cell52.setPaddingLeft(5);
+ tableTop2Cell52.setBorderColor(BaseColor.WHITE);
+ tableTop2Cell52.setColspan(5);
+ tableTop2.addCell(tableTop2Cell52);
+
+ PdfPCell tableTop2Cell53 = new PdfPCell(new Paragraph("", valueFont));
+ tableTop2Cell53.setHorizontalAlignment(Element.ALIGN_LEFT);
+ tableTop2Cell53.setVerticalAlignment(Element.ALIGN_MIDDLE);
+ tableTop2Cell53.setBorder(Rectangle.NO_BORDER);
+ tableTop2Cell53.setPaddingBottom(3);
+ tableTop2Cell53.setPaddingTop(1);
+ tableTop2Cell53.setPaddingLeft(5);
+ tableTop2Cell53.setColspan(5);
+ tableTop2.addCell(tableTop2Cell53);
+
+
+ //托盘条码
+ PdfPCell tableTop2Cell60 = new PdfPCell(new Paragraph(lz("托盘条码") + ":", whiteFont));
+ tableTop2Cell60.setHorizontalAlignment(Element.ALIGN_LEFT);
+ tableTop2Cell60.setVerticalAlignment(Element.ALIGN_MIDDLE);
+ tableTop2Cell60.setBackgroundColor(backgroundColor);
+ tableTop2Cell60.setBorderColor(BaseColor.WHITE);
+ tableTop2Cell60.setPaddingBottom(3);
+ tableTop2Cell60.setPaddingTop(1);
+ tableTop2Cell60.setPaddingLeft(5);
+ tableTop2Cell60.setColspan(5);
+ tableTop2.addCell(tableTop2Cell60);
+
+ PdfPCell tableTop2Cell61 = new PdfPCell(new Paragraph("", valueFont));
+ tableTop2Cell61.setHorizontalAlignment(Element.ALIGN_LEFT);
+ tableTop2Cell61.setVerticalAlignment(Element.ALIGN_MIDDLE);
+ tableTop2Cell61.setBorder(Rectangle.NO_BORDER);
+ tableTop2Cell61.setPaddingBottom(3);
+ tableTop2Cell61.setPaddingTop(1);
+ tableTop2Cell61.setPaddingLeft(5);
+ tableTop2Cell61.setColspan(5);
+ tableTop2.addCell(tableTop2Cell61);
+
+ PdfPCell tableTop2Cell62 = new PdfPCell(new Paragraph("", valueFont));
+ tableTop2Cell62.setHorizontalAlignment(Element.ALIGN_LEFT);
+ tableTop2Cell62.setVerticalAlignment(Element.ALIGN_MIDDLE);
+ tableTop2Cell62.setPaddingBottom(3);
+ tableTop2Cell62.setPaddingTop(1);
+ tableTop2Cell62.setPaddingLeft(5);
+ tableTop2Cell62.setBorderColor(BaseColor.WHITE);
+ tableTop2Cell62.setColspan(5);
+ tableTop2.addCell(tableTop2Cell62);
+
+ PdfPCell tableTop2Cell63 = new PdfPCell(new Paragraph("", valueFont));
+ tableTop2Cell63.setHorizontalAlignment(Element.ALIGN_LEFT);
+ tableTop2Cell63.setVerticalAlignment(Element.ALIGN_MIDDLE);
+ tableTop2Cell63.setBorder(Rectangle.NO_BORDER);
+ tableTop2Cell63.setPaddingBottom(3);
+ tableTop2Cell63.setPaddingTop(1);
+ tableTop2Cell63.setPaddingLeft(5);
+ tableTop2Cell63.setColspan(5);
+ tableTop2.addCell(tableTop2Cell63);
+
+ document.add(tableTop2);
+
+ for (MesTraceabilityReportDataModel dataModel : mesTraceabilityReportModel.getMesTraceabilityReportDataModelList()) {
+ //设备工艺表格
+ PdfPTable equtable = new PdfPTable(6);
+ equtable.setSpacingBefore(10);
+ equtable.setWidths(new float[]{8f, 8f, 8f, 8f, 8f, 8f});
+ equtable.setWidthPercentage(100);
+
+ //表头
+ PdfPCell equCell01 = new PdfPCell(new Paragraph(lz("设备/工艺"), whiteFont));
+ equCell01.setBackgroundColor(backgroundColor);
+ equCell01.setHorizontalAlignment(Element.ALIGN_CENTER);
+ equCell01.setHorizontalAlignment(Element.ALIGN_MIDDLE);
+ equCell01.setPaddingBottom(3);
+ equCell01.setPaddingTop(1);
+ equCell01.setColspan(1);
+ equtable.addCell(equCell01);
+
+ PdfPCell equCell02 = new PdfPCell(new Paragraph(lz("工艺开始时间"), whiteFont));
+ equCell02.setBackgroundColor(backgroundColor);
+ equCell02.setHorizontalAlignment(Element.ALIGN_CENTER);
+ equCell02.setHorizontalAlignment(Element.ALIGN_MIDDLE);
+ equCell02.setPaddingBottom(3);
+ equCell02.setPaddingTop(1);
+ equCell02.setColspan(1);
+ equtable.addCell(equCell02);
+
+ PdfPCell equCell03 = new PdfPCell(new Paragraph(lz("工艺结束时间"), whiteFont));
+ equCell03.setBackgroundColor(backgroundColor);
+ equCell03.setHorizontalAlignment(Element.ALIGN_CENTER);
+ equCell03.setHorizontalAlignment(Element.ALIGN_MIDDLE);
+ equCell03.setPaddingBottom(3);
+ equCell03.setPaddingTop(1);
+ equCell03.setColspan(1);
+ equtable.addCell(equCell03);
+
+ PdfPCell equCell04 = new PdfPCell(new Paragraph(lz("托盘条码"), whiteFont));
+ equCell04.setBackgroundColor(backgroundColor);
+ equCell04.setHorizontalAlignment(Element.ALIGN_CENTER);
+ equCell04.setHorizontalAlignment(Element.ALIGN_MIDDLE);
+ equCell04.setPaddingBottom(3);
+ equCell04.setPaddingTop(1);
+ equCell04.setColspan(1);
+ equtable.addCell(equCell04);
+
+ PdfPCell equCell05 = new PdfPCell(new Paragraph(lz("持续时间"), whiteFont));
+ equCell05.setBackgroundColor(backgroundColor);
+ equCell05.setHorizontalAlignment(Element.ALIGN_CENTER);
+ equCell05.setVerticalAlignment(Element.ALIGN_MIDDLE);
+ equCell05.setPaddingBottom(3);
+ equCell05.setPaddingTop(1);
+ equCell05.setColspan(1);
+ equtable.addCell(equCell05);
+
+ PdfPCell equCell06 = new PdfPCell(new Paragraph(lz("结果"), whiteFont));
+ equCell06.setBackgroundColor(backgroundColor);
+ equCell06.setHorizontalAlignment(Element.ALIGN_CENTER);
+ equCell06.setVerticalAlignment(Element.ALIGN_MIDDLE);
+ equCell06.setPaddingBottom(3);
+ equCell06.setPaddingTop(1);
+ equCell06.setColspan(1);
+ equtable.addCell(equCell06);
+
+ // 构建每一列
+ PdfPCell equCell00 = new PdfPCell(new Paragraph(dataModel.getEquipmentCode(), valueFont));
+ equCell00.setHorizontalAlignment(Element.ALIGN_LEFT);
+ equCell00.setVerticalAlignment(Element.ALIGN_MIDDLE);
+ equCell00.setColspan(7);
+ equtable.addCell(equCell00);
+
+ PdfPCell equCell11 = new PdfPCell(new Paragraph(dataModel.getCraftCode(), valueFont));
+ equCell11.setHorizontalAlignment(Element.ALIGN_CENTER);
+ equCell11.setVerticalAlignment(Element.ALIGN_MIDDLE);
+ equCell11.setPaddingBottom(3);
+ equCell11.setPaddingTop(1);
+ equtable.addCell(equCell11);
+
+ PdfPCell equCell21 = new PdfPCell(new Paragraph(dataModel.getStartDateTime(), valueFont));
+ equCell21.setHorizontalAlignment(Element.ALIGN_CENTER);
+ equCell21.setVerticalAlignment(Element.ALIGN_MIDDLE);
+ equCell21.setPaddingBottom(3);
+ equCell21.setPaddingTop(1);
+ equtable.addCell(equCell21);
+
+ PdfPCell equCell31 = new PdfPCell(new Paragraph(dataModel.getCompleteDateTime(), valueFont));
+ equCell31.setHorizontalAlignment(Element.ALIGN_CENTER);
+ equCell31.setVerticalAlignment(Element.ALIGN_MIDDLE);
+ equCell31.setPaddingBottom(3);
+ equCell31.setPaddingTop(1);
+ equtable.addCell(equCell31);
+
+ PdfPCell equCell41 = new PdfPCell(new Paragraph(dataModel.getTrayNo(), valueFont));
+ equCell41.setHorizontalAlignment(Element.ALIGN_CENTER);
+ equCell41.setVerticalAlignment(Element.ALIGN_MIDDLE);
+ equCell41.setPaddingBottom(3);
+ equCell41.setPaddingTop(1);
+ equtable.addCell(equCell41);
+
+ PdfPCell equCell51 = new PdfPCell(new Paragraph(dataModel.getDurationStr(), valueFont));
+ equCell51.setHorizontalAlignment(Element.ALIGN_CENTER);
+ equCell51.setVerticalAlignment(Element.ALIGN_MIDDLE);
+ equCell51.setPaddingBottom(3);
+ equCell51.setPaddingTop(1);
+ equtable.addCell(equCell51);
+
+ PdfPCell equCell61 = new PdfPCell(new Paragraph(CommonEnumUtil.VALID == dataModel.getIsComplete() ? "OK" : "NO", valueFont));
+ equCell61.setHorizontalAlignment(Element.ALIGN_CENTER);
+ equCell61.setVerticalAlignment(Element.ALIGN_MIDDLE);
+ equCell61.setPaddingBottom(3);
+ equCell61.setPaddingTop(1);
+ equtable.addCell(equCell61);
+ int index = 0;
+ for (MesWorkCellScanMonitorLog log : dataModel.getMesWorkCellScanMonitorLogs()) {
+ // 构建每一列
+ PdfPCell equcontentCell00 = new PdfPCell(new Paragraph("", valueFont));
+ equcontentCell00.setHorizontalAlignment(Element.ALIGN_LEFT);
+ equcontentCell00.setBorder(Rectangle.NO_BORDER);
+ equcontentCell00.setColspan(1);
+ equtable.addCell(equcontentCell00);
+
+ PdfPCell equcontentCell11 = new PdfPCell(new Paragraph(log.getMessage(), valueFont));
+ equcontentCell11.setHorizontalAlignment(Element.ALIGN_CENTER);
+ equcontentCell11.setVerticalAlignment(Element.ALIGN_MIDDLE);
+ equcontentCell11.setPaddingBottom(3);
+ equcontentCell11.setPaddingTop(1);
+
+ if (index % 2 == 0) {
+ equcontentCell11.setBackgroundColor(new BaseColor(253, 239, 192));//黄色
+ } else {
+ equcontentCell11.setBackgroundColor(BaseColor.WHITE);//白色
+ }
+
+ equcontentCell11.setColspan(4);
+ equtable.addCell(equcontentCell11);
+
+ PdfPCell equcontentCell21 = new PdfPCell(new Paragraph(log.getScanInfo(), valueFont));
+ equcontentCell21.setHorizontalAlignment(Element.ALIGN_CENTER);
+ equcontentCell21.setVerticalAlignment(Element.ALIGN_MIDDLE);
+ equcontentCell21.setPaddingBottom(3);
+ equcontentCell21.setPaddingTop(1);
+
+ if (index % 2 == 0) {
+ equcontentCell21.setBackgroundColor(new BaseColor(253, 239, 192));//黄色
+ } else {
+ equcontentCell21.setBackgroundColor(BaseColor.WHITE);//白色
+ }
+ equcontentCell21.setColspan(2);
+ equtable.addCell(equcontentCell21);
+ index++;
+ }
+
+ document.add(equtable);
+ }
+ // 关闭文档
+ document.close();
+ //文件上传
+ PutObjectResult result = HuaWeiOBSUtil.putObjectByMultipartFile(MesCommonConstant.OBS_BUCKET_NAME, file.getName(), convert(file));
+ //删除文件
+ file.deleteOnExit();
+ return result.getObjectUrl();
+ }
+
+ public static MultipartFile convert(File file) throws IOException {
+ FileInputStream input = new FileInputStream(file);
+ return new MockMultipartFile("file", file.getName(), "text/plain", input);
+ }
+
+}
diff --git a/pom.xml b/pom.xml
index dd8e78a..4dacc21 100644
--- a/pom.xml
+++ b/pom.xml
@@ -200,6 +200,13 @@
i3plus-icloud-softswitch
${i3plus.icloud.version}
+
+
+ com.itextpdf
+ itextpdf
+ 5.5.13.2
+
+