问题清单修复

tags/yfai-mes-ext-v1.0 yfai-mes-ext-v1.0
jun 10 months ago
parent 0994b7ffaa
commit c0e3d72b51

@ -37,10 +37,7 @@ import org.springframework.util.CollectionUtils;
import java.io.IOException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.*;
import java.util.stream.Collectors;
/**
@ -87,6 +84,12 @@ public class MesYfReportServiceImpl implements IMesYfReportService {
@Autowired
private IMesFileService mesFileService;
@Autowired
private MesEquipmentLogDetailRepository mesEquipmentLogDetailRepository;
@Autowired
private MesEquipmentRepository mesEquipmentRepository;
@Override
public ListPager<MesDeviceDataQueryReportResultModel> queryMesDeviceDataByPager(MesDeviceDataQueryReportConditionModel queryReportModel, Pager pager) {
ListPager<MesDeviceDataQueryReportResultModel> mesDeviceDataQueryReportResultModelListPager =
@ -152,10 +155,9 @@ public class MesYfReportServiceImpl implements IMesYfReportService {
List<String> processCodeList = productionRecordList.stream().map(MesProductionRecord::getProcessCode).filter(StringUtil::isNotEmpty).collect(Collectors.toList());
//装配记录表
List<MesProductionAssembly> productionAssemblyList = mesProductionAssemblyRepository.findByHqlWhere(packBean);
Map<String, List<MesProductionAssembly>> productionAssemblyMap = CollectionUtils.isEmpty(productionAssemblyList) ? null : productionAssemblyList.stream().collect(Collectors.groupingBy(t -> t.getWorkCenterCode() + t.getWorkCellCode() + t.getEquipmentCode()));
//工位扫描监控日志
List<MesWorkCellScanMonitorLog> mesWorkCellScanMonitorLogs = getWorkCellScanMonitorLogList(productionRecordList);
Map<String, List<MesWorkCellScanMonitorLog>> mesWorkCellScanMonitorMap = CollectionUtils.isEmpty(mesWorkCellScanMonitorLogs) ? null : mesWorkCellScanMonitorLogs.stream().collect(Collectors.groupingBy(t -> t.getWorkCenterCode() + t.getWorkCellCode() + t.getEquipmentCode()));
Map<String, List<MesProductionAssembly>> productionAssemblyMap = CollectionUtils.isEmpty(productionAssemblyList) ? null : productionAssemblyList.stream().collect(Collectors.groupingBy(t -> new StringJoiner(MesExtConstWords.COMMA).add(t.getWorkCenterCode()).add(t.getWorkCellCode()).add(t.getEquipmentCode()).toString()));
//根据设备代码查询设备id
Map<String, List<MesEquipmentLogDetail>> mesEquipmentLogDetailMap = getMesEquipmentLogDetailMap(mesProduceSn, productionRecordList);
//查询工序名称
Map<String, MesProcess> processMap = getMesProcessMap(mesProduceSn, processCodeList);
//数据组装
@ -174,13 +176,14 @@ public class MesYfReportServiceImpl implements IMesYfReportService {
duration += dataModel.getDuration();
}
//装配记录表
String key = mesProductionRecord.getWorkCenterCode() + mesProductionRecord.getWorkCellCode() + mesProductionRecord.getEquipmentCode();
String key = new StringJoiner(MesExtConstWords.COMMA).add(mesProductionRecord.getWorkCenterCode()).add(mesProductionRecord.getWorkCellCode()).add(mesProductionRecord.getEquipmentCode()).toString();
if (!Objects.isNull(productionAssemblyMap) && productionAssemblyMap.containsKey(key)) {
dataModel.setProductionAssemblyList(productionAssemblyMap.get(key));
}
//工位扫描监控日志
if (!Objects.isNull(mesWorkCellScanMonitorMap) && mesWorkCellScanMonitorMap.containsKey(key)) {
dataModel.setMesWorkCellScanMonitorLogs(mesWorkCellScanMonitorMap.get(key));
//工艺加工参数
key = new StringJoiner(MesExtConstWords.COMMA).add(mesProductionRecord.getMouldRecordId().toString()).add(mesProductionRecord.getWorkCenterCode()).add(mesProductionRecord.getWorkCellCode()).add(mesProductionRecord.getEquipmentCode()).toString();
if (!Objects.isNull(mesEquipmentLogDetailMap) && mesEquipmentLogDetailMap.containsKey(key)) {
dataModel.setMesEquipmentLogDetailList(mesEquipmentLogDetailMap.get(key));
}
//查询工序名称
if(StringUtil.isNotEmpty(dataModel.getProcessCode())){
@ -217,6 +220,31 @@ public class MesYfReportServiceImpl implements IMesYfReportService {
return mesTraceabilityReportModelList;
}
private Map<String, List<MesEquipmentLogDetail>> getMesEquipmentLogDetailMap(MesProduceSn mesProduceSn, List<MesProductionRecord> productionRecordList) {
List<String> organizeCodeEquipList = getEquipList(mesProduceSn, productionRecordList);
//工艺加工参数
if(CollectionUtils.isEmpty(organizeCodeEquipList)) return null;
return getMesEquipmentLogDetailMap(mesProduceSn, productionRecordList, organizeCodeEquipList);
}
private Map<String, List<MesEquipmentLogDetail>> getMesEquipmentLogDetailMap(MesProduceSn mesProduceSn, List<MesProductionRecord> productionRecordList, List<String> organizeCodeEquipList) {
DdlPackBean packBean = DdlPackBean.getDdlPackBean(mesProduceSn.getOrganizeCode());
DdlPreparedPack.getInPackList(organizeCodeEquipList, MesExtConstWords.ORG_EQUIP_ID, packBean);
DdlPreparedPack.getInPackList(productionRecordList.stream().map(MesProductionRecord::getMouldRecordId).collect(Collectors.toList()), "mouldRecordId", packBean);
DdlPreparedPack.getInPackArray(new Object[]{MesExtEnumUtil.EQUIP_VARIABLE_TYPE.PROCESS_FINISH.getValue(), MesExtEnumUtil.EQUIP_VARIABLE_TYPE.PROCESS.getValue()}, "variableType", packBean);
List<MesEquipmentLogDetail> mesEquipmentLogDetailList = mesEquipmentLogDetailRepository.findByHqlWhere(packBean);
if (CollectionUtils.isEmpty(mesEquipmentLogDetailList)) return null;
return mesEquipmentLogDetailList.stream().collect(Collectors.groupingBy(t -> new StringJoiner(MesExtConstWords.COMMA).add(t.getMouldRecordId().toString()).add(t.getWorkCenterCode()).add(t.getWorkCellCode()).add(t.getEquipmentCode()).toString()));
}
private List<String> getEquipList(MesProduceSn mesProduceSn, List<MesProductionRecord> productionRecordList) {
DdlPackBean packBean = DdlPackBean.getDdlPackBean(mesProduceSn.getOrganizeCode());
DdlPreparedPack.getInPackList(productionRecordList.stream().map(MesProductionRecord::getEquipmentCode).collect(Collectors.toList()), "equipmentCode", packBean);
List<MesEquipment> mesEquipmentList = mesEquipmentRepository.findByHqlWhere(packBean);
if (CollectionUtils.isEmpty(mesEquipmentList)) return null;
return mesEquipmentList.stream().map(t -> new StringJoiner(MesExtConstWords.E_UNDERLINE).add(t.getOrganizeCode()).add(t.getEquipId().toString()).toString()).collect(Collectors.toList());
}
private MesWorkCenter getWorkCenter(MesProduceSn produceSn) {
MesWorkCenter workCenter = workCenterRepository.getByProperty(
new String[]{MesExtConstWords.ORGANIZE_CODE, MesExtConstWords.IS_DELETED, MesExtConstWords.IS_VALID, MesExtConstWords.WORK_CENTER_CODE},

@ -3,7 +3,8 @@ package cn.estsh.i3plus.ext.mes.apiservice.utils;
import cn.estsh.i3plus.ext.mes.api.base.file.IMesFileService;
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.bean.MesEquipmentLogDetail;
import cn.estsh.i3plus.pojo.mes.bean.MesProductionAssembly;
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;
@ -51,8 +52,21 @@ public class MesTraceabilityTemp {
//设备
Font equFont = new Font(bfChinese, 8, Font.NORMAL);
equFont.setColor(new BaseColor(196, 222, 249));
//装备配件记录
Font assemblyFont = new Font(bfChinese, 8, Font.NORMAL);
assemblyFont.setColor(BaseColor.BLACK);
BaseColor assemblyBackColor = new BaseColor(193, 255, 192);
//工艺参数
Font equipmentLogFont = new Font(bfChinese, 8, Font.NORMAL);
equipmentLogFont.setColor(BaseColor.BLACK);
BaseColor equipmentLogColor = new BaseColor(191, 255, 255);
//蓝色背景色
BaseColor backgroundColor = new BaseColor(84, 132, 216);
//加工记录背景颜色
BaseColor recordBackgroundColor = new BaseColor(196, 220, 255);
//边框
BaseColor boardColor = new BaseColor(169, 169, 171);
//创建临时文件
file.createNewFile();
PdfWriter.getInstance(document, new FileOutputStream(file));
@ -478,6 +492,7 @@ public class MesTraceabilityTemp {
equCell01.setBackgroundColor(backgroundColor);
equCell01.setHorizontalAlignment(Element.ALIGN_CENTER);
equCell01.setVerticalAlignment(Element.ALIGN_MIDDLE);
equCell01.setBorderColor(BaseColor.WHITE);
equCell01.setPaddingBottom(3);
equCell01.setPaddingTop(1);
equCell01.setColspan(1);
@ -487,6 +502,7 @@ public class MesTraceabilityTemp {
equCell02.setBackgroundColor(backgroundColor);
equCell02.setHorizontalAlignment(Element.ALIGN_CENTER);
equCell02.setVerticalAlignment(Element.ALIGN_MIDDLE);
equCell02.setBorderColor(BaseColor.WHITE);
equCell02.setPaddingBottom(3);
equCell02.setPaddingTop(1);
equCell02.setColspan(1);
@ -496,6 +512,7 @@ public class MesTraceabilityTemp {
equCell03.setBackgroundColor(backgroundColor);
equCell03.setHorizontalAlignment(Element.ALIGN_CENTER);
equCell03.setVerticalAlignment(Element.ALIGN_MIDDLE);
equCell03.setBorderColor(BaseColor.WHITE);
equCell03.setPaddingBottom(3);
equCell03.setPaddingTop(1);
equCell03.setColspan(1);
@ -505,6 +522,7 @@ public class MesTraceabilityTemp {
equCell04.setBackgroundColor(backgroundColor);
equCell04.setHorizontalAlignment(Element.ALIGN_CENTER);
equCell04.setVerticalAlignment(Element.ALIGN_MIDDLE);
equCell04.setBorderColor(BaseColor.WHITE);
equCell04.setPaddingBottom(3);
equCell04.setPaddingTop(1);
equCell04.setColspan(1);
@ -514,6 +532,7 @@ public class MesTraceabilityTemp {
equCell05.setBackgroundColor(backgroundColor);
equCell05.setHorizontalAlignment(Element.ALIGN_CENTER);
equCell05.setVerticalAlignment(Element.ALIGN_MIDDLE);
equCell05.setBorderColor(BaseColor.WHITE);
equCell05.setPaddingBottom(3);
equCell05.setPaddingTop(1);
equCell05.setColspan(1);
@ -523,6 +542,7 @@ public class MesTraceabilityTemp {
equCell06.setBackgroundColor(backgroundColor);
equCell06.setHorizontalAlignment(Element.ALIGN_CENTER);
equCell06.setVerticalAlignment(Element.ALIGN_MIDDLE);
equCell06.setBorderColor(BaseColor.WHITE);
equCell06.setPaddingBottom(3);
equCell06.setPaddingTop(1);
equCell06.setColspan(1);
@ -530,14 +550,18 @@ public class MesTraceabilityTemp {
// 构建每一列
PdfPCell equCell00 = new PdfPCell(new Paragraph(dataModel.getEquipmentCode(), tableValueFont));
equCell00.setBackgroundColor(recordBackgroundColor);
equCell00.setHorizontalAlignment(Element.ALIGN_LEFT);
equCell00.setVerticalAlignment(Element.ALIGN_MIDDLE);
equCell00.setBorderColor(BaseColor.WHITE);
equCell00.setColspan(7);
equtable.addCell(equCell00);
PdfPCell equCell11 = new PdfPCell(new Paragraph(dataModel.getCraftCode(), tableValueFont));
equCell11.setHorizontalAlignment(Element.ALIGN_CENTER);
equCell11.setVerticalAlignment(Element.ALIGN_MIDDLE);
equCell11.setBackgroundColor(recordBackgroundColor);
equCell11.setBorderColor(BaseColor.WHITE);
equCell11.setPaddingBottom(3);
equCell11.setPaddingTop(1);
equtable.addCell(equCell11);
@ -545,6 +569,8 @@ public class MesTraceabilityTemp {
PdfPCell equCell21 = new PdfPCell(new Paragraph(dataModel.getStartDateTime(), tableValueFont));
equCell21.setHorizontalAlignment(Element.ALIGN_CENTER);
equCell21.setVerticalAlignment(Element.ALIGN_MIDDLE);
equCell21.setBackgroundColor(recordBackgroundColor);
equCell21.setBorderColor(BaseColor.WHITE);
equCell21.setPaddingBottom(3);
equCell21.setPaddingTop(1);
equtable.addCell(equCell21);
@ -552,6 +578,8 @@ public class MesTraceabilityTemp {
PdfPCell equCell31 = new PdfPCell(new Paragraph(dataModel.getCompleteDateTime(), tableValueFont));
equCell31.setHorizontalAlignment(Element.ALIGN_CENTER);
equCell31.setVerticalAlignment(Element.ALIGN_MIDDLE);
equCell31.setBackgroundColor(recordBackgroundColor);
equCell31.setBorderColor(BaseColor.WHITE);
equCell31.setPaddingBottom(3);
equCell31.setPaddingTop(1);
equtable.addCell(equCell31);
@ -559,6 +587,8 @@ public class MesTraceabilityTemp {
PdfPCell equCell41 = new PdfPCell(new Paragraph(dataModel.getTrayNo(), tableValueFont));
equCell41.setHorizontalAlignment(Element.ALIGN_CENTER);
equCell41.setVerticalAlignment(Element.ALIGN_MIDDLE);
equCell41.setBorderColor(BaseColor.WHITE);
equCell41.setBackgroundColor(recordBackgroundColor);
equCell41.setPaddingBottom(3);
equCell41.setPaddingTop(1);
equtable.addCell(equCell41);
@ -566,6 +596,8 @@ public class MesTraceabilityTemp {
PdfPCell equCell51 = new PdfPCell(new Paragraph(dataModel.getDurationStr(), tableValueFont));
equCell51.setHorizontalAlignment(Element.ALIGN_CENTER);
equCell51.setVerticalAlignment(Element.ALIGN_MIDDLE);
equCell51.setBackgroundColor(recordBackgroundColor);
equCell51.setBorderColor(BaseColor.WHITE);
equCell51.setPaddingBottom(3);
equCell51.setPaddingTop(1);
equtable.addCell(equCell51);
@ -573,51 +605,76 @@ public class MesTraceabilityTemp {
PdfPCell equCell61 = new PdfPCell(new Paragraph(CommonEnumUtil.VALID == dataModel.getIsComplete() ? "OK" : "NO", tableValueFont));
equCell61.setHorizontalAlignment(Element.ALIGN_CENTER);
equCell61.setVerticalAlignment(Element.ALIGN_MIDDLE);
equCell61.setBackgroundColor(recordBackgroundColor);
equCell61.setBorderColor(BaseColor.WHITE);
equCell61.setPaddingBottom(3);
equCell61.setPaddingTop(1);
equtable.addCell(equCell61);
int index = 0;
if (!CollectionUtils.isEmpty(dataModel.getMesWorkCellScanMonitorLogs())) {
for (MesWorkCellScanMonitorLog log : dataModel.getMesWorkCellScanMonitorLogs()) {
// 构建每一列
PdfPCell equcontentCell00 = new PdfPCell(new Paragraph("", tableValueFont));
equcontentCell00.setHorizontalAlignment(Element.ALIGN_LEFT);
equcontentCell00.setBorder(Rectangle.NO_BORDER);
equcontentCell00.setColspan(1);
equtable.addCell(equcontentCell00);
PdfPCell equcontentCell11 = new PdfPCell(new Paragraph(log.getMessage(), tableValueFont));
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);//白色
// //设备信息
// PdfPCell equCell71 = new PdfPCell(new Paragraph(lz("test111111111111111111111111111111111111111"), whiteFont));
// equCell71.setBackgroundColor(backgroundColor);
// equCell71.setHorizontalAlignment(Element.ALIGN_CENTER);
// equCell71.setVerticalAlignment(Element.ALIGN_MIDDLE);
// equCell71.setPaddingBottom(3);
// equCell71.setPaddingTop(1);
// equCell71.setColspan(7);
// equCell61.setBackgroundColor(recordBackgroundColor);
// equtable.addCell(equCell71);
//装配记录
if (!CollectionUtils.isEmpty(dataModel.getProductionAssemblyList())) {
for (MesProductionAssembly assembly : dataModel.getProductionAssemblyList()) {
PdfPCell assemblyCell1 = new PdfPCell(new Paragraph(assembly.getAssemblySn(), assemblyFont));
assemblyCell1.setPaddingBottom(3);
assemblyCell1.setPaddingTop(1);
assemblyCell1.setColspan(2);
assemblyCell1.setBackgroundColor(assemblyBackColor);
assemblyCell1.setBorderColor(boardColor);
equtable.addCell(assemblyCell1);
PdfPCell assemblyCell2 = new PdfPCell(new Paragraph(assembly.getAssemblyPartName(), assemblyFont));
assemblyCell2.setHorizontalAlignment(Element.ALIGN_RIGHT);
assemblyCell2.setVerticalAlignment(Element.ALIGN_RIGHT);
assemblyCell2.setBorderColor(boardColor);
assemblyCell2.setPaddingBottom(3);
assemblyCell2.setPaddingTop(1);
assemblyCell2.setColspan(2);
assemblyCell2.setBackgroundColor(assemblyBackColor);
equtable.addCell(assemblyCell2);
PdfPCell assemblyCell3 = new PdfPCell(new Paragraph(assembly.getModifyDatetime(), assemblyFont));
assemblyCell3.setHorizontalAlignment(Element.ALIGN_RIGHT);
assemblyCell3.setVerticalAlignment(Element.ALIGN_RIGHT);
assemblyCell3.setBorderColor(boardColor);
assemblyCell3.setPaddingBottom(3);
assemblyCell3.setPaddingTop(1);
assemblyCell3.setColspan(2);
assemblyCell3.setBackgroundColor(assemblyBackColor);
equtable.addCell(assemblyCell3);
}
}
//工艺参数
if (!CollectionUtils.isEmpty(dataModel.getMesEquipmentLogDetailList())) {
for (MesEquipmentLogDetail equipmentLogDetail : dataModel.getMesEquipmentLogDetailList()) {
equcontentCell11.setColspan(4);
PdfPCell equcontentCell11 = new PdfPCell(new Paragraph(equipmentLogDetail.getEquipVariableName(), equipmentLogFont));
equcontentCell11.setPaddingBottom(3);
equcontentCell11.setPaddingTop(1);
equcontentCell11.setBackgroundColor(equipmentLogColor);
equcontentCell11.setColspan(2);
equcontentCell11.setBorderColor(boardColor);
equtable.addCell(equcontentCell11);
PdfPCell equcontentCell21 = new PdfPCell(new Paragraph(log.getScanInfo(), tableValueFont));
PdfPCell equcontentCell21 = new PdfPCell(new Paragraph(equipmentLogDetail.getEquipVariableValue(), equipmentLogFont));
equcontentCell21.setHorizontalAlignment(Element.ALIGN_CENTER);
equcontentCell21.setVerticalAlignment(Element.ALIGN_MIDDLE);
equcontentCell21.setBorderColor(boardColor);
equcontentCell21.setPaddingBottom(3);
equcontentCell21.setPaddingTop(1);
if (index % 2 == 0) {
equcontentCell21.setBackgroundColor(new BaseColor(253, 239, 192));//黄色
} else {
equcontentCell21.setBackgroundColor(BaseColor.WHITE);//白色
}
equcontentCell21.setBackgroundColor(equipmentLogColor);
equcontentCell21.setColspan(2);
equtable.addCell(equcontentCell21);
index++;
}
}
document.add(equtable);
}
// 关闭文档

Loading…
Cancel
Save