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 java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.stream.Collectors;
@ -203,14 +202,34 @@ public class MesWhiteListController extends MesBaseController {
@ApiOperation(value = "qmsSuspicious", notes = " ")
public ResultBean doQmsSuspiciousTest(String organizeCode) {
DdlPackBean packBean = DdlPackBean.getDdlPackBean(organizeCode);
// DdlPreparedPack.getNumEqualPack(CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue(), "systemSyncStatus", packBean);
DdlPreparedPack.timeBuilder(
new SimpleDateFormat("yyyy-MM-dd").format(TimeTool.getDateBefore(new Date(), 1)) + " 00:00:00",
TimeTool.getToday() + " 00:00:00", "createDatetime", packBean, true);
LocalDateTime now = LocalDateTime.now();
LocalDateTime oneHourAgo = now.minusHours(1);
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
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);
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);
}

@ -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.platform.common.tool.TimeTool;
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.mes.bean.nc.MesPartInspection;
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");
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);
@ -92,17 +93,11 @@ public class MesQmsSuspiciousJob extends BaseMesScheduleJob {
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)).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);
}
}
MesPartInspection next = value.stream().sorted(Comparator.comparing(MesPartInspection::getCreateDatetime).reversed()).iterator().next();
partInspectionList.add(next);
}
LOGGER.info("MES可疑品汇总 ----- partInspectionList{}",partInspectionList.size());
qmsSuspiciousService.doQmsSuspiciousByPartInspection(partInspectionList, organizeCode);
for (MesPartInspection mesPartInspection : mesPartInspectionList) {

@ -1,5 +1,7 @@
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 lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
@ -8,4 +10,9 @@ import org.springframework.stereotype.Service;
@Slf4j
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.rework.MesReworkTask;
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.util.MesExtEnumUtil;
import com.alibaba.fastjson.JSON;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -40,6 +42,9 @@ public class MesQmsSuspiciousService extends BaseMesService<MesQmsSuspicious> im
@Autowired
private MesReworkTaskRepository mesReworkTaskRepository;
@Autowired
private MesPartInspectionRepository partInspectionRepository;
@Override
protected void setPackQueryBean(MesQmsSuspicious bean, DdlPackBean packBean) {
DdlPreparedPack.getStringLikerPack(bean.getPartNo(), "partNo", packBean);
@ -58,78 +63,103 @@ public class MesQmsSuspiciousService extends BaseMesService<MesQmsSuspicious> im
//根据物料对可疑品分组
for (Map.Entry<String, List<MesPartInspection>> stringListEntry : workOrderPartMap.entrySet()) {
String key = stringListEntry.getKey();
List<MesPartInspection> mesPartInspections = stringListEntry.getValue();
MesPartInspection next = mesPartInspections.iterator().next();
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();
//新增一条数据到报废表中
MesQmsSuspicious mesQmsSuspicious = new MesQmsSuspicious();
mesQmsSuspicious.setOrganizeCode(organizeCode);
mesQmsSuspicious.setInspectionDate(next.getInspectionDate());
//检验数量是全部数量汇总
double sumQty = mesPartInspections.stream().mapToDouble(MesPartInspection::getQty).sum();
mesQmsSuspicious.setInspectionQty((int) sumQty);
//一次合格数 nc_status=10 inspection_status=10
double qualifiedQty = mesPartInspections.stream().filter(m -> m.getNcStatus() == 10 && m.getInspectionStatus() == 10).mapToDouble(MesPartInspection::getQty).sum();
mesQmsSuspicious.setQualifiedQty((int) qualifiedQty);
//不合格数 nc_status=10 inspection_status=20
double unqualifiedQty = mesPartInspections.stream().filter(m -> m.getNcStatus() == 10 && m.getInspectionStatus() == 20).mapToDouble(MesPartInspection::getQty).sum();
mesQmsSuspicious.setUnqualifiedQty((int) unqualifiedQty);
//误判数量 nc_status=30 inspection_status=20
double misjudgmentQty = mesPartInspections.stream().filter(m -> m.getNcStatus() == 30).mapToDouble(MesPartInspection::getQty).sum();
mesQmsSuspicious.setMisjudgmentQty((int) misjudgmentQty);
//一次报废数 nc_status=40 inspection_status=20
double scrappedQty = mesPartInspections.stream().filter(m -> m.getNcStatus() == 40 && m.getInspectionStatus() == 20).mapToDouble(MesPartInspection::getQty).sum();
mesQmsSuspicious.setScrappedQty((int) scrappedQty);
//新增一条数据到报废表中
MesQmsSuspicious mesQmsSuspicious = new MesQmsSuspicious();
mesQmsSuspicious.setOrganizeCode(organizeCode);
mesQmsSuspicious.setInspectionDate(next.getInspectionDate());
//返工合格数 nc_status=50 返工单 status=20
Integer reworkQualified = 0;
//返工pending创建返工单未处理
Integer reworkPending = 0;
//返工数
Integer reworkQty = 0;
List<MesPartInspectionDetail> mesPartInspectionDetails = new ArrayList<>();
for (MesPartInspection mesPartInspection : mesPartInspections) {
if(!StringUtil.isEmpty(idDetailListMap.get(mesPartInspection.getId()))){
mesPartInspectionDetails.addAll(idDetailListMap.get(mesPartInspection.getId()));
}
//计算返工数量
if (mesPartInspection.getNcStatus() == MesExtEnumUtil.PART_INSPECTION_NC_STATUS.REWORK.getValue()) {
MesReworkTask reworkTask = mesReworkTaskRepository.getById(mesPartInspection.getReworkTaskId());
if (!StringUtil.isEmpty(reworkTask)) {
//返工是否完成
if (reworkTask.getStatus() == MesExtEnumUtil.REWORK_TASK_STATUS.FINISH.getValue()) {
reworkQualified += mesPartInspection.getQty();
//检验数量是全部数量汇总
double sumQty = mesPartInspections.stream().mapToDouble(MesPartInspection::getQty).sum();
mesQmsSuspicious.setInspectionQty((int) sumQty);
//一次合格数 nc_status=10 inspection_status=10
double qualifiedQty = mesPartInspections.stream().filter(m -> m.getNcStatus() == 10 && m.getInspectionStatus() == 10).mapToDouble(MesPartInspection::getQty).sum();
mesQmsSuspicious.setQualifiedQty((int) qualifiedQty);
//不合格数 nc_status=10 inspection_status=20
double unqualifiedQty = mesPartInspections.stream().filter(m -> m.getNcStatus() == 10 && m.getInspectionStatus() == 20).mapToDouble(MesPartInspection::getQty).sum();
mesQmsSuspicious.setUnqualifiedQty((int) unqualifiedQty);
//误判数量 nc_status=30 inspection_status=20
double misjudgmentQty = mesPartInspections.stream().filter(m -> m.getNcStatus() == 30).mapToDouble(MesPartInspection::getQty).sum();
mesQmsSuspicious.setMisjudgmentQty((int) misjudgmentQty);
//一次报废数 nc_status=40 inspection_status=20
double scrappedQty = mesPartInspections.stream().filter(m -> m.getNcStatus() == 40 && m.getInspectionStatus() == 20).mapToDouble(MesPartInspection::getQty).sum();
mesQmsSuspicious.setScrappedQty((int) scrappedQty);
//返工合格数 nc_status=50 返工单 status=20
Integer reworkQualified = 0;
//返工pending创建返工单未处理
Integer reworkPending = 0;
//返工数
Integer reworkQty = 0;
List<MesPartInspectionDetail> mesPartInspectionDetails = new ArrayList<>();
for (MesPartInspection mesPartInspection : mesPartInspections) {
if (!StringUtil.isEmpty(idDetailListMap.get(mesPartInspection.getId()))) {
mesPartInspectionDetails.addAll(idDetailListMap.get(mesPartInspection.getId()));
}
//计算返工数量
if (mesPartInspection.getNcStatus() == MesExtEnumUtil.PART_INSPECTION_NC_STATUS.REWORK.getValue()) {
MesReworkTask reworkTask = mesReworkTaskRepository.getById(mesPartInspection.getReworkTaskId());
if (!StringUtil.isEmpty(reworkTask)) {
//返工是否完成
if (reworkTask.getStatus() == MesExtEnumUtil.REWORK_TASK_STATUS.FINISH.getValue()) {
reworkQualified += mesPartInspection.getQty();
} else {
reworkPending += mesPartInspection.getQty();
}
} else {
reworkPending += mesPartInspection.getQty();
}
} else {
reworkPending += mesPartInspection.getQty();
reworkQty += mesPartInspection.getQty();
}
reworkQty+= mesPartInspection.getQty();
}
mesQmsSuspicious.setReworkQty(reworkQty);
mesQmsSuspicious.setReworkQualified(reworkQualified);
mesQmsSuspicious.setReworkPending(reworkPending);
mesQmsSuspicious.setNcPending(0);
mesQmsSuspicious.setReworkScrapped(0);
mesQmsSuspicious.setPartNo(key);
mesQmsSuspicious.setPartName(next.getPartName());
//缺陷分类缺陷数量JOSN格式:
//[{"Defect_Name":"缺陷01","Defect_Qty":1},{"Defect_Name":"缺陷02","Defect_Qty":2}]
Map<String, List<MesPartInspectionDetail>> listDefectMap = mesPartInspectionDetails.stream().collect(Collectors.groupingBy(MesPartInspectionDetail::getDefectTypeName));
List<Map<String, Object>> defectsList = new ArrayList<>();
for (Map.Entry<String, List<MesPartInspectionDetail>> listEntry : listDefectMap.entrySet()) {
Map<String, Object> defectMap = new HashMap<>();
defectMap.put("Defect_Name", listEntry.getKey());
defectMap.put("Defect_Qty", listEntry.getValue().size());
defectsList.add(defectMap);
}
//缺陷分布json
mesQmsSuspicious.setDefects(JSON.toJSONString(defectsList));
ConvertBean.serviceModelInitialize(mesQmsSuspicious, "MesSuspiciousJob");
baseRDao.insert(mesQmsSuspicious);
}
mesQmsSuspicious.setReworkQty(reworkQty);
mesQmsSuspicious.setReworkQualified(reworkQualified);
mesQmsSuspicious.setReworkPending(reworkPending);
mesQmsSuspicious.setNcPending(0);
mesQmsSuspicious.setReworkScrapped(0);
mesQmsSuspicious.setPartNo(key);
mesQmsSuspicious.setPartName(next.getPartName());
//缺陷分类缺陷数量JOSN格式:
//[{"Defect_Name":"缺陷01","Defect_Qty":1},{"Defect_Name":"缺陷02","Defect_Qty":2}]
Map<String, List<MesPartInspectionDetail>> listDefectMap = mesPartInspectionDetails.stream().collect(Collectors.groupingBy(MesPartInspectionDetail::getDefectTypeName));
List<Map<String, Object>> defectsList = new ArrayList<>();
for (Map.Entry<String, List<MesPartInspectionDetail>> listEntry : listDefectMap.entrySet()) {
Map<String, Object> defectMap = new HashMap<>();
defectMap.put("Defect_Name",listEntry.getKey());
defectMap.put("Defect_Qty",listEntry.getValue().size());
defectsList.add(defectMap);
}
//缺陷分布json
mesQmsSuspicious.setDefects(JSON.toJSONString(defectsList));
ConvertBean.serviceModelInitialize(mesQmsSuspicious, "MesSuspiciousJob");
baseRDao.insert(mesQmsSuspicious);
}
}
}

@ -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);
// //设备信息
// 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()) {
PdfPCell equcontentCell11 = new PdfPCell(new Paragraph(equipmentLogDetail.getEquipVariableName(), equipmentLogFont));
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);
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