|
|
|
@ -7,6 +7,7 @@ import cn.estsh.i3plus.ext.mes.pcn.pojo.context.*;
|
|
|
|
|
import cn.estsh.i3plus.ext.mes.pcn.pojo.util.MesPcnExtConstWords;
|
|
|
|
|
import cn.estsh.i3plus.mes.pcn.serviceimpl.fsm.BaseStepService;
|
|
|
|
|
import cn.estsh.i3plus.mes.pcn.util.PojoAttrUtil;
|
|
|
|
|
import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
|
|
|
|
|
import cn.estsh.i3plus.pojo.base.enumutil.MesPcnEnumUtil;
|
|
|
|
|
import cn.estsh.i3plus.pojo.mes.bean.MesWorkCenter;
|
|
|
|
|
import cn.estsh.i3plus.pojo.mes.model.AttrBean;
|
|
|
|
@ -24,6 +25,8 @@ import org.springframework.util.StringUtils;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.Comparator;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Optional;
|
|
|
|
|
import java.util.concurrent.atomic.AtomicReference;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -68,8 +71,27 @@ public class MesAssemblyShowSortStepService extends BaseStepService {
|
|
|
|
|
//获取上下文加工规则数据信息集合
|
|
|
|
|
List<MesProdRuleContext> prodRuleContextList = productionDispatchContextStepService.getProdRuleDataContext(reqBean);
|
|
|
|
|
|
|
|
|
|
//不存在加工规则数据信息则进行查询
|
|
|
|
|
if (CollectionUtils.isEmpty(prodRuleContextList)) prodRuleContextList = doHandleProdRuleData(reqBean, resultBean, stepResult, cellEquipContext);
|
|
|
|
|
//获取上下文产出零件数据信息集合
|
|
|
|
|
List<MesProductionPartContext> productionPartContextList = productionDispatchContextStepService.getProductionPartContext(reqBean);
|
|
|
|
|
|
|
|
|
|
//获取上下文进料零件条码信息集合
|
|
|
|
|
List<MesProductionPsInContext> productionPsInContextList = productionDispatchContextStepService.getProductionPsInContext(reqBean);
|
|
|
|
|
|
|
|
|
|
//根据现有数据【产出零件数据】【进料零件条码信息】比对上下文中已经存在的加工规则数据信息集合, 没有加工规则的数据进行查询
|
|
|
|
|
if (CollectionUtils.isEmpty(prodRuleContextList)) prodRuleContextList = new ArrayList<>();
|
|
|
|
|
Integer initSize = prodRuleContextList.size();
|
|
|
|
|
|
|
|
|
|
//封装排序加工规则
|
|
|
|
|
doHandleProdRuleData(reqBean, resultBean, stepResult, workCenter, cellEquipContext, prodRuleContextList, productionPartContextList, productionPsInContextList);
|
|
|
|
|
|
|
|
|
|
if (prodRuleContextList.size() != initSize) {
|
|
|
|
|
//保存上下文产品加工规则信息集合
|
|
|
|
|
productionDispatchContextStepService.saveProdRuleDataContext(reqBean, prodRuleContextList);
|
|
|
|
|
//保存上下文产出零件信息
|
|
|
|
|
if (!CollectionUtils.isEmpty(productionPartContextList)) productionDispatchContextStepService.saveProductionPartContext(reqBean, productionPartContextList);
|
|
|
|
|
//保存进料主条码数据
|
|
|
|
|
if (!CollectionUtils.isEmpty(productionPsInContextList)) productionDispatchContextStepService.saveProductionPsInContext(reqBean, productionPsInContextList);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!stepResult.isCompleted()) return stepResult;
|
|
|
|
|
|
|
|
|
@ -77,29 +99,33 @@ public class MesAssemblyShowSortStepService extends BaseStepService {
|
|
|
|
|
if (!showProductionAssembly(reqBean, resultBean, workCenter, cellEquipContext, prodRuleContextList))
|
|
|
|
|
return execSuccessCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog(), stepResult, "当前未查询到相关的装配件清单");
|
|
|
|
|
|
|
|
|
|
//保存上下文产品加工规则信息集合
|
|
|
|
|
productionDispatchContextStepService.saveProdRuleDataContext(reqBean, prodRuleContextList);
|
|
|
|
|
|
|
|
|
|
return execSuccessCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog(), stepResult, "显示装配件扫描项成功!");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//查询排序线加工规则装配件数据信息
|
|
|
|
|
private List<MesProdRuleContext> doHandleProdRuleData(StationRequestBean reqBean, StationResultBean resultBean, StepResult stepResult, MesCellEquipContext cellEquipContext) {
|
|
|
|
|
private void doHandleProdRuleData(StationRequestBean reqBean, StationResultBean resultBean, StepResult stepResult, MesWorkCenter workCenter, MesCellEquipContext cellEquipContext,
|
|
|
|
|
List<MesProdRuleContext> prodRuleContextList, List<MesProductionPartContext> productionPartContextList, List<MesProductionPsInContext> productionPsInContextList) {
|
|
|
|
|
|
|
|
|
|
//从上下文中取出生产工单数据信息集合
|
|
|
|
|
List<MesProductionPartContext> productionPartContextList = productionDispatchContextStepService.getProductionPartContext(reqBean);
|
|
|
|
|
//上下文中不存在进料主条码数据信息
|
|
|
|
|
if (CollectionUtils.isEmpty(productionPsInContextList) || CollectionUtils.isEmpty(productionPartContextList))
|
|
|
|
|
execNonCompleteAndSendMsg(reqBean, resultBean.writeDbLog(), stepResult, String.format("生产线[%s]工位[%s]的上下文中已不存在加工单或条码数据信息,请重置工序!", reqBean.getWorkCenterCode(), reqBean.getWorkCellCode()));
|
|
|
|
|
|
|
|
|
|
//拿到当前最大的foreignKey
|
|
|
|
|
Optional<MesProductionPsInContext> maxForeignKeyOptional = productionPsInContextList.stream().filter(o -> (null != o && !StringUtils.isEmpty(o.getForeignKey()))).max(Comparator.comparing(MesProductionPsInContext::getForeignKey));
|
|
|
|
|
Integer foreignKey = (null != maxForeignKeyOptional && maxForeignKeyOptional.isPresent()) ? maxForeignKeyOptional.get().getForeignKey() : MesPcnExtConstWords.ZERO;
|
|
|
|
|
|
|
|
|
|
//上下文中不存在生产工单数据信息集合
|
|
|
|
|
if (CollectionUtils.isEmpty(productionPartContextList)) execNonCompleteAndSendMsg(reqBean, resultBean.writeDbLog(), stepResult, String.format("生产线[%s]工位[%s]的上下文中已不存在生产工单数据信息,请重新扫描加工单!", reqBean.getWorkCenterCode(), reqBean.getWorkCellCode()));
|
|
|
|
|
for (MesProductionPsInContext productionPsInContext : productionPsInContextList) {
|
|
|
|
|
|
|
|
|
|
//获取排序线的装配件清单
|
|
|
|
|
List<MesProdRuleContext> prodRuleContextList = prodRuleCfgExtService.getProdRuleSortContextList(new MesProdRuleContext(reqBean.getOrganizeCode(), reqBean.getWorkCenterCode(), reqBean.getWorkCellCode(), reqBean.getProcessCode()), productionPartContextList);
|
|
|
|
|
//foreignKey有值代表已经匹配过产品加工规则
|
|
|
|
|
if (null == productionPsInContext || productionPsInContext.getIsFinishCode().compareTo(CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue()) == 0 || !StringUtils.isEmpty(productionPsInContext.getForeignKey())) continue;
|
|
|
|
|
|
|
|
|
|
//保存设备当前一轮工序的装配件清单信息
|
|
|
|
|
if (!CollectionUtils.isEmpty(prodRuleContextList)) productionDispatchContextStepService.saveProdRuleDataContext(reqBean, prodRuleContextList);
|
|
|
|
|
//【排序线】获取产品加工规则(条码对应的装配件绑定记录,目前条码等同工单)
|
|
|
|
|
prodRuleContextList.add(prodRuleCfgExtService.getProdRuleSortContext(new MesProdRuleContext(
|
|
|
|
|
reqBean.getOrganizeCode(), reqBean.getWorkCenterCode(), reqBean.getWorkCellCode(), reqBean.getProcessCode(), productionPsInContext.getProductSn()).foreignKey(
|
|
|
|
|
productionPartContextList.stream().filter(o -> (null != o && o.getWorkOrderNo().equals(productionPsInContext.getWorkOrderNo()))).findFirst().get().foreignKey(productionPsInContext.foreignKey(foreignKey += 1).getForeignKey()).getForeignKey())));
|
|
|
|
|
|
|
|
|
|
return prodRuleContextList;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -142,6 +168,10 @@ public class MesAssemblyShowSortStepService extends BaseStepService {
|
|
|
|
|
assemblyShowContextList.add(assemblyShowContext(item));
|
|
|
|
|
}
|
|
|
|
|
assemblyShowContextList = assemblyShowContextList.stream().filter(o -> null != o).sorted(Comparator.comparing(MesAssemblyShowContext::getRouteSeq)).collect(Collectors.toList());
|
|
|
|
|
|
|
|
|
|
AtomicReference<Integer> index = new AtomicReference<>(0);
|
|
|
|
|
assemblyShowContextList.forEach(o -> o.index(index.updateAndGet(v -> v + 1)));
|
|
|
|
|
|
|
|
|
|
return assemblyShowContextList;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|