|
|
@ -10,6 +10,7 @@ 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.MesDeviceDataQueryReportConditionModel;
|
|
|
|
import cn.estsh.i3plus.ext.mes.pojo.model.report.MesDeviceDataQueryReportResultModel;
|
|
|
|
import cn.estsh.i3plus.ext.mes.pojo.model.report.MesDeviceDataQueryReportResultModel;
|
|
|
|
import cn.estsh.i3plus.ext.mes.pojo.model.report.MesProdRuleReportConditionModel;
|
|
|
|
import cn.estsh.i3plus.ext.mes.pojo.model.report.MesProdRuleReportConditionModel;
|
|
|
|
|
|
|
|
import cn.estsh.i3plus.ext.mes.pojo.util.MesExtConstWords;
|
|
|
|
import cn.estsh.i3plus.mes.apiservice.util.DateUtil;
|
|
|
|
import cn.estsh.i3plus.mes.apiservice.util.DateUtil;
|
|
|
|
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;
|
|
|
@ -74,11 +75,14 @@ public class MesYfReportServiceImpl implements IMesYfReportService {
|
|
|
|
private MesProductionAssemblyRepository mesProductionAssemblyRepository;
|
|
|
|
private MesProductionAssemblyRepository mesProductionAssemblyRepository;
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
@Autowired
|
|
|
|
private MesWorkCellScanMonitorLogRepository mesWorkCellScanMonitorLogRepository;
|
|
|
|
private MesWorkCellScanMonitorLogRepository workCellScanMonitorLogRepository;
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
@Autowired
|
|
|
|
private MesProcessRepository mesProcessRepository;
|
|
|
|
private MesProcessRepository mesProcessRepository;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
|
|
private MesWorkCenterRepository workCenterRepository;
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public ListPager<MesDeviceDataQueryReportResultModel> queryMesDeviceDataByPager(MesDeviceDataQueryReportConditionModel queryReportModel, Pager pager) {
|
|
|
|
public ListPager<MesDeviceDataQueryReportResultModel> queryMesDeviceDataByPager(MesDeviceDataQueryReportConditionModel queryReportModel, Pager pager) {
|
|
|
|
ListPager<MesDeviceDataQueryReportResultModel> mesDeviceDataQueryReportResultModelListPager =
|
|
|
|
ListPager<MesDeviceDataQueryReportResultModel> mesDeviceDataQueryReportResultModelListPager =
|
|
|
@ -138,7 +142,7 @@ public class MesYfReportServiceImpl implements IMesYfReportService {
|
|
|
|
public List<MesTraceabilityReportModel> findTraceabilityReport(MesProduceSn mesProduceSn) {
|
|
|
|
public List<MesTraceabilityReportModel> findTraceabilityReport(MesProduceSn mesProduceSn) {
|
|
|
|
DdlPackBean packBean = getDdlPackBean(mesProduceSn);
|
|
|
|
DdlPackBean packBean = getDdlPackBean(mesProduceSn);
|
|
|
|
//查询条码记录表
|
|
|
|
//查询条码记录表
|
|
|
|
MesProduceSn produceSn = mesProduceSnService.findMesProduceSn(mesProduceSn.getOrganizeCode(), mesProduceSn.getProductSn()).iterator().next();
|
|
|
|
MesProduceSn produceSn = mesProduceSnService.findMesProduceSn(mesProduceSn.getOrganizeCode(), mesProduceSn.getProductSn()).get(0);
|
|
|
|
//设备加工记录表
|
|
|
|
//设备加工记录表
|
|
|
|
List<MesProductionRecord> productionRecordList = mesProductionRecordService.findMesProductionRecord(mesProduceSn.getOrganizeCode(), mesProduceSn.getProductSn());
|
|
|
|
List<MesProductionRecord> productionRecordList = mesProductionRecordService.findMesProductionRecord(mesProduceSn.getOrganizeCode(), mesProduceSn.getProductSn());
|
|
|
|
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());
|
|
|
@ -146,7 +150,7 @@ public class MesYfReportServiceImpl implements IMesYfReportService {
|
|
|
|
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 -> t.getWorkCenterCode() + t.getWorkCellCode() + t.getEquipmentCode()));
|
|
|
|
//工位扫描监控日志
|
|
|
|
//工位扫描监控日志
|
|
|
|
List<MesWorkCellScanMonitorLog> mesWorkCellScanMonitorLogs = mesWorkCellScanMonitorLogRepository.findByHqlWhere(packBean);
|
|
|
|
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<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);
|
|
|
@ -154,7 +158,7 @@ public class MesYfReportServiceImpl implements IMesYfReportService {
|
|
|
|
List<MesTraceabilityReportModel> mesTraceabilityReportModelList = new ArrayList<>();
|
|
|
|
List<MesTraceabilityReportModel> mesTraceabilityReportModelList = new ArrayList<>();
|
|
|
|
MesTraceabilityReportModel mesTraceabilityReportModel = new MesTraceabilityReportModel();
|
|
|
|
MesTraceabilityReportModel mesTraceabilityReportModel = new MesTraceabilityReportModel();
|
|
|
|
BeanUtils.copyProperties(produceSn, mesTraceabilityReportModel);
|
|
|
|
BeanUtils.copyProperties(produceSn, mesTraceabilityReportModel);
|
|
|
|
mesTraceabilityReportModel.setProdType(MesExtEnumUtil.TRACEABILITY_REPORT_PROD_TYPE.NO_SORT.getValue());
|
|
|
|
mesTraceabilityReportModel.setProdType(getWorkCenter(produceSn).getCenterType());
|
|
|
|
int duration = 0;
|
|
|
|
int duration = 0;
|
|
|
|
for (MesProductionRecord mesProductionRecord : productionRecordList) {
|
|
|
|
for (MesProductionRecord mesProductionRecord : productionRecordList) {
|
|
|
|
MesTraceabilityReportDataModel dataModel = new MesTraceabilityReportDataModel();
|
|
|
|
MesTraceabilityReportDataModel dataModel = new MesTraceabilityReportDataModel();
|
|
|
@ -209,6 +213,30 @@ public class MesYfReportServiceImpl implements IMesYfReportService {
|
|
|
|
return mesTraceabilityReportModelList;
|
|
|
|
return mesTraceabilityReportModelList;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private MesWorkCenter getWorkCenter(MesProduceSn produceSn) {
|
|
|
|
|
|
|
|
MesWorkCenter workCenter = workCenterRepository.getByProperty(
|
|
|
|
|
|
|
|
new String[]{MesExtConstWords.ORGANIZE_CODE, MesExtConstWords.IS_DELETED, MesExtConstWords.IS_VALID, MesExtConstWords.WORK_CENTER_CODE},
|
|
|
|
|
|
|
|
new Object[]{produceSn.getOrganizeCode(), CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue(), CommonEnumUtil.IS_VAILD.VAILD.getValue(), produceSn.getWorkCenterCode()});
|
|
|
|
|
|
|
|
if (null == workCenter) MesException.throwMesBusiException("条码[%s]关联的生产线[%s]信息不存在", produceSn.getProductSn(), produceSn.getWorkCenterCode());
|
|
|
|
|
|
|
|
return workCenter;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private List<MesWorkCellScanMonitorLog> getWorkCellScanMonitorLogList(List<MesProductionRecord> productionRecordList) {
|
|
|
|
|
|
|
|
if (CollectionUtils.isEmpty(productionRecordList)) return null;
|
|
|
|
|
|
|
|
List<MesWorkCellScanMonitorLog> workCellScanMonitorLogList = new ArrayList<>();
|
|
|
|
|
|
|
|
for (MesProductionRecord productionRecord : productionRecordList) {
|
|
|
|
|
|
|
|
if (null == productionRecord) continue;
|
|
|
|
|
|
|
|
//云端 MesWorkCellScanMonitorLog 按照 工厂+生产线 分表 只能根据开模ID查询, 条码字段是产出条码 不是主条码, 一模多腔场景存的是多个条码分号分隔
|
|
|
|
|
|
|
|
DdlPackBean packBean = DdlPackBean.getDdlPackBean(productionRecord.getOrganizeCode());
|
|
|
|
|
|
|
|
DdlPreparedPack.getStringEqualPack(productionRecord.getWorkCenterCode(), MesExtConstWords.WORK_CENTER_CODE, packBean);
|
|
|
|
|
|
|
|
DdlPreparedPack.getStringEqualPack(productionRecord.getWorkCellCode(), MesExtConstWords.WORK_CELL_CODE, packBean);
|
|
|
|
|
|
|
|
DdlPreparedPack.getNumEqualPack(productionRecord.getMouldRecordId(), MesExtConstWords.MOULD_RECORD_ID, packBean);
|
|
|
|
|
|
|
|
List<MesWorkCellScanMonitorLog> itemList = workCellScanMonitorLogRepository.findByHqlWhere(packBean);
|
|
|
|
|
|
|
|
if (!CollectionUtils.isEmpty(itemList)) workCellScanMonitorLogList.addAll(itemList);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return workCellScanMonitorLogList;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private Map<String, MesProcess> getMesProcessMap(MesProduceSn mesProduceSn, List<String> processCodeList) {
|
|
|
|
private Map<String, MesProcess> getMesProcessMap(MesProduceSn mesProduceSn, List<String> processCodeList) {
|
|
|
|
Map<String, MesProcess> processMap = null;
|
|
|
|
Map<String, MesProcess> processMap = null;
|
|
|
|
if(!CollectionUtils.isEmpty(processCodeList)){
|
|
|
|
if(!CollectionUtils.isEmpty(processCodeList)){
|
|
|
|