|
|
|
@ -26,11 +26,9 @@ import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
|
import org.springframework.util.StringUtils;
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
import java.util.Optional;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
import java.util.stream.Stream;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @Description : 发送加工参数
|
|
|
|
@ -78,8 +76,11 @@ public class MesSendEquipParamsCmdStepService extends BaseStepService {
|
|
|
|
|
//获取生产线信息
|
|
|
|
|
MesWorkCenter workCenter = productionProcessContext.getWorkCenter();
|
|
|
|
|
|
|
|
|
|
//搜集数据:根据数据关联键分组加工参数关联ID集合
|
|
|
|
|
Map<Integer, List<Long>> sourceIdMap2ForeignKey = new HashMap<>();
|
|
|
|
|
|
|
|
|
|
//搜集加工参数关联ID集合 根据生产线类型区分
|
|
|
|
|
List<Long> sourceIdList = getEquipmentProdParamCfgSourceIdList(productionProcessContext, prodRuleContextList, workCenter);
|
|
|
|
|
List<Long> sourceIdList = getEquipmentProdParamCfgSourceIdList(productionProcessContext, prodRuleContextList, workCenter, sourceIdMap2ForeignKey);
|
|
|
|
|
|
|
|
|
|
//根据来源ID查询设备加工参数信息
|
|
|
|
|
List<MesEquipmentProdParamCfg> equipmentProdParamCfgList = equipmentProdParamCfgService.getEquipmentProdParamCfgList(reqBean.getOrganizeCode(), sourceIdList);
|
|
|
|
@ -123,7 +124,7 @@ public class MesSendEquipParamsCmdStepService extends BaseStepService {
|
|
|
|
|
productionPsOutContexts.stream().filter(i -> (null != i && !StringUtils.isEmpty(i.getForeignKey()) && i.getForeignKey().compareTo(o.getForeignKey()) == 0)).findFirst();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
doSendEquipParamsCmd(reqBean, resultBean, o, cellEquipContext, eppcMap2SourceId, evMap, productResult, productionPartContextOp, productionPsInContextOp, productionPsOutContextOp);
|
|
|
|
|
doSendEquipParamsCmd(reqBean, resultBean, o, sourceIdMap2ForeignKey.get(o.getForeignKey()), cellEquipContext, eppcMap2SourceId, evMap, productResult, productionPartContextOp, productionPsInContextOp, productionPsOutContextOp);
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
@ -131,10 +132,15 @@ public class MesSendEquipParamsCmdStepService extends BaseStepService {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//搜集加工参数关联ID集合
|
|
|
|
|
private List<Long> getEquipmentProdParamCfgSourceIdList(MesProductionProcessContext productionProcessContext, List<MesProdRuleContext> prodRuleContextList, MesWorkCenter workCenter) {
|
|
|
|
|
private List<Long> getEquipmentProdParamCfgSourceIdList(MesProductionProcessContext productionProcessContext, List<MesProdRuleContext> prodRuleContextList, MesWorkCenter workCenter, Map<Integer, List<Long>> sourceIdMap2ForeignKey) {
|
|
|
|
|
if (MesExtEnumUtil.WORK_CENTER_TYPE.NOSORT.getValue() == workCenter.getCenterType()) {
|
|
|
|
|
//非排序
|
|
|
|
|
return prodRuleContextList.stream().filter(o -> (null != o && !StringUtils.isEmpty(o.getPid()))).map(MesProdRuleContext::getPid).collect(Collectors.toList());
|
|
|
|
|
List<Long> sourceIdList = new ArrayList<>();
|
|
|
|
|
prodRuleContextList.stream().filter(o -> (null != o && !StringUtils.isEmpty(o.getPid()))).forEach(o -> {
|
|
|
|
|
sourceIdMap2ForeignKey.put(o.getForeignKey(), Stream.of(o.getPid()).collect(Collectors.toList()));
|
|
|
|
|
sourceIdList.add(o.getPid());
|
|
|
|
|
});
|
|
|
|
|
return sourceIdList;
|
|
|
|
|
} else {
|
|
|
|
|
//排序
|
|
|
|
|
List<Long> sourceIdList = null;
|
|
|
|
@ -143,6 +149,7 @@ public class MesSendEquipParamsCmdStepService extends BaseStepService {
|
|
|
|
|
List<Long> itemIdList = prodRuleContext.getSortAssemblyDataContext().stream().filter(o -> (null != o && !StringUtils.isEmpty(o.getPid()))).map(MesProductionAssemblySortContext::getPid).collect(Collectors.toList());
|
|
|
|
|
if (CollectionUtils.isEmpty(itemIdList)) continue;
|
|
|
|
|
if (CollectionUtils.isEmpty(sourceIdList)) sourceIdList = new ArrayList<>();
|
|
|
|
|
sourceIdMap2ForeignKey.put(prodRuleContext.getForeignKey(), itemIdList);
|
|
|
|
|
sourceIdList.addAll(itemIdList);
|
|
|
|
|
}
|
|
|
|
|
return sourceIdList;
|
|
|
|
@ -150,14 +157,20 @@ public class MesSendEquipParamsCmdStepService extends BaseStepService {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//发送设备加工参数
|
|
|
|
|
private void doSendEquipParamsCmd(StationRequestBean reqBean, StationResultBean resultBean, MesProdRuleContext prodRuleContext, MesCellEquipContext cellEquipContext,
|
|
|
|
|
private void doSendEquipParamsCmd(StationRequestBean reqBean, StationResultBean resultBean, MesProdRuleContext prodRuleContext, List<Long> sourceIdList, MesCellEquipContext cellEquipContext,
|
|
|
|
|
Map<Long, List<MesEquipmentProdParamCfg>> eppcMap2SourceId, Map<Long, MesEquipmentVariable> evMap, String productResult,
|
|
|
|
|
Optional<MesProductionPartContext> productionPartContextOp, Optional<MesProductionPsInContext> productionPsInContextOp, Optional<MesProductionPsOutContext> productionPsOutContextOp) {
|
|
|
|
|
|
|
|
|
|
if (CollectionUtils.isEmpty(sourceIdList)) return;
|
|
|
|
|
|
|
|
|
|
for (Long sourceId : sourceIdList) {
|
|
|
|
|
|
|
|
|
|
if (StringUtils.isEmpty(sourceId)) continue;
|
|
|
|
|
|
|
|
|
|
//当前加工规则的PID对应的设备加工参数
|
|
|
|
|
List<MesEquipmentProdParamCfg> equipmentProdParamCfgList = eppcMap2SourceId.get(prodRuleContext.getPid());
|
|
|
|
|
List<MesEquipmentProdParamCfg> equipmentProdParamCfgList = eppcMap2SourceId.get(sourceId);
|
|
|
|
|
|
|
|
|
|
if (CollectionUtils.isEmpty(equipmentProdParamCfgList)) return;
|
|
|
|
|
if (CollectionUtils.isEmpty(equipmentProdParamCfgList)) continue;
|
|
|
|
|
|
|
|
|
|
MesProductionPartContext productionPartContext = (null != productionPartContextOp && productionPartContextOp.isPresent()) ? productionPartContextOp.get() : null;
|
|
|
|
|
|
|
|
|
@ -206,6 +219,8 @@ public class MesSendEquipParamsCmdStepService extends BaseStepService {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private String checkTransformUpperCase(String matchRule) {
|
|
|
|
|
matchRule = matchRule.trim();
|
|
|
|
|
return matchRule.contains(MesPcnExtConstWords.PERCENT) ? matchRule.toUpperCase() : matchRule;
|
|
|
|
|