|
|
|
@ -6,10 +6,12 @@ import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesProductionProcessContextStepServ
|
|
|
|
|
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesProductionRecordService;
|
|
|
|
|
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.actor.shipping.dispatch.IFsmCommonService;
|
|
|
|
|
import cn.estsh.i3plus.mes.pcn.serviceimpl.fsm.BaseStepService;
|
|
|
|
|
import cn.estsh.i3plus.mes.pcn.serviceimpl.fsm.IStepService;
|
|
|
|
|
import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
|
|
|
|
|
import cn.estsh.i3plus.pojo.base.enumutil.MesPcnEnumUtil;
|
|
|
|
|
import cn.estsh.i3plus.pojo.mes.bean.MesWorkCell;
|
|
|
|
|
import cn.estsh.i3plus.pojo.mes.model.StationRequestBean;
|
|
|
|
|
import cn.estsh.i3plus.pojo.mes.model.StationResultBean;
|
|
|
|
|
import cn.estsh.i3plus.pojo.mes.model.StepResult;
|
|
|
|
@ -50,6 +52,9 @@ public class MesAssemblyMatchNosortStepService extends BaseStepService {
|
|
|
|
|
@Autowired
|
|
|
|
|
private IMesProductionRecordService productionRecordService;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private IFsmCommonService fsmCommonService;
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public StepResult execute(StationRequestBean reqBean) {
|
|
|
|
|
|
|
|
|
@ -114,11 +119,13 @@ 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);
|
|
|
|
|
//匹配成功 【result=true 代表单次扫描匹配成功; hasUnBindAssembly=false 代表浑腔模式全部匹配成功】
|
|
|
|
|
if (result || !hasUnBindAssembly) {
|
|
|
|
|
productionDispatchContextStepService.saveProdRuleDataContext(reqBean, prodRuleContextList);
|
|
|
|
|
assemblyShowNosortStepService.showProductionAssembly(reqBean, resultBean, productionProcessContext.getWorkCenter(), cellEquipContext, prodRuleContextList);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//全部匹配完毕,存在进料的时候直接调用 生成零件条码工步
|
|
|
|
|
//全部匹配完毕,存在进料且进料数量满足腔数的时候直接调用 生成零件条码工步
|
|
|
|
|
if (!hasUnBindAssembly && !CollectionUtils.isEmpty(productionPsInContextList) && productionPsInContextList.size() >= needQty) ((IStepService) SpringContextsUtil.getBean("mesProductSnGenerateStepService")).execute(reqBean);
|
|
|
|
|
|
|
|
|
|
//没有待绑定数据, 验证当前是否满足腔数 没有进料主条码代码当前加工规则已经全部加载, 有的话需要判断是否全部扫完 没有扫完需要返回false继续扫描主条码
|
|
|
|
@ -131,11 +138,44 @@ public class MesAssemblyMatchNosortStepService extends BaseStepService {
|
|
|
|
|
if (result) return execDynamicsCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog().scanInfo(assemblySn),
|
|
|
|
|
stepResult.nextTriggerEvent(MesPcnExtConstWords.NEXT_TRIGGER_EVENT_ASSEMBLY), false, MesPcnEnumUtil.STATION_BUSI_TYPE.MESSAGE, MesPcnEnumUtil.STATION_DATA_TYPE.TEXT, isSkip ? stepResult.getMsg() : String.format("上下文中的装配件条码%s匹配成功!", assemblySn));
|
|
|
|
|
|
|
|
|
|
//匹配失败验证是否重置装配件扫描项
|
|
|
|
|
MesWorkCell workCell = productionProcessContext.getWorkCell();
|
|
|
|
|
if (!StringUtils.isEmpty(workCell.getIsResetScan()) && workCell.getIsResetScan().compareTo(CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue()) == 0) {
|
|
|
|
|
productionDispatchContextStepService.saveProdRuleDataContext(reqBean, resetAssembly(reqBean, prodRuleContextList));
|
|
|
|
|
assemblyShowNosortStepService.showProductionAssembly(reqBean, resultBean, productionProcessContext.getWorkCenter(), cellEquipContext, prodRuleContextList);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return execNonCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog().scanInfo(assemblySn),
|
|
|
|
|
stepResult.nextTriggerEvent(MesPcnExtConstWords.NEXT_TRIGGER_EVENT_ASSEMBLY), String.format("上下文中的装配件条码%s匹配失败!%s", assemblySn, StringUtils.isEmpty(stepResult.getMsg()) ? MesPcnExtConstWords.EMPTY : stepResult.getMsg()));
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private List<MesProdRuleContext> resetAssembly(StationRequestBean reqBean, List<MesProdRuleContext> prodRuleContextList) {
|
|
|
|
|
|
|
|
|
|
//是否支持混腔扫描[工位参数]
|
|
|
|
|
String cavityNosortCfg = fsmCommonService.doHandleFsmWcpcMapDataForDoScan(reqBean).get(MesPcnExtConstWords.CAVITY_NOSORT_CFG);
|
|
|
|
|
|
|
|
|
|
prodRuleContextList.forEach(o -> {
|
|
|
|
|
|
|
|
|
|
if (!StringUtils.isEmpty(o.getAssemblyDataJson())) {
|
|
|
|
|
|
|
|
|
|
List<MesProductionAssemblyNosortContext> productionAssemblyNosortContextList = o.getNosortAssemblyDataContext();
|
|
|
|
|
|
|
|
|
|
if (!StringUtils.isEmpty(cavityNosortCfg) || hasUnBindAssemblyOptional(productionAssemblyNosortContextList)) {
|
|
|
|
|
|
|
|
|
|
productionAssemblyNosortContextList.forEach(i -> { if (i.getIsResetScan().compareTo(CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue()) == 0) i.assemblyStatusReset(); });
|
|
|
|
|
|
|
|
|
|
o.assemblyDataJson(productionAssemblyNosortContextList);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return prodRuleContextList;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//验证当前是否属于装配件跳过码
|
|
|
|
|
private Boolean checkIsSkip(MesProductionProcessContext productionProcessContext, List<MesEquipVariableCollectContext> equipVariableCollectContextList) {
|
|
|
|
|
if (equipVariableCollectContextList.size() > 1) return false;
|
|
|
|
@ -156,19 +196,21 @@ public class MesAssemblyMatchNosortStepService extends BaseStepService {
|
|
|
|
|
for (MesProdRuleContext prodRuleContext : prodRuleContextList) {
|
|
|
|
|
if (null == prodRuleContext || StringUtils.isEmpty(prodRuleContext.getAssemblyDataJson())) continue;
|
|
|
|
|
List<MesProductionAssemblyNosortContext> productionAssemblyNosortContextList = prodRuleContext.getNosortAssemblyDataContext();
|
|
|
|
|
Optional<MesProductionAssemblyNosortContext> optional = productionAssemblyNosortContextList.stream().filter(o -> (null != o && o.getAssemblyStatus().compareTo(MesExtEnumUtil.ASSEMBLY_STATUS.ASSEMBLY_STATUS_30.getValue()) == 0)).findFirst();
|
|
|
|
|
if (null == optional || !optional.isPresent()) continue;
|
|
|
|
|
if (!hasUnBindAssemblyOptional(productionAssemblyNosortContextList)) continue;
|
|
|
|
|
hasUnBindAssembly = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
return hasUnBindAssembly;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private Boolean hasUnBindAssemblyOptional(List<MesProductionAssemblyNosortContext> productionAssemblyNosortContextList) {
|
|
|
|
|
Optional<MesProductionAssemblyNosortContext> optional = productionAssemblyNosortContextList.stream().filter(o -> (null != o && o.getAssemblyStatus().compareTo(MesExtEnumUtil.ASSEMBLY_STATUS.ASSEMBLY_STATUS_30.getValue()) == 0)).findFirst();
|
|
|
|
|
return (null == optional || !optional.isPresent()) ? false : true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//处理待验证的装配件条码 [扫描模式匹配成功返回true, 否则返回flase, 非扫描模式需要验证是否全部匹配完成]
|
|
|
|
|
private Boolean doHandleMatchAssembly(StationRequestBean reqBean, StationResultBean resultBean, StepResult stepResult, List<MesProdRuleContext> prodRuleContextList, List<MesEquipVariableCollectContext> equipVariableCollectContextList, Boolean isSkip) {
|
|
|
|
|
|
|
|
|
|
Boolean flag = false;
|
|
|
|
|
|
|
|
|
|
//遍历产品加工规则
|
|
|
|
|
for (MesProdRuleContext prodRuleContext : prodRuleContextList) {
|
|
|
|
|
|
|
|
|
@ -178,6 +220,8 @@ public class MesAssemblyMatchNosortStepService extends BaseStepService {
|
|
|
|
|
//获取非排序装配件清单
|
|
|
|
|
List<MesProductionAssemblyNosortContext> productionAssemblyNosortContextList = prodRuleContext.getNosortAssemblyDataContext();
|
|
|
|
|
|
|
|
|
|
Boolean flag = false;
|
|
|
|
|
|
|
|
|
|
//遍历装配件清单
|
|
|
|
|
LOOP:
|
|
|
|
|
for (MesProductionAssemblyNosortContext productionAssemblyNosortContext : productionAssemblyNosortContextList) {
|
|
|
|
@ -239,7 +283,7 @@ public class MesAssemblyMatchNosortStepService extends BaseStepService {
|
|
|
|
|
flag = true;
|
|
|
|
|
|
|
|
|
|
//装配件清单该数据标记已装配 (如果是自制件赋值productSnId)
|
|
|
|
|
productionAssemblyNosortContext.assemblyStatus().assemblySn(equipVariableCollectContext.getEquipVariableValue()).productSnId(filterList.get(0).getProductSnId());
|
|
|
|
|
productionAssemblyNosortContext.assemblyStatus(equipVariableCollectContext.getEquipVariableValue()).productSnId(filterList.get(0).getProductSnId());
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -256,7 +300,7 @@ public class MesAssemblyMatchNosortStepService extends BaseStepService {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return flag;
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|