tags/yfai-pcn-ext-v1.0
gsz 11 months ago
commit d53b160e64

@ -22,10 +22,10 @@ public interface IMesAssemblyExtService {
List<MesProductionAssembly> getProductionAssemblyList(String organizeCode, Integer dataSource, List<Long> sourceIdList); List<MesProductionAssembly> getProductionAssemblyList(String organizeCode, Integer dataSource, List<Long> sourceIdList);
@ApiOperation(value = "获取非排序装配件配置信息") @ApiOperation(value = "获取非排序装配件配置信息")
List<MesProductionAssemblyNosortContext> getProductionAssemblyNosortContextList(String organizeCode, Long... pids); List<MesProductionAssemblyNosortContext> getProductionAssemblyNosortContextList(MesProdRuleContext prodRuleContext);
@ApiOperation(value = "获取非排序装配件配置信息") @ApiOperation(value = "获取非排序装配件配置信息")
List<MesAssemblyNosortCfg> getAssemblyNosortCfgList(String organizeCode, Long... pids); List<MesAssemblyNosortCfg> getAssemblyNosortCfgList(String organizeCode, Long pid);
} }

@ -15,7 +15,7 @@ public interface IMesProdRuleCfgExtService {
List<MesProdRuleNosortCfg> getProdRuleNosortCfgList(MesProdRuleContext... prodRuleContext); List<MesProdRuleNosortCfg> getProdRuleNosortCfgList(MesProdRuleContext... prodRuleContext);
@ApiOperation(value = "【非排序线】获取产品加工规则对应的装配件信息") @ApiOperation(value = "【非排序线】获取产品加工规则对应的装配件信息")
MesProdRuleContext getProdRuleContext(MesProdRuleNosortCfg prodRuleNosortCfg, Integer foreignKey); MesProdRuleContext getProdRuleContext(MesProdRuleContext prodRuleContext);
@ApiOperation(value = "【排序线】获取产品加工规则(条码对应的装配件绑定记录,目前条码等同工单)") @ApiOperation(value = "【排序线】获取产品加工规则(条码对应的装配件绑定记录,目前条码等同工单)")
MesProdRuleContext getProdRuleSortContext(MesProdRuleContext prodRuleContext); MesProdRuleContext getProdRuleSortContext(MesProdRuleContext prodRuleContext);

@ -58,7 +58,7 @@ public class MesAssemblyExtService implements IMesAssemblyExtService {
List<MesProductionAssemblySortContext> productionAssemblySortContextList = new ArrayList<>(); List<MesProductionAssemblySortContext> productionAssemblySortContextList = new ArrayList<>();
workOrderAssemblyList.forEach(o -> productionAssemblySortContextList.add(new MesProductionAssemblySortContext(o, getProductionAssembly(productionAssemblyMap, o.getId())))); workOrderAssemblyList.forEach(o -> productionAssemblySortContextList.add(new MesProductionAssemblySortContext().copy(o, getProductionAssembly(productionAssemblyMap, o.getId()))));
return productionAssemblySortContextList; return productionAssemblySortContextList;
} }
@ -99,22 +99,18 @@ public class MesAssemblyExtService implements IMesAssemblyExtService {
//获取非排序装配件配置信息 //获取非排序装配件配置信息
@Override @Override
public List<MesProductionAssemblyNosortContext> getProductionAssemblyNosortContextList(String organizeCode, Long... pids) { public List<MesProductionAssemblyNosortContext> getProductionAssemblyNosortContextList(MesProdRuleContext prodRuleContext) {
if (StringUtils.isEmpty(organizeCode) || null == pids) return null; if (null == prodRuleContext || StringUtils.isEmpty(prodRuleContext.getOrganizeCode()) || StringUtils.isEmpty(prodRuleContext.getPid())) return null;
//获取非排序装配件配置信息 //获取非排序装配件配置信息
List<MesAssemblyNosortCfg> assemblyNosortCfgList = getAssemblyNosortCfgList(organizeCode, pids); List<MesAssemblyNosortCfg> assemblyNosortCfgList = getAssemblyNosortCfgList(prodRuleContext.getOrganizeCode(), prodRuleContext.getPid());
if (CollectionUtils.isEmpty(assemblyNosortCfgList)) return null; if (CollectionUtils.isEmpty(assemblyNosortCfgList)) return null;
//获取装配件绑定记录
Map<Long, MesProductionAssembly> productionAssemblyMap = groupProductionAssembly(filterProductionAssemblyList(getProductionAssemblyList(
organizeCode, MesExtEnumUtil.PRODUCTION_ASSEMBLY_DATA_SOURCE.NOSORT.getValue(), assemblyNosortCfgList.stream().filter(o -> null != o).map(MesAssemblyNosortCfg::getId).collect(Collectors.toList()))));
List<MesProductionAssemblyNosortContext> productionAssemblyNosortContextList = new ArrayList<>(); List<MesProductionAssemblyNosortContext> productionAssemblyNosortContextList = new ArrayList<>();
assemblyNosortCfgList.forEach(o -> productionAssemblyNosortContextList.add(new MesProductionAssemblyNosortContext(o, getProductionAssembly(productionAssemblyMap, o.getId())))); assemblyNosortCfgList.forEach(o -> productionAssemblyNosortContextList.add(new MesProductionAssemblyNosortContext().copy(o, prodRuleContext)));
return productionAssemblyNosortContextList; return productionAssemblyNosortContextList;
@ -122,11 +118,10 @@ public class MesAssemblyExtService implements IMesAssemblyExtService {
//获取非排序装配件配置信息 //获取非排序装配件配置信息
@Override @Override
public List<MesAssemblyNosortCfg> getAssemblyNosortCfgList(String organizeCode, Long... pids) { public List<MesAssemblyNosortCfg> getAssemblyNosortCfgList(String organizeCode, Long pid) {
if (StringUtils.isEmpty(organizeCode) || null == pids) return null; if (StringUtils.isEmpty(organizeCode) || StringUtils.isEmpty(pid)) return null;
DdlPackBean packBean = DdlPackBean.getDdlPackBean(organizeCode); DdlPackBean packBean = DdlPackBean.getDdlPackBean(organizeCode);
if (pids.length == 1) DdlPreparedPack.getNumEqualPack(pids[0], MesPcnExtConstWords.PID, packBean); DdlPreparedPack.getNumEqualPack(pid, MesPcnExtConstWords.PID, packBean);
else DdlPreparedPack.getInPackArray(pids, MesPcnExtConstWords.PID, packBean);
return assemblyNosortCfgRepository.findByHqlWhere(packBean); return assemblyNosortCfgRepository.findByHqlWhere(packBean);
} }

@ -73,11 +73,9 @@ public class MesProdRuleCfgExtService implements IMesProdRuleCfgExtService {
//【非排序线】获取产品加工规则对应的装配件信息 //【非排序线】获取产品加工规则对应的装配件信息
@Override @Override
public MesProdRuleContext getProdRuleContext(MesProdRuleNosortCfg prodRuleNosortCfg, Integer foreignKey) { public MesProdRuleContext getProdRuleContext(MesProdRuleContext prodRuleContext) {
MesProdRuleContext prodRuleContext = new MesProdRuleContext().foreignKey(foreignKey).pid(prodRuleNosortCfg.getId());
BeanUtils.copyProperties(prodRuleNosortCfg, prodRuleContext);
//获取非排序装配件配置信息 //获取非排序装配件配置信息
if (CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue() == prodRuleContext.getIsHasBind()) prodRuleContext.assemblyDataJson(assemblyExtService.getProductionAssemblyNosortContextList(prodRuleContext.getOrganizeCode(), prodRuleContext.getPid())); if (CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue() == prodRuleContext.getIsHasBind()) prodRuleContext.assemblyDataJson(assemblyExtService.getProductionAssemblyNosortContextList(prodRuleContext));
return prodRuleContext; return prodRuleContext;
} }

@ -3,6 +3,7 @@ package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.rulematch;
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesNumberRuleMatchDispatchService; import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesNumberRuleMatchDispatchService;
import com.google.common.base.Objects; import com.google.common.base.Objects;
import jdk.nashorn.internal.runtime.regexp.joni.Regex; import jdk.nashorn.internal.runtime.regexp.joni.Regex;
import jodd.util.StringUtil;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
@ -22,11 +23,8 @@ public class MesNumberRuleMatchRegularExpressionService implements IMesNumberRul
String matchRule = params[1].toString(); String matchRule = params[1].toString();
if (sn.matches(matchRule)){ return match(matchRule, sn);
return true;
}
return false;
} }
private boolean match(String ruleStr, String barCode) { private boolean match(String ruleStr, String barCode) {
@ -52,10 +50,31 @@ public class MesNumberRuleMatchRegularExpressionService implements IMesNumberRul
Matcher matcher = regex.matcher(rule); Matcher matcher = regex.matcher(rule);
return matcher.matches(); return matcher.matches();
} }
String ruleNoSpecialChar = transfer(rule);
String barcodeNoSpecialChar = transfer(barCode);
///将规则转换为正则表达式,使用正则表达式进行匹配,正则中去除二维码的起始特殊符号
//update by huxj 2020.04.07 添加二维码前缀正则匹配
String regStr = "^" + ruleNoSpecialChar.toLowerCase().replace(")", "\\)").replace("?", "(?:.|\n){1}").replace("*", "(?:.|-\n)*").replace("[", "\\[") + "$";
//Regex rgx = new Regex("^" + ruleNoSpecialChar.ToLower().Replace("?", @"(?:.|\n){1}").Replace("*", @"(?:.|\n)*") + "$");
Pattern regex = Pattern.compile(regStr);
//end update
if (regex.matcher(barcodeNoSpecialChar.toLowerCase()).matches()) return true;
if (rule == barCode) return true;
} }
return false; return false;
} }
public String transfer(String str){
// 1. 定义正则表达式,匹配特殊字符
String regex = "[^a-zA-Z0-9^\\s^*?[)>.:^/]]";
// 2. 使用正则表达式替换特殊字符为空字符串
return str.replaceAll(regex, "");
}
public static void main(String[] args) { public static void main(String[] args) {
String sn = "1574110000123"; String sn = "1574110000123";
String matchRule = "1574110000*"; String matchRule = "1574110000*";

@ -0,0 +1,195 @@
package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.step;
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesNumberRuleMatchDispatchService;
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesProdRuleCfgExtService;
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesProductionDispatchContextStepService;
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesProductionProcessContextStepService;
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.pojo.base.enumutil.CommonEnumUtil;
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.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
/**
* @Description :
* @Author : wangjie
**/
@Slf4j
@Service("mesAssemblyMatchNosortStepService")
public class MesAssemblyMatchNosortStepService extends BaseStepService {
@Autowired
private IFsmCommonService fsmCommonService;
@Autowired
private IMesProductionProcessContextStepService productionProcessContextStepService;
@Autowired
private IMesProductionDispatchContextStepService productionDispatchContextStepService;
@Autowired
private IMesProdRuleCfgExtService prodRuleCfgExtService;
@Autowired
private IMesNumberRuleMatchDispatchService numberRuleMatchDispatchService;
@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);
//从上下文中取出生产线对象
MesCellEquipContext cellEquipContext = productionProcessContext.getCurCellEquip();
//获取上下文产出零件数据信息集合
List<MesProductionPartContext> productionPartContextList = productionDispatchContextStepService.getProductionPartContext(reqBean);
//获取上下文进料零件条码信息集合
List<MesProductionPsInContext> productionPsInContextList = productionDispatchContextStepService.getProductionPsInContext(reqBean);
//获取上下文产品加工规则数据信息集合
List<MesProdRuleContext> prodRuleContextList = productionDispatchContextStepService.getProdRuleDataContext(reqBean);
//获取上下文生产扫/读信息:装配件条码
List<MesEquipVariableCollectContext> equipVariableCollectContextList = productionDispatchContextStepService.getScanAssemblySnContext(reqBean);
//删除上下文扫/读信息:装配件条码
if (!CollectionUtils.isEmpty(equipVariableCollectContextList)) productionDispatchContextStepService.deleteScanAssemblySnContext(reqBean);
//计算实际需要的加工规则个数
Integer needProdRuleContextSize = calcNeedProdRuleContextSize(productionPartContextList, productionPsInContextList, cellEquipContext);
//未知腔数[工位参数]
String cavityUnknownCfg = fsmCommonService.doHandleFsmWcpcMapDataForDoScan(reqBean).get(MesPcnExtConstWords.CAVITY_UNKNOWN_CFG);
if (!CollectionUtils.isEmpty(productionPartContextList) && !CollectionUtils.isEmpty(productionPsInContextList)) //存在产出零件 存在进料主条码
doMatchAssemblyHasPpAndPs(reqBean, resultBean, stepResult, productionProcessContext, cellEquipContext, productionPartContextList, productionPsInContextList, prodRuleContextList, equipVariableCollectContextList, needProdRuleContextSize);
else if (!CollectionUtils.isEmpty(productionPartContextList)) //存在产出零件 不存在进料主条码
doMatchAssemblyHasPp(reqBean, resultBean, stepResult, productionProcessContext, cellEquipContext, productionPartContextList, prodRuleContextList, equipVariableCollectContextList, needProdRuleContextSize);
else if (!CollectionUtils.isEmpty(productionPsInContextList)) //不存在产出零件 存在进料主条码
doMatchAssemblyHasPs(reqBean, resultBean, stepResult, productionProcessContext, cellEquipContext, productionPsInContextList, prodRuleContextList, equipVariableCollectContextList, needProdRuleContextSize);
else if (StringUtils.isEmpty(cavityUnknownCfg)) //不存在产出零件 不存在进料主条码 根据设备腔数反向匹配加工规则
doMatchAssemblyHasCavity(reqBean, resultBean, stepResult, productionProcessContext, cellEquipContext, prodRuleContextList, equipVariableCollectContextList, needProdRuleContextSize);
else //不存在产出零件 不存在进料主条码 未知腔数 反向完成匹配后获取对应的加工规则
doMatchAssemblyUnknowCavity(reqBean, resultBean, stepResult, productionProcessContext, cellEquipContext, prodRuleContextList, equipVariableCollectContextList);
return stepResult;
}
//计算实际需要的加工规则个数
private Integer calcNeedProdRuleContextSize(List<MesProductionPartContext> productionPartContextList, List<MesProductionPsInContext> productionPsInContextList, MesCellEquipContext cellEquipContext) {
List<MesProductionPartContext> ppList = CollectionUtils.isEmpty(productionPartContextList) ? null :
productionPartContextList.stream().filter(o -> (null != o && o.getIsFinishCode().compareTo(CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue()) == 0)).collect(Collectors.toList());
List<MesProductionPsInContext> ppiList = CollectionUtils.isEmpty(productionPsInContextList) ? null :
productionPsInContextList.stream().filter(o -> (null != o && o.getIsFinishCode().compareTo(CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue()) == 0)).collect(Collectors.toList());
if (!CollectionUtils.isEmpty(ppList)) return ppList.size();
if (!CollectionUtils.isEmpty(ppiList)) return ppiList.size();
return cellEquipContext.getCavity();
}
//存在产出零件 存在进料主条码
private StepResult doMatchAssemblyHasPpAndPs(StationRequestBean reqBean, StationResultBean resultBean, StepResult stepResult, MesProductionProcessContext productionProcessContext, MesCellEquipContext cellEquipContext, List<MesProductionPartContext> productionPartContextList, List<MesProductionPsInContext> productionPsInContextList, List<MesProdRuleContext> prodRuleContextList, List<MesEquipVariableCollectContext> equipVariableCollectContextList, Integer needProdRuleContextSize) {
if (CollectionUtils.isEmpty(prodRuleContextList)) execExpSendMsgAndThrowEx(reqBean, resultBean.writeDbLog(), "当前上下文中不存在非排序加工规则数据,请重置工序!");
//存在产出零件 存在进料主条码 不存在待验证装配件条码
if (CollectionUtils.isEmpty(equipVariableCollectContextList)) return doMatchAssemblyHasPpAndPs(reqBean, resultBean, stepResult, productionProcessContext, cellEquipContext, productionPartContextList, productionPsInContextList, prodRuleContextList, needProdRuleContextSize);
return stepResult;
}
//存在产出零件 存在进料主条码 不存在待验证装配件条码
private StepResult doMatchAssemblyHasPpAndPs(StationRequestBean reqBean, StationResultBean resultBean, StepResult stepResult, MesProductionProcessContext productionProcessContext, MesCellEquipContext cellEquipContext, List<MesProductionPartContext> productionPartContextList, List<MesProductionPsInContext> productionPsInContextList, List<MesProdRuleContext> prodRuleContextList, Integer needProdRuleContextSize) {
Boolean hasUnBindAssembly = false;
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;
hasUnBindAssembly = true;
break;
}
return hasUnBindAssembly ? stepResult.isCompleted(false).nextTriggerEvent(MesPcnExtConstWords.NEXT_TRIGGER_EVENT_ASSEMBLY).msg("当前上下文中不存在待验证的装配件条码,但存在未装配的装配件清单!") :
(needProdRuleContextSize.compareTo(prodRuleContextList.size()) != 0 ? stepResult.isCompleted(false).nextTriggerEvent(MesPcnExtConstWords.NEXT_TRIGGER_EVENT_ASSEMBLY).msg("当前上下文中不存在待验证的装配件条码,当前上下文中的主条码数量未满足腔数!请扫描第") : stepResult);
}
//存在产出零件 不存在进料主条码
private void doMatchAssemblyHasPp(StationRequestBean reqBean, StationResultBean resultBean, StepResult stepResult, MesProductionProcessContext productionProcessContext, MesCellEquipContext cellEquipContext, List<MesProductionPartContext> productionPartContextList, List<MesProdRuleContext> prodRuleContextList, List<MesEquipVariableCollectContext> equipVariableCollectContextList, Integer needProdRuleContextSize) {
}
//不存在产出零件 存在进料主条码
private void doMatchAssemblyHasPs(StationRequestBean reqBean, StationResultBean resultBean, StepResult stepResult, MesProductionProcessContext productionProcessContext, MesCellEquipContext cellEquipContext, List<MesProductionPsInContext> productionPsInContextList, List<MesProdRuleContext> prodRuleContextList, List<MesEquipVariableCollectContext> equipVariableCollectContextList, Integer needProdRuleContextSize) {
}
//不存在产出零件 不存在进料主条码 根据设备腔数反向匹配加工规则
private void doMatchAssemblyHasCavity(StationRequestBean reqBean, StationResultBean resultBean, StepResult stepResult, MesProductionProcessContext productionProcessContext, MesCellEquipContext cellEquipContext, List<MesProdRuleContext> prodRuleContextList, List<MesEquipVariableCollectContext> equipVariableCollectContextList, Integer needProdRuleContextSize) {
}
//不存在产出零件 不存在进料主条码 未知腔数 反向完成匹配后获取对应的加工规则
private void doMatchAssemblyUnknowCavity(StationRequestBean reqBean, StationResultBean resultBean, StepResult stepResult, MesProductionProcessContext productionProcessContext, MesCellEquipContext cellEquipContext, List<MesProdRuleContext> prodRuleContextList, List<MesEquipVariableCollectContext> equipVariableCollectContextList) {
}
}

@ -0,0 +1,63 @@
package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.step;
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesProductionProcessContextStepService;
import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesProductionProcessContext;
import cn.estsh.i3plus.mes.pcn.serviceimpl.fsm.BaseStepService;
import cn.estsh.i3plus.mes.pcn.serviceimpl.fsm.IStepService;
import cn.estsh.i3plus.pojo.mes.bean.MesWorkCenter;
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 cn.estsh.impp.framework.boot.util.SpringContextsUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* @Description :
* @Author : wangjie
**/
@Slf4j
@Service("mesAssemblyMatchStepService")
public class MesAssemblyMatchStepService extends BaseStepService {
@Autowired
private IMesProductionProcessContextStepService productionProcessContextStepService;
@Override
public StepResult init(StationRequestBean reqBean) {
//显示装配件扫描项工步
return ((IStepService) SpringContextsUtil.getBean("mesAssemblyShowStepService")).execute(reqBean);
}
@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();
//排序线 装配件匹配工步
if (MesExtEnumUtil.WORK_CENTER_TYPE.SORT.getValue() == workCenter.getCenterType()) return stepResult;
//非排序线 装配件匹配工步
return ((IStepService) SpringContextsUtil.getBean("mesAssemblyMatchNosortStepService")).execute(reqBean);
}
}

@ -2,10 +2,7 @@ package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.step;
import cn.estsh.i3plus.ext.mes.pcn.api.base.IMesMouldMultiCavityService; import cn.estsh.i3plus.ext.mes.pcn.api.base.IMesMouldMultiCavityService;
import cn.estsh.i3plus.ext.mes.pcn.api.busi.*; import cn.estsh.i3plus.ext.mes.pcn.api.busi.*;
import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesCellEquipContext; import cn.estsh.i3plus.ext.mes.pcn.pojo.context.*;
import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesEquipLogDispatchContext;
import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesEquipVariableCollectContext;
import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesProductionProcessContext;
import cn.estsh.i3plus.ext.mes.pcn.pojo.util.MesPcnExtConstWords; 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.serviceimpl.fsm.BaseStepService;
import cn.estsh.i3plus.pojo.base.enumutil.MesPcnEnumUtil; import cn.estsh.i3plus.pojo.base.enumutil.MesPcnEnumUtil;
@ -21,6 +18,7 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -76,9 +74,18 @@ public class MesAssemblyReadStepService extends BaseStepService {
//获取上下文信息 //获取上下文信息
MesProductionProcessContext productionProcessContext = productionProcessContextStepService.getCurCellEquipment(reqBean, stepParamMap); MesProductionProcessContext productionProcessContext = productionProcessContextStepService.getCurCellEquipment(reqBean, stepParamMap);
//配置错误 抛出异常
if (!productionProcessContext.getSuccess()) execExpSendMsgAndThrowEx(reqBean, resultBean.writeDbLog(), productionProcessContext.getMessage());
//当前工序已存在读取待验证的装配件条码 //当前工序已存在读取待验证的装配件条码
if (productionDispatchContextStepService.checkScanAssemblySnIsExistContext(reqBean)) return stepResult; if (productionDispatchContextStepService.checkScanAssemblySnIsExistContext(reqBean)) return stepResult;
//当前工位使用的设备
MesCellEquipContext cellEquipContext = productionProcessContext.getCurCellEquip();
//验证当前是否需要读装配件条码
if (!checkIsNeedReedAssembly(reqBean)) return execSuccessCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog(), stepResult, String.format("当前上下文中的加工规则未配置装配件扫描项,无需读设备[%s]装配件条码!", cellEquipContext.getEquipmentCode()));
//获取生产过程上下文对象有异常信息 抛出异常 //获取生产过程上下文对象有异常信息 抛出异常
if (!productionProcessContextStepService.getEquipmentVariableCfgList(productionProcessContext).getSuccess()) execExpSendMsgAndThrowEx(reqBean, resultBean.writeDbLog(), productionProcessContext.getMessage()); if (!productionProcessContextStepService.getEquipmentVariableCfgList(productionProcessContext).getSuccess()) execExpSendMsgAndThrowEx(reqBean, resultBean.writeDbLog(), productionProcessContext.getMessage());
@ -88,9 +95,6 @@ public class MesAssemblyReadStepService extends BaseStepService {
//根据变量类别[装配件]搜集设备数据变量接口逻辑信息 //根据变量类别[装配件]搜集设备数据变量接口逻辑信息
equipmentVariableCfgList = productionProcessContextStepService.collectEquipmentVariableCfgList(equipmentVariableCfgList, MesExtEnumUtil.EQUIP_VARIABLE_CFG_CATEGORY.ASSEMBLY.getValue()); equipmentVariableCfgList = productionProcessContextStepService.collectEquipmentVariableCfgList(equipmentVariableCfgList, MesExtEnumUtil.EQUIP_VARIABLE_CFG_CATEGORY.ASSEMBLY.getValue());
//当前工位使用的设备
MesCellEquipContext cellEquipContext = productionProcessContext.getCurCellEquip();
//配置错误 抛出异常 //配置错误 抛出异常
if (!productionProcessContextStepService.checkNecessaryEquipmentVariableCfg(productionProcessContext, cellEquipContext, equipmentVariableCfgList, MesExtEnumUtil.EQUIP_VARIABLE_CFG_CATEGORY.ASSEMBLY.getValue()).getSuccess()) if (!productionProcessContextStepService.checkNecessaryEquipmentVariableCfg(productionProcessContext, cellEquipContext, equipmentVariableCfgList, MesExtEnumUtil.EQUIP_VARIABLE_CFG_CATEGORY.ASSEMBLY.getValue()).getSuccess())
execExpSendMsgAndThrowEx(reqBean, resultBean.writeDbLog(), productionProcessContext.getMessage()); execExpSendMsgAndThrowEx(reqBean, resultBean.writeDbLog(), productionProcessContext.getMessage());
@ -123,6 +127,22 @@ public class MesAssemblyReadStepService extends BaseStepService {
} }
private Boolean checkIsNeedReedAssembly(StationRequestBean reqBean) {
//获取上下文产品加工规则数据信息集合
List<MesProdRuleContext> prodRuleContextList = productionDispatchContextStepService.getProdRuleDataContext(reqBean);
//没有加工规则代表需要反向匹配出加工规则, 需要直接读取
if (CollectionUtils.isEmpty(prodRuleContextList)) return true;
//判断加工规则中是否存在还有装配件的数据
Optional<MesProdRuleContext> optional = prodRuleContextList.stream().filter(o -> (null != o && !StringUtils.isEmpty(o.getAssemblyDataJson()))).findFirst();
//不存在返回fasle不用读取
return (null == optional || !optional.isPresent()) ? false : true;
}
//匹配读取的装配件的有效性 //匹配读取的装配件的有效性
private StepResult matchAssemblySnValid(StationRequestBean reqBean, StationResultBean resultBean, Optional<Map<String, MesProdRouteOptParam>> stepParamMap, StepResult stepResult, MesProductionProcessContext productionProcessContext, MesCellEquipContext cellEquipContext, MesEquipLogDispatchContext equipLogDispatchContext) { private StepResult matchAssemblySnValid(StationRequestBean reqBean, StationResultBean resultBean, Optional<Map<String, MesProdRouteOptParam>> stepParamMap, StepResult stepResult, MesProductionProcessContext productionProcessContext, MesCellEquipContext cellEquipContext, MesEquipLogDispatchContext equipLogDispatchContext) {

@ -4,6 +4,8 @@ import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesProductionCustomContextStepServi
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesProductionDispatchContextStepService; import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesProductionDispatchContextStepService;
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesProductionProcessContextStepService; import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesProductionProcessContextStepService;
import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesEquipVariableCollectContext; import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesEquipVariableCollectContext;
import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesProdRuleContext;
import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesProductionPartContext;
import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesProductionProcessContext; import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesProductionProcessContext;
import cn.estsh.i3plus.mes.pcn.serviceimpl.fsm.BaseStepService; import cn.estsh.i3plus.mes.pcn.serviceimpl.fsm.BaseStepService;
import cn.estsh.i3plus.platform.common.tool.TimeTool; import cn.estsh.i3plus.platform.common.tool.TimeTool;
@ -14,10 +16,12 @@ import cn.estsh.i3plus.pojo.mes.util.MesExtEnumUtil;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Optional;
/** /**
* @Description : * @Description :
@ -52,6 +56,9 @@ public class MesAssemblyScanStepService extends BaseStepService {
StepResult stepResult = StepResult.getSuccessComplete(); StepResult stepResult = StepResult.getSuccessComplete();
//验证当前是否需要读装配件条码 【当前验证只能对内部触发生效】
if (!checkIsNeedScanAssembly(reqBean)) return execSuccessCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog(), stepResult, "当前上下文中的加工规则未配置装配件扫描项,无需扫描装配件条码!");
if (StringUtils.isEmpty(reqBean.getScanInfo())) execSendGuideAndThrowEx(reqBean, resultBean.writeDbLog(), "请扫描装配件条码!"); if (StringUtils.isEmpty(reqBean.getScanInfo())) execSendGuideAndThrowEx(reqBean, resultBean.writeDbLog(), "请扫描装配件条码!");
//扫描信息置空 //扫描信息置空
@ -76,6 +83,25 @@ public class MesAssemblyScanStepService extends BaseStepService {
} }
private Boolean checkIsNeedScanAssembly(StationRequestBean reqBean) {
//获取上下文产出零件信息
List<MesProductionPartContext> productionPartContextList = productionDispatchContextStepService.getProductionPartContext(reqBean);
//获取上下文产品加工规则数据信息集合
List<MesProdRuleContext> prodRuleContextList = productionDispatchContextStepService.getProdRuleDataContext(reqBean);
//没有加工规则代表需要反向匹配出加工规则, 需要直接读取
if (CollectionUtils.isEmpty(prodRuleContextList)) return true;
//判断加工规则中是否存在还有装配件的数据
Optional<MesProdRuleContext> optional = prodRuleContextList.stream().filter(o -> (null != o && !StringUtils.isEmpty(o.getAssemblyDataJson()))).findFirst();
//不存在返回fasle不用读取
return (null == optional || !optional.isPresent()) ? false : true;
}
private List<MesEquipVariableCollectContext> getAssemblySnJson(StationRequestBean reqBean, String scanInfo) { private List<MesEquipVariableCollectContext> getAssemblySnJson(StationRequestBean reqBean, String scanInfo) {
List<MesEquipVariableCollectContext> equipVariableCollectContextList = new ArrayList<>(); List<MesEquipVariableCollectContext> equipVariableCollectContextList = new ArrayList<>();

@ -153,7 +153,9 @@ public class MesAssemblyShowNosortStepService extends BaseStepService {
if (CollectionUtils.isEmpty(prodRuleNosortCfgList)) execExpSendMsgAndThrowEx(reqBean, resultBean.writeDbLog(), String.format("请检查非排序产品加工规则信息,未查询到设备[%s]产出零件[%s]进料零件[空]进料零件规则[空]的配置信息", cellEquipContext.getEquipmentCode(), productionPartContext.getPartNo())); if (CollectionUtils.isEmpty(prodRuleNosortCfgList)) execExpSendMsgAndThrowEx(reqBean, resultBean.writeDbLog(), String.format("请检查非排序产品加工规则信息,未查询到设备[%s]产出零件[%s]进料零件[空]进料零件规则[空]的配置信息", cellEquipContext.getEquipmentCode(), productionPartContext.getPartNo()));
//【非排序线】获取产品加工规则对应的装配件信息 //【非排序线】获取产品加工规则对应的装配件信息
if (prodRuleNosortCfgList.size() == 1) prodRuleContextList.add(prodRuleCfgExtService.getProdRuleContext(prodRuleNosortCfgList.get(0), productionPartContext.foreignKey(foreignKey += 1).getForeignKey())); if (prodRuleNosortCfgList.size() == 1) prodRuleContextList.add(prodRuleCfgExtService.getProdRuleContext(
new MesProdRuleContext(reqBean.getOrganizeCode(), reqBean.getWorkCenterCode(), reqBean.getWorkCellCode(), reqBean.getProcessCode()).
copy(prodRuleNosortCfgList.get(0)).workOrderNo(productionPartContext.getWorkOrderNo()).foreignKey(productionPartContext.foreignKey(foreignKey += 1).getForeignKey())));
if (prodRuleNosortCfgList.size() > 1) this.sendMessage(reqBean, resultBean, String.format( if (prodRuleNosortCfgList.size() > 1) this.sendMessage(reqBean, resultBean, String.format(
"显示装配件匹配非排序产品加工规则[%s]条,直接跳过,后续通过装配件规则匹配加工规则,数据源:[%s]!", prodRuleNosortCfgList.size(), JSONObject.toJSONString(productionPartContext)), MesPcnEnumUtil.STATION_BUSI_TYPE.RUNNING_INFO, MesPcnEnumUtil.STATION_DATA_TYPE.TEXT); "显示装配件匹配非排序产品加工规则[%s]条,直接跳过,后续通过装配件规则匹配加工规则,数据源:[%s]!", prodRuleNosortCfgList.size(), JSONObject.toJSONString(productionPartContext)), MesPcnEnumUtil.STATION_BUSI_TYPE.RUNNING_INFO, MesPcnEnumUtil.STATION_DATA_TYPE.TEXT);
@ -187,7 +189,8 @@ public class MesAssemblyShowNosortStepService extends BaseStepService {
cellEquipContext.getEquipmentCode(), !StringUtils.isEmpty(productionPsInContext.getPartNo()) ? String.format("号匹配[%s]", productionPsInContext.getPartNo()) : String.format("规则匹配[%s]", productionPsInContext.getProductSn()))); cellEquipContext.getEquipmentCode(), !StringUtils.isEmpty(productionPsInContext.getPartNo()) ? String.format("号匹配[%s]", productionPsInContext.getPartNo()) : String.format("规则匹配[%s]", productionPsInContext.getProductSn())));
//【非排序线】获取产品加工规则对应的装配件信息 //【非排序线】获取产品加工规则对应的装配件信息
if (filterList.size() == 1) prodRuleContextList.add(prodRuleCfgExtService.getProdRuleContext(filterList.get(0), productionPsInContext.foreignKey(foreignKey += 1).getForeignKey())); if (filterList.size() == 1) prodRuleContextList.add(prodRuleCfgExtService.getProdRuleContext(
new MesProdRuleContext(reqBean.getOrganizeCode(), reqBean.getWorkCenterCode(), reqBean.getWorkCellCode(), reqBean.getProcessCode()).copy(prodRuleNosortCfgList.get(0)).productSn(productionPsInContext.getProductSn()).foreignKey(productionPsInContext.foreignKey(foreignKey += 1).getForeignKey())));
if (filterList.size() > 1) this.sendMessage(reqBean, resultBean, String.format( if (filterList.size() > 1) this.sendMessage(reqBean, resultBean, String.format(
"显示装配件匹配非排序产品加工规则[%s]条,直接跳过,后续通过装配件规则匹配加工规则,数据源:[%s]!", filterList.size(), JSONObject.toJSONString(productionPsInContext)), MesPcnEnumUtil.STATION_BUSI_TYPE.RUNNING_INFO, MesPcnEnumUtil.STATION_DATA_TYPE.TEXT); "显示装配件匹配非排序产品加工规则[%s]条,直接跳过,后续通过装配件规则匹配加工规则,数据源:[%s]!", filterList.size(), JSONObject.toJSONString(productionPsInContext)), MesPcnEnumUtil.STATION_BUSI_TYPE.RUNNING_INFO, MesPcnEnumUtil.STATION_DATA_TYPE.TEXT);
@ -199,7 +202,7 @@ public class MesAssemblyShowNosortStepService extends BaseStepService {
private List<MesProdRuleNosortCfg> getProdRuleNosortCfgList(StationRequestBean reqBean, MesCellEquipContext cellEquipContext, List<MesProductionPsInContext> productionPsInContextList, List<String> outPartNoList) { 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()); 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()) && StringUtils.isEmpty(o.getPartNo()))).findFirst(); 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( List<MesProdRuleNosortCfg> prodRuleNosortCfgList = prodRuleCfgExtService.getProdRuleNosortCfgList(
!CollectionUtils.isEmpty(inPartNoList) ? new MesProdRuleContext(reqBean.getOrganizeCode()).equipmentCode(cellEquipContext.getEquipmentCode()).inPartNos(inPartNoList).outPartNos(outPartNoList) : null, !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()).inPartRuleIsNotEmpty().outPartNos(outPartNoList) : null); (null != optional && optional.isPresent()) ? new MesProdRuleContext(reqBean.getOrganizeCode()).equipmentCode(cellEquipContext.getEquipmentCode()).inPartRuleIsNotEmpty().outPartNos(outPartNoList) : null);
@ -224,8 +227,10 @@ public class MesAssemblyShowNosortStepService extends BaseStepService {
List<MesProdRuleNosortCfg> outPartNoProdRuleList = !CollectionUtils.isEmpty(prodRuleNosortCfgMap) ? prodRuleNosortCfgMap.get(productionPartContext.getPartNo()) : null; List<MesProdRuleNosortCfg> outPartNoProdRuleList = !CollectionUtils.isEmpty(prodRuleNosortCfgMap) ? prodRuleNosortCfgMap.get(productionPartContext.getPartNo()) : null;
MesProdRuleNosortCfg filter = null; MesProdRuleNosortCfg filter = null;
String productSn = null;
Optional<MesProductionPsInContext> optional = productionPsInContextList.stream().filter(o -> (null != o && StringUtils.isEmpty(o.getForeignKey()))).findFirst(); //判断是否还存在待匹配的主条码信息, 内部循环匹配成功会标记 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; if (null == optional || !optional.isPresent()) break;
for (MesProductionPsInContext productionPsInContext : productionPsInContextList) { for (MesProductionPsInContext productionPsInContext : productionPsInContextList) {
@ -244,6 +249,7 @@ public class MesAssemblyShowNosortStepService extends BaseStepService {
productionPartContext.foreignKey(productionPsInContext.foreignKey(foreignKey += 1).getForeignKey()); productionPartContext.foreignKey(productionPsInContext.foreignKey(foreignKey += 1).getForeignKey());
filter = innerfilterList.get(0); filter = innerfilterList.get(0);
productSn = productionPsInContext.getProductSn();
break; break;
@ -252,7 +258,8 @@ public class MesAssemblyShowNosortStepService extends BaseStepService {
if (null == filter) execExpSendMsgAndThrowEx(reqBean, resultBean.writeDbLog(), String.format("请检查非排序产品加工规则信息,未查询到设备[%s]产出零件[%s]匹配任意一个主条码的配置信息", cellEquipContext.getEquipmentCode(), productionPartContext.getPartName())); if (null == filter) execExpSendMsgAndThrowEx(reqBean, resultBean.writeDbLog(), String.format("请检查非排序产品加工规则信息,未查询到设备[%s]产出零件[%s]匹配任意一个主条码的配置信息", cellEquipContext.getEquipmentCode(), productionPartContext.getPartName()));
//【非排序线】获取产品加工规则对应的装配件信息 //【非排序线】获取产品加工规则对应的装配件信息
prodRuleContextList.add(prodRuleCfgExtService.getProdRuleContext(filter, productionPartContext.getForeignKey())); prodRuleContextList.add(prodRuleCfgExtService.getProdRuleContext(
new MesProdRuleContext(reqBean.getOrganizeCode(), reqBean.getWorkCenterCode(), reqBean.getWorkCellCode(), reqBean.getProcessCode()).copy(filter).workOrderNo(productionPartContext.getWorkOrderNo()).productSn(productSn).foreignKey(productionPartContext.getForeignKey())));
} }
@ -330,12 +337,6 @@ public class MesAssemblyShowNosortStepService extends BaseStepService {
private MesAssemblyShowContext assemblyShowContext(MesProductionAssemblyContext o, MesProdRuleContext prodRuleContext, String workOrderNo) { private MesAssemblyShowContext assemblyShowContext(MesProductionAssemblyContext o, MesProdRuleContext prodRuleContext, String workOrderNo) {
MesAssemblyShowContext assemblyShowContext = new MesAssemblyShowContext(); MesAssemblyShowContext assemblyShowContext = new MesAssemblyShowContext();
BeanUtils.copyProperties(o, assemblyShowContext); BeanUtils.copyProperties(o, assemblyShowContext);
if (!StringUtils.isEmpty(workOrderNo)) assemblyShowContext.setWorkOrderNo(workOrderNo);
assemblyShowContext.setPartNo(prodRuleContext.getOutPartNo());
if (StringUtils.isEmpty(assemblyShowContext.getRouteSeq())) assemblyShowContext.setRouteSeq(MesPcnExtConstWords.ZERO);
if (StringUtils.isEmpty(assemblyShowContext.getAssemblyStatus())) assemblyShowContext.setAssemblyStatus(MesExtEnumUtil.ASSEMBLY_STATUS.ASSEMBLY_STATUS_30.getValue());
if (MesExtEnumUtil.ASSEMBLY_STATUS.ASSEMBLY_STATUS_30.getValue() == assemblyShowContext.getAssemblyStatus() && (MesExtEnumUtil.ASSEMBLY_MATCH_TYPE.MATCH_TYPE_50.getValue() == assemblyShowContext.getMatchType() ||
MesExtEnumUtil.ASSEMBLY_MATCH_TYPE.MATCH_TYPE_60.getValue() == assemblyShowContext.getMatchType())) assemblyShowContext.setAssemblyStatus(MesExtEnumUtil.ASSEMBLY_STATUS.ASSEMBLY_STATUS_10.getValue());
assemblyShowContext.setAssemblyStatusName(MesExtEnumUtil.ASSEMBLY_STATUS.valueOfDescription(assemblyShowContext.getAssemblyStatus())); assemblyShowContext.setAssemblyStatusName(MesExtEnumUtil.ASSEMBLY_STATUS.valueOfDescription(assemblyShowContext.getAssemblyStatus()));
if (MesExtEnumUtil.ASSEMBLY_STATUS.ASSEMBLY_STATUS_30.getValue() != assemblyShowContext.getAssemblyStatus()) if (MesExtEnumUtil.ASSEMBLY_STATUS.ASSEMBLY_STATUS_30.getValue() != assemblyShowContext.getAssemblyStatus())
assemblyShowContext.setColor(StringUtils.isEmpty(assemblyShowContext.getShowColor()) ? MesExtEnumUtil.COLOR.GREEN.getValue() : assemblyShowContext.getShowColor()); assemblyShowContext.setColor(StringUtils.isEmpty(assemblyShowContext.getShowColor()) ? MesExtEnumUtil.COLOR.GREEN.getValue() : assemblyShowContext.getShowColor());

@ -121,8 +121,8 @@ public class MesAssemblyShowSortStepService extends BaseStepService {
if (null == productionPsInContext || productionPsInContext.getIsFinishCode().compareTo(CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue()) == 0 || !StringUtils.isEmpty(productionPsInContext.getForeignKey())) continue; if (null == productionPsInContext || productionPsInContext.getIsFinishCode().compareTo(CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue()) == 0 || !StringUtils.isEmpty(productionPsInContext.getForeignKey())) continue;
//【排序线】获取产品加工规则(条码对应的装配件绑定记录,目前条码等同工单) //【排序线】获取产品加工规则(条码对应的装配件绑定记录,目前条码等同工单)
prodRuleContextList.add(prodRuleCfgExtService.getProdRuleSortContext(new MesProdRuleContext( prodRuleContextList.add(prodRuleCfgExtService.getProdRuleSortContext(
reqBean.getOrganizeCode(), reqBean.getWorkCenterCode(), reqBean.getWorkCellCode(), reqBean.getProcessCode(), productionPsInContext.getProductSn()).foreignKey( new MesProdRuleContext(reqBean.getOrganizeCode(), reqBean.getWorkCenterCode(), reqBean.getWorkCellCode(), reqBean.getProcessCode()).workOrderNo(productionPsInContext.getWorkOrderNo()).productSn(productionPsInContext.getProductSn()).foreignKey(
productionPartContextList.stream().filter(o -> (null != o && o.getWorkOrderNo().equals(productionPsInContext.getWorkOrderNo()))).findFirst().get().foreignKey(productionPsInContext.foreignKey(foreignKey += 1).getForeignKey()).getForeignKey()))); productionPartContextList.stream().filter(o -> (null != o && o.getWorkOrderNo().equals(productionPsInContext.getWorkOrderNo()))).findFirst().get().foreignKey(productionPsInContext.foreignKey(foreignKey += 1).getForeignKey()).getForeignKey())));
} }
@ -185,9 +185,6 @@ public class MesAssemblyShowSortStepService extends BaseStepService {
private MesAssemblyShowContext assemblyShowContext(MesProductionAssemblyContext o) { private MesAssemblyShowContext assemblyShowContext(MesProductionAssemblyContext o) {
MesAssemblyShowContext assemblyShowContext = new MesAssemblyShowContext(); MesAssemblyShowContext assemblyShowContext = new MesAssemblyShowContext();
BeanUtils.copyProperties(o, assemblyShowContext); BeanUtils.copyProperties(o, assemblyShowContext);
if (StringUtils.isEmpty(assemblyShowContext.getRouteSeq())) assemblyShowContext.setRouteSeq(MesPcnExtConstWords.ZERO);
if (MesExtEnumUtil.ASSEMBLY_STATUS.ASSEMBLY_STATUS_30.getValue() == assemblyShowContext.getAssemblyStatus() && (MesExtEnumUtil.ASSEMBLY_MATCH_TYPE.MATCH_TYPE_50.getValue() == assemblyShowContext.getMatchType() ||
MesExtEnumUtil.ASSEMBLY_MATCH_TYPE.MATCH_TYPE_60.getValue() == assemblyShowContext.getMatchType())) assemblyShowContext.setAssemblyStatus(MesExtEnumUtil.ASSEMBLY_STATUS.ASSEMBLY_STATUS_10.getValue());
assemblyShowContext.setAssemblyStatusName(MesExtEnumUtil.ASSEMBLY_STATUS.valueOfDescription(o.getAssemblyStatus())); assemblyShowContext.setAssemblyStatusName(MesExtEnumUtil.ASSEMBLY_STATUS.valueOfDescription(o.getAssemblyStatus()));
if (MesExtEnumUtil.ASSEMBLY_STATUS.ASSEMBLY_STATUS_30.getValue() != assemblyShowContext.getAssemblyStatus()) if (MesExtEnumUtil.ASSEMBLY_STATUS.ASSEMBLY_STATUS_30.getValue() != assemblyShowContext.getAssemblyStatus())
assemblyShowContext.setColor(StringUtils.isEmpty(assemblyShowContext.getShowColor()) ? MesExtEnumUtil.COLOR.GREEN.getValue() : assemblyShowContext.getShowColor()); assemblyShowContext.setColor(StringUtils.isEmpty(assemblyShowContext.getShowColor()) ? MesExtEnumUtil.COLOR.GREEN.getValue() : assemblyShowContext.getShowColor());

@ -5,6 +5,7 @@ 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.context.*;
import cn.estsh.i3plus.ext.mes.pcn.pojo.util.MesPcnExtConstWords; 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.serviceimpl.fsm.BaseStepService;
import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
import cn.estsh.i3plus.pojo.base.enumutil.MesPcnEnumUtil; import cn.estsh.i3plus.pojo.base.enumutil.MesPcnEnumUtil;
import cn.estsh.i3plus.pojo.mes.bean.MesEquipmentVariable; import cn.estsh.i3plus.pojo.mes.bean.MesEquipmentVariable;
import cn.estsh.i3plus.pojo.mes.bean.MesEquipmentVariableCfg; import cn.estsh.i3plus.pojo.mes.bean.MesEquipmentVariableCfg;
@ -163,8 +164,6 @@ public class MesProductSnReadStepService extends BaseStepService {
execThreadSleepAndSendTaskCompleteAndThrowEx(reqBean, resultBean.writeDbLog(), stepResult.isCompleted(false).msg(String.format("当前读取到设备[%s]主条码全部为空腔,持续监听中...", cellEquipContext.getEquipmentCode())), execThreadSleepAndSendTaskCompleteAndThrowEx(reqBean, resultBean.writeDbLog(), stepResult.isCompleted(false).msg(String.format("当前读取到设备[%s]主条码全部为空腔,持续监听中...", cellEquipContext.getEquipmentCode())),
MesPcnEnumUtil.STATION_BUSI_TYPE.MESSAGE, MesPcnEnumUtil.STATION_DATA_TYPE.EXP_TEXT, stepParamMap, MesPcnExtConstWords.READ_FAILURE_SLEEP, MesPcnExtConstWords.READ_FAILURE_SLEEP_DEFAULT_TIME); MesPcnEnumUtil.STATION_BUSI_TYPE.MESSAGE, MesPcnEnumUtil.STATION_DATA_TYPE.EXP_TEXT, stepParamMap, MesPcnExtConstWords.READ_FAILURE_SLEEP, MesPcnExtConstWords.READ_FAILURE_SLEEP_DEFAULT_TIME);
//根据读取条码分组数据 //根据读取条码分组数据
Map<String, List<MesEquipVariableCollectContext>> produceSnCollectMap = productSnList.stream().filter(o -> null != o).collect(Collectors.groupingBy(MesEquipVariableCollectContext::getEquipVariableValue)); Map<String, List<MesEquipVariableCollectContext>> produceSnCollectMap = productSnList.stream().filter(o -> null != o).collect(Collectors.groupingBy(MesEquipVariableCollectContext::getEquipVariableValue));
@ -183,6 +182,10 @@ public class MesProductSnReadStepService extends BaseStepService {
execThreadSleepAndSendTaskCompleteAndThrowEx(reqBean, resultBean.writeDbLog(), stepResult.isCompleted(false).msg(String.format("当前读取到设备[%s]主条码数量[%s]与工位设备维护的腔数[%s]不一致,持续监听中...", cellEquipContext.getEquipmentCode(), equipVariableCollectContextList.size(), cellEquipContext.getCavity())), execThreadSleepAndSendTaskCompleteAndThrowEx(reqBean, resultBean.writeDbLog(), stepResult.isCompleted(false).msg(String.format("当前读取到设备[%s]主条码数量[%s]与工位设备维护的腔数[%s]不一致,持续监听中...", cellEquipContext.getEquipmentCode(), equipVariableCollectContextList.size(), cellEquipContext.getCavity())),
MesPcnEnumUtil.STATION_BUSI_TYPE.MESSAGE, MesPcnEnumUtil.STATION_DATA_TYPE.EXP_TEXT, stepParamMap, MesPcnExtConstWords.READ_FAILURE_SLEEP, MesPcnExtConstWords.READ_FAILURE_SLEEP_DEFAULT_TIME); MesPcnEnumUtil.STATION_BUSI_TYPE.MESSAGE, MesPcnEnumUtil.STATION_DATA_TYPE.EXP_TEXT, stepParamMap, MesPcnExtConstWords.READ_FAILURE_SLEEP, MesPcnExtConstWords.READ_FAILURE_SLEEP_DEFAULT_TIME);
//比对产出零件的空腔数量与主条码的空腔数量, 产出零件的空腔数必须小于主条码的空腔数
if (!checkFinishCodeSizeValid(stepResult, cellEquipContext, productionPartContextList, finishCodeList).isCompleted())
execThreadSleepAndSendTaskCompleteAndThrowEx(reqBean, resultBean.writeDbLog(), stepResult.isCompleted(false).msg(stepResult.getMsg()), MesPcnEnumUtil.STATION_BUSI_TYPE.MESSAGE, MesPcnEnumUtil.STATION_DATA_TYPE.EXP_TEXT, stepParamMap, MesPcnExtConstWords.READ_FAILURE_SLEEP, MesPcnExtConstWords.READ_FAILURE_SLEEP_DEFAULT_TIME);
//保存设备当前一轮工序的待验证的主条码信息 //保存设备当前一轮工序的待验证的主条码信息
productionDispatchContextStepService.saveScanProductSnContext(reqBean, productSnList); productionDispatchContextStepService.saveScanProductSnContext(reqBean, productSnList);
@ -192,6 +195,22 @@ public class MesProductSnReadStepService extends BaseStepService {
} }
//比对产出零件的空腔数量与主条码的空腔数量, 产出零件的空腔数必须小于主条码的空腔数
private StepResult checkFinishCodeSizeValid(StepResult stepResult, MesCellEquipContext cellEquipContext, List<MesProductionPartContext> productionPartContextList, List<MesEquipVariableCollectContext> finishCodeList) {
//没有产出零件 不需要对比空腔数量
if (CollectionUtils.isEmpty(productionPartContextList)) return stepResult;
List<MesProductionPartContext> finishCodePpList = productionPartContextList.stream().filter(o -> (null != o && o.getIsFinishCode().compareTo(CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue()) == 0)).collect(Collectors.toList());
Integer ppSize = CollectionUtils.isEmpty(finishCodePpList) ? MesPcnExtConstWords.ZERO : finishCodePpList.size();
Integer psSize = CollectionUtils.isEmpty(finishCodeList) ? MesPcnExtConstWords.ZERO : finishCodeList.size();
return ppSize.compareTo(psSize) <= 0 ? stepResult :
stepResult.isCompleted(false).msg(String.format("当前读取到设备[%s]主条码空腔数量[%s]小于产出零件对应的空腔数量[%s],持续监听中...", cellEquipContext.getEquipmentCode(), psSize, ppSize));
}
//封装无需验证的finishCode空腔数据 //封装无需验证的finishCode空腔数据
private List<MesProductionPsInContext> getProductionPsInContextList(List<MesEquipVariableCollectContext> finishCodeList) { private List<MesProductionPsInContext> getProductionPsInContextList(List<MesEquipVariableCollectContext> finishCodeList) {
List<MesProductionPsInContext> productionPsInContextList = new ArrayList<>(); List<MesProductionPsInContext> productionPsInContextList = new ArrayList<>();
@ -199,6 +218,7 @@ public class MesProductSnReadStepService extends BaseStepService {
return productionPsInContextList; return productionPsInContextList;
} }
//搜集主条码值与空腔值
private List<MesEquipVariableCollectContext> filterEquipVariableCollectContextList(MesProductionProcessContext productionProcessContext, List<MesEquipVariableCollectContext> equipVariableCollectContextList, Boolean flag) { private List<MesEquipVariableCollectContext> filterEquipVariableCollectContextList(MesProductionProcessContext productionProcessContext, List<MesEquipVariableCollectContext> equipVariableCollectContextList, Boolean flag) {
return flag ? equipVariableCollectContextList.stream().filter(o -> (null != o && !o.getEquipVariableValue().equals(productionProcessContext.getFinishCode()))).collect(Collectors.toList()) : return flag ? equipVariableCollectContextList.stream().filter(o -> (null != o && !o.getEquipVariableValue().equals(productionProcessContext.getFinishCode()))).collect(Collectors.toList()) :
equipVariableCollectContextList.stream().filter(o -> (null != o && o.getEquipVariableValue().equals(productionProcessContext.getFinishCode()))).collect(Collectors.toList()); equipVariableCollectContextList.stream().filter(o -> (null != o && o.getEquipVariableValue().equals(productionProcessContext.getFinishCode()))).collect(Collectors.toList());

@ -124,8 +124,13 @@ public class MesProductSnScanNosortStepService extends BaseStepService {
//验证是否存在重复主条码 //验证是否存在重复主条码
if (checkIsExistRepeatScan(productionProcessContext, equipVariableCollectContextList, productionPsInContextList)) return execNonCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog(), stepResult, String.format("当前扫描信息主条码[%s],上下文中存在重复扫描的主条码!", scanInfo)); if (checkIsExistRepeatScan(productionProcessContext, equipVariableCollectContextList, productionPsInContextList)) return execNonCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog(), stepResult, String.format("当前扫描信息主条码[%s],上下文中存在重复扫描的主条码!", scanInfo));
Boolean scanInfoIsFinishCode = !scanInfo.equals(productionProcessContext.getFinishCode()) ? false : true;
//比对产出零件的空腔数量与主条码的空腔数量, 产出零件的空腔数必须小于 剩余待扫描主条码数量加上已扫描的空腔数量
if (!checkFinishCodeSize(stepResult, productionPartContextList, productionPsInContextList, scanInfoIsFinishCode).isCompleted()) return execNonCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog(), stepResult, stepResult.getMsg());
//保存上下文扫/读信息:主条码 或者 添加了finishCode后的主条码数据 //保存上下文扫/读信息:主条码 或者 添加了finishCode后的主条码数据
if (!scanInfo.equals(productionProcessContext.getFinishCode())) productionDispatchContextStepService.saveScanProductSnContext(reqBean, equipVariableCollectContextList); if (!scanInfoIsFinishCode) productionDispatchContextStepService.saveScanProductSnContext(reqBean, equipVariableCollectContextList);
else productionPsInContextList = saveProductionPsInContextList(reqBean, productionPsInContextList); else productionPsInContextList = saveProductionPsInContextList(reqBean, productionPsInContextList);
//前期扫描数量已等于腔数 //前期扫描数量已等于腔数
@ -141,7 +146,7 @@ public class MesProductSnScanNosortStepService extends BaseStepService {
MesPcnEnumUtil.STATION_BUSI_TYPE.MESSAGE, MesPcnEnumUtil.STATION_DATA_TYPE.TEXT, String.format("当前扫描信息%s[%s],已知腔数[%s],还需要再连续扫描[%s]次主条码!", scanInfoName, scanInfo, needQty, needQty - equipVariableCollectContextList.size())); MesPcnEnumUtil.STATION_BUSI_TYPE.MESSAGE, MesPcnEnumUtil.STATION_DATA_TYPE.TEXT, String.format("当前扫描信息%s[%s],已知腔数[%s],还需要再连续扫描[%s]次主条码!", scanInfoName, scanInfo, needQty, needQty - equipVariableCollectContextList.size()));
//扫描场景 验证是否全部为空腔 //扫描场景 验证是否全部为空腔
if (!checkIsAllFinishCode(equipVariableCollectContextList, productionPartContextList)) if (!checkIsAllFinishCode(productionPsInContextList, equipVariableCollectContextList))
return execSuccessCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog(), stepResult, String.format("当前扫描信息%s[%s]%s!", scanInfoName, scanInfo, scanedQty.compareTo(needQty) == 0 ? String.format(",上下文中的主条码个数[%s]已满足腔数", scanedQty) : MesPcnExtConstWords.EMPTY)); return execSuccessCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog(), stepResult, String.format("当前扫描信息%s[%s]%s!", scanInfoName, scanInfo, scanedQty.compareTo(needQty) == 0 ? String.format(",上下文中的主条码个数[%s]已满足腔数", scanedQty) : MesPcnExtConstWords.EMPTY));
//删除上下文扫/读信息:主条码 //删除上下文扫/读信息:主条码
@ -252,10 +257,31 @@ public class MesProductSnScanNosortStepService extends BaseStepService {
} }
//验证是否全部为空腔 ////比对产出零件的空腔数量与主条码的空腔数量, 产出零件的空腔数必须小于 剩余待扫描主条码数量加上已扫描的空腔数量
private Boolean checkIsAllFinishCode(List<MesEquipVariableCollectContext> equipVariableCollectContextList, List<MesProductionPartContext> productionPartContextList) { private StepResult checkFinishCodeSize(StepResult stepResult, List<MesProductionPartContext> productionPartContextList, List<MesProductionPsInContext> productionPsInContextList, Boolean scanInfoIsFinishCode) {
Optional<MesProductionPartContext> optional = productionPartContextList.stream().filter(o -> (null != o && o.getIsFinishCode().compareTo(CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue()) == 0)).findFirst();
return ((null != optional && optional.isPresent()) || !CollectionUtils.isEmpty(equipVariableCollectContextList)) ? false : true; //没有产出零件 不需要对比空腔数量
if (CollectionUtils.isEmpty(productionPartContextList)) return stepResult;
List<MesProductionPartContext> finishCodePpList = productionPartContextList.stream().filter(o -> (null != o && o.getIsFinishCode().compareTo(CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue()) == 0)).collect(Collectors.toList());
List<MesProductionPsInContext> finishCodePsList = CollectionUtils.isEmpty(productionPsInContextList) ? null : productionPsInContextList.stream().filter(o -> (null != o && o.getIsFinishCode().compareTo(CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue()) == 0)).collect(Collectors.toList());
//产出零件的空腔数
Integer ppSize = CollectionUtils.isEmpty(finishCodePpList) ? MesPcnExtConstWords.ZERO : finishCodePpList.size();
//已扫描的主条码空腔数量
Integer psSize = (CollectionUtils.isEmpty(finishCodePsList) ? MesPcnExtConstWords.ZERO : finishCodePsList.size()) + (!scanInfoIsFinishCode ? MesPcnExtConstWords.ZERO : MesPcnExtConstWords.ONE);
//剩余待扫描主条码数量
Integer remainSize = productionPartContextList.size() - (CollectionUtils.isEmpty(productionPsInContextList) ? MesPcnExtConstWords.ZERO : productionPsInContextList.size()) - MesPcnExtConstWords.ONE;
return ppSize.compareTo(remainSize + psSize) < 0 ? stepResult : stepResult.isCompleted(false).msg(String.format("产出零件存在空腔数[%s],扫描的主条码空腔数[%s],当前主条码必须扫描空腔码!", ppSize, psSize));
}
private Boolean checkIsAllFinishCode(List<MesProductionPsInContext> productionPsInContextList, List<MesEquipVariableCollectContext> equipVariableCollectContextList) {
//扫描场景 验证是否全部为空腔
Optional<MesProductionPsInContext> optional = productionPsInContextList.stream().filter(o -> (null != o && o.getIsFinishCode().compareTo(CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue()) == 0)).findFirst();
//已验证的主条码全部空腔 并且 当前待验证主条码不存在数据 则全部空腔
return ((null == optional || !optional.isPresent()) && CollectionUtils.isEmpty(equipVariableCollectContextList)) ? true : false;
} }
} }

@ -1,15 +1,18 @@
package cn.estsh.i3plus.ext.mes.pcn.pojo.context; package cn.estsh.i3plus.ext.mes.pcn.pojo.context;
import cn.estsh.i3plus.pojo.mes.bean.MesProdRuleNosortCfg;
import cn.estsh.i3plus.pojo.mes.bean.MesWorkCenter; import cn.estsh.i3plus.pojo.mes.bean.MesWorkCenter;
import cn.estsh.i3plus.pojo.mes.util.MesExtEnumUtil; import cn.estsh.i3plus.pojo.mes.util.MesExtEnumUtil;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import io.swagger.annotations.ApiParam; import io.swagger.annotations.ApiParam;
import lombok.Data; import lombok.Data;
import org.springframework.beans.BeanUtils;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import java.io.Serializable; import java.io.Serializable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Comparator;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -27,14 +30,15 @@ public class MesProdRuleContext implements Serializable {
@ApiParam(name = "数据关联键") @ApiParam(name = "数据关联键")
private Integer foreignKey; private Integer foreignKey;
@ApiParam(name = "工单号,不一定有值")
private String workOrderNo;
@ApiParam(name = "读/扫主条码信息(内制件/外协件/排序条码即工单号),不一定有值") @ApiParam(name = "读/扫主条码信息(内制件/外协件/排序条码即工单号),不一定有值")
private String productSn; private String productSn;
@ApiParam("装配件绑定清单 [JSON]List<MesProductionAssemblyContext>") @ApiParam("装配件绑定清单 [JSON]List<MesProductionAssemblyContext>")
public String assemblyDataJson; public String assemblyDataJson;
//-------以下排序属性-------------
@ApiParam("生产线代码") @ApiParam("生产线代码")
public String workCenterCode; public String workCenterCode;
@ -44,6 +48,9 @@ public class MesProdRuleContext implements Serializable {
@ApiParam("工序代码") @ApiParam("工序代码")
public String processCode; public String processCode;
@ApiParam(name = "是否验证装配件扫描顺序")
private Integer isCheckBindSeq;
//-------以下非排序属性------------- //-------以下非排序属性-------------
@ApiParam("非排序产品加工规则ID") @ApiParam("非排序产品加工规则ID")
@ -78,9 +85,6 @@ public class MesProdRuleContext implements Serializable {
@ApiParam(name = "是否包装") @ApiParam(name = "是否包装")
private Integer isPackage; private Integer isPackage;
@ApiParam(name = "是否验证装配件扫描顺序")
private Integer isCheckBindSeq;
@ApiParam(name = "成品站点") @ApiParam(name = "成品站点")
private String partLocation; private String partLocation;
@ -107,12 +111,27 @@ public class MesProdRuleContext implements Serializable {
this.organizeCode = organizeCode; this.organizeCode = organizeCode;
} }
public MesProdRuleContext(String organizeCode, String workCenterCode, String workCellCode, String processCode, String productSn) { public MesProdRuleContext(String organizeCode, String workCenterCode, String workCellCode, String processCode) {
this.organizeCode = organizeCode; this.organizeCode = organizeCode;
this.workCenterCode = workCenterCode; this.workCenterCode = workCenterCode;
this.workCellCode = workCellCode; this.workCellCode = workCellCode;
this.processCode = processCode; this.processCode = processCode;
}
public MesProdRuleContext copy(MesProdRuleNosortCfg prodRuleNosortCfg) {
BeanUtils.copyProperties(prodRuleNosortCfg, this);
this.pid = prodRuleNosortCfg.getId();
return this;
}
public MesProdRuleContext workOrderNo(String workOrderNo) {
this.workOrderNo = workOrderNo;
return this;
}
public MesProdRuleContext productSn(String productSn) {
this.productSn = productSn; this.productSn = productSn;
return this;
} }
public MesProdRuleContext foreignKey(Integer foreignKey) { public MesProdRuleContext foreignKey(Integer foreignKey) {
@ -183,14 +202,21 @@ public class MesProdRuleContext implements Serializable {
public List<MesProductionAssemblyContext> getAssemblyDataContext(MesWorkCenter workCenter) { public List<MesProductionAssemblyContext> getAssemblyDataContext(MesWorkCenter workCenter) {
if (StringUtils.isEmpty(this.assemblyDataJson)) return null; if (StringUtils.isEmpty(this.assemblyDataJson)) return null;
List<MesProductionAssemblyContext> productionAssemblyContextList = new ArrayList<>(); List<MesProductionAssemblyContext> productionAssemblyContextList = new ArrayList<>();
if (MesExtEnumUtil.WORK_CENTER_TYPE.SORT.getValue() == workCenter.getCenterType()) { if (MesExtEnumUtil.WORK_CENTER_TYPE.SORT.getValue() == workCenter.getCenterType()) getSortAssemblyDataContext().forEach(o -> productionAssemblyContextList.add(o));
List<MesProductionAssemblySortContext> productionAssemblySortContextList = JSONObject.parseArray(this.assemblyDataJson, MesProductionAssemblySortContext.class); else getNosortAssemblyDataContext().forEach(o -> productionAssemblyContextList.add(o));
productionAssemblySortContextList.forEach(o -> productionAssemblyContextList.add(o));
} else {
List<MesProductionAssemblyNosortContext> productionAssemblyNosortContextList = JSONObject.parseArray(this.assemblyDataJson, MesProductionAssemblyNosortContext.class);
productionAssemblyNosortContextList.forEach(o -> productionAssemblyContextList.add(o));
}
return productionAssemblyContextList; return productionAssemblyContextList;
} }
//非排序装配件清单
public List<MesProductionAssemblyNosortContext> getNosortAssemblyDataContext() {
List<MesProductionAssemblyNosortContext> nosortAssemblyList = !StringUtils.isEmpty(this.assemblyDataJson) ? JSONObject.parseArray(this.assemblyDataJson, MesProductionAssemblyNosortContext.class) : null;
return CollectionUtils.isEmpty(nosortAssemblyList) ? null : nosortAssemblyList.stream().filter(o -> null != o).sorted(Comparator.comparing(MesProductionAssemblyNosortContext::getRouteSeq)).collect(Collectors.toList());
}
//排序装配件清单
public List<MesProductionAssemblySortContext> getSortAssemblyDataContext() {
List<MesProductionAssemblySortContext> sortAssemblyList = !StringUtils.isEmpty(this.assemblyDataJson) ? JSONObject.parseArray(this.assemblyDataJson, MesProductionAssemblySortContext.class) : null;
return CollectionUtils.isEmpty(sortAssemblyList) ? null : sortAssemblyList.stream().filter(o -> null != o).sorted(Comparator.comparing(MesProductionAssemblySortContext::getRouteSeq)).collect(Collectors.toList());
}
} }

@ -1,10 +1,12 @@
package cn.estsh.i3plus.ext.mes.pcn.pojo.context; package cn.estsh.i3plus.ext.mes.pcn.pojo.context;
import cn.estsh.i3plus.ext.mes.pcn.pojo.util.MesPcnExtConstWords;
import cn.estsh.i3plus.pojo.mes.bean.MesAssemblyNosortCfg; import cn.estsh.i3plus.pojo.mes.bean.MesAssemblyNosortCfg;
import cn.estsh.i3plus.pojo.mes.bean.MesProductionAssembly; import cn.estsh.i3plus.pojo.mes.util.MesExtEnumUtil;
import io.swagger.annotations.ApiParam; import io.swagger.annotations.ApiParam;
import lombok.Data; import lombok.Data;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.util.StringUtils;
import java.io.Serializable; import java.io.Serializable;
@ -28,9 +30,17 @@ public class MesProductionAssemblyNosortContext extends MesProductionAssemblyCon
@ApiParam(value = "工序用量") @ApiParam(value = "工序用量")
private Integer qty; private Integer qty;
public MesProductionAssemblyNosortContext(MesAssemblyNosortCfg assemblyNosortCfg, MesProductionAssembly productionAssembly) { public MesProductionAssemblyNosortContext() {}
public MesProductionAssemblyNosortContext copy(MesAssemblyNosortCfg assemblyNosortCfg, MesProdRuleContext prodRuleContext) {
if (null != assemblyNosortCfg) BeanUtils.copyProperties(assemblyNosortCfg, this); if (null != assemblyNosortCfg) BeanUtils.copyProperties(assemblyNosortCfg, this);
if (null != productionAssembly) BeanUtils.copyProperties(productionAssembly, this); if (null != prodRuleContext) BeanUtils.copyProperties(prodRuleContext, this);
this.partNo = prodRuleContext.getOutPartNo();
if (StringUtils.isEmpty(this.routeSeq)) this.routeSeq = MesPcnExtConstWords.ZERO;
this.assemblyStatus = MesExtEnumUtil.ASSEMBLY_STATUS.ASSEMBLY_STATUS_30.getValue();
if (MesExtEnumUtil.ASSEMBLY_MATCH_TYPE.MATCH_TYPE_50.getValue() == this.matchType || MesExtEnumUtil.ASSEMBLY_MATCH_TYPE.MATCH_TYPE_60.getValue() == this.matchType)
this.assemblyStatus = MesExtEnumUtil.ASSEMBLY_STATUS.ASSEMBLY_STATUS_10.getValue();
return this;
} }
} }

@ -1,10 +1,13 @@
package cn.estsh.i3plus.ext.mes.pcn.pojo.context; package cn.estsh.i3plus.ext.mes.pcn.pojo.context;
import cn.estsh.i3plus.ext.mes.pcn.pojo.util.MesPcnExtConstWords;
import cn.estsh.i3plus.pojo.mes.bean.MesProductionAssembly; import cn.estsh.i3plus.pojo.mes.bean.MesProductionAssembly;
import cn.estsh.i3plus.pojo.mes.bean.MesWorkOrderAssembly; import cn.estsh.i3plus.pojo.mes.bean.MesWorkOrderAssembly;
import cn.estsh.i3plus.pojo.mes.util.MesExtEnumUtil;
import io.swagger.annotations.ApiParam; import io.swagger.annotations.ApiParam;
import lombok.Data; import lombok.Data;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.util.StringUtils;
import java.io.Serializable; import java.io.Serializable;
@ -105,9 +108,14 @@ public class MesProductionAssemblySortContext extends MesProductionAssemblyConte
public MesProductionAssemblySortContext() {} public MesProductionAssemblySortContext() {}
public MesProductionAssemblySortContext(MesWorkOrderAssembly workOrderAssembly, MesProductionAssembly productionAssembly) { public MesProductionAssemblySortContext copy(MesWorkOrderAssembly workOrderAssembly, MesProductionAssembly productionAssembly) {
if (null != workOrderAssembly) BeanUtils.copyProperties(workOrderAssembly, this); if (null != workOrderAssembly) BeanUtils.copyProperties(workOrderAssembly, this);
if (null != productionAssembly) BeanUtils.copyProperties(productionAssembly, this); if (null != productionAssembly) BeanUtils.copyProperties(productionAssembly, this);
if (StringUtils.isEmpty(this.routeSeq)) this.routeSeq = MesPcnExtConstWords.ZERO;
if (this.assemblyStatus.compareTo(MesExtEnumUtil.ASSEMBLY_STATUS.ASSEMBLY_STATUS_30.getValue()) == 0 &&
(MesExtEnumUtil.ASSEMBLY_MATCH_TYPE.MATCH_TYPE_50.getValue() == this.matchType || MesExtEnumUtil.ASSEMBLY_MATCH_TYPE.MATCH_TYPE_60.getValue() == this.matchType))
this.assemblyStatus = MesExtEnumUtil.ASSEMBLY_STATUS.ASSEMBLY_STATUS_10.getValue();
return this;
} }
} }

@ -191,6 +191,10 @@ public class MesPcnExtConstWords {
// 工位参数按钮事件: 解除锁定 // 工位参数按钮事件: 解除锁定
public static final String FUNCTION_PRODUCTION_UNLOCK = "FUNCTION_PRODUCTION_UNLOCK"; public static final String FUNCTION_PRODUCTION_UNLOCK = "FUNCTION_PRODUCTION_UNLOCK";
// 自定义触发事件: 装配件
public static final String NEXT_TRIGGER_EVENT_ASSEMBLY = "ASSEMBLY";
// 自定义触发事件: 主条码
public static final String NEXT_TRIGGER_EVENT_PRODUCT_SN = "PRODUCT_SN";
// 0 // 0
public static final String ZERO_STR = "0"; public static final String ZERO_STR = "0";

Loading…
Cancel
Save