Merge remote-tracking branch 'origin/dev' into dev

tags/yfai-mes-ext-v1.6
微笑着面对明天 9 months ago
commit 1390979630

@ -28,10 +28,9 @@ import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Arrays; import java.time.LocalDateTime;
import java.util.Date; import java.time.format.DateTimeFormatter;
import java.util.List; import java.util.*;
import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -203,14 +202,34 @@ public class MesWhiteListController extends MesBaseController {
@ApiOperation(value = "qmsSuspicious", notes = " ") @ApiOperation(value = "qmsSuspicious", notes = " ")
public ResultBean doQmsSuspiciousTest(String organizeCode) { public ResultBean doQmsSuspiciousTest(String organizeCode) {
DdlPackBean packBean = DdlPackBean.getDdlPackBean(organizeCode); DdlPackBean packBean = DdlPackBean.getDdlPackBean(organizeCode);
// DdlPreparedPack.getNumEqualPack(CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue(), "systemSyncStatus", packBean); LocalDateTime now = LocalDateTime.now();
DdlPreparedPack.timeBuilder( LocalDateTime oneHourAgo = now.minusHours(1);
new SimpleDateFormat("yyyy-MM-dd").format(TimeTool.getDateBefore(new Date(), 1)) + " 00:00:00", DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
TimeTool.getToday() + " 00:00:00", "createDatetime", packBean, true); String formattedNow = now.format(formatter);
String formattedOneHourAgo = oneHourAgo.format(formatter);
DdlPreparedPack.getNumEqualPack(CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue(), "qmsSync", packBean);
DdlPreparedPack.timeBuilder(formattedOneHourAgo, formattedNow, "createDatetime", packBean, true);
List<MesPartInspection> mesPartInspectionList = partInspectionRepository.findByHqlWhere(packBean); List<MesPartInspection> mesPartInspectionList = partInspectionRepository.findByHqlWhere(packBean);
if (!CollectionUtils.isEmpty(mesPartInspectionList)) { if (!CollectionUtils.isEmpty(mesPartInspectionList)) {
qmsSuspiciousService.doQmsSuspiciousByPartInspection(mesPartInspectionList,organizeCode); //过滤掉已经汇总的
List<MesPartInspection> partInspectionList = new ArrayList<>();
//排序取未同步的一条最早的
Map<String, List<MesPartInspection>> partMap = mesPartInspectionList.stream().collect(Collectors.groupingBy(p -> p.getSn() + "-" + p.getPartNo()));
for (Map.Entry<String, List<MesPartInspection>> stringListEntry : partMap.entrySet()) {
List<MesPartInspection> value = stringListEntry.getValue();
MesPartInspection next = value.stream().sorted(Comparator.comparing(MesPartInspection::getCreateDatetime).reversed()).iterator().next();
partInspectionList.add(next);
}
qmsSuspiciousService.doQmsSuspiciousByPartInspection(partInspectionList, organizeCode);
for (MesPartInspection mesPartInspection : mesPartInspectionList) {
mesPartInspection.setQmsSync(1);
mesPartInspection.setSystemSyncDatetime(TimeTool.getNowTime(true));
}
partInspectionRepository.saveAll(mesPartInspectionList);
} }
return ResultBean.success().setSuccess(true); return ResultBean.success().setSuccess(true);
} }

@ -4,6 +4,7 @@ import cn.estsh.i3plus.ext.mes.api.base.IMesQmsSuspiciousService;
import cn.estsh.i3plus.mes.apiservice.schedulejob.BaseMesScheduleJob; import cn.estsh.i3plus.mes.apiservice.schedulejob.BaseMesScheduleJob;
import cn.estsh.i3plus.platform.common.tool.TimeTool; import cn.estsh.i3plus.platform.common.tool.TimeTool;
import cn.estsh.i3plus.pojo.base.bean.DdlPackBean; import cn.estsh.i3plus.pojo.base.bean.DdlPackBean;
import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
import cn.estsh.i3plus.pojo.base.tool.DdlPreparedPack; import cn.estsh.i3plus.pojo.base.tool.DdlPreparedPack;
import cn.estsh.i3plus.pojo.mes.bean.nc.MesPartInspection; import cn.estsh.i3plus.pojo.mes.bean.nc.MesPartInspection;
import cn.estsh.i3plus.pojo.mes.repository.MesPartInspectionRepository; import cn.estsh.i3plus.pojo.mes.repository.MesPartInspectionRepository;
@ -81,7 +82,7 @@ public class MesQmsSuspiciousJob extends BaseMesScheduleJob {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
String formattedNow = now.format(formatter); String formattedNow = now.format(formatter);
String formattedOneHourAgo = oneHourAgo.format(formatter); String formattedOneHourAgo = oneHourAgo.format(formatter);
DdlPreparedPack.getNumEqualPack(CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue(), "qmsSync", packBean);
DdlPreparedPack.timeBuilder(formattedOneHourAgo, formattedNow, "createDatetime", packBean, true); DdlPreparedPack.timeBuilder(formattedOneHourAgo, formattedNow, "createDatetime", packBean, true);
List<MesPartInspection> mesPartInspectionList = partInspectionRepository.findByHqlWhere(packBean); List<MesPartInspection> mesPartInspectionList = partInspectionRepository.findByHqlWhere(packBean);
@ -92,17 +93,11 @@ public class MesQmsSuspiciousJob extends BaseMesScheduleJob {
Map<String, List<MesPartInspection>> partMap = mesPartInspectionList.stream().collect(Collectors.groupingBy(p -> p.getSn() + "-" + p.getPartNo())); Map<String, List<MesPartInspection>> partMap = mesPartInspectionList.stream().collect(Collectors.groupingBy(p -> p.getSn() + "-" + p.getPartNo()));
for (Map.Entry<String, List<MesPartInspection>> stringListEntry : partMap.entrySet()) { for (Map.Entry<String, List<MesPartInspection>> stringListEntry : partMap.entrySet()) {
List<MesPartInspection> value = stringListEntry.getValue(); List<MesPartInspection> value = stringListEntry.getValue();
MesPartInspection next = value.stream().sorted(Comparator.comparing(MesPartInspection::getCreateDatetime)).iterator().next(); MesPartInspection next = value.stream().sorted(Comparator.comparing(MesPartInspection::getCreateDatetime).reversed()).iterator().next();
DdlPackBean packBeanNew = DdlPackBean.getDdlPackBean(organizeCode);
DdlPreparedPack.getStringEqualPack(next.getPartNo(), "partNo", packBeanNew);
DdlPreparedPack.getStringEqualPack(next.getSn(), "sn", packBeanNew);
DdlPreparedPack.getNumEqualPack(1, "qmsSync", packBeanNew);
boolean flg = partInspectionRepository.isExitByHql(packBeanNew);
if (!flg) {
partInspectionList.add(next); partInspectionList.add(next);
} }
} LOGGER.info("MES可疑品汇总 ----- partInspectionList{}",partInspectionList.size());
qmsSuspiciousService.doQmsSuspiciousByPartInspection(partInspectionList, organizeCode); qmsSuspiciousService.doQmsSuspiciousByPartInspection(partInspectionList, organizeCode);
for (MesPartInspection mesPartInspection : mesPartInspectionList) { for (MesPartInspection mesPartInspection : mesPartInspectionList) {

@ -1,5 +1,7 @@
package cn.estsh.i3plus.ext.mes.apiservice.serviceimpl.base; package cn.estsh.i3plus.ext.mes.apiservice.serviceimpl.base;
import cn.estsh.i3plus.pojo.base.bean.DdlPackBean;
import cn.estsh.i3plus.pojo.base.tool.DdlPreparedPack;
import cn.estsh.i3plus.pojo.mes.bean.MesPartProdGroupWindowTime; import cn.estsh.i3plus.pojo.mes.bean.MesPartProdGroupWindowTime;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -8,4 +10,9 @@ import org.springframework.stereotype.Service;
@Slf4j @Slf4j
public class MesPartProdGroupWindowTimeService extends BaseMesService<MesPartProdGroupWindowTime> { public class MesPartProdGroupWindowTimeService extends BaseMesService<MesPartProdGroupWindowTime> {
@Override
protected void setPackQueryBean(MesPartProdGroupWindowTime bean, DdlPackBean packBean) {
DdlPreparedPack.getStringEqualPack(bean.getPartProdGroupCode(), "partProdGroupCode", packBean);
DdlPreparedPack.getStringEqualPack(bean.getPartProdGroupName(), "partProdGroupName", packBean);
}
} }

@ -10,10 +10,12 @@ import cn.estsh.i3plus.pojo.mes.bean.nc.MesPartInspection;
import cn.estsh.i3plus.pojo.mes.bean.nc.MesPartInspectionDetail; import cn.estsh.i3plus.pojo.mes.bean.nc.MesPartInspectionDetail;
import cn.estsh.i3plus.pojo.mes.bean.rework.MesReworkTask; import cn.estsh.i3plus.pojo.mes.bean.rework.MesReworkTask;
import cn.estsh.i3plus.pojo.mes.repository.MesPartInspectionDetailRepository; import cn.estsh.i3plus.pojo.mes.repository.MesPartInspectionDetailRepository;
import cn.estsh.i3plus.pojo.mes.repository.MesPartInspectionRepository;
import cn.estsh.i3plus.pojo.mes.repository.MesReworkTaskRepository; import cn.estsh.i3plus.pojo.mes.repository.MesReworkTaskRepository;
import cn.estsh.i3plus.pojo.mes.util.MesExtEnumUtil; import cn.estsh.i3plus.pojo.mes.util.MesExtEnumUtil;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -40,6 +42,9 @@ public class MesQmsSuspiciousService extends BaseMesService<MesQmsSuspicious> im
@Autowired @Autowired
private MesReworkTaskRepository mesReworkTaskRepository; private MesReworkTaskRepository mesReworkTaskRepository;
@Autowired
private MesPartInspectionRepository partInspectionRepository;
@Override @Override
protected void setPackQueryBean(MesQmsSuspicious bean, DdlPackBean packBean) { protected void setPackQueryBean(MesQmsSuspicious bean, DdlPackBean packBean) {
DdlPreparedPack.getStringLikerPack(bean.getPartNo(), "partNo", packBean); DdlPreparedPack.getStringLikerPack(bean.getPartNo(), "partNo", packBean);
@ -58,13 +63,36 @@ public class MesQmsSuspiciousService extends BaseMesService<MesQmsSuspicious> im
//根据物料对可疑品分组 //根据物料对可疑品分组
for (Map.Entry<String, List<MesPartInspection>> stringListEntry : workOrderPartMap.entrySet()) { for (Map.Entry<String, List<MesPartInspection>> stringListEntry : workOrderPartMap.entrySet()) {
String key = stringListEntry.getKey(); String key = stringListEntry.getKey();
List<MesPartInspection> mesPartInspections = stringListEntry.getValue(); List<MesPartInspection> mesPartInspectionsList = stringListEntry.getValue();
//修改时间的集合
List<MesPartInspection> mesPartInspectionsListTime = new ArrayList<>();
for (MesPartInspection partInspection : mesPartInspectionsList) {
MesPartInspection partInspectionNew = new MesPartInspection();
BeanUtils.copyProperties(partInspection, partInspectionNew);
//去创建日期换算整点2024-07-25 10:00:00
DdlPackBean packBeanNew = DdlPackBean.getDdlPackBean(organizeCode);
DdlPreparedPack.getStringEqualPack(partInspection.getPartNo(), "partNo", packBeanNew);
DdlPreparedPack.getStringEqualPack(partInspection.getSn(), "sn", packBeanNew);
packBeanNew.setOrderByStr(" order by createDatetime ");
MesPartInspection partInspectionDao = partInspectionRepository.getByProperty(packBeanNew);
String qmsTime = partInspection.getCreateDatetime().substring(0, 13) + ":00:00";
if (!StringUtil.isEmpty(partInspectionDao)) {
qmsTime = partInspectionDao.getCreateDatetime().substring(0, 13) + ":00:00";
}
partInspectionNew.setInspectionDate(qmsTime);
mesPartInspectionsListTime.add(partInspectionNew);
}
//根据时间分组发送
Map<String, List<MesPartInspection>> mesPartInspectionsMap = mesPartInspectionsListTime.stream().collect(Collectors.groupingBy(MesPartInspection::getInspectionDate));
for (Map.Entry<String, List<MesPartInspection>> partInspection : mesPartInspectionsMap.entrySet()) {
List<MesPartInspection> mesPartInspections = partInspection.getValue();
MesPartInspection next = mesPartInspections.iterator().next(); MesPartInspection next = mesPartInspections.iterator().next();
//新增一条数据到报废表中 //新增一条数据到报废表中
MesQmsSuspicious mesQmsSuspicious = new MesQmsSuspicious(); MesQmsSuspicious mesQmsSuspicious = new MesQmsSuspicious();
mesQmsSuspicious.setOrganizeCode(organizeCode); mesQmsSuspicious.setOrganizeCode(organizeCode);
mesQmsSuspicious.setInspectionDate(next.getInspectionDate()); mesQmsSuspicious.setInspectionDate(next.getInspectionDate());
//检验数量是全部数量汇总 //检验数量是全部数量汇总
double sumQty = mesPartInspections.stream().mapToDouble(MesPartInspection::getQty).sum(); double sumQty = mesPartInspections.stream().mapToDouble(MesPartInspection::getQty).sum();
mesQmsSuspicious.setInspectionQty((int) sumQty); mesQmsSuspicious.setInspectionQty((int) sumQty);
@ -131,5 +159,7 @@ public class MesQmsSuspiciousService extends BaseMesService<MesQmsSuspicious> im
baseRDao.insert(mesQmsSuspicious); baseRDao.insert(mesQmsSuspicious);
} }
}
} }
} }

@ -37,10 +37,7 @@ import org.springframework.util.CollectionUtils;
import java.io.IOException; import java.io.IOException;
import java.text.ParseException; import java.text.ParseException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.*;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
@ -87,6 +84,12 @@ public class MesYfReportServiceImpl implements IMesYfReportService {
@Autowired @Autowired
private IMesFileService mesFileService; private IMesFileService mesFileService;
@Autowired
private MesEquipmentLogDetailRepository mesEquipmentLogDetailRepository;
@Autowired
private MesEquipmentRepository mesEquipmentRepository;
@Override @Override
public ListPager<MesDeviceDataQueryReportResultModel> queryMesDeviceDataByPager(MesDeviceDataQueryReportConditionModel queryReportModel, Pager pager) { public ListPager<MesDeviceDataQueryReportResultModel> queryMesDeviceDataByPager(MesDeviceDataQueryReportConditionModel queryReportModel, Pager pager) {
ListPager<MesDeviceDataQueryReportResultModel> mesDeviceDataQueryReportResultModelListPager = 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<String> processCodeList = productionRecordList.stream().map(MesProductionRecord::getProcessCode).filter(StringUtil::isNotEmpty).collect(Collectors.toList());
//装配记录表 //装配记录表
List<MesProductionAssembly> productionAssemblyList = mesProductionAssemblyRepository.findByHqlWhere(packBean); 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())); 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
List<MesWorkCellScanMonitorLog> mesWorkCellScanMonitorLogs = getWorkCellScanMonitorLogList(productionRecordList); Map<String, List<MesEquipmentLogDetail>> mesEquipmentLogDetailMap = getMesEquipmentLogDetailMap(mesProduceSn, productionRecordList);
Map<String, List<MesWorkCellScanMonitorLog>> mesWorkCellScanMonitorMap = CollectionUtils.isEmpty(mesWorkCellScanMonitorLogs) ? null : mesWorkCellScanMonitorLogs.stream().collect(Collectors.groupingBy(t -> t.getWorkCenterCode() + t.getWorkCellCode() + t.getEquipmentCode()));
//查询工序名称 //查询工序名称
Map<String, MesProcess> processMap = getMesProcessMap(mesProduceSn, processCodeList); Map<String, MesProcess> processMap = getMesProcessMap(mesProduceSn, processCodeList);
//数据组装 //数据组装
@ -174,13 +176,14 @@ public class MesYfReportServiceImpl implements IMesYfReportService {
duration += dataModel.getDuration(); 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)) { if (!Objects.isNull(productionAssemblyMap) && productionAssemblyMap.containsKey(key)) {
dataModel.setProductionAssemblyList(productionAssemblyMap.get(key)); dataModel.setProductionAssemblyList(productionAssemblyMap.get(key));
} }
//工位扫描监控日志 //工艺加工参数
if (!Objects.isNull(mesWorkCellScanMonitorMap) && mesWorkCellScanMonitorMap.containsKey(key)) { key = new StringJoiner(MesExtConstWords.COMMA).add(mesProductionRecord.getMouldRecordId().toString()).add(mesProductionRecord.getWorkCenterCode()).add(mesProductionRecord.getWorkCellCode()).add(mesProductionRecord.getEquipmentCode()).toString();
dataModel.setMesWorkCellScanMonitorLogs(mesWorkCellScanMonitorMap.get(key)); if (!Objects.isNull(mesEquipmentLogDetailMap) && mesEquipmentLogDetailMap.containsKey(key)) {
dataModel.setMesEquipmentLogDetailList(mesEquipmentLogDetailMap.get(key));
} }
//查询工序名称 //查询工序名称
if(StringUtil.isNotEmpty(dataModel.getProcessCode())){ if(StringUtil.isNotEmpty(dataModel.getProcessCode())){
@ -217,6 +220,31 @@ public class MesYfReportServiceImpl implements IMesYfReportService {
return mesTraceabilityReportModelList; 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) { private MesWorkCenter getWorkCenter(MesProduceSn produceSn) {
MesWorkCenter workCenter = workCenterRepository.getByProperty( MesWorkCenter workCenter = workCenterRepository.getByProperty(
new String[]{MesExtConstWords.ORGANIZE_CODE, MesExtConstWords.IS_DELETED, MesExtConstWords.IS_VALID, MesExtConstWords.WORK_CENTER_CODE}, 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.api.base.file.IMesFileService;
import cn.estsh.i3plus.ext.mes.pojo.constant.MesCommonConstant; import cn.estsh.i3plus.ext.mes.pojo.constant.MesCommonConstant;
import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil; 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.MesTraceabilityReportDataModel;
import cn.estsh.i3plus.pojo.mes.model.report.MesTraceabilityReportModel; import cn.estsh.i3plus.pojo.mes.model.report.MesTraceabilityReportModel;
import cn.estsh.i3plus.pojo.mes.util.MesExtEnumUtil; import cn.estsh.i3plus.pojo.mes.util.MesExtEnumUtil;
@ -51,8 +52,21 @@ public class MesTraceabilityTemp {
//设备 //设备
Font equFont = new Font(bfChinese, 8, Font.NORMAL); Font equFont = new Font(bfChinese, 8, Font.NORMAL);
equFont.setColor(new BaseColor(196, 222, 249)); 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 backgroundColor = new BaseColor(84, 132, 216);
//加工记录背景颜色
BaseColor recordBackgroundColor = new BaseColor(196, 220, 255);
//边框
BaseColor boardColor = new BaseColor(169, 169, 171);
//创建临时文件 //创建临时文件
file.createNewFile(); file.createNewFile();
PdfWriter.getInstance(document, new FileOutputStream(file)); PdfWriter.getInstance(document, new FileOutputStream(file));
@ -478,6 +492,7 @@ public class MesTraceabilityTemp {
equCell01.setBackgroundColor(backgroundColor); equCell01.setBackgroundColor(backgroundColor);
equCell01.setHorizontalAlignment(Element.ALIGN_CENTER); equCell01.setHorizontalAlignment(Element.ALIGN_CENTER);
equCell01.setVerticalAlignment(Element.ALIGN_MIDDLE); equCell01.setVerticalAlignment(Element.ALIGN_MIDDLE);
equCell01.setBorderColor(BaseColor.WHITE);
equCell01.setPaddingBottom(3); equCell01.setPaddingBottom(3);
equCell01.setPaddingTop(1); equCell01.setPaddingTop(1);
equCell01.setColspan(1); equCell01.setColspan(1);
@ -487,6 +502,7 @@ public class MesTraceabilityTemp {
equCell02.setBackgroundColor(backgroundColor); equCell02.setBackgroundColor(backgroundColor);
equCell02.setHorizontalAlignment(Element.ALIGN_CENTER); equCell02.setHorizontalAlignment(Element.ALIGN_CENTER);
equCell02.setVerticalAlignment(Element.ALIGN_MIDDLE); equCell02.setVerticalAlignment(Element.ALIGN_MIDDLE);
equCell02.setBorderColor(BaseColor.WHITE);
equCell02.setPaddingBottom(3); equCell02.setPaddingBottom(3);
equCell02.setPaddingTop(1); equCell02.setPaddingTop(1);
equCell02.setColspan(1); equCell02.setColspan(1);
@ -496,6 +512,7 @@ public class MesTraceabilityTemp {
equCell03.setBackgroundColor(backgroundColor); equCell03.setBackgroundColor(backgroundColor);
equCell03.setHorizontalAlignment(Element.ALIGN_CENTER); equCell03.setHorizontalAlignment(Element.ALIGN_CENTER);
equCell03.setVerticalAlignment(Element.ALIGN_MIDDLE); equCell03.setVerticalAlignment(Element.ALIGN_MIDDLE);
equCell03.setBorderColor(BaseColor.WHITE);
equCell03.setPaddingBottom(3); equCell03.setPaddingBottom(3);
equCell03.setPaddingTop(1); equCell03.setPaddingTop(1);
equCell03.setColspan(1); equCell03.setColspan(1);
@ -505,6 +522,7 @@ public class MesTraceabilityTemp {
equCell04.setBackgroundColor(backgroundColor); equCell04.setBackgroundColor(backgroundColor);
equCell04.setHorizontalAlignment(Element.ALIGN_CENTER); equCell04.setHorizontalAlignment(Element.ALIGN_CENTER);
equCell04.setVerticalAlignment(Element.ALIGN_MIDDLE); equCell04.setVerticalAlignment(Element.ALIGN_MIDDLE);
equCell04.setBorderColor(BaseColor.WHITE);
equCell04.setPaddingBottom(3); equCell04.setPaddingBottom(3);
equCell04.setPaddingTop(1); equCell04.setPaddingTop(1);
equCell04.setColspan(1); equCell04.setColspan(1);
@ -514,6 +532,7 @@ public class MesTraceabilityTemp {
equCell05.setBackgroundColor(backgroundColor); equCell05.setBackgroundColor(backgroundColor);
equCell05.setHorizontalAlignment(Element.ALIGN_CENTER); equCell05.setHorizontalAlignment(Element.ALIGN_CENTER);
equCell05.setVerticalAlignment(Element.ALIGN_MIDDLE); equCell05.setVerticalAlignment(Element.ALIGN_MIDDLE);
equCell05.setBorderColor(BaseColor.WHITE);
equCell05.setPaddingBottom(3); equCell05.setPaddingBottom(3);
equCell05.setPaddingTop(1); equCell05.setPaddingTop(1);
equCell05.setColspan(1); equCell05.setColspan(1);
@ -523,6 +542,7 @@ public class MesTraceabilityTemp {
equCell06.setBackgroundColor(backgroundColor); equCell06.setBackgroundColor(backgroundColor);
equCell06.setHorizontalAlignment(Element.ALIGN_CENTER); equCell06.setHorizontalAlignment(Element.ALIGN_CENTER);
equCell06.setVerticalAlignment(Element.ALIGN_MIDDLE); equCell06.setVerticalAlignment(Element.ALIGN_MIDDLE);
equCell06.setBorderColor(BaseColor.WHITE);
equCell06.setPaddingBottom(3); equCell06.setPaddingBottom(3);
equCell06.setPaddingTop(1); equCell06.setPaddingTop(1);
equCell06.setColspan(1); equCell06.setColspan(1);
@ -530,14 +550,18 @@ public class MesTraceabilityTemp {
// 构建每一列 // 构建每一列
PdfPCell equCell00 = new PdfPCell(new Paragraph(dataModel.getEquipmentCode(), tableValueFont)); PdfPCell equCell00 = new PdfPCell(new Paragraph(dataModel.getEquipmentCode(), tableValueFont));
equCell00.setBackgroundColor(recordBackgroundColor);
equCell00.setHorizontalAlignment(Element.ALIGN_LEFT); equCell00.setHorizontalAlignment(Element.ALIGN_LEFT);
equCell00.setVerticalAlignment(Element.ALIGN_MIDDLE); equCell00.setVerticalAlignment(Element.ALIGN_MIDDLE);
equCell00.setBorderColor(BaseColor.WHITE);
equCell00.setColspan(7); equCell00.setColspan(7);
equtable.addCell(equCell00); equtable.addCell(equCell00);
PdfPCell equCell11 = new PdfPCell(new Paragraph(dataModel.getCraftCode(), tableValueFont)); PdfPCell equCell11 = new PdfPCell(new Paragraph(dataModel.getCraftCode(), tableValueFont));
equCell11.setHorizontalAlignment(Element.ALIGN_CENTER); equCell11.setHorizontalAlignment(Element.ALIGN_CENTER);
equCell11.setVerticalAlignment(Element.ALIGN_MIDDLE); equCell11.setVerticalAlignment(Element.ALIGN_MIDDLE);
equCell11.setBackgroundColor(recordBackgroundColor);
equCell11.setBorderColor(BaseColor.WHITE);
equCell11.setPaddingBottom(3); equCell11.setPaddingBottom(3);
equCell11.setPaddingTop(1); equCell11.setPaddingTop(1);
equtable.addCell(equCell11); equtable.addCell(equCell11);
@ -545,6 +569,8 @@ public class MesTraceabilityTemp {
PdfPCell equCell21 = new PdfPCell(new Paragraph(dataModel.getStartDateTime(), tableValueFont)); PdfPCell equCell21 = new PdfPCell(new Paragraph(dataModel.getStartDateTime(), tableValueFont));
equCell21.setHorizontalAlignment(Element.ALIGN_CENTER); equCell21.setHorizontalAlignment(Element.ALIGN_CENTER);
equCell21.setVerticalAlignment(Element.ALIGN_MIDDLE); equCell21.setVerticalAlignment(Element.ALIGN_MIDDLE);
equCell21.setBackgroundColor(recordBackgroundColor);
equCell21.setBorderColor(BaseColor.WHITE);
equCell21.setPaddingBottom(3); equCell21.setPaddingBottom(3);
equCell21.setPaddingTop(1); equCell21.setPaddingTop(1);
equtable.addCell(equCell21); equtable.addCell(equCell21);
@ -552,6 +578,8 @@ public class MesTraceabilityTemp {
PdfPCell equCell31 = new PdfPCell(new Paragraph(dataModel.getCompleteDateTime(), tableValueFont)); PdfPCell equCell31 = new PdfPCell(new Paragraph(dataModel.getCompleteDateTime(), tableValueFont));
equCell31.setHorizontalAlignment(Element.ALIGN_CENTER); equCell31.setHorizontalAlignment(Element.ALIGN_CENTER);
equCell31.setVerticalAlignment(Element.ALIGN_MIDDLE); equCell31.setVerticalAlignment(Element.ALIGN_MIDDLE);
equCell31.setBackgroundColor(recordBackgroundColor);
equCell31.setBorderColor(BaseColor.WHITE);
equCell31.setPaddingBottom(3); equCell31.setPaddingBottom(3);
equCell31.setPaddingTop(1); equCell31.setPaddingTop(1);
equtable.addCell(equCell31); equtable.addCell(equCell31);
@ -559,6 +587,8 @@ public class MesTraceabilityTemp {
PdfPCell equCell41 = new PdfPCell(new Paragraph(dataModel.getTrayNo(), tableValueFont)); PdfPCell equCell41 = new PdfPCell(new Paragraph(dataModel.getTrayNo(), tableValueFont));
equCell41.setHorizontalAlignment(Element.ALIGN_CENTER); equCell41.setHorizontalAlignment(Element.ALIGN_CENTER);
equCell41.setVerticalAlignment(Element.ALIGN_MIDDLE); equCell41.setVerticalAlignment(Element.ALIGN_MIDDLE);
equCell41.setBorderColor(BaseColor.WHITE);
equCell41.setBackgroundColor(recordBackgroundColor);
equCell41.setPaddingBottom(3); equCell41.setPaddingBottom(3);
equCell41.setPaddingTop(1); equCell41.setPaddingTop(1);
equtable.addCell(equCell41); equtable.addCell(equCell41);
@ -566,6 +596,8 @@ public class MesTraceabilityTemp {
PdfPCell equCell51 = new PdfPCell(new Paragraph(dataModel.getDurationStr(), tableValueFont)); PdfPCell equCell51 = new PdfPCell(new Paragraph(dataModel.getDurationStr(), tableValueFont));
equCell51.setHorizontalAlignment(Element.ALIGN_CENTER); equCell51.setHorizontalAlignment(Element.ALIGN_CENTER);
equCell51.setVerticalAlignment(Element.ALIGN_MIDDLE); equCell51.setVerticalAlignment(Element.ALIGN_MIDDLE);
equCell51.setBackgroundColor(recordBackgroundColor);
equCell51.setBorderColor(BaseColor.WHITE);
equCell51.setPaddingBottom(3); equCell51.setPaddingBottom(3);
equCell51.setPaddingTop(1); equCell51.setPaddingTop(1);
equtable.addCell(equCell51); equtable.addCell(equCell51);
@ -573,51 +605,76 @@ public class MesTraceabilityTemp {
PdfPCell equCell61 = new PdfPCell(new Paragraph(CommonEnumUtil.VALID == dataModel.getIsComplete() ? "OK" : "NO", tableValueFont)); PdfPCell equCell61 = new PdfPCell(new Paragraph(CommonEnumUtil.VALID == dataModel.getIsComplete() ? "OK" : "NO", tableValueFont));
equCell61.setHorizontalAlignment(Element.ALIGN_CENTER); equCell61.setHorizontalAlignment(Element.ALIGN_CENTER);
equCell61.setVerticalAlignment(Element.ALIGN_MIDDLE); equCell61.setVerticalAlignment(Element.ALIGN_MIDDLE);
equCell61.setBackgroundColor(recordBackgroundColor);
equCell61.setBorderColor(BaseColor.WHITE);
equCell61.setPaddingBottom(3); equCell61.setPaddingBottom(3);
equCell61.setPaddingTop(1); equCell61.setPaddingTop(1);
equtable.addCell(equCell61); equtable.addCell(equCell61);
int index = 0; // //设备信息
if (!CollectionUtils.isEmpty(dataModel.getMesWorkCellScanMonitorLogs())) { // PdfPCell equCell71 = new PdfPCell(new Paragraph(lz("test111111111111111111111111111111111111111"), whiteFont));
for (MesWorkCellScanMonitorLog log : dataModel.getMesWorkCellScanMonitorLogs()) { // equCell71.setBackgroundColor(backgroundColor);
// 构建每一列 // equCell71.setHorizontalAlignment(Element.ALIGN_CENTER);
PdfPCell equcontentCell00 = new PdfPCell(new Paragraph("", tableValueFont)); // equCell71.setVerticalAlignment(Element.ALIGN_MIDDLE);
equcontentCell00.setHorizontalAlignment(Element.ALIGN_LEFT); // equCell71.setPaddingBottom(3);
equcontentCell00.setBorder(Rectangle.NO_BORDER); // equCell71.setPaddingTop(1);
equcontentCell00.setColspan(1); // equCell71.setColspan(7);
equtable.addCell(equcontentCell00); // equCell61.setBackgroundColor(recordBackgroundColor);
// equtable.addCell(equCell71);
PdfPCell equcontentCell11 = new PdfPCell(new Paragraph(log.getMessage(), tableValueFont)); //装配记录
equcontentCell11.setHorizontalAlignment(Element.ALIGN_CENTER); if (!CollectionUtils.isEmpty(dataModel.getProductionAssemblyList())) {
equcontentCell11.setVerticalAlignment(Element.ALIGN_MIDDLE); for (MesProductionAssembly assembly : dataModel.getProductionAssemblyList()) {
equcontentCell11.setPaddingBottom(3); PdfPCell assemblyCell1 = new PdfPCell(new Paragraph(assembly.getAssemblySn(), assemblyFont));
equcontentCell11.setPaddingTop(1); assemblyCell1.setPaddingBottom(3);
assemblyCell1.setPaddingTop(1);
if (index % 2 == 0) { assemblyCell1.setColspan(2);
equcontentCell11.setBackgroundColor(new BaseColor(253, 239, 192));//黄色 assemblyCell1.setBackgroundColor(assemblyBackColor);
} else { assemblyCell1.setBorderColor(boardColor);
equcontentCell11.setBackgroundColor(BaseColor.WHITE);//白色 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); 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.setHorizontalAlignment(Element.ALIGN_CENTER);
equcontentCell21.setVerticalAlignment(Element.ALIGN_MIDDLE); equcontentCell21.setVerticalAlignment(Element.ALIGN_MIDDLE);
equcontentCell21.setBorderColor(boardColor);
equcontentCell21.setPaddingBottom(3); equcontentCell21.setPaddingBottom(3);
equcontentCell21.setPaddingTop(1); equcontentCell21.setPaddingTop(1);
equcontentCell21.setBackgroundColor(equipmentLogColor);
if (index % 2 == 0) {
equcontentCell21.setBackgroundColor(new BaseColor(253, 239, 192));//黄色
} else {
equcontentCell21.setBackgroundColor(BaseColor.WHITE);//白色
}
equcontentCell21.setColspan(2); equcontentCell21.setColspan(2);
equtable.addCell(equcontentCell21); equtable.addCell(equcontentCell21);
index++;
} }
} }
document.add(equtable); document.add(equtable);
} }
// 关闭文档 // 关闭文档

Loading…
Cancel
Save