|
|
|
@ -29,7 +29,7 @@ import java.util.stream.Collectors;
|
|
|
|
|
import java.util.stream.Stream;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @Description : 容器扣减匹配装配件站点工步
|
|
|
|
|
* @Description : 站点匹配装配件工步
|
|
|
|
|
* @Author : wangjie
|
|
|
|
|
**/
|
|
|
|
|
@Slf4j
|
|
|
|
@ -72,26 +72,26 @@ public class MesStationMatchAssemblyStepService extends BaseStepService {
|
|
|
|
|
Optional<MesProdRuleContext> optional = prodRuleContextList.stream().filter(o -> (null != o && !StringUtils.isEmpty(o.getIsMatchContainer()))).findFirst();
|
|
|
|
|
if (null == optional || !optional.isPresent()) {
|
|
|
|
|
return stepDynamicsCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog(), stepResult, true,
|
|
|
|
|
MesPcnEnumUtil.STATION_BUSI_TYPE.RUNNING_INFO, MesPcnEnumUtil.STATION_DATA_TYPE.TEXT, "验证每腔不存在容器匹配的装配件,默认跳过容器扣减匹配站点!");
|
|
|
|
|
MesPcnEnumUtil.STATION_BUSI_TYPE.RUNNING_INFO, MesPcnEnumUtil.STATION_DATA_TYPE.TEXT, "验证每腔不存在容器匹配的装配件,默认跳过站点匹配装配件!");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//处理设备站点【装配件站点&&混料站点】
|
|
|
|
|
List<MesStation> stationList = productionProcessContextStepService.dispatchEquipmentStationContext(reqBean, productionProcessContext.getCurCellEquip().getEquipmentCode(),
|
|
|
|
|
Stream.of(MesExtEnumUtil.STATION_TYPE.STATION_TYPE_20.getValue(), MesExtEnumUtil.STATION_TYPE.STATION_TYPE_40.getValue()).collect(Collectors.toList()));
|
|
|
|
|
|
|
|
|
|
if (CollectionUtils.isEmpty(stationList)) stepExpSendMsgAndThrowEx(reqBean, resultBean.writeDbLog(), "容器条码扣减装配件时验证设备未关联支持扣减的站点");
|
|
|
|
|
if (CollectionUtils.isEmpty(stationList)) stepExpSendMsgAndThrowEx(reqBean, resultBean.writeDbLog(), "站点匹配装配件时验证设备未关联支持扣减的站点");
|
|
|
|
|
|
|
|
|
|
//保存站点用于缺料时进行上料绑定
|
|
|
|
|
productionDispatchContextStepService.dispatchMatchStationContext(reqBean, stationList);
|
|
|
|
|
|
|
|
|
|
//获取容器条码上料明细表信息【可扣减】【根据 主表seq,主表createDatetime,明细表createDatetime 正序】
|
|
|
|
|
List<MesContainerPackageDetailContext> containerSnStationList = stationContainerSnExtService.getContainerSnStationContext(reqBean.getOrganizeCode(), stationList);
|
|
|
|
|
List<MesContainerPackageDetailContext> containerPackageDetailContextList = stationContainerSnExtService.getContainerPackageDetailContext(reqBean.getOrganizeCode(), stationList);
|
|
|
|
|
|
|
|
|
|
if (CollectionUtils.isEmpty(containerSnStationList)) return stepNonCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog(),
|
|
|
|
|
stepResult.nextTriggerEvent(MesPcnExtConstWords.NEXT_TRIGGER_EVENT_FEEDING), "容器条码扣减装配件时验证当前无可扣减的原材料信息!");
|
|
|
|
|
if (CollectionUtils.isEmpty(containerPackageDetailContextList)) return stepNonCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog(),
|
|
|
|
|
stepResult.nextTriggerEvent(MesPcnExtConstWords.NEXT_TRIGGER_EVENT_FEEDING), "站点匹配装配件时验证当前无可扣减的原材料信息!");
|
|
|
|
|
|
|
|
|
|
//将可扣减的条码进行原子性缓存, 并获取最新的实际库存
|
|
|
|
|
productionCustomContextStepService.dispatchContainerSnAtomicity(reqBean.getOrganizeCode(), containerSnStationList);
|
|
|
|
|
productionCustomContextStepService.dispatchContainerPackageDetailAtomicity(reqBean.getOrganizeCode(), containerPackageDetailContextList);
|
|
|
|
|
|
|
|
|
|
//获取弹框输入的工单数量, 未弹框默认 数量=1
|
|
|
|
|
Double orderQtyDialogContext = productionDispatchContextStepService.getOrderQtyDialogContext(reqBean);
|
|
|
|
@ -102,7 +102,7 @@ public class MesStationMatchAssemblyStepService extends BaseStepService {
|
|
|
|
|
Map<String, MesStation> stationMap2Lock = new HashMap<>();
|
|
|
|
|
|
|
|
|
|
//匹配装配件的工序用量
|
|
|
|
|
dispatchStationMatchAssembly(reqBean, resultBean, stepResult, workCenter, prodRuleContextList, containerSnStationList, orderQtyDialogContext, stationMap2Lock);
|
|
|
|
|
dispatchStationMatchAssembly(reqBean, resultBean, stepResult, workCenter, prodRuleContextList, containerPackageDetailContextList, orderQtyDialogContext, stationMap2Lock);
|
|
|
|
|
|
|
|
|
|
if (!stepResult.isCompleted()) return stepNonCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog(), stepResult.nextTriggerEvent(MesPcnExtConstWords.NEXT_TRIGGER_EVENT_FEEDING), stepResult.getMsg());
|
|
|
|
|
|
|
|
|
@ -117,16 +117,16 @@ public class MesStationMatchAssemblyStepService extends BaseStepService {
|
|
|
|
|
((MesAssemblyShowSortStepService) SpringContextsUtil.getBean("mesAssemblyShowSortStepService")).showProductionAssembly(reqBean, resultBean, workCenter, prodRuleContextList, true, true);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return stepSuccessCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog(), stepResult, "容器条码扣减装配件验证成功!");
|
|
|
|
|
return stepSuccessCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog(), stepResult, "站点匹配装配件验证成功!");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//匹配装配件的工序用量【遍历加工规则】
|
|
|
|
|
private void dispatchStationMatchAssembly(StationRequestBean reqBean, StationResultBean resultBean, StepResult stepResult, MesWorkCenter workCenter,
|
|
|
|
|
List<MesProdRuleContext> prodRuleContextList, List<MesContainerPackageDetailContext> containerSnStationList,
|
|
|
|
|
List<MesProdRuleContext> prodRuleContextList, List<MesContainerPackageDetailContext> containerPackageDetailContextList,
|
|
|
|
|
Double orderQtyDialogContext, Map<String, MesStation> stationMap2Lock) {
|
|
|
|
|
for (MesProdRuleContext prodRuleContext : prodRuleContextList) {
|
|
|
|
|
if (null == prodRuleContext || StringUtils.isEmpty(prodRuleContext.getIsMatchContainer())) continue;
|
|
|
|
|
List<MesProductionAssemblyContext> productionAssemblyContextList = dispatchStationMatchAssembly(reqBean, resultBean, stepResult, workCenter, prodRuleContext, containerSnStationList, orderQtyDialogContext, stationMap2Lock);
|
|
|
|
|
List<MesProductionAssemblyContext> productionAssemblyContextList = dispatchStationMatchAssembly(reqBean, resultBean, stepResult, workCenter, prodRuleContext, containerPackageDetailContextList, orderQtyDialogContext, stationMap2Lock);
|
|
|
|
|
if (!stepResult.isCompleted()) break;
|
|
|
|
|
prodRuleContext.assemblyDataJson(productionAssemblyContextList);
|
|
|
|
|
}
|
|
|
|
@ -134,7 +134,7 @@ public class MesStationMatchAssemblyStepService extends BaseStepService {
|
|
|
|
|
|
|
|
|
|
//匹配装配件的工序用量【遍历装配件】
|
|
|
|
|
private List<MesProductionAssemblyContext> dispatchStationMatchAssembly(StationRequestBean reqBean, StationResultBean resultBean, StepResult stepResult, MesWorkCenter workCenter,
|
|
|
|
|
MesProdRuleContext prodRuleContext, List<MesContainerPackageDetailContext> containerSnStationList,
|
|
|
|
|
MesProdRuleContext prodRuleContext, List<MesContainerPackageDetailContext> containerPackageDetailContextList,
|
|
|
|
|
Double orderQtyDialogContext, Map<String, MesStation> stationMap2Lock) {
|
|
|
|
|
List<MesProductionAssemblyContext> productionAssemblyContextList = prodRuleContext.getAssemblyDataContext(workCenter);
|
|
|
|
|
for (MesProductionAssemblyContext productionAssemblyContext : productionAssemblyContextList) {
|
|
|
|
@ -145,11 +145,13 @@ public class MesStationMatchAssemblyStepService extends BaseStepService {
|
|
|
|
|
|
|
|
|
|
//未匹配的工序用量
|
|
|
|
|
Double unMatchQty = MathOperation.mul(productionAssemblyContext.getQty(), orderQtyDialogContext);
|
|
|
|
|
List<String> containerSnDataList = null;
|
|
|
|
|
List<String> containerSnList = null;
|
|
|
|
|
for (MesContainerPackageDetailContext containerPackageDetailContext : containerSnStationList) {
|
|
|
|
|
//支持被扣减的原料条码
|
|
|
|
|
List<MesContainerPackageDetailContext> containerSnDataList = null;
|
|
|
|
|
//用于给装配件清单赋值
|
|
|
|
|
List<String> barCodeList = null;
|
|
|
|
|
for (MesContainerPackageDetailContext containerPackageDetailContext : containerPackageDetailContextList) {
|
|
|
|
|
if (null == containerPackageDetailContext || StringUtils.isEmpty(containerPackageDetailContext.getPartNo())) continue;
|
|
|
|
|
if (!containerPackageDetailContext.getPartNo().equals(productionAssemblyContext.getPartNo()) || MathOperation.compareTo(containerPackageDetailContext.getRemainQty(), new Double(0)) <= 0) continue;
|
|
|
|
|
if (!containerPackageDetailContext.getPartNo().equals(productionAssemblyContext.getAssemblyPartNo()) || MathOperation.compareTo(containerPackageDetailContext.getRemainQty(), new Double(0)) <= 0) continue;
|
|
|
|
|
|
|
|
|
|
//验证时效性
|
|
|
|
|
Map<String, Object> result = timeEfficientCfgMatchService.checkSnTimelinessContainerMatch(reqBean.getOrganizeCode(), containerPackageDetailContext,
|
|
|
|
@ -173,10 +175,10 @@ public class MesStationMatchAssemblyStepService extends BaseStepService {
|
|
|
|
|
//将能够扣减的所有条码跟当前装配件关联
|
|
|
|
|
if (CollectionUtils.isEmpty(containerSnDataList)) {
|
|
|
|
|
containerSnDataList = new ArrayList<>();
|
|
|
|
|
containerSnList = new ArrayList<>();
|
|
|
|
|
barCodeList = new ArrayList<>();
|
|
|
|
|
}
|
|
|
|
|
containerSnDataList.add(productionCustomContextStepService.getContainerSnAtomicityKey(reqBean.getOrganizeCode(), containerPackageDetailContext));
|
|
|
|
|
containerSnList.add(containerPackageDetailContext.getContainerSn());
|
|
|
|
|
containerSnDataList.add(containerPackageDetailContext);
|
|
|
|
|
barCodeList.add(containerPackageDetailContext.getBarCode());
|
|
|
|
|
if (!stationMap2Lock.containsKey(containerPackageDetailContext.getStation())) stationMap2Lock.put(containerPackageDetailContext.getStation(), containerPackageDetailContext.getStationInfo());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -186,11 +188,11 @@ public class MesStationMatchAssemblyStepService extends BaseStepService {
|
|
|
|
|
productionAssemblyContext.setAssemblySn(null);
|
|
|
|
|
productionAssemblyContext.setMatchDatetime(null);
|
|
|
|
|
}
|
|
|
|
|
stepResult.isCompleted(false).msg(String.format("容器条码扣减装配件时验证零件号[%s]当前缺料,请扫描上料条码!", productionAssemblyContext.getPartNo()));
|
|
|
|
|
stepResult.isCompleted(false).msg(String.format("站点匹配装配件时验证零件号[%s]当前缺料,请扫描上料条码!", productionAssemblyContext.getPartNo()));
|
|
|
|
|
break;
|
|
|
|
|
} else {
|
|
|
|
|
productionAssemblyContext.setAssemblyStatus(MesExtEnumUtil.ASSEMBLY_STATUS.ASSEMBLY_STATUS_10.getValue());
|
|
|
|
|
productionAssemblyContext.setAssemblySn(containerSnList.get(0));
|
|
|
|
|
productionAssemblyContext.setAssemblySn(barCodeList.get(0));
|
|
|
|
|
productionAssemblyContext.setMatchDatetime((new SimpleDateFormat(MesPcnExtConstWords.DATE_FORMAT_SSS)).format(new Date()));
|
|
|
|
|
productionAssemblyContext.setContainerSnData(JSONObject.toJSONString(containerSnDataList));
|
|
|
|
|
}
|
|
|
|
|