tags/yfai-pcn-ext-v1.0
王杰 11 months ago
parent b8f6e67d8b
commit 1c01b3bc24

@ -110,7 +110,7 @@ public class MesAssemblyGeneratePartNoStepService extends BaseStepService {
productionDispatchContextStepService.saveProdRuleDataContext(reqBean, prodRuleContextList);
//显示装配件信息
assemblyShowNosortStepService.showProductionAssembly(reqBean, resultBean, productionProcessContext.getWorkCenter(), cellEquipContext, prodRuleContextList, null);
assemblyShowNosortStepService.showProductionAssembly(reqBean, resultBean, productionProcessContext.getWorkCenter(), cellEquipContext, prodRuleContextList);
return execSuccessCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog(), stepResult.nextTriggerEvent(null), String.format("上下文中的装配件条码%s匹配成功!", assemblySn));

@ -112,7 +112,7 @@ public class MesAssemblyMatchNosortStepService extends BaseStepService {
String assemblySn = equipVariableCollectContextList.stream().filter(o -> null != o).map(MesEquipVariableCollectContext::getEquipVariableValue).collect(Collectors.toList()).toString();
//匹配成功
if (result || !hasUnBindAssembly) productionDispatchContextStepService.saveProdRuleDataContext(reqBean, prodRuleContextList);
if (result || !hasUnBindAssembly) assemblyShowNosortStepService.showProductionAssembly(reqBean, resultBean, productionProcessContext.getWorkCenter(), cellEquipContext, prodRuleContextList, productionPartContextList);
if (result || !hasUnBindAssembly) assemblyShowNosortStepService.showProductionAssembly(reqBean, resultBean, productionProcessContext.getWorkCenter(), cellEquipContext, prodRuleContextList);
//全部匹配完毕,存在进料的时候直接调用 生成零件条码工步
if (!hasUnBindAssembly && !CollectionUtils.isEmpty(productionPsInContextList) && productionPsInContextList.size() >= needQty) ((IStepService) SpringContextsUtil.getBean("mesProductSnGenerateStepService")).execute(reqBean);

@ -86,6 +86,7 @@ public class MesAssemblyShowNosortStepService extends BaseStepService {
//封装非排序加工规则
doHandleProdRuleData(reqBean, resultBean, stepResult, workCenter, productionProcessContext, cellEquipContext, prodRuleContextList, productionPartContextList, productionPsInContextList);
//匹配失败需要清除本次扫描/读取信息
if (!stepResult.isCompleted() && doBusiCheckToDelete(reqBean, productionPartContextList, productionPsInContextList)) return execNonCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog(), stepResult, stepResult.getMsg());
if (prodRuleContextList.size() != initSize) {
@ -98,7 +99,7 @@ public class MesAssemblyShowNosortStepService extends BaseStepService {
}
//显示装配件信息
showProductionAssembly(reqBean, resultBean, workCenter, cellEquipContext, prodRuleContextList, productionPartContextList);
showProductionAssembly(reqBean, resultBean, workCenter, cellEquipContext, prodRuleContextList);
return execSuccessCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog(), stepResult, "装配件扫描项已查询完毕,请查看!");
}
@ -141,7 +142,7 @@ public class MesAssemblyShowNosortStepService extends BaseStepService {
MesCellEquipContext cellEquipContext, List<MesProdRuleContext> prodRuleContextList, List<MesProductionPartContext> productionPartContextList, List<String> outPartNoList, Integer foreignKey) {
//【非排序线】获取产品加工规则 ; 条件进料[NULL]
List<MesProdRuleNosortCfg> prodRuleNosortCfgList = prodRuleCfgExtService.getProdRuleNosortCfgList(new MesProdRuleContext(reqBean.getOrganizeCode()).equipmentCode(cellEquipContext.getEquipmentCode()).outPartNos(outPartNoList).inPartIsEmpty(true).inPartRuleIsEmpty(true));
List<MesProdRuleNosortCfg> prodRuleNosortCfgList = prodRuleCfgExtService.getProdRuleNosortCfgList(new MesProdRuleContext(reqBean.getOrganizeCode()).equipmentCode(cellEquipContext.getEquipmentCode()).outPartNos(outPartNoList).inPartIsEmpty(true));
//根据产出零件分组数据
Map<String, List<MesProdRuleNosortCfg>> prodRuleNosortCfgMap = groupProdRuleNosortCfgList(prodRuleNosortCfgList);
@ -153,9 +154,9 @@ public class MesAssemblyShowNosortStepService extends BaseStepService {
List<MesProdRuleNosortCfg> filterList = !CollectionUtils.isEmpty(prodRuleNosortCfgMap) ? prodRuleNosortCfgMap.get(productionPartContext.getPartNo()) : null;
if (CollectionUtils.isEmpty(filterList) || filterList.size() > 1) {
productionPartContext.busiCheckToDelete();
productionPartContextList.forEach(o -> o.busiCheckToDelete());
return execNonCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog(), stepResult, String.format(
"请检查非排序产品加工规则信息,根据设备[%s]产出零件[%s]进料零件[空]进料零件规则[空]查询到[%s]条加工规则配置信息,无法显示出装配件清单!", cellEquipContext.getEquipmentCode(), productionPartContext.getPartNo(), CollectionUtils.isEmpty(filterList) ? MesPcnExtConstWords.ZERO : filterList.size()));
"请检查非排序产品加工规则信息,根据设备[%s]产出零件[%s]进料零件[空]查询到[%s]条加工规则配置信息,无法显示出装配件清单!", cellEquipContext.getEquipmentCode(), productionPartContext.getPartNo(), CollectionUtils.isEmpty(filterList) ? MesPcnExtConstWords.ZERO : filterList.size()));
}
//【非排序线】获取产品加工规则对应的装配件信息
@ -190,15 +191,16 @@ public class MesAssemblyShowNosortStepService extends BaseStepService {
else filterList = (List<MesProdRuleNosortCfg>) numberRuleMatchDispatchService.matchNumberRule(reqBean.getOrganizeCode(), productionPsInContext.getProductSn(), filterProdRuleNosortCfgList(prodRuleNosortCfgList));
if (CollectionUtils.isEmpty(filterList) || filterList.size() > 1) {
productionPsInContext.busiCheckToDelete();
if (productionPsInContext.getMessageSource().compareTo(MesExtEnumUtil.CELL_MESSAGE_SOURCE.SCAN.getValue()) == 0) productionPsInContext.busiCheckToDelete();
else productionPsInContextList.forEach(o -> o.busiCheckToDelete());
return execNonCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog(), stepResult, String.format(
"请检查非排序产品加工规则信息,根据设备[%s]进料零件条码[%s]查询到[%s]条加工规则配置信息,无法显示出装配件清单!", cellEquipContext.getEquipmentCode(), productionPsInContext.getProductSn(), CollectionUtils.isEmpty(filterList) ? MesPcnExtConstWords.ZERO : filterList.size()));
}
if (!StringUtils.isEmpty(productionPsInContext.getPartNo()) && !(Boolean) productionRecordService.checkSnTimeliness(
reqBean.getOrganizeCode(), productionPsInContext.getProductSn(), filterList.get(0).getId(), MesExtEnumUtil.TIME_DATA_SOURCE.DATA_SOURCE20.getValue(), false).get(MesPcnExtConstWords.RESULT)) {
productionPsInContext.busiCheckToDelete();
if (productionPsInContext.getMessageSource().compareTo(MesExtEnumUtil.CELL_MESSAGE_SOURCE.SCAN.getValue()) == 0) productionPsInContext.busiCheckToDelete();
else productionPsInContextList.forEach(o -> o.busiCheckToDelete());
return execNonCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog(), stepResult, String.format("请检查进料主条码信息,进料主条码[%s]时效性验证不通过!", productionPsInContext.getProductSn()));
}
@ -261,7 +263,8 @@ public class MesAssemblyShowNosortStepService extends BaseStepService {
if (!StringUtils.isEmpty(productionPsInContext.getPartNo()) && !(Boolean) productionRecordService.checkSnTimeliness(
reqBean.getOrganizeCode(), productionPsInContext.getProductSn(), innerfilterList.get(0).getId(), MesExtEnumUtil.TIME_DATA_SOURCE.DATA_SOURCE20.getValue(), false).get(MesPcnExtConstWords.RESULT)) {
productionPsInContext.busiCheckToDelete();
if (productionPsInContext.getMessageSource().compareTo(MesExtEnumUtil.CELL_MESSAGE_SOURCE.SCAN.getValue()) == 0) productionPsInContext.busiCheckToDelete();
else productionPsInContextList.forEach(o -> o.busiCheckToDelete());
return execNonCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog(), stepResult, String.format("请检查进料主条码信息,进料主条码[%s]时效性验证不通过!", productionPsInContext.getProductSn()));
}
@ -273,26 +276,25 @@ public class MesAssemblyShowNosortStepService extends BaseStepService {
}
if (CollectionUtils.isEmpty(innerfilterList) || innerfilterList.size() > 1) {
productionPsInContextList.forEach(o -> {
if (StringUtils.isEmpty(o.getForeignKey()) || o.getIsFinishCode().compareTo(CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue()) == 0) o.busiCheckToDelete();
});
return execNonCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog(), stepResult, String.format(
"请检查非排序产品加工规则信息,根据设备[%s]产出零件[%s]匹配任意一个主条码%s查询到[%s]条加工规则配置信息,无法显示出装配件清单!", cellEquipContext.getEquipmentCode(), productionPartContext.getPartNo(),
productionPsInContextList.stream().filter(o -> (null != o && StringUtils.isEmpty(o.getForeignKey()) && o.getIsFinishCode().compareTo(CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue()) == 0)).map(MesProductionPsInContext::getProductSn).collect(Collectors.toList()).toString(),
CollectionUtils.isEmpty(innerfilterList) ? MesPcnExtConstWords.ZERO : innerfilterList.size()));
}
//【非排序线】获取产品加工规则对应的装配件信息
if (!CollectionUtils.isEmpty(innerfilterList) && innerfilterList.size() == 1)
prodRuleContextList.add(prodRuleCfgExtService.getProdRuleNosortContext(new MesProdRuleContext(
reqBean.getOrganizeCode(), reqBean.getWorkCenterCode(), reqBean.getWorkCellCode(), reqBean.getProcessCode(), productionProcessContext.getCraftCode()).
copy(innerfilterList.get(0)).workOrderNo(productionPartContext.getWorkOrderNo()).productSn(productSn)).foreignKey(productionPartContext.getForeignKey()));
}
//判断是否还存在待匹配的主条码信息
Optional<MesProductionPsInContext> optional = productionPsInContextList.stream().filter(o -> (null != o && StringUtils.isEmpty(o.getForeignKey()) && o.getIsFinishCode().compareTo(CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue()) == 0)).findFirst();
if (null != optional && optional.isPresent()) {
if (optional.get().getMessageSource().compareTo(MesExtEnumUtil.CELL_MESSAGE_SOURCE.SCAN.getValue()) == 0) optional.get().busiCheckToDelete();
else productionPsInContextList.forEach(o -> o.busiCheckToDelete());
return execNonCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog(), stepResult, String.format(
"请检查非排序产品加工规则信息,根据设备[%s]产出零件%s匹配主条码%s未查询到唯一的加工规则配置信息,无法显示出装配件清单!", cellEquipContext.getEquipmentCode(),
productionPartContextList.stream().filter(o -> (null != o && StringUtils.isEmpty(o.getForeignKey()) && o.getIsFinishCode().compareTo(CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue()) == 0)).map(MesProductionPartContext::getPartNo).collect(Collectors.toList()).toString(),
productionPsInContextList.stream().filter(o -> (null != o && StringUtils.isEmpty(o.getForeignKey()) && o.getIsFinishCode().compareTo(CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue()) == 0)).map(MesProductionPsInContext::getProductSn).collect(Collectors.toList()).toString()));
}
return stepResult;
}
@ -313,22 +315,18 @@ public class MesAssemblyShowNosortStepService extends BaseStepService {
}
//显示装配件信息
public Boolean showProductionAssembly(StationRequestBean reqBean, StationResultBean resultBean, MesWorkCenter workCenter, MesCellEquipContext cellEquipContext, List<MesProdRuleContext> prodRuleContextList, List<MesProductionPartContext> productionPartContextList) {
Map<Integer, MesProductionPartContext> productionPartMap = productionPartContextList == null ? null : productionPartContextList.stream().filter(o -> null != o && o.getForeignKey() != null).collect(Collectors.toMap(MesProductionPartContext::getForeignKey, o -> o));
public Boolean showProductionAssembly(StationRequestBean reqBean, StationResultBean resultBean, MesWorkCenter workCenter, MesCellEquipContext cellEquipContext, List<MesProdRuleContext> prodRuleContextList) {
for (MesProdRuleContext prodRuleContext : prodRuleContextList) {
if (null == prodRuleContext || StringUtils.isEmpty(prodRuleContext.getAssemblyDataJson())) continue;
String workOrderNo = getWorkOrderNo(productionPartMap, prodRuleContext.getForeignKey());
//封装匹配当前设备的装配件信息
List<MesAssemblyShowContext> assemblyShowContextList = getAssemblyShowContextList(cellEquipContext, prodRuleContext.getAssemblyDataContext(workCenter), prodRuleContext, workOrderNo);
List<MesAssemblyShowContext> assemblyShowContextList = getAssemblyShowContextList(cellEquipContext, prodRuleContext.getAssemblyDataContext(workCenter));
if (CollectionUtils.isEmpty(assemblyShowContextList)) continue;
//装配件清单列表标题
List<AttrBean> attrBeanList = dataAttrList(workOrderNo);
List<AttrBean> attrBeanList = dataAttrList(prodRuleContext.getWorkOrderNo());
//封装多表格
resultBean.addStationResultBeans(new StationResultBean().dataType(MesPcnEnumUtil.STATION_DATA_TYPE.TABLE.getValue()).dataAttrList(attrBeanList).resultList(assemblyShowContextList));
@ -349,12 +347,12 @@ public class MesAssemblyShowNosortStepService extends BaseStepService {
}
//封装匹配当前设备的装配件信息
private List<MesAssemblyShowContext> getAssemblyShowContextList(MesCellEquipContext cellEquipContext, List<MesProductionAssemblyContext> productionAssemblyContextList, MesProdRuleContext prodRuleContext, String workOrderNo) {
private List<MesAssemblyShowContext> getAssemblyShowContextList(MesCellEquipContext cellEquipContext, List<MesProductionAssemblyContext> productionAssemblyContextList) {
if (CollectionUtils.isEmpty(productionAssemblyContextList)) return null;
List<MesAssemblyShowContext> assemblyShowContextList = new ArrayList<>();
for (MesProductionAssemblyContext item : productionAssemblyContextList) {
if (null == item) continue;
assemblyShowContextList.add(assemblyShowContext(item, prodRuleContext, workOrderNo));
assemblyShowContextList.add(assemblyShowContext(item));
}
assemblyShowContextList = assemblyShowContextList.stream().filter(o -> null != o).sorted(Comparator.comparing(MesAssemblyShowContext::getRouteSeq)).collect(Collectors.toList());
@ -366,9 +364,10 @@ public class MesAssemblyShowNosortStepService extends BaseStepService {
}
//封装装配件信息
private MesAssemblyShowContext assemblyShowContext(MesProductionAssemblyContext o, MesProdRuleContext prodRuleContext, String workOrderNo) {
private MesAssemblyShowContext assemblyShowContext(MesProductionAssemblyContext o) {
MesAssemblyShowContext assemblyShowContext = new MesAssemblyShowContext();
BeanUtils.copyProperties(o, assemblyShowContext);
assemblyShowContext.setMatchTypeName(MesExtEnumUtil.ASSEMBLY_MATCH_TYPE.valueOfDescription(assemblyShowContext.getMatchType()));
assemblyShowContext.setAssemblyStatusName(MesExtEnumUtil.ASSEMBLY_STATUS.valueOfDescription(assemblyShowContext.getAssemblyStatus()));
if (MesExtEnumUtil.ASSEMBLY_STATUS.ASSEMBLY_STATUS_30.getValue() != assemblyShowContext.getAssemblyStatus())
assemblyShowContext.setColor(StringUtils.isEmpty(assemblyShowContext.getShowColor()) ? MesExtEnumUtil.COLOR.GREEN.getValue() : assemblyShowContext.getShowColor());
@ -379,6 +378,7 @@ public class MesAssemblyShowNosortStepService extends BaseStepService {
private List<AttrBean> dataAttrList(String workOrderNo) {
List<AttrBean> attrBeanList = new ArrayList<>();
PojoAttrUtil.loadPojoAttrs(attrBeanList, MesPcnExtConstWords.INDEX, "序号");
PojoAttrUtil.loadPojoAttrs(attrBeanList, MesPcnExtConstWords.MATCH_TYPE_NAME, "装配方式");
if (!StringUtils.isEmpty(workOrderNo)) PojoAttrUtil.loadPojoAttrs(attrBeanList, MesPcnExtConstWords.WORK_ORDER_NO, "生产工单编号");
PojoAttrUtil.loadPojoAttrs(attrBeanList, MesPcnExtConstWords.PART_NO, "零件编码");
PojoAttrUtil.loadPojoAttrs(attrBeanList, MesPcnExtConstWords.ASSEMBLY_PART_NO, "原料编码");
@ -388,6 +388,7 @@ public class MesAssemblyShowNosortStepService extends BaseStepService {
return attrBeanList;
}
//清除本次扫描/读取信息 有进料【只】需要清除进料,否则存在产出零件需要清除产出零件 【只需要清除被标记的数据】
private Boolean doBusiCheckToDelete(StationRequestBean reqBean, List<MesProductionPartContext> productionPartContextList, List<MesProductionPsInContext> productionPsInContextList) {
if (!CollectionUtils.isEmpty(productionPsInContextList)) productionDispatchContextStepService.saveProductionPsInContext(reqBean,
productionPsInContextList.stream().filter(o -> (null != o && o.getBusiCheckToDelete().compareTo(CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue()) == 0)).collect(Collectors.toList()));

@ -0,0 +1,399 @@
package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.step;
import cn.estsh.i3plus.ext.mes.pcn.api.busi.*;
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.MesProdRuleNosortCfg;
import cn.estsh.i3plus.pojo.mes.bean.MesWorkCenter;
import cn.estsh.i3plus.pojo.mes.model.AttrBean;
import cn.estsh.i3plus.pojo.mes.model.StationRequestBean;
import cn.estsh.i3plus.pojo.mes.model.StationResultBean;
import cn.estsh.i3plus.pojo.mes.model.StepResult;
import cn.estsh.i3plus.pojo.mes.util.MesExtEnumUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import java.util.*;
import java.util.concurrent.atomic.AtomicReference;
import java.util.stream.Collectors;
/**
* @Description :
* @Author : wangjie
**/
@Slf4j
@Service("mesAssemblyShowNosortStepService2")
public class MesAssemblyShowNosortStepService2 extends BaseStepService {
@Autowired
private IMesProductionProcessContextStepService productionProcessContextStepService;
@Autowired
private IMesProductionDispatchContextStepService productionDispatchContextStepService;
@Autowired
private IMesProdRuleCfgExtService prodRuleCfgExtService;
@Autowired
private IMesNumberRuleMatchDispatchService numberRuleMatchDispatchService;
@Autowired
private IMesProductionRecordService productionRecordService;
@Override
public StepResult execute(StationRequestBean reqBean) {
StationResultBean resultBean = new StationResultBean();
StepResult stepResult = StepResult.getSuccessComplete();
//获取上下文信息
MesProductionProcessContext productionProcessContext = productionProcessContextStepService.getCurCellEquipment(reqBean);
//配置错误 抛出异常
if (!productionProcessContext.getSuccess()) execExpSendMsgAndThrowEx(reqBean, resultBean.writeDbLog(), productionProcessContext.getMessage());
//存储生产过程上下文对象
productionProcessContextStepService.saveProductionProcessContext(reqBean, productionProcessContext);
//从上下文中取出生产线对象
MesWorkCenter workCenter = productionProcessContext.getWorkCenter();
//从上下文中取出生产线对象
MesCellEquipContext cellEquipContext = productionProcessContext.getCurCellEquip();
//获取上下文加工规则数据信息集合
List<MesProdRuleContext> prodRuleContextList = productionDispatchContextStepService.getProdRuleDataContext(reqBean);
//获取上下文产出零件数据信息集合
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, productionProcessContext, cellEquipContext, prodRuleContextList, productionPartContextList, productionPsInContextList);
if (!stepResult.isCompleted() && doBusiCheckToDelete(reqBean, productionPartContextList, productionPsInContextList)) return execNonCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog(), stepResult, stepResult.getMsg());
if (prodRuleContextList.size() != initSize) {
//保存上下文产品加工规则信息集合
productionDispatchContextStepService.saveProdRuleDataContext(reqBean, prodRuleContextList);
//保存上下文产出零件信息
if (!CollectionUtils.isEmpty(productionPartContextList)) productionDispatchContextStepService.saveProductionPartContext(reqBean, productionPartContextList);
//保存进料主条码数据
if (!CollectionUtils.isEmpty(productionPsInContextList)) productionDispatchContextStepService.saveProductionPsInContext(reqBean, productionPsInContextList);
}
//显示装配件信息
showProductionAssembly(reqBean, resultBean, workCenter, cellEquipContext, prodRuleContextList, productionPartContextList);
return execSuccessCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog(), stepResult, "装配件扫描项已查询完毕,请查看!");
}
private StepResult doHandleProdRuleData(StationRequestBean reqBean, StationResultBean resultBean, StepResult stepResult, MesWorkCenter workCenter, MesProductionProcessContext productionProcessContext, MesCellEquipContext cellEquipContext,
List<MesProdRuleContext> prodRuleContextList, List<MesProductionPartContext> productionPartContextList, List<MesProductionPsInContext> productionPsInContextList) {
//没有【产出零件数据】【进料零件条码信息】,则直接跳过 【当前是生成零件号场景】
if (CollectionUtils.isEmpty(productionPartContextList) && CollectionUtils.isEmpty(productionPsInContextList)) return stepResult;
//根据进料条件获取匹配加工规则数据(只能查询到一条,否则报错)
if (CollectionUtils.isEmpty(productionPartContextList)) return doHandleProdRuleDataByProductSn(reqBean, resultBean, stepResult, workCenter, productionProcessContext, cellEquipContext, prodRuleContextList, productionPsInContextList);
//根据是否存在【产出零件数据】获取剩余待匹配的加工规则数据 (只能查询到一条,否则报错)
else return doHandleProdRuleDataByProductionPart(reqBean, resultBean, stepResult, workCenter, productionProcessContext, cellEquipContext, prodRuleContextList, productionPartContextList, productionPsInContextList);
}
//根据是否存在【产出零件数据】获取剩余待匹配的加工规则数据 (只能查询到一条,否则报错)
private StepResult doHandleProdRuleDataByProductionPart(StationRequestBean reqBean, StationResultBean resultBean, StepResult stepResult, MesWorkCenter workCenter, MesProductionProcessContext productionProcessContext,
MesCellEquipContext cellEquipContext, List<MesProdRuleContext> prodRuleContextList, List<MesProductionPartContext> productionPartContextList, List<MesProductionPsInContext> productionPsInContextList) {
//加工规则的数据已与产出零件的数量一致
if (!CollectionUtils.isEmpty(prodRuleContextList) && prodRuleContextList.size() == productionPartContextList.size()) return stepResult;
//拿到当前最大的foreignKey
Optional<MesProductionPartContext> maxForeignKeyOptional = productionPartContextList.stream().filter(o -> (null != o && !StringUtils.isEmpty(o.getForeignKey()))).max(Comparator.comparing(MesProductionPartContext::getForeignKey));
Integer foreignKey = (null != maxForeignKeyOptional && maxForeignKeyOptional.isPresent()) ? maxForeignKeyOptional.get().getForeignKey() : MesPcnExtConstWords.ZERO;
//搜集未匹配规则的产出零件
List<String> outPartNoList = productionPartContextList.stream().filter(o -> (null != o && StringUtils.isEmpty(o.getForeignKey()) && !StringUtils.isEmpty(o.getPartNo()))).map(MesProductionPartContext::getPartNo).collect(Collectors.toList());
//没有【进料零件条码信息】信息, 根据进料[NULL]条件获取匹配当前产出零件的加工规则数据(只能查询到一条,否则报错)
if (CollectionUtils.isEmpty(productionPsInContextList)) return doHandleProdRuleDataByProductionPartAndEmptyProductSn(reqBean, resultBean, stepResult, workCenter, productionProcessContext, cellEquipContext, prodRuleContextList, productionPartContextList, outPartNoList, foreignKey);
//存在【产出零件数据】信息, 存在【进料零件条码信息】 获取匹配当前产出零件的加工规则数据 (只能查询到一条,否则报错)
else return doHandleProdRuleDataByProductionPartAndProductSn(reqBean, resultBean, stepResult, workCenter, productionProcessContext, cellEquipContext, prodRuleContextList, productionPartContextList, productionPsInContextList, outPartNoList, foreignKey);
}
//没有【进料零件条码信息】信息, 根据进料[NULL]条件获取匹配当前产出零件的加工规则数据(只能查询到一条,否则报错)
private StepResult doHandleProdRuleDataByProductionPartAndEmptyProductSn(StationRequestBean reqBean, StationResultBean resultBean, StepResult stepResult, MesWorkCenter workCenter, MesProductionProcessContext productionProcessContext,
MesCellEquipContext cellEquipContext, List<MesProdRuleContext> prodRuleContextList, List<MesProductionPartContext> productionPartContextList, List<String> outPartNoList, Integer foreignKey) {
//【非排序线】获取产品加工规则 ; 条件进料[NULL]
List<MesProdRuleNosortCfg> prodRuleNosortCfgList = prodRuleCfgExtService.getProdRuleNosortCfgList(new MesProdRuleContext(reqBean.getOrganizeCode()).equipmentCode(cellEquipContext.getEquipmentCode()).outPartNos(outPartNoList).inPartIsEmpty(true).inPartRuleIsEmpty(true));
//根据产出零件分组数据
Map<String, List<MesProdRuleNosortCfg>> prodRuleNosortCfgMap = groupProdRuleNosortCfgList(prodRuleNosortCfgList);
for (MesProductionPartContext productionPartContext : productionPartContextList) {
//foreignKey有值代表已经匹配过产品加工规则
if (null == productionPartContext || productionPartContext.getIsFinishCode().compareTo(CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue()) == 0 || !StringUtils.isEmpty(productionPartContext.getForeignKey())) continue;
List<MesProdRuleNosortCfg> filterList = !CollectionUtils.isEmpty(prodRuleNosortCfgMap) ? prodRuleNosortCfgMap.get(productionPartContext.getPartNo()) : null;
if (CollectionUtils.isEmpty(filterList) || filterList.size() > 1) {
productionPartContext.busiCheckToDelete();
return execNonCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog(), stepResult, String.format(
"请检查非排序产品加工规则信息,根据设备[%s]产出零件[%s]进料零件[空]进料零件规则[空]查询到[%s]条加工规则配置信息,无法显示出装配件清单!", cellEquipContext.getEquipmentCode(), productionPartContext.getPartNo(), CollectionUtils.isEmpty(filterList) ? MesPcnExtConstWords.ZERO : filterList.size()));
}
//【非排序线】获取产品加工规则对应的装配件信息
prodRuleContextList.add(prodRuleCfgExtService.getProdRuleNosortContext(new MesProdRuleContext(
reqBean.getOrganizeCode(), reqBean.getWorkCenterCode(), reqBean.getWorkCellCode(), reqBean.getProcessCode(), productionProcessContext.getCraftCode()).
copy(prodRuleNosortCfgList.get(0)).workOrderNo(productionPartContext.getWorkOrderNo()).foreignKey(productionPartContext.foreignKey(foreignKey += 1).getForeignKey())));
}
return stepResult;
}
//没有【产出零件数据】信息 , 根据进料条件获取匹配加工规则数据(只能查询到一条,否则报错)
private StepResult doHandleProdRuleDataByProductSn(StationRequestBean reqBean, StationResultBean resultBean, StepResult stepResult, MesWorkCenter workCenter, MesProductionProcessContext productionProcessContext,
MesCellEquipContext cellEquipContext, List<MesProdRuleContext> prodRuleContextList, List<MesProductionPsInContext> productionPsInContextList) {
//【非排序线】获取产品加工规则 ; 分别根据 进料零件有值 与 进料规则不为空 查询 再合并数据返回
List<MesProdRuleNosortCfg> prodRuleNosortCfgList = getProdRuleNosortCfgList(reqBean, cellEquipContext, productionPsInContextList, null);
//拿到当前最大的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;
for (MesProductionPsInContext productionPsInContext : productionPsInContextList) {
//foreignKey有值代表已经匹配过产品加工规则
if (null == productionPsInContext || productionPsInContext.getIsFinishCode().compareTo(CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue()) == 0 || !StringUtils.isEmpty(productionPsInContext.getForeignKey())) continue;
List<MesProdRuleNosortCfg> filterList;
//搜集进料零件号匹配的产品加工规则
if (!StringUtils.isEmpty(productionPsInContext.getPartNo())) filterList = filterProdRuleNosortCfgList(prodRuleNosortCfgList, productionPsInContext.getPartNo());
//进料零件条码匹配进料零件规则
else filterList = (List<MesProdRuleNosortCfg>) numberRuleMatchDispatchService.matchNumberRule(reqBean.getOrganizeCode(), productionPsInContext.getProductSn(), filterProdRuleNosortCfgList(prodRuleNosortCfgList));
if (CollectionUtils.isEmpty(filterList) || filterList.size() > 1) {
productionPsInContext.busiCheckToDelete();
return execNonCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog(), stepResult, String.format(
"请检查非排序产品加工规则信息,根据设备[%s]进料零件条码[%s]查询到[%s]条加工规则配置信息,无法显示出装配件清单!", cellEquipContext.getEquipmentCode(), productionPsInContext.getProductSn(), CollectionUtils.isEmpty(filterList) ? MesPcnExtConstWords.ZERO : filterList.size()));
}
if (!StringUtils.isEmpty(productionPsInContext.getPartNo()) && !(Boolean) productionRecordService.checkSnTimeliness(
reqBean.getOrganizeCode(), productionPsInContext.getProductSn(), filterList.get(0).getId(), MesExtEnumUtil.TIME_DATA_SOURCE.DATA_SOURCE20.getValue(), false).get(MesPcnExtConstWords.RESULT)) {
productionPsInContext.busiCheckToDelete();
return execNonCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog(), stepResult, String.format("请检查进料主条码信息,进料主条码[%s]时效性验证不通过!", productionPsInContext.getProductSn()));
}
//【非排序线】获取产品加工规则对应的装配件信息
prodRuleContextList.add(prodRuleCfgExtService.getProdRuleNosortContext(new MesProdRuleContext(
reqBean.getOrganizeCode(), reqBean.getWorkCenterCode(), reqBean.getWorkCellCode(), reqBean.getProcessCode(), productionProcessContext.getCraftCode())
.copy(prodRuleNosortCfgList.get(0)).productSn(productionPsInContext.getProductSn()).foreignKey(productionPsInContext.foreignKey(foreignKey += 1).getForeignKey())));
}
return stepResult;
}
private List<MesProdRuleNosortCfg> getProdRuleNosortCfgList(StationRequestBean reqBean, MesCellEquipContext cellEquipContext, List<MesProductionPsInContext> productionPsInContextList, List<String> outPartNoList) {
//【非排序线】获取产品加工规则 ; 分别根据 进料零件有值 与 进料规则不为空 查询 再合并数据返回, 条件可能携带产出零件
List<String> inPartNoList = productionPsInContextList.stream().filter(o -> (null != o && StringUtils.isEmpty(o.getForeignKey()) && !StringUtils.isEmpty(o.getPartNo()))).map(MesProductionPsInContext::getPartNo).collect(Collectors.toList());
Optional<MesProductionPsInContext> optional = productionPsInContextList.stream().filter(o -> (null != o && StringUtils.isEmpty(o.getForeignKey()) && o.getIsFinishCode().compareTo(CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue()) == 0 && StringUtils.isEmpty(o.getPartNo()))).findFirst();
List<MesProdRuleNosortCfg> prodRuleNosortCfgList = prodRuleCfgExtService.getProdRuleNosortCfgList(
!CollectionUtils.isEmpty(inPartNoList) ? new MesProdRuleContext(reqBean.getOrganizeCode()).equipmentCode(cellEquipContext.getEquipmentCode()).inPartNos(inPartNoList).outPartNos(outPartNoList) : null,
(null != optional && optional.isPresent()) ? new MesProdRuleContext(reqBean.getOrganizeCode()).equipmentCode(cellEquipContext.getEquipmentCode()).inPartIsEmpty(true).inPartRuleIsEmpty(false).outPartNos(outPartNoList) : null);
return prodRuleNosortCfgList;
}
//存在【产出零件数据】信息, 存在【进料零件条码信息】 获取匹配当前产出零件的加工规则数据 (只能查询到一条,否则报错)
private StepResult doHandleProdRuleDataByProductionPartAndProductSn(StationRequestBean reqBean, StationResultBean resultBean, StepResult stepResult, MesWorkCenter workCenter, MesProductionProcessContext productionProcessContext, MesCellEquipContext cellEquipContext,
List<MesProdRuleContext> prodRuleContextList, List<MesProductionPartContext> productionPartContextList, List<MesProductionPsInContext> productionPsInContextList, List<String> outPartNoList, Integer foreignKey) {
//【非排序线】获取产品加工规则 ; 分别根据 进料零件有值 与 进料规则不为空 查询 再合并数据返回, 条件携带产出零件
List<MesProdRuleNosortCfg> prodRuleNosortCfgList = getProdRuleNosortCfgList(reqBean, cellEquipContext, productionPsInContextList, outPartNoList);
//根据产出零件分组数据
Map<String, List<MesProdRuleNosortCfg>> prodRuleNosortCfgMap = groupProdRuleNosortCfgList(prodRuleNosortCfgList);
for (MesProductionPartContext productionPartContext : productionPartContextList) {
//foreignKey有值代表已经匹配过产品加工规则
if (null == productionPartContext || productionPartContext.getIsFinishCode().compareTo(CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue()) == 0 || !StringUtils.isEmpty(productionPartContext.getForeignKey())) continue;
//获取匹配产出零件的所有加工规则
List<MesProdRuleNosortCfg> outPartNoProdRuleList = !CollectionUtils.isEmpty(prodRuleNosortCfgMap) ? prodRuleNosortCfgMap.get(productionPartContext.getPartNo()) : null;
String productSn = null;
//判断是否还存在待匹配的主条码信息, 内部循环匹配成功会标记 foreignKey
Optional<MesProductionPsInContext> optional = productionPsInContextList.stream().filter(o -> (null != o && StringUtils.isEmpty(o.getForeignKey()) && o.getIsFinishCode().compareTo(CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue()) == 0)).findFirst();
if (null == optional || !optional.isPresent()) break;
List<MesProdRuleNosortCfg> innerfilterList = null;
for (MesProductionPsInContext productionPsInContext : productionPsInContextList) {
//foreignKey有值代表已经匹配过产品加工规则
if (null == productionPsInContext || productionPartContext.getIsFinishCode().compareTo(CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue()) == 0 || !StringUtils.isEmpty(productionPsInContext.getForeignKey())) continue;
//搜集进料零件号匹配的产品加工规则
if (!StringUtils.isEmpty(productionPsInContext.getPartNo())) innerfilterList = filterProdRuleNosortCfgList(outPartNoProdRuleList, productionPsInContext.getPartNo());
//进料零件条码匹配进料零件规则
else innerfilterList = (List<MesProdRuleNosortCfg>) numberRuleMatchDispatchService.matchNumberRule(reqBean.getOrganizeCode(), productionPsInContext.getProductSn(), filterProdRuleNosortCfgList(outPartNoProdRuleList));
if (CollectionUtils.isEmpty(innerfilterList) || innerfilterList.size() > 1) continue;
if (!StringUtils.isEmpty(productionPsInContext.getPartNo()) && !(Boolean) productionRecordService.checkSnTimeliness(
reqBean.getOrganizeCode(), productionPsInContext.getProductSn(), innerfilterList.get(0).getId(), MesExtEnumUtil.TIME_DATA_SOURCE.DATA_SOURCE20.getValue(), false).get(MesPcnExtConstWords.RESULT)) {
productionPsInContext.busiCheckToDelete();
return execNonCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog(), stepResult, String.format("请检查进料主条码信息,进料主条码[%s]时效性验证不通过!", productionPsInContext.getProductSn()));
}
productionPartContext.foreignKey(productionPsInContext.foreignKey(foreignKey += 1).getForeignKey());
productSn = productionPsInContext.getProductSn();
break;
}
if (CollectionUtils.isEmpty(innerfilterList) || innerfilterList.size() > 1) {
productionPsInContextList.forEach(o -> {
if (StringUtils.isEmpty(o.getForeignKey()) || o.getIsFinishCode().compareTo(CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue()) == 0) o.busiCheckToDelete();
});
return execNonCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog(), stepResult, String.format(
"请检查非排序产品加工规则信息,根据设备[%s]产出零件[%s]匹配任意一个主条码%s查询到[%s]条加工规则配置信息,无法显示出装配件清单!", cellEquipContext.getEquipmentCode(), productionPartContext.getPartNo(),
productionPsInContextList.stream().filter(o -> (null != o && StringUtils.isEmpty(o.getForeignKey()) && o.getIsFinishCode().compareTo(CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue()) == 0)).map(MesProductionPsInContext::getProductSn).collect(Collectors.toList()).toString(),
CollectionUtils.isEmpty(innerfilterList) ? MesPcnExtConstWords.ZERO : innerfilterList.size()));
}
//【非排序线】获取产品加工规则对应的装配件信息
prodRuleContextList.add(prodRuleCfgExtService.getProdRuleNosortContext(new MesProdRuleContext(
reqBean.getOrganizeCode(), reqBean.getWorkCenterCode(), reqBean.getWorkCellCode(), reqBean.getProcessCode(), productionProcessContext.getCraftCode()).
copy(innerfilterList.get(0)).workOrderNo(productionPartContext.getWorkOrderNo()).productSn(productSn)).foreignKey(productionPartContext.getForeignKey()));
}
return stepResult;
}
//搜集进料零件号匹配的产品加工规则
private List<MesProdRuleNosortCfg> filterProdRuleNosortCfgList(List<MesProdRuleNosortCfg> prodRuleNosortCfgList, String partNo) {
return CollectionUtils.isEmpty(prodRuleNosortCfgList) ? null : prodRuleNosortCfgList.stream().filter(o -> (null != o && !StringUtils.isEmpty(o.getInPartNo()) && o.getInPartNo().equals(partNo))).collect(Collectors.toList());
}
//搜集进料零件规则有值的产品加工规则
private List<MesProdRuleNosortCfg> filterProdRuleNosortCfgList(List<MesProdRuleNosortCfg> prodRuleNosortCfgList) {
return CollectionUtils.isEmpty(prodRuleNosortCfgList) ? null : prodRuleNosortCfgList.stream().filter(o -> (null != o && StringUtils.isEmpty(o.getInPartNo()) && !StringUtils.isEmpty(o.getInPartNoRule()))).collect(Collectors.toList());
}
//根据产出零件分组数据
private Map<String, List<MesProdRuleNosortCfg>> groupProdRuleNosortCfgList(List<MesProdRuleNosortCfg> prodRuleNosortCfgList) {
return CollectionUtils.isEmpty(prodRuleNosortCfgList) ? null : prodRuleNosortCfgList.stream().filter(o -> null != o).collect(Collectors.groupingBy(MesProdRuleNosortCfg::getOutPartNo));
}
//显示装配件信息
public Boolean showProductionAssembly(StationRequestBean reqBean, StationResultBean resultBean, MesWorkCenter workCenter, MesCellEquipContext cellEquipContext, List<MesProdRuleContext> prodRuleContextList, List<MesProductionPartContext> productionPartContextList) {
Map<Integer, MesProductionPartContext> productionPartMap = productionPartContextList == null ? null : productionPartContextList.stream().filter(o -> null != o && o.getForeignKey() != null).collect(Collectors.toMap(MesProductionPartContext::getForeignKey, o -> o));
for (MesProdRuleContext prodRuleContext : prodRuleContextList) {
if (null == prodRuleContext || StringUtils.isEmpty(prodRuleContext.getAssemblyDataJson())) continue;
String workOrderNo = getWorkOrderNo(productionPartMap, prodRuleContext.getForeignKey());
//封装匹配当前设备的装配件信息
List<MesAssemblyShowContext> assemblyShowContextList = getAssemblyShowContextList(cellEquipContext, prodRuleContext.getAssemblyDataContext(workCenter), prodRuleContext, workOrderNo);
if (CollectionUtils.isEmpty(assemblyShowContextList)) continue;
//装配件清单列表标题
List<AttrBean> attrBeanList = dataAttrList(workOrderNo);
//封装多表格
resultBean.addStationResultBeans(new StationResultBean().dataType(MesPcnEnumUtil.STATION_DATA_TYPE.TABLE.getValue()).dataAttrList(attrBeanList).resultList(assemblyShowContextList));
}
if (CollectionUtils.isEmpty(resultBean.getStationResultBeans())) return false;
resultBean.busiType(MesPcnEnumUtil.STATION_BUSI_TYPE.STEP_CUSTOM_CONTENT.getValue()).dataType(MesPcnEnumUtil.STATION_DATA_TYPE.TABLES.getValue());
this.sendMessage(reqBean, resultBean);
return true;
}
private String getWorkOrderNo(Map<Integer, MesProductionPartContext> productionPartMap, Integer foreignKey) {
return (!CollectionUtils.isEmpty(productionPartMap) && productionPartMap.containsKey(foreignKey)) ? productionPartMap.get(foreignKey).getWorkOrderNo() : null;
}
//封装匹配当前设备的装配件信息
private List<MesAssemblyShowContext> getAssemblyShowContextList(MesCellEquipContext cellEquipContext, List<MesProductionAssemblyContext> productionAssemblyContextList, MesProdRuleContext prodRuleContext, String workOrderNo) {
if (CollectionUtils.isEmpty(productionAssemblyContextList)) return null;
List<MesAssemblyShowContext> assemblyShowContextList = new ArrayList<>();
for (MesProductionAssemblyContext item : productionAssemblyContextList) {
if (null == item) continue;
assemblyShowContextList.add(assemblyShowContext(item, prodRuleContext, workOrderNo));
}
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;
}
//封装装配件信息
private MesAssemblyShowContext assemblyShowContext(MesProductionAssemblyContext o, MesProdRuleContext prodRuleContext, String workOrderNo) {
MesAssemblyShowContext assemblyShowContext = new MesAssemblyShowContext();
BeanUtils.copyProperties(o, assemblyShowContext);
assemblyShowContext.setAssemblyStatusName(MesExtEnumUtil.ASSEMBLY_STATUS.valueOfDescription(assemblyShowContext.getAssemblyStatus()));
if (MesExtEnumUtil.ASSEMBLY_STATUS.ASSEMBLY_STATUS_30.getValue() != assemblyShowContext.getAssemblyStatus())
assemblyShowContext.setColor(StringUtils.isEmpty(assemblyShowContext.getShowColor()) ? MesExtEnumUtil.COLOR.GREEN.getValue() : assemblyShowContext.getShowColor());
return assemblyShowContext;
}
//装配件清单列表标题
private List<AttrBean> dataAttrList(String workOrderNo) {
List<AttrBean> attrBeanList = new ArrayList<>();
PojoAttrUtil.loadPojoAttrs(attrBeanList, MesPcnExtConstWords.INDEX, "序号");
if (!StringUtils.isEmpty(workOrderNo)) PojoAttrUtil.loadPojoAttrs(attrBeanList, MesPcnExtConstWords.WORK_ORDER_NO, "生产工单编号");
PojoAttrUtil.loadPojoAttrs(attrBeanList, MesPcnExtConstWords.PART_NO, "零件编码");
PojoAttrUtil.loadPojoAttrs(attrBeanList, MesPcnExtConstWords.ASSEMBLY_PART_NO, "原料编码");
PojoAttrUtil.loadPojoAttrs(attrBeanList, MesPcnExtConstWords.ASSEMBLY_PART_NAME, "原料名称");
PojoAttrUtil.loadPojoAttrs(attrBeanList, MesPcnExtConstWords.ASSEMBLY_SN, "原料条码");
PojoAttrUtil.loadPojoAttrs(attrBeanList, MesPcnExtConstWords.ASSEMBLY_STATUS_NAME, "装配状态");
return attrBeanList;
}
private Boolean doBusiCheckToDelete(StationRequestBean reqBean, List<MesProductionPartContext> productionPartContextList, List<MesProductionPsInContext> productionPsInContextList) {
if (!CollectionUtils.isEmpty(productionPsInContextList)) productionDispatchContextStepService.saveProductionPsInContext(reqBean,
productionPsInContextList.stream().filter(o -> (null != o && o.getBusiCheckToDelete().compareTo(CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue()) == 0)).collect(Collectors.toList()));
else if (!CollectionUtils.isEmpty(productionPartContextList)) productionDispatchContextStepService.saveProductionPartContext(reqBean,
productionPartContextList.stream().filter(o -> (null != o && o.getBusiCheckToDelete().compareTo(CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue()) == 0)).collect(Collectors.toList()));
return true;
}
}

@ -1,402 +0,0 @@
//package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.step;
//
//import cn.estsh.i3plus.ext.mes.pcn.api.busi.*;
//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.MesProdRuleNosortCfg;
//import cn.estsh.i3plus.pojo.mes.bean.MesWorkCenter;
//import cn.estsh.i3plus.pojo.mes.model.AttrBean;
//import cn.estsh.i3plus.pojo.mes.model.StationRequestBean;
//import cn.estsh.i3plus.pojo.mes.model.StationResultBean;
//import cn.estsh.i3plus.pojo.mes.model.StepResult;
//import cn.estsh.i3plus.pojo.mes.util.MesExtEnumUtil;
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.beans.BeanUtils;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.stereotype.Service;
//import org.springframework.util.CollectionUtils;
//import org.springframework.util.StringUtils;
//
//import java.util.*;
//import java.util.concurrent.atomic.AtomicReference;
//import java.util.stream.Collectors;
//
///**
// * @Description : 显示装配件扫描项工步【非排序】
// * @Author : wangjie
// **/
//@Slf4j
//@Service("mesAssemblyShowNosortStepServiceBak")
//public class MesAssemblyShowNosortStepServiceBak extends BaseStepService {
//
// @Autowired
// private IMesProductionProcessContextStepService productionProcessContextStepService;
//
// @Autowired
// private IMesProductionDispatchContextStepService productionDispatchContextStepService;
//
// @Autowired
// private IMesProdRuleCfgExtService prodRuleCfgExtService;
//
// @Autowired
// private IMesNumberRuleMatchDispatchService numberRuleMatchDispatchService;
//
// @Autowired
// private IMesProductionRecordService productionRecordService;
//
// @Override
// public StepResult execute(StationRequestBean reqBean) {
//
// StationResultBean resultBean = new StationResultBean();
//
// StepResult stepResult = StepResult.getSuccessComplete();
//
// //获取上下文信息
// MesProductionProcessContext productionProcessContext = productionProcessContextStepService.getCurCellEquipment(reqBean);
//
// //配置错误 抛出异常
// if (!productionProcessContext.getSuccess()) execExpSendMsgAndThrowEx(reqBean, resultBean.writeDbLog(), productionProcessContext.getMessage());
//
// //存储生产过程上下文对象
// productionProcessContextStepService.saveProductionProcessContext(reqBean, productionProcessContext);
//
// //从上下文中取出生产线对象
// MesWorkCenter workCenter = productionProcessContext.getWorkCenter();
//
// //从上下文中取出生产线对象
// MesCellEquipContext cellEquipContext = productionProcessContext.getCurCellEquip();
//
// //获取上下文加工规则数据信息集合
// List<MesProdRuleContext> prodRuleContextList = productionDispatchContextStepService.getProdRuleDataContext(reqBean);
//
// //获取上下文产出零件数据信息集合
// 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, productionProcessContext, cellEquipContext, prodRuleContextList, productionPartContextList, productionPsInContextList);
//
// if (!stepResult.isCompleted() && doBusiCheckToDelete(reqBean, productionPartContextList, productionPsInContextList)) return execNonCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog(), stepResult, stepResult.getMsg());
//
// if (prodRuleContextList.size() != initSize) {
// //保存上下文产品加工规则信息集合
// productionDispatchContextStepService.saveProdRuleDataContext(reqBean, prodRuleContextList);
// //保存上下文产出零件信息
// if (!CollectionUtils.isEmpty(productionPartContextList)) productionDispatchContextStepService.saveProductionPartContext(reqBean, productionPartContextList);
// //保存进料主条码数据
// if (!CollectionUtils.isEmpty(productionPsInContextList)) productionDispatchContextStepService.saveProductionPsInContext(reqBean, productionPsInContextList);
// }
//
// //显示装配件信息
// showProductionAssembly(reqBean, resultBean, workCenter, cellEquipContext, prodRuleContextList, productionPartContextList);
//
// return execSuccessCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog(), stepResult, "装配件扫描项已查询完毕,请查看!");
// }
//
// private StepResult doHandleProdRuleData(StationRequestBean reqBean, StationResultBean resultBean, StepResult stepResult, MesWorkCenter workCenter, MesProductionProcessContext productionProcessContext, MesCellEquipContext cellEquipContext,
// List<MesProdRuleContext> prodRuleContextList, List<MesProductionPartContext> productionPartContextList, List<MesProductionPsInContext> productionPsInContextList) {
// //没有【产出零件数据】【进料零件条码信息】,则直接跳过 【当前是生成零件号场景】
// if (CollectionUtils.isEmpty(productionPartContextList) && CollectionUtils.isEmpty(productionPsInContextList)) return stepResult;
//
// //根据进料条件获取匹配加工规则数据(只能查询到一条,否则报错)
// if (CollectionUtils.isEmpty(productionPartContextList)) return doHandleProdRuleDataByProductSn(reqBean, resultBean, stepResult, workCenter, productionProcessContext, cellEquipContext, prodRuleContextList, productionPsInContextList);
// //根据是否存在【产出零件数据】获取剩余待匹配的加工规则数据 (只能查询到一条,否则报错)
// else return doHandleProdRuleDataByProductionPart(reqBean, resultBean, stepResult, workCenter, productionProcessContext, cellEquipContext, prodRuleContextList, productionPartContextList, productionPsInContextList);
//
// }
//
// //根据是否存在【产出零件数据】获取剩余待匹配的加工规则数据 (只能查询到一条,否则报错)
// private StepResult doHandleProdRuleDataByProductionPart(StationRequestBean reqBean, StationResultBean resultBean, StepResult stepResult, MesWorkCenter workCenter, MesProductionProcessContext productionProcessContext,
// MesCellEquipContext cellEquipContext, List<MesProdRuleContext> prodRuleContextList, List<MesProductionPartContext> productionPartContextList, List<MesProductionPsInContext> productionPsInContextList) {
//
// //加工规则的数据已与产出零件的数量一致
// if (!CollectionUtils.isEmpty(prodRuleContextList) && prodRuleContextList.size() == productionPartContextList.size()) return stepResult;
//
// //拿到当前最大的foreignKey
// Optional<MesProductionPartContext> maxForeignKeyOptional = productionPartContextList.stream().filter(o -> (null != o && !StringUtils.isEmpty(o.getForeignKey()))).max(Comparator.comparing(MesProductionPartContext::getForeignKey));
// Integer foreignKey = (null != maxForeignKeyOptional && maxForeignKeyOptional.isPresent()) ? maxForeignKeyOptional.get().getForeignKey() : MesPcnExtConstWords.ZERO;
//
// //搜集未匹配规则的产出零件
// List<String> outPartNoList = productionPartContextList.stream().filter(o -> (null != o && StringUtils.isEmpty(o.getForeignKey()) && !StringUtils.isEmpty(o.getPartNo()))).map(MesProductionPartContext::getPartNo).collect(Collectors.toList());
//
// //没有【进料零件条码信息】信息, 根据进料[NULL]条件获取匹配当前产出零件的加工规则数据(只能查询到一条,否则报错)
// if (CollectionUtils.isEmpty(productionPsInContextList)) return doHandleProdRuleDataByProductionPartAndEmptyProductSn(reqBean, resultBean, stepResult, workCenter, productionProcessContext, cellEquipContext, prodRuleContextList, productionPartContextList, outPartNoList, foreignKey);
// //存在【产出零件数据】信息, 存在【进料零件条码信息】 获取匹配当前产出零件的加工规则数据 (只能查询到一条,否则报错)
// else return doHandleProdRuleDataByProductionPartAndProductSn(reqBean, resultBean, stepResult, workCenter, productionProcessContext, cellEquipContext, prodRuleContextList, productionPartContextList, productionPsInContextList, outPartNoList, foreignKey);
//
// }
//
// //没有【进料零件条码信息】信息, 根据进料[NULL]条件获取匹配当前产出零件的加工规则数据(只能查询到一条,否则报错)
// private StepResult doHandleProdRuleDataByProductionPartAndEmptyProductSn(StationRequestBean reqBean, StationResultBean resultBean, StepResult stepResult, MesWorkCenter workCenter, MesProductionProcessContext productionProcessContext,
// MesCellEquipContext cellEquipContext, List<MesProdRuleContext> prodRuleContextList, List<MesProductionPartContext> productionPartContextList, List<String> outPartNoList, Integer foreignKey) {
//
// //【非排序线】获取产品加工规则 ; 条件进料[NULL]
// List<MesProdRuleNosortCfg> prodRuleNosortCfgList = prodRuleCfgExtService.getProdRuleNosortCfgList(new MesProdRuleContext(reqBean.getOrganizeCode()).equipmentCode(cellEquipContext.getEquipmentCode()).outPartNos(outPartNoList).inPartIsEmpty(true));
// //根据产出零件分组数据
// Map<String, List<MesProdRuleNosortCfg>> prodRuleNosortCfgMap = groupProdRuleNosortCfgList(prodRuleNosortCfgList);
//
// for (MesProductionPartContext productionPartContext : productionPartContextList) {
//
// //foreignKey有值代表已经匹配过产品加工规则
// if (null == productionPartContext || productionPartContext.getIsFinishCode().compareTo(CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue()) == 0 || !StringUtils.isEmpty(productionPartContext.getForeignKey())) continue;
//
// List<MesProdRuleNosortCfg> filterList = !CollectionUtils.isEmpty(prodRuleNosortCfgMap) ? prodRuleNosortCfgMap.get(productionPartContext.getPartNo()) : null;
//
// if (CollectionUtils.isEmpty(filterList) || filterList.size() > 1) {
// if (productionPartContext.getMessageSource().compareTo(MesExtEnumUtil.CELL_MESSAGE_SOURCE.SCAN.getValue()) == 0) productionPartContext.busiCheckToDelete();
// else productionPartContextList.forEach(o -> o.busiCheckToDelete());
// return execNonCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog(), stepResult, String.format(
// "请检查非排序产品加工规则信息,根据设备[%s]产出零件[%s]进料零件[空]查询到[%s]条加工规则配置信息,无法显示出装配件清单!", cellEquipContext.getEquipmentCode(), productionPartContext.getPartNo(), CollectionUtils.isEmpty(filterList) ? MesPcnExtConstWords.ZERO : filterList.size()));
// }
//
// //【非排序线】获取产品加工规则对应的装配件信息
// prodRuleContextList.add(prodRuleCfgExtService.getProdRuleNosortContext(new MesProdRuleContext(
// reqBean.getOrganizeCode(), reqBean.getWorkCenterCode(), reqBean.getWorkCellCode(), reqBean.getProcessCode(), productionProcessContext.getCraftCode()).
// copy(prodRuleNosortCfgList.get(0)).workOrderNo(productionPartContext.getWorkOrderNo()).foreignKey(productionPartContext.foreignKey(foreignKey += 1).getForeignKey())));
//
// }
// return stepResult;
// }
//
// //没有【产出零件数据】信息 , 根据进料条件获取匹配加工规则数据(只能查询到一条,否则报错)
// private StepResult doHandleProdRuleDataByProductSn(StationRequestBean reqBean, StationResultBean resultBean, StepResult stepResult, MesWorkCenter workCenter, MesProductionProcessContext productionProcessContext,
// MesCellEquipContext cellEquipContext, List<MesProdRuleContext> prodRuleContextList, List<MesProductionPsInContext> productionPsInContextList) {
//
// //【非排序线】获取产品加工规则 ; 分别根据 进料零件有值 与 进料规则不为空 查询 再合并数据返回
// List<MesProdRuleNosortCfg> prodRuleNosortCfgList = getProdRuleNosortCfgList(reqBean, cellEquipContext, productionPsInContextList, null);
//
// //拿到当前最大的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;
//
// for (MesProductionPsInContext productionPsInContext : productionPsInContextList) {
//
// //foreignKey有值代表已经匹配过产品加工规则
// if (null == productionPsInContext || productionPsInContext.getIsFinishCode().compareTo(CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue()) == 0 || !StringUtils.isEmpty(productionPsInContext.getForeignKey())) continue;
//
// List<MesProdRuleNosortCfg> filterList;
// //搜集进料零件号匹配的产品加工规则
// if (!StringUtils.isEmpty(productionPsInContext.getPartNo())) filterList = filterProdRuleNosortCfgList(prodRuleNosortCfgList, productionPsInContext.getPartNo());
// //进料零件条码匹配进料零件规则
// else filterList = (List<MesProdRuleNosortCfg>) numberRuleMatchDispatchService.matchNumberRule(reqBean.getOrganizeCode(), productionPsInContext.getProductSn(), filterProdRuleNosortCfgList(prodRuleNosortCfgList));
//
// if (CollectionUtils.isEmpty(filterList) || filterList.size() > 1) {
// productionPsInContext.busiCheckToDelete();
// if (productionPsInContext.getMessageSource().compareTo(MesExtEnumUtil.CELL_MESSAGE_SOURCE.SCAN.getValue()) == 0) productionPsInContext.busiCheckToDelete();
// else productionPsInContextList.forEach(o -> o.busiCheckToDelete());
// return execNonCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog(), stepResult, String.format(
// "请检查非排序产品加工规则信息,根据设备[%s]进料零件条码[%s]查询到[%s]条加工规则配置信息,无法显示出装配件清单!", cellEquipContext.getEquipmentCode(), productionPsInContext.getProductSn(), CollectionUtils.isEmpty(filterList) ? MesPcnExtConstWords.ZERO : filterList.size()));
// }
//
// if (!StringUtils.isEmpty(productionPsInContext.getPartNo()) && !(Boolean) productionRecordService.checkSnTimeliness(
// reqBean.getOrganizeCode(), productionPsInContext.getProductSn(), filterList.get(0).getId(), MesExtEnumUtil.TIME_DATA_SOURCE.DATA_SOURCE20.getValue(), false).get(MesPcnExtConstWords.RESULT)) {
// if (productionPsInContext.getMessageSource().compareTo(MesExtEnumUtil.CELL_MESSAGE_SOURCE.SCAN.getValue()) == 0) productionPsInContext.busiCheckToDelete();
// else productionPsInContextList.forEach(o -> o.busiCheckToDelete());
// return execNonCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog(), stepResult, String.format("请检查进料主条码信息,进料主条码[%s]时效性验证不通过!", productionPsInContext.getProductSn()));
// }
//
// //【非排序线】获取产品加工规则对应的装配件信息
// prodRuleContextList.add(prodRuleCfgExtService.getProdRuleNosortContext(new MesProdRuleContext(
// reqBean.getOrganizeCode(), reqBean.getWorkCenterCode(), reqBean.getWorkCellCode(), reqBean.getProcessCode(), productionProcessContext.getCraftCode())
// .copy(prodRuleNosortCfgList.get(0)).productSn(productionPsInContext.getProductSn()).foreignKey(productionPsInContext.foreignKey(foreignKey += 1).getForeignKey())));
//
// }
//
// return stepResult;
//
// }
//
// private List<MesProdRuleNosortCfg> getProdRuleNosortCfgList(StationRequestBean reqBean, MesCellEquipContext cellEquipContext, List<MesProductionPsInContext> productionPsInContextList, List<String> outPartNoList) {
// //【非排序线】获取产品加工规则 ; 分别根据 进料零件有值 与 进料规则不为空 查询 再合并数据返回, 条件可能携带产出零件
// List<String> inPartNoList = productionPsInContextList.stream().filter(o -> (null != o && StringUtils.isEmpty(o.getForeignKey()) && !StringUtils.isEmpty(o.getPartNo()))).map(MesProductionPsInContext::getPartNo).collect(Collectors.toList());
// Optional<MesProductionPsInContext> optional = productionPsInContextList.stream().filter(o -> (null != o && StringUtils.isEmpty(o.getForeignKey()) && o.getIsFinishCode().compareTo(CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue()) == 0 && StringUtils.isEmpty(o.getPartNo()))).findFirst();
// List<MesProdRuleNosortCfg> prodRuleNosortCfgList = prodRuleCfgExtService.getProdRuleNosortCfgList(
// !CollectionUtils.isEmpty(inPartNoList) ? new MesProdRuleContext(reqBean.getOrganizeCode()).equipmentCode(cellEquipContext.getEquipmentCode()).inPartNos(inPartNoList).outPartNos(outPartNoList) : null,
// (null != optional && optional.isPresent()) ? new MesProdRuleContext(reqBean.getOrganizeCode()).equipmentCode(cellEquipContext.getEquipmentCode()).inPartIsEmpty(true).inPartRuleIsEmpty(false).outPartNos(outPartNoList) : null);
// return prodRuleNosortCfgList;
// }
//
// //存在【产出零件数据】信息, 存在【进料零件条码信息】 获取匹配当前产出零件的加工规则数据 (只能查询到一条,否则报错)
// private StepResult doHandleProdRuleDataByProductionPartAndProductSn(StationRequestBean reqBean, StationResultBean resultBean, StepResult stepResult, MesWorkCenter workCenter, MesProductionProcessContext productionProcessContext, MesCellEquipContext cellEquipContext,
// List<MesProdRuleContext> prodRuleContextList, List<MesProductionPartContext> productionPartContextList, List<MesProductionPsInContext> productionPsInContextList, List<String> outPartNoList, Integer foreignKey) {
//
// //【非排序线】获取产品加工规则 ; 分别根据 进料零件有值 与 进料规则不为空 查询 再合并数据返回, 条件携带产出零件
// List<MesProdRuleNosortCfg> prodRuleNosortCfgList = getProdRuleNosortCfgList(reqBean, cellEquipContext, productionPsInContextList, outPartNoList);
// //根据产出零件分组数据
// Map<String, List<MesProdRuleNosortCfg>> prodRuleNosortCfgMap = groupProdRuleNosortCfgList(prodRuleNosortCfgList);
//
// for (MesProductionPartContext productionPartContext : productionPartContextList) {
//
// //foreignKey有值代表已经匹配过产品加工规则
// if (null == productionPartContext || productionPartContext.getIsFinishCode().compareTo(CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue()) == 0 || !StringUtils.isEmpty(productionPartContext.getForeignKey())) continue;
//
// //获取匹配产出零件的所有加工规则
// List<MesProdRuleNosortCfg> outPartNoProdRuleList = !CollectionUtils.isEmpty(prodRuleNosortCfgMap) ? prodRuleNosortCfgMap.get(productionPartContext.getPartNo()) : null;
//
// String productSn = null;
//
// //判断是否还存在待匹配的主条码信息, 内部循环匹配成功会标记 foreignKey
// Optional<MesProductionPsInContext> optional = productionPsInContextList.stream().filter(o -> (null != o && StringUtils.isEmpty(o.getForeignKey()) && o.getIsFinishCode().compareTo(CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue()) == 0)).findFirst();
// if (null == optional || !optional.isPresent()) break;
//
// List<MesProdRuleNosortCfg> innerfilterList = null;
// for (MesProductionPsInContext productionPsInContext : productionPsInContextList) {
//
// //foreignKey有值代表已经匹配过产品加工规则
// if (null == productionPsInContext || productionPartContext.getIsFinishCode().compareTo(CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue()) == 0 || !StringUtils.isEmpty(productionPsInContext.getForeignKey())) continue;
//
// //搜集进料零件号匹配的产品加工规则
// if (!StringUtils.isEmpty(productionPsInContext.getPartNo())) innerfilterList = filterProdRuleNosortCfgList(outPartNoProdRuleList, productionPsInContext.getPartNo());
// //进料零件条码匹配进料零件规则
// else innerfilterList = (List<MesProdRuleNosortCfg>) numberRuleMatchDispatchService.matchNumberRule(reqBean.getOrganizeCode(), productionPsInContext.getProductSn(), filterProdRuleNosortCfgList(outPartNoProdRuleList));
//
// if (CollectionUtils.isEmpty(innerfilterList) || innerfilterList.size() > 1) continue;
//
// if (!StringUtils.isEmpty(productionPsInContext.getPartNo()) && !(Boolean) productionRecordService.checkSnTimeliness(
// reqBean.getOrganizeCode(), productionPsInContext.getProductSn(), innerfilterList.get(0).getId(), MesExtEnumUtil.TIME_DATA_SOURCE.DATA_SOURCE20.getValue(), false).get(MesPcnExtConstWords.RESULT)) {
// if (productionPsInContext.getMessageSource().compareTo(MesExtEnumUtil.CELL_MESSAGE_SOURCE.SCAN.getValue()) == 0) productionPsInContext.busiCheckToDelete();
// else productionPsInContextList.forEach(o -> o.busiCheckToDelete());
// return execNonCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog(), stepResult, String.format("请检查进料主条码信息,进料主条码[%s]时效性验证不通过!", productionPsInContext.getProductSn()));
// }
//
// productionPartContext.foreignKey(productionPsInContext.foreignKey(foreignKey += 1).getForeignKey());
//
// productSn = productionPsInContext.getProductSn();
//
// break;
//
// }
//
// if (CollectionUtils.isEmpty(innerfilterList) || innerfilterList.size() > 1) {
//
// if (productionPsInContext.getMessageSource().compareTo(MesExtEnumUtil.CELL_MESSAGE_SOURCE.SCAN.getValue()) == 0) productionPsInContext.busiCheckToDelete();
// else productionPsInContextList.forEach(o -> o.busiCheckToDelete());
//
// return execNonCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog(), stepResult, String.format(
// "请检查非排序产品加工规则信息,根据设备[%s]产出零件[%s]匹配任意一个主条码%s查询到[%s]条加工规则配置信息,无法显示出装配件清单!", cellEquipContext.getEquipmentCode(), productionPartContext.getPartNo(),
// productionPsInContextList.stream().filter(o -> (null != o && StringUtils.isEmpty(o.getForeignKey()) && o.getIsFinishCode().compareTo(CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue()) == 0)).map(MesProductionPsInContext::getProductSn).collect(Collectors.toList()).toString(),
// CollectionUtils.isEmpty(innerfilterList) ? MesPcnExtConstWords.ZERO : innerfilterList.size()));
//
// }
//
// //【非排序线】获取产品加工规则对应的装配件信息
// prodRuleContextList.add(prodRuleCfgExtService.getProdRuleNosortContext(new MesProdRuleContext(
// reqBean.getOrganizeCode(), reqBean.getWorkCenterCode(), reqBean.getWorkCellCode(), reqBean.getProcessCode(), productionProcessContext.getCraftCode()).
// copy(innerfilterList.get(0)).workOrderNo(productionPartContext.getWorkOrderNo()).productSn(productSn)).foreignKey(productionPartContext.getForeignKey()));
//
// }
//
// return stepResult;
//
// }
//
// //搜集进料零件号匹配的产品加工规则
// private List<MesProdRuleNosortCfg> filterProdRuleNosortCfgList(List<MesProdRuleNosortCfg> prodRuleNosortCfgList, String partNo) {
// return CollectionUtils.isEmpty(prodRuleNosortCfgList) ? null : prodRuleNosortCfgList.stream().filter(o -> (null != o && !StringUtils.isEmpty(o.getInPartNo()) && o.getInPartNo().equals(partNo))).collect(Collectors.toList());
// }
//
// //搜集进料零件规则有值的产品加工规则
// private List<MesProdRuleNosortCfg> filterProdRuleNosortCfgList(List<MesProdRuleNosortCfg> prodRuleNosortCfgList) {
// return CollectionUtils.isEmpty(prodRuleNosortCfgList) ? null : prodRuleNosortCfgList.stream().filter(o -> (null != o && StringUtils.isEmpty(o.getInPartNo()) && !StringUtils.isEmpty(o.getInPartNoRule()))).collect(Collectors.toList());
// }
//
// //根据产出零件分组数据
// private Map<String, List<MesProdRuleNosortCfg>> groupProdRuleNosortCfgList(List<MesProdRuleNosortCfg> prodRuleNosortCfgList) {
// return CollectionUtils.isEmpty(prodRuleNosortCfgList) ? null : prodRuleNosortCfgList.stream().filter(o -> null != o).collect(Collectors.groupingBy(MesProdRuleNosortCfg::getOutPartNo));
// }
//
// //显示装配件信息
// public Boolean showProductionAssembly(StationRequestBean reqBean, StationResultBean resultBean, MesWorkCenter workCenter, MesCellEquipContext cellEquipContext, List<MesProdRuleContext> prodRuleContextList, List<MesProductionPartContext> productionPartContextList) {
//
// Map<Integer, MesProductionPartContext> productionPartMap = productionPartContextList == null ? null : productionPartContextList.stream().filter(o -> null != o && o.getForeignKey() != null).collect(Collectors.toMap(MesProductionPartContext::getForeignKey, o -> o));
//
// for (MesProdRuleContext prodRuleContext : prodRuleContextList) {
//
// if (null == prodRuleContext || StringUtils.isEmpty(prodRuleContext.getAssemblyDataJson())) continue;
//
// String workOrderNo = getWorkOrderNo(productionPartMap, prodRuleContext.getForeignKey());
//
// //封装匹配当前设备的装配件信息
// List<MesAssemblyShowContext> assemblyShowContextList = getAssemblyShowContextList(cellEquipContext, prodRuleContext.getAssemblyDataContext(workCenter), prodRuleContext, workOrderNo);
// if (CollectionUtils.isEmpty(assemblyShowContextList)) continue;
//
// //装配件清单列表标题
// List<AttrBean> attrBeanList = dataAttrList(workOrderNo);
//
// //封装多表格
// resultBean.addStationResultBeans(new StationResultBean().dataType(MesPcnEnumUtil.STATION_DATA_TYPE.TABLE.getValue()).dataAttrList(attrBeanList).resultList(assemblyShowContextList));
//
// }
//
// if (CollectionUtils.isEmpty(resultBean.getStationResultBeans())) return false;
//
// resultBean.busiType(MesPcnEnumUtil.STATION_BUSI_TYPE.STEP_CUSTOM_CONTENT.getValue()).dataType(MesPcnEnumUtil.STATION_DATA_TYPE.TABLES.getValue());
// this.sendMessage(reqBean, resultBean);
//
// return true;
//
// }
//
// private String getWorkOrderNo(Map<Integer, MesProductionPartContext> productionPartMap, Integer foreignKey) {
// return (!CollectionUtils.isEmpty(productionPartMap) && productionPartMap.containsKey(foreignKey)) ? productionPartMap.get(foreignKey).getWorkOrderNo() : null;
// }
//
// //封装匹配当前设备的装配件信息
// private List<MesAssemblyShowContext> getAssemblyShowContextList(MesCellEquipContext cellEquipContext, List<MesProductionAssemblyContext> productionAssemblyContextList, MesProdRuleContext prodRuleContext, String workOrderNo) {
// if (CollectionUtils.isEmpty(productionAssemblyContextList)) return null;
// List<MesAssemblyShowContext> assemblyShowContextList = new ArrayList<>();
// for (MesProductionAssemblyContext item : productionAssemblyContextList) {
// if (null == item) continue;
// assemblyShowContextList.add(assemblyShowContext(item, prodRuleContext, workOrderNo));
// }
//
// 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;
// }
//
// //封装装配件信息
// private MesAssemblyShowContext assemblyShowContext(MesProductionAssemblyContext o, MesProdRuleContext prodRuleContext, String workOrderNo) {
// MesAssemblyShowContext assemblyShowContext = new MesAssemblyShowContext();
// BeanUtils.copyProperties(o, assemblyShowContext);
// assemblyShowContext.setAssemblyStatusName(MesExtEnumUtil.ASSEMBLY_STATUS.valueOfDescription(assemblyShowContext.getAssemblyStatus()));
// if (MesExtEnumUtil.ASSEMBLY_STATUS.ASSEMBLY_STATUS_30.getValue() != assemblyShowContext.getAssemblyStatus())
// assemblyShowContext.setColor(StringUtils.isEmpty(assemblyShowContext.getShowColor()) ? MesExtEnumUtil.COLOR.GREEN.getValue() : assemblyShowContext.getShowColor());
// return assemblyShowContext;
// }
//
// //装配件清单列表标题
// private List<AttrBean> dataAttrList(String workOrderNo) {
// List<AttrBean> attrBeanList = new ArrayList<>();
// PojoAttrUtil.loadPojoAttrs(attrBeanList, MesPcnExtConstWords.INDEX, "序号");
// if (!StringUtils.isEmpty(workOrderNo)) PojoAttrUtil.loadPojoAttrs(attrBeanList, MesPcnExtConstWords.WORK_ORDER_NO, "生产工单编号");
// PojoAttrUtil.loadPojoAttrs(attrBeanList, MesPcnExtConstWords.PART_NO, "零件编码");
// PojoAttrUtil.loadPojoAttrs(attrBeanList, MesPcnExtConstWords.ASSEMBLY_PART_NO, "原料编码");
// PojoAttrUtil.loadPojoAttrs(attrBeanList, MesPcnExtConstWords.ASSEMBLY_PART_NAME, "原料名称");
// PojoAttrUtil.loadPojoAttrs(attrBeanList, MesPcnExtConstWords.ASSEMBLY_SN, "原料条码");
// PojoAttrUtil.loadPojoAttrs(attrBeanList, MesPcnExtConstWords.ASSEMBLY_STATUS_NAME, "装配状态");
// return attrBeanList;
// }
//
// private Boolean doBusiCheckToDelete(StationRequestBean reqBean, List<MesProductionPartContext> productionPartContextList, List<MesProductionPsInContext> productionPsInContextList) {
// if (!CollectionUtils.isEmpty(productionPsInContextList)) productionDispatchContextStepService.saveProductionPsInContext(reqBean,
// productionPsInContextList.stream().filter(o -> (null != o && o.getBusiCheckToDelete().compareTo(CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue()) == 0)).collect(Collectors.toList()));
// else if (!CollectionUtils.isEmpty(productionPartContextList)) productionDispatchContextStepService.saveProductionPartContext(reqBean,
// productionPartContextList.stream().filter(o -> (null != o && o.getBusiCheckToDelete().compareTo(CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue()) == 0)).collect(Collectors.toList()));
// return true;
// }
//
//}

@ -118,8 +118,11 @@ public class MesProductSnScanNosortStepService extends BaseStepService {
//扫描信息为空 并且 判断当前是否必须要扫描
if (StringUtils.isEmpty(scanInfo) && (scanedQty.compareTo(needQty) < 0 || isAllowJump)) execSendGuideAndThrowEx(reqBean, resultBean.writeDbLog(), "请扫描主条码!");
//是否支持混腔扫描[工位参数]
String cavityNosortCfg = fsmCommonService.doHandleFsmWcpcMapDataForDoScan(reqBean).get(MesPcnExtConstWords.CAVITY_NOSORT_CFG);
//封装待验证的主条码信息
if (!scanInfo.equals(productionProcessContext.getFinishCode())) equipVariableCollectContextList = doHandleScanProductSnContext(reqBean, scanInfo, equipVariableCollectContextList);
if (!scanInfo.equals(productionProcessContext.getFinishCode())) equipVariableCollectContextList = doHandleScanProductSnContext(reqBean, scanInfo, equipVariableCollectContextList, cavityNosortCfg);
//验证是否存在重复主条码
if (checkIsExistRepeatScan(productionProcessContext, equipVariableCollectContextList, productionPsInContextList)) return execNonCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog(), stepResult, String.format("当前扫描信息主条码[%s],上下文中存在重复扫描的主条码!", scanInfo));
@ -136,9 +139,6 @@ public class MesProductSnScanNosortStepService extends BaseStepService {
//前期扫描数量已等于腔数
scanedQty = calcScanedQty(equipVariableCollectContextList, productionPsInContextList);
//是否支持混腔扫描[工位参数]
String cavityNosortCfg = fsmCommonService.doHandleFsmWcpcMapDataForDoScan(reqBean).get(MesPcnExtConstWords.CAVITY_NOSORT_CFG);
String scanInfoName = !scanInfo.equals(productionProcessContext.getFinishCode()) ? "主条码" : "空腔码";
if (scanedQty.compareTo(needQty) < 0 && !StringUtils.isEmpty(cavityNosortCfg))
@ -227,11 +227,12 @@ public class MesProductSnScanNosortStepService extends BaseStepService {
}
//封装扫/读信息:主条码信息
private List<MesEquipVariableCollectContext> doHandleScanProductSnContext(StationRequestBean reqBean, String scanInfo, List<MesEquipVariableCollectContext> equipVariableCollectContextList) {
private List<MesEquipVariableCollectContext> doHandleScanProductSnContext(StationRequestBean reqBean, String scanInfo, List<MesEquipVariableCollectContext> equipVariableCollectContextList, String cavityNosortCfg) {
if (CollectionUtils.isEmpty(equipVariableCollectContextList)) equipVariableCollectContextList = new ArrayList<>();
equipVariableCollectContextList.add(new MesEquipVariableCollectContext(reqBean.getOrganizeCode(), scanInfo, TimeTool.getNowTime(true), MesExtEnumUtil.CELL_MESSAGE_SOURCE.SCAN.getValue()));
equipVariableCollectContextList.add(new MesEquipVariableCollectContext(reqBean.getOrganizeCode(), scanInfo, TimeTool.getNowTime(true),
StringUtils.isEmpty(cavityNosortCfg) ? MesExtEnumUtil.CELL_MESSAGE_SOURCE.SCAN.getValue() : MesExtEnumUtil.CELL_MESSAGE_SOURCE.MANY.getValue()));
return equipVariableCollectContextList;

@ -46,6 +46,9 @@ public class MesAssemblyShowContext implements Serializable {
@ApiParam("装配零件状态")
private String assemblyStatusName;
@ApiParam("装配件条码确认方式")
private String matchTypeName;
@ApiParam("序号")
private Integer index;

@ -13,6 +13,9 @@ public class MesProductionAssemblyContext implements Serializable {
private static final long serialVersionUID = 2382117884422723639L;
@ApiParam("生产工单号")
private String workOrderNo;
@ApiParam("装配件零件编码")
public String assemblyPartNo;

@ -91,6 +91,10 @@ public class MesPcnExtConstWords {
public static final String ASSEMBLY_STATUS = "assemblyStatus";
// 装配件绑定状态
public static final String ASSEMBLY_STATUS_NAME = "assemblyStatusName";
// 装配件确认方式
public static final String MATCH_TYPE = "matchType";
// 装配件确认方式
public static final String MATCH_TYPE_NAME = "matchTypeName";
// 装配件零件编码
public static final String ASSEMBLY_PART_NO = "assemblyPartNo";
// 装配件零件名称

Loading…
Cancel
Save