可复用件

tags/yfai-pcn-ext-v1.0
王杰 1 year ago
parent 1c65a74374
commit 09dc9c7200

@ -2,6 +2,7 @@ package 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.MesProdShiftContext;
import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesProductionAssemblyNosortContext;
import cn.estsh.i3plus.pojo.mes.model.StationKvBean;
import cn.estsh.i3plus.pojo.mes.model.StationRequestBean;
import cn.estsh.i3plus.pojo.mes.util.MesExtEnumUtil;
@ -76,4 +77,17 @@ public interface IMesProductionCustomContextStepService {
@ApiOperation(value = "获取生产线的当前班组班次信息")
MesProdShiftContext getMesProdShiftKvBean(String orgainzeCode, String workCenterCode);
@ApiOperation(value = "根据装配件规则ID获取可复用条码")
String getRepeatAssemblySn(String organizeCode, String workCenterCode, String workCellCode, String assemblyNosortCfgId);
@ApiOperation(value = "根据设备代码获取可复用条码的个数")
Integer getRepeatAssemblySnCount(String organizeCode, String workCenterCode, String workCellCode, String equipmentCode);
@ApiOperation(value = "保存可复用条码到上下文")
Boolean saveRepeatAssemblySn(String organizeCode, String workCenterCode, String workCellCode, MesProductionAssemblyNosortContext productionAssemblyNosortContext);
@ApiOperation(value = "删除上下文可复用条码信息")
void deleteRepeatAssemblySn(String organizeCode, String workCenterCode, String workCellCode);
}

@ -1,6 +1,7 @@
package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.busi;
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesAssemblyExtService;
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesProductionCustomContextStepService;
import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesProdRuleContext;
import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesProductionAssemblyNosortContext;
import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesProductionAssemblySortContext;
@ -39,6 +40,9 @@ public class MesAssemblyExtService implements IMesAssemblyExtService {
@Autowired
private MesAssemblyNosortCfgRepository assemblyNosortCfgRepository;
@Autowired
private IMesProductionCustomContextStepService productionCustomContextStepService;
//【排序线】获取生产工单装配件绑定记录
@Override
public List<MesProductionAssemblySortContext> getProductionAssemblySortContextList(MesProdRuleContext prodRuleContext) {
@ -111,7 +115,10 @@ public class MesAssemblyExtService implements IMesAssemblyExtService {
List<MesProductionAssemblyNosortContext> productionAssemblyNosortContextList = new ArrayList<>();
assemblyNosortCfgList.forEach(o -> productionAssemblyNosortContextList.add(new MesProductionAssemblyNosortContext().copy(o, prodRuleContext)));
//遍历装配件规则, 实例化装配件清单对象, 判断是否配置可复用
assemblyNosortCfgList.forEach(o -> productionAssemblyNosortContextList.add(
new MesProductionAssemblyNosortContext().copy(prodRuleContext, o, getRepeatAssemblySn(prodRuleContext.getOrganizeCode(), prodRuleContext.getWorkCenterCode(), prodRuleContext.getWorkCellCode(), o)))
);
return productionAssemblyNosortContextList;
@ -164,4 +171,13 @@ public class MesAssemblyExtService implements IMesAssemblyExtService {
return CollectionUtils.isEmpty(productionAssemblyMap) ? null : productionAssemblyMap.get(id);
}
//验证装配件规则对应的ID是否存在可复用装配件条码
private String getRepeatAssemblySn(String organizeCode, String workCenterCode, String workCellCode, MesAssemblyNosortCfg assemblyNosortCfg) {
if (null == assemblyNosortCfg || StringUtils.isEmpty(assemblyNosortCfg.getIsRepeat()) || assemblyNosortCfg.getIsRepeat().compareTo(CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue()) == 0) return null;
return productionCustomContextStepService.getRepeatAssemblySn(organizeCode, workCenterCode, workCellCode, assemblyNosortCfg.getId().toString());
}
}

@ -41,6 +41,9 @@ public class MesAssemblyGeneratePartNoStepService extends BaseStepService {
private IMesProductionDispatchContextStepService productionDispatchContextStepService;
@Autowired
private IMesProductionCustomContextStepService productionCustomContextStepService;
@Autowired
private IMesNumberRuleMatchDispatchService numberRuleMatchDispatchService;
@Autowired
@ -168,23 +171,32 @@ public class MesAssemblyGeneratePartNoStepService extends BaseStepService {
if (null == productionAssemblyNosortContext) continue;
for (MesEquipVariableCollectContext equipVariableCollectContext : equipVariableCollectContextList) {
//非扫描模式 或者 扫描模式情况下非可复用件
if (equipVariableCollectContextList.get(0).getMessageSource().compareTo(MesExtEnumUtil.CELL_MESSAGE_SOURCE.SCAN.getValue()) != 0 ||
(StringUtils.isEmpty(productionAssemblyNosortContext.getIsRepeat()) || productionAssemblyNosortContext.getIsRepeat().compareTo(CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue()) == 0)) {
for (MesEquipVariableCollectContext equipVariableCollectContext : equipVariableCollectContextList) {
//已被消费
if (null == equipVariableCollectContext || equipVariableCollectContext.getIsConsume().compareTo(CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue()) == 0) continue;
//已被消费
if (null == equipVariableCollectContext || equipVariableCollectContext.getIsConsume().compareTo(CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue()) == 0) continue;
//匹配规则
List<MesProductionAssemblyNosortContext> filterList = (List<MesProductionAssemblyNosortContext>)
numberRuleMatchDispatchService.matchNumberRule(reqBean.getOrganizeCode(), equipVariableCollectContext.getEquipVariableValue(), Stream.of(productionAssemblyNosortContext).collect(Collectors.toList()));
//匹配规则
List<MesProductionAssemblyNosortContext> filterList = (List<MesProductionAssemblyNosortContext>)
numberRuleMatchDispatchService.matchNumberRule(reqBean.getOrganizeCode(), equipVariableCollectContext.getEquipVariableValue(), Stream.of(productionAssemblyNosortContext).collect(Collectors.toList()));
//匹配失败
if (CollectionUtils.isEmpty(filterList)) continue;
//匹配失败
if (CollectionUtils.isEmpty(filterList)) continue;
//装配件清单该数据标记已装配
productionAssemblyNosortContext.assemblyStatus().assemblySn(equipVariableCollectContext.getEquipVariableValue());
//装配件清单该数据标记已装配
productionAssemblyNosortContext.assemblyStatus().assemblySn(equipVariableCollectContext.getEquipVariableValue());
}
}
String getRepeatAssemblySn = getRepeatAssemblySn(reqBean.getOrganizeCode(), reqBean.getWorkCenterCode(), reqBean.getWorkCellCode(), productionAssemblyNosortContext);
if (!StringUtils.isEmpty(getRepeatAssemblySn)) productionAssemblyNosortContext.assemblyStatus().assemblySn(getRepeatAssemblySn);
//判断当前装配件规则是否被成功匹配条码
if (productionAssemblyNosortContext.getAssemblyStatus().compareTo(MesExtEnumUtil.ASSEMBLY_STATUS.ASSEMBLY_STATUS_30.getValue()) == 0) break;
@ -216,5 +228,16 @@ public class MesAssemblyGeneratePartNoStepService extends BaseStepService {
}
//验证装配件规则对应的ID是否存在可复用装配件条码
private String getRepeatAssemblySn(String organizeCode, String workCenterCode, String workCellCode, MesProductionAssemblyNosortContext productionAssemblyNosortContext) {
if (productionAssemblyNosortContext.getAssemblyStatus().compareTo(MesExtEnumUtil.ASSEMBLY_STATUS.ASSEMBLY_STATUS_30.getValue()) != 0) return null;
if (null == productionAssemblyNosortContext || StringUtils.isEmpty(productionAssemblyNosortContext.getIsRepeat()) || productionAssemblyNosortContext.getIsRepeat().compareTo(CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue()) == 0) return null;
return productionCustomContextStepService.getRepeatAssemblySn(organizeCode, workCenterCode, workCellCode, productionAssemblyNosortContext.getSourceId().toString());
}
}

@ -1,6 +1,7 @@
package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.step;
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesProduceSnExtService;
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesProductionCustomContextStepService;
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.*;
@ -41,6 +42,9 @@ public class MesAssemblySaveNosortStepService extends BaseStepService {
private IMesProductionDispatchContextStepService productionDispatchContextStepService;
@Autowired
private IMesProductionCustomContextStepService productionCustomContextStepService;
@Autowired
private MesProductionAssemblyRepository productionAssemblyRepository;
@Autowired
@ -139,6 +143,9 @@ public class MesAssemblySaveNosortStepService extends BaseStepService {
if (!StringUtils.isEmpty(productionAssemblyNosortContext.getProductSnId())) productSnId.add(productionAssemblyNosortContext.getProductSnId());
if (productionAssemblyNosortContext.getIsRepeat2Cache().compareTo(CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue()) == 0)
productionCustomContextStepService.saveRepeatAssemblySn(reqBean.getOrganizeCode(), reqBean.getWorkCenterCode(), reqBean.getWorkCellCode(), productionAssemblyNosortContext);
}
}

@ -4,6 +4,7 @@ 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.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.serviceimpl.fsm.BaseStepService;
import cn.estsh.i3plus.platform.common.tool.TimeTool;
import cn.estsh.i3plus.pojo.base.enumutil.MesPcnEnumUtil;
@ -94,14 +95,19 @@ public class MesAssemblyScanStepService extends BaseStepService {
//没有加工规则代表需要反向匹配出加工规则, 需要根据设备腔数直接批量扫描 生成零件号
if (CollectionUtils.isEmpty(prodRuleContextList)) {
//获取上下文生产扫/读信息:装配件条码
//根据设备代码获取可复用条码的个数
Integer count = productionCustomContextStepService.getRepeatAssemblySnCount(reqBean.getOrganizeCode(), reqBean.getWorkCenterCode(), reqBean.getWorkCellCode(), cellEquipContext.getEquipmentCode());
//获取上下文生产扫/读信息:装配件条码
List<MesEquipVariableCollectContext> cachedEquipVariableCollectContextList = productionDispatchContextStepService.getScanAssemblySnContext(reqBean);
//删除上下文扫/读信息:装配件条码
productionDispatchContextStepService.deleteScanAssemblySnContext(reqBean);
if (!CollectionUtils.isEmpty(cachedEquipVariableCollectContextList) && cachedEquipVariableCollectContextList.size() > needQty)
execSendGuideAndThrowEx(reqBean, resultBean.writeDbLog(), String.format("当前上下文中的装配件条码数量[%s]已经超过设备腔数[%s]每腔个数[%s]配置,请重新扫描装配件条码!", cachedEquipVariableCollectContextList.size(), cellEquipContext.getCavity(), cellEquipContext.getBindQty()));
Integer scanedQty = !CollectionUtils.isEmpty(cachedEquipVariableCollectContextList) ? cachedEquipVariableCollectContextList.size() : MesPcnExtConstWords.ZERO + count;
//判断当前已存在数量是否超过需要数量
if (scanedQty > needQty) execSendGuideAndThrowEx(reqBean, resultBean.writeDbLog(), String.format(
"当前上下文中的可复用条码数量[%s]加上装配件条码数量[%s]已经超过设备腔数[%s]每腔个数[%s]配置,请重新扫描装配件条码!", count, cachedEquipVariableCollectContextList.size(), cellEquipContext.getCavity(), cellEquipContext.getBindQty()));
if (!CollectionUtils.isEmpty(cachedEquipVariableCollectContextList)) {
if (cachedEquipVariableCollectContextList.size() == needQty) equipVariableCollectContextList = cachedEquipVariableCollectContextList;

@ -114,6 +114,7 @@ public class MesProductSnSaveStepService extends BaseStepService {
produceSn.setCraftCode(productionProcessContext.getCraftCode());
//TODO 获取下个工艺代码
//produceSn.setNextCraftCode();
//TODO 重新覆盖打印模版
produceSn.setSnStatus(MesExtEnumUtil.PRODUCE_SN_STATUS.OFFLINE.getValue());
produceSn.setQcStatus(!StringUtils.isEmpty(productResult) ? Integer.valueOf(productResult) : MesExtEnumUtil.PRODUCE_QC_STATUS.QUALIFIED.getValue());

@ -3,6 +3,7 @@ package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.step.context;
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesProductionCustomContextStepService;
import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesCellEquipContext;
import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesProdShiftContext;
import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesProductionAssemblyNosortContext;
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.StationKvBeanUtil;
@ -229,4 +230,39 @@ public class MesProductionCustomContextStepService extends BaseStepService imple
deleteFsmBusiData(reqBean.getOrganizeCode(), getProductionStatisticsContextKey(reqBean), MesPcnExtConstWords.PRODUCTION_STATISTICS_CONTEXT);
}
//工位加工锁KEY
private String getRepeatAssemblySnContextKey(String organizeCode, String workCenterCode, String workCellCode) {
return new StringJoiner(MesPcnExtConstWords.COLON).add(organizeCode).add(MesPcnExtConstWords.PRODUCTION_PROCESS_CONTEXT).add(MesPcnExtConstWords.REPEAT_ASSEMBLY_SN_CONTEXT).add(workCenterCode).add(workCellCode).toString();
}
//根据装配件规则ID获取可复用条码
@Override
public String getRepeatAssemblySn(String organizeCode, String workCenterCode, String workCellCode, String assemblyNosortCfgId) {
String repeatAssemblySnJson = getFsmBusiData(organizeCode, getRepeatAssemblySnContextKey(organizeCode, workCenterCode, workCellCode), assemblyNosortCfgId);
MesProductionAssemblyNosortContext productionAssemblyNosortContext = !StringUtils.isEmpty(repeatAssemblySnJson) ? JSONObject.parseObject(repeatAssemblySnJson, MesProductionAssemblyNosortContext.class) : null;
return null != productionAssemblyNosortContext ? productionAssemblyNosortContext.getAssemblySn() : null;
}
//根据设备代码获取可复用条码的个数
@Override
public Integer getRepeatAssemblySnCount(String organizeCode, String workCenterCode, String workCellCode, String equipmentCode) {
String countStr = getFsmBusiData(organizeCode, getRepeatAssemblySnContextKey(organizeCode, workCenterCode, workCellCode), equipmentCode);
return !StringUtils.isEmpty(countStr) ? Integer.valueOf(countStr) : MesPcnExtConstWords.ZERO;
}
//根据装配件规则ID获取可复用条码
@Override
public Boolean saveRepeatAssemblySn(String organizeCode, String workCenterCode, String workCellCode, MesProductionAssemblyNosortContext productionAssemblyNosortContext) {
Integer count = getRepeatAssemblySnCount(organizeCode, workCenterCode, workCellCode, productionAssemblyNosortContext.getEquipmentCode()) + 1;
saveFsmBusiData(organizeCode, getRepeatAssemblySnContextKey(organizeCode, workCenterCode, workCellCode), productionAssemblyNosortContext.getEquipmentCode(), count.toString());
return saveFsmBusiData(organizeCode, getRepeatAssemblySnContextKey(organizeCode, workCenterCode, workCellCode), productionAssemblyNosortContext.getSourceId().toString(), JSONObject.toJSONString(productionAssemblyNosortContext));
}
//删除上下文可复用条码信息
@Override
public void deleteRepeatAssemblySn(String organizeCode, String workCenterCode, String workCellCode) {
deleteFsmBusiData(organizeCode, getRepeatAssemblySnContextKey(organizeCode, workCenterCode, workCellCode));
}
}

@ -4,6 +4,7 @@ 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.pojo.util.MesPcnExtConstWords;
import cn.estsh.i3plus.mes.pcn.serviceimpl.fsm.process.BaseProcessMonitorService;
import cn.estsh.i3plus.pojo.base.codemaker.SnowflakeIdMaker;
import cn.estsh.i3plus.pojo.base.enumutil.MesPcnEnumUtil;
import cn.estsh.i3plus.pojo.mes.model.StationRequestBean;
import cn.estsh.i3plus.pojo.mes.model.StationResultBean;
@ -21,9 +22,22 @@ public class MesProductionProcessMonitorService extends BaseProcessMonitorServic
@Autowired
private IMesProductionCustomContextStepService productionCustomContextStepService;
@Autowired
private SnowflakeIdMaker snowflakeIdMaker;
@Override
public Boolean doProcessStart(StationRequestBean requestBean) {
return super.doProcessStart(requestBean);
Long mouldId = snowflakeIdMaker.nextId();
return true;
}
@Override

@ -1,6 +1,7 @@
package cn.estsh.i3plus.ext.mes.pcn.pojo.context;
import cn.estsh.i3plus.ext.mes.pcn.pojo.util.MesPcnExtConstWords;
import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
import cn.estsh.i3plus.pojo.mes.bean.MesAssemblyNosortCfg;
import cn.estsh.i3plus.pojo.mes.util.MesExtEnumUtil;
import io.swagger.annotations.ApiParam;
@ -24,6 +25,9 @@ public class MesProductionAssemblyNosortContext extends MesProductionAssemblyCon
@ApiParam(value = "是否可复用条码")
private Integer isRepeat;
@ApiParam(value = "是否可复用条码是否写入上下文进行复用")
private Integer isRepeat2Cache = CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue();
@ApiParam(value = "是否忽略回车")
private Integer isIgnoreEntry;
@ -32,7 +36,7 @@ public class MesProductionAssemblyNosortContext extends MesProductionAssemblyCon
public MesProductionAssemblyNosortContext() {}
public MesProductionAssemblyNosortContext copy(MesAssemblyNosortCfg assemblyNosortCfg, MesProdRuleContext prodRuleContext) {
public MesProductionAssemblyNosortContext copy(MesProdRuleContext prodRuleContext, MesAssemblyNosortCfg assemblyNosortCfg, String assemblySn) {
BeanUtils.copyProperties(assemblyNosortCfg, this);
BeanUtils.copyProperties(prodRuleContext, this);
this.sourceId = assemblyNosortCfg.getId();
@ -41,6 +45,11 @@ public class MesProductionAssemblyNosortContext extends MesProductionAssemblyCon
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();
if (!StringUtils.isEmpty(assemblySn)) {
this.assemblySn = assemblySn;
this.isRepeat2Cache = CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue();
this.assemblyStatus = MesExtEnumUtil.ASSEMBLY_STATUS.ASSEMBLY_STATUS_10.getValue();
}
return this;
}

@ -279,4 +279,5 @@ public class MesProductionProcessContext implements Serializable {
this.cavityGroupDetailJson = JSONObject.toJSONString(mesCavityGroupDetailCfgs);
return this.isNeedCache();
}
}

@ -267,6 +267,8 @@ public class MesPcnExtConstWords {
public static final String PROD_SHIFT_DATA_CONTEXT = "PROD_SHIFT_DATA_CONTEXT";
// 上下文: 加工统计信息
public static final String PRODUCTION_STATISTICS_CONTEXT = "PRODUCTION_STATISTICS_CONTEXT";
// 可复用装配件条码上下文
public static final String REPEAT_ASSEMBLY_SN_CONTEXT = "REPEAT_ASSEMBLY_SN_CONTEXT";
// 上下文: 展示组件数据
public static final String MODULE_CONTENT_CONTEXT = "MODULE_CONTENT_CONTEXT";

Loading…
Cancel
Save