吸塑扣减装配件工步

mes-uat-changshu0609-temp-wj-250616-xisu
王杰 4 weeks ago
commit 1ebc9037bc

@ -132,9 +132,15 @@ public interface IMesProductionCustomContextStepService {
MesWorkOrderCompleteQtyContext dispatchWorkOrderCompleteQtyContext(StationRequestBean reqBean, Boolean noCalcOrderQty, String workOrderNo, Double calcCompleteQty); MesWorkOrderCompleteQtyContext dispatchWorkOrderCompleteQtyContext(StationRequestBean reqBean, Boolean noCalcOrderQty, String workOrderNo, Double calcCompleteQty);
@ApiOperation(value = "可扣减条码的缓存key") @ApiOperation(value = "可扣减条码的缓存key")
String getContainerSnAtomicityKey(String organizeCode, MesContainerPackageDetailContext context); String getContainerPackageDetailAtomicityKey(String organizeCode, MesContainerPackageDetailContext context);
@ApiOperation(value = "获取缓存中的原料剩余数量,用于缓存扣减")
Double getContainerPackageDetailRemainQty(String organizeCode, String key);
@ApiOperation(value = "将可扣减的条码通过原子性的方式写到缓存, 并获取最新的实际库存") @ApiOperation(value = "将可扣减的条码通过原子性的方式写到缓存, 并获取最新的实际库存")
void dispatchContainerSnAtomicity(String organizeCode, List<MesContainerPackageDetailContext> containerSnStationList); List<MesContainerPackageDetailContext> dispatchContainerPackageDetailAtomicity(String organizeCode, List<MesContainerPackageDetailContext> containerPackageDetailContextList);
@ApiOperation(value = "重置原料条码的缓存库存")
void dispatchContainerPackageDetailContext(String organizeCode, Map<String, MesContainerPackageDetailContext> remainQtyMap2Cache);
} }

@ -25,7 +25,7 @@ public interface IMesStationContainerSnExtService {
List<MesContainerSnStation> getContainerSnStationListByStation(String organizeCode, List<String> stationList); List<MesContainerSnStation> getContainerSnStationListByStation(String organizeCode, List<String> stationList);
@ApiOperation(value = "获取容器条码上料明细表信息【可扣减】【根据 主表seq,主表createDatetime,明细表createDatetime 正序】") @ApiOperation(value = "获取容器条码上料明细表信息【可扣减】【根据 主表seq,主表createDatetime,明细表createDatetime 正序】")
List<MesContainerPackageDetailContext> getContainerSnStationContext(String organizeCode, List<MesStation> stationList); List<MesContainerPackageDetailContext> getContainerPackageDetailContext(String organizeCode, List<MesStation> stationList);
@ApiOperation(value = "获取容器条码上料主表信息") @ApiOperation(value = "获取容器条码上料主表信息")
List<MesContainerPackage> getContainerPackageList(String organizeCode, List<MesContainerSnStation> containerSnStationList, Integer packageStatus); List<MesContainerPackage> getContainerPackageList(String organizeCode, List<MesContainerSnStation> containerSnStationList, Integer packageStatus);

@ -85,7 +85,7 @@ public class MesStationContainerSnExtService implements IMesStationContainerSnEx
//获取容器条码上料明细表信息【可扣减】【根据 主表seq,主表createDatetime,明细表createDatetime 正序】 //获取容器条码上料明细表信息【可扣减】【根据 主表seq,主表createDatetime,明细表createDatetime 正序】
@Override @Override
@Transactional(propagation = Propagation.NOT_SUPPORTED) @Transactional(propagation = Propagation.NOT_SUPPORTED)
public List<MesContainerPackageDetailContext> getContainerSnStationContext(String organizeCode, List<MesStation> stationList) { public List<MesContainerPackageDetailContext> getContainerPackageDetailContext(String organizeCode, List<MesStation> stationList) {
//获取站点关联的容器条码, key = containerSn //获取站点关联的容器条码, key = containerSn
Map<String, List<MesContainerSnStation>> containerSnStationMap = getContainerSnStationMap(organizeCode, stationList); Map<String, List<MesContainerSnStation>> containerSnStationMap = getContainerSnStationMap(organizeCode, stationList);
if (CollectionUtils.isEmpty(containerSnStationMap)) return null; if (CollectionUtils.isEmpty(containerSnStationMap)) return null;

@ -3,17 +3,22 @@ package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.step;
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesProductionCustomContextStepService; 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.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.api.busi.IMesStationContainerSnExtService; import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesContainerPackageDetailContext;
import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesProdRuleContext; import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesProdRuleContext;
import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesProductionAssemblyContext;
import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesProductionProcessContext; 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.actor.shipping.dispatch.IFsmCommonService; import cn.estsh.i3plus.mes.pcn.actor.shipping.dispatch.IFsmCommonService;
import cn.estsh.i3plus.mes.pcn.serviceimpl.fsm.BaseStepService; import cn.estsh.i3plus.mes.pcn.serviceimpl.fsm.BaseStepService;
import cn.estsh.i3plus.platform.common.tool.MathOperation;
import cn.estsh.i3plus.pojo.base.enumutil.MesPcnEnumUtil; import cn.estsh.i3plus.pojo.base.enumutil.MesPcnEnumUtil;
import cn.estsh.i3plus.pojo.mes.bean.MesStation; import cn.estsh.i3plus.pojo.mes.bean.MesStation;
import cn.estsh.i3plus.pojo.mes.bean.MesWorkCenter;
import cn.estsh.i3plus.pojo.mes.model.StationRequestBean; import cn.estsh.i3plus.pojo.mes.model.StationRequestBean;
import cn.estsh.i3plus.pojo.mes.model.StationResultBean; import cn.estsh.i3plus.pojo.mes.model.StationResultBean;
import cn.estsh.i3plus.pojo.mes.model.StepResult; import cn.estsh.i3plus.pojo.mes.model.StepResult;
import cn.estsh.i3plus.pojo.mes.util.MesExtEnumUtil;
import com.alibaba.fastjson.JSONObject;
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;
@ -43,9 +48,6 @@ public class MesStationDeductionAssemblyStepService extends BaseStepService {
private IMesProductionCustomContextStepService productionCustomContextStepService; private IMesProductionCustomContextStepService productionCustomContextStepService;
@Autowired @Autowired
private IMesStationContainerSnExtService stationContainerSnExtService;
@Autowired
private IFsmCommonService fsmCommonService; private IFsmCommonService fsmCommonService;
private final static Map<String, ReentrantLock> lockMap = new ConcurrentHashMap<>(); private final static Map<String, ReentrantLock> lockMap = new ConcurrentHashMap<>();
@ -99,6 +101,11 @@ public class MesStationDeductionAssemblyStepService extends BaseStepService {
List<String> stationNameList = CollectionUtils.isEmpty(stationMap2Lock) ? null : new ArrayList<>(stationMap2Lock.keySet()); List<String> stationNameList = CollectionUtils.isEmpty(stationMap2Lock) ? null : new ArrayList<>(stationMap2Lock.keySet());
if (CollectionUtils.isEmpty(stationNameList)) stepExpSendMsgAndThrowEx(reqBean, resultBean.writeDbLog(), "当前未获取到缓存的扣料站点信息,请重置工序解决!"); if (CollectionUtils.isEmpty(stationNameList)) stepExpSendMsgAndThrowEx(reqBean, resultBean.writeDbLog(), "当前未获取到缓存的扣料站点信息,请重置工序解决!");
MesWorkCenter workCenter = productionProcessContext.getWorkCenter();
//获取弹框输入的工单数量, 未弹框默认 数量=1
Double orderQtyDialogContext = productionDispatchContextStepService.getOrderQtyDialogContext(reqBean);
List<ReentrantLock> acquiredLocks = new ArrayList<>(); List<ReentrantLock> acquiredLocks = new ArrayList<>();
try { try {
if (!tryLock(acquiredLocks, stationNameList)) { if (!tryLock(acquiredLocks, stationNameList)) {
@ -106,9 +113,16 @@ public class MesStationDeductionAssemblyStepService extends BaseStepService {
MesPcnEnumUtil.STATION_BUSI_TYPE.RUNNING_INFO, MesPcnEnumUtil.STATION_DATA_TYPE.TEXT, "站点扣减装配件扣减失败,即将重试!"); MesPcnEnumUtil.STATION_BUSI_TYPE.RUNNING_INFO, MesPcnEnumUtil.STATION_DATA_TYPE.TEXT, "站点扣减装配件扣减失败,即将重试!");
} }
//用于重置原料条码的缓存库存
Map<String, MesContainerPackageDetailContext> remainQtyMap2Cache = new HashMap<>();
//执行容器装配件的缓存扣减
dispatchStationDeductionAssembly(reqBean, resultBean, stepResult, workCenter, prodRuleContextList, orderQtyDialogContext, remainQtyMap2Cache);
if (!stepResult.isCompleted()) return stepNonCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog(), stepResult.nextTriggerEvent(MesPcnExtConstWords.NEXT_TRIGGER_EVENT_FEEDING), stepResult.getMsg());
//重置原料条码的缓存库存
productionCustomContextStepService.dispatchContainerPackageDetailContext(reqBean.getOrganizeCode(), remainQtyMap2Cache);
} catch (InterruptedException e) { } catch (InterruptedException e) {
@ -117,10 +131,96 @@ public class MesStationDeductionAssemblyStepService extends BaseStepService {
unLockAll(acquiredLocks); unLockAll(acquiredLocks);
} }
return stepResult; return stepSuccessCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog(), stepResult, "站点扣减装配件验证成功!");
}
//执行容器装配件的缓存扣减
private void dispatchStationDeductionAssembly(StationRequestBean reqBean, StationResultBean resultBean, StepResult stepResult, MesWorkCenter workCenter,
List<MesProdRuleContext> prodRuleContextList, Double orderQtyDialogContext, Map<String, MesContainerPackageDetailContext> remainQtyMap2Cache) {
for (MesProdRuleContext prodRuleContext : prodRuleContextList) {
if (null == prodRuleContext || StringUtils.isEmpty(prodRuleContext.getIsMatchContainer())) continue;
List<MesProductionAssemblyContext> productionAssemblyContextList = dispatchStationDeductionAssembly(reqBean, resultBean, stepResult, workCenter, prodRuleContext, orderQtyDialogContext, remainQtyMap2Cache);
if (!stepResult.isCompleted()) break;
prodRuleContext.assemblyDataJson(productionAssemblyContextList);
}
} }
//执行容器装配件的缓存扣减
private List<MesProductionAssemblyContext> dispatchStationDeductionAssembly(StationRequestBean reqBean, StationResultBean resultBean, StepResult stepResult, MesWorkCenter workCenter,
MesProdRuleContext prodRuleContext, Double orderQtyDialogContext, Map<String, MesContainerPackageDetailContext> remainQtyMap2Cache) {
List<MesProductionAssemblyContext> productionAssemblyContextList = prodRuleContext.getAssemblyDataContext(workCenter);
for (MesProductionAssemblyContext productionAssemblyContext : productionAssemblyContextList) {
if (null == productionAssemblyContext || productionAssemblyContext.getMatchType().compareTo(MesExtEnumUtil.ASSEMBLY_MATCH_TYPE.MATCH_TYPE_80.getValue()) != 0) continue;
//未匹配的工序用量
Double unMatchQty = MathOperation.mul(productionAssemblyContext.getQty(), orderQtyDialogContext);
//扣料原料条码信息
List<MesContainerPackageDetailContext> deductionContextList = null;
//用于给装配件清单赋值
List<String> barCodeList = null;
//解析前面预先匹配的能够进行扣减的原料条码
List<MesContainerPackageDetailContext> containerSnDataList = JSONObject.parseArray(productionAssemblyContext.getContainerSnData(), MesContainerPackageDetailContext.class);
for (MesContainerPackageDetailContext containerPackageDetailContext : containerSnDataList) {
if (StringUtils.isEmpty(containerPackageDetailContext)) continue;
//获取缓存中的原料剩余数量,用于缓存扣减
Double remainQtyCache;
if (!remainQtyMap2Cache.containsKey(containerPackageDetailContext.getRemainKey())) {
remainQtyCache = productionCustomContextStepService.getContainerPackageDetailRemainQty(reqBean.getOrganizeCode(), containerPackageDetailContext.getRemainKey());
remainQtyMap2Cache.put(containerPackageDetailContext.getRemainKey(), new MesContainerPackageDetailContext(containerPackageDetailContext).remainQtyCached(remainQtyCache).remainQty(remainQtyCache));
} else {
remainQtyCache = remainQtyMap2Cache.get(containerPackageDetailContext.getRemainKey()).getRemainQty();
}
//当前原料条码已经扣减完成
if (MathOperation.compareTo(remainQtyCache, new Double(0)) <= 0) continue;
//剩余未匹配的工序用量
Double remainQty = MathOperation.sub(remainQtyCache, unMatchQty);
//全部匹配完成
if (MathOperation.compareTo(remainQty, new Double(0)) >= 0) {
remainQtyMap2Cache.get(containerPackageDetailContext.getRemainKey()).remainQty(remainQty);
unMatchQty = new Double(0);
} else {
//未匹配完成, 0-负数=正数
remainQtyMap2Cache.get(containerPackageDetailContext.getRemainKey()).remainQty(new Double(0));
unMatchQty = MathOperation.sub(new Double(0), remainQty);
}
if (CollectionUtils.isEmpty(deductionContextList)) {
deductionContextList = new ArrayList<>();
barCodeList = new ArrayList<>();
}
deductionContextList.add(new MesContainerPackageDetailContext(containerPackageDetailContext).deductionQty(MathOperation.sub(remainQtyCache, remainQtyMap2Cache.get(containerPackageDetailContext.getRemainKey()).getRemainQty())));
barCodeList.add(containerPackageDetailContext.getBarCode());
//如果存在未匹配的工序用量
if (MathOperation.compareTo(unMatchQty, new Double(0)) <= 0) break;
}
if (MathOperation.compareTo(unMatchQty, new Double(0)) > 0) {
if (!StringUtils.isEmpty(productionAssemblyContext.getAssemblySn())) {
productionAssemblyContext.setAssemblyStatus(MesExtEnumUtil.ASSEMBLY_STATUS.ASSEMBLY_STATUS_30.getValue());
productionAssemblyContext.setAssemblySn(null);
productionAssemblyContext.setMatchDatetime(null);
}
stepResult.isCompleted(false).msg(String.format("站点扣减装配件时验证零件号[%s]当前缺料,请扫描上料条码!", productionAssemblyContext.getPartNo()));
break;
} else {
productionAssemblyContext.setAssemblySn(barCodeList.get(0));
productionAssemblyContext.setContainerSnData(JSONObject.toJSONString(deductionContextList));
}
}
return productionAssemblyContextList;
}
private Boolean tryLock(List<ReentrantLock> acquiredLocks, List<String> stationNameList) throws InterruptedException { private Boolean tryLock(List<ReentrantLock> acquiredLocks, List<String> stationNameList) throws InterruptedException {

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

@ -396,26 +396,49 @@ public class MesProductionCustomContextStepService extends BaseStepService imple
return workOrderCompleteQtyContext; return workOrderCompleteQtyContext;
} }
//可扣减条码的缓存key
@Override @Override
public String getContainerSnAtomicityKey(String organizeCode, MesContainerPackageDetailContext context) { public String getContainerPackageDetailAtomicityKey(String organizeCode, MesContainerPackageDetailContext context) {
return new StringJoiner(MesPcnExtConstWords.COLON) return new StringJoiner(MesPcnExtConstWords.COLON)
.add(organizeCode) .add(organizeCode)
.add(MesPcnExtConstWords.CONTAINER_SN_REMAIN_CONTEXT) .add(MesPcnExtConstWords.CONTAINER_SN_REMAIN_CONTEXT)
.add(context.getStation()) .add(context.getStation())
.add(new StringJoiner(MesPcnExtConstWords.AND).add(context.getContainerSn()).add(context.getId().toString()).toString()) .add(context.getContainerSn())
.add(new StringJoiner(MesPcnExtConstWords.AND).add(context.getBarCode()).add(context.getId().toString()).toString())
.toString(); .toString();
} }
//将可扣减的条码通过原子性的方式写到缓存, 并获取最新的实际库存 //获取缓存中的原料信息,用于缓存扣减
@Override @Override
public void dispatchContainerSnAtomicity(String organizeCode, List<MesContainerPackageDetailContext> containerSnStationList) { public Double getContainerPackageDetailRemainQty(String organizeCode, String key) {
if (StringUtils.isEmpty(organizeCode) || CollectionUtils.isEmpty(containerSnStationList)) return; String remainQty = getFsmBusiData(organizeCode, key);
// containerSnStationList.stream().forEach(o -> { return StringUtils.isEmpty(remainQty) ? new Double(0) : new Double(remainQty);
// String key = getContainerSnAtomicityKey(organizeCode, o);
// Boolean success = dispatchFsmBusiDataAtomicity(organizeCode, key, o.getQty().toString(), MesPcnEnumUtil.EXPIRE_TIME.DEFAULT.getValue());
// if (success) o.remainQty(o.getQty());
// else o.remainQty(getFsmBusiData(organizeCode, key));
// });
} }
//将可扣减的条码通过原子性的方式写到缓存, 并获取最新的实际库存
@Override
public List<MesContainerPackageDetailContext> dispatchContainerPackageDetailAtomicity(String organizeCode, List<MesContainerPackageDetailContext> containerPackageDetailContextList) {
if (StringUtils.isEmpty(organizeCode) || CollectionUtils.isEmpty(containerPackageDetailContextList)) return containerPackageDetailContextList;
containerPackageDetailContextList.stream().forEach(o -> {
String remainKey = getContainerPackageDetailAtomicityKey(organizeCode, o);
Boolean success = dispatchFsmBusiDataAtomicity(organizeCode, remainKey, o.getQty().toString(), MesPcnEnumUtil.EXPIRE_TIME.DEFAULT.getValue());
o.remainKey(remainKey);
if (success) {
o.remainQty(o.getQty());
} else {
o.remainQty(getFsmBusiData(organizeCode, remainKey));
}
});
return containerPackageDetailContextList;
}
@Override
public void dispatchContainerPackageDetailContext(String organizeCode, Map<String, MesContainerPackageDetailContext> remainQtyMap2Cache) {
for (Map.Entry<String, MesContainerPackageDetailContext> entry : remainQtyMap2Cache.entrySet()) {
if (null == entry) continue;
MesContainerPackageDetailContext containerPackageDetailContext = entry.getValue();
if (MathOperation.compareTo(containerPackageDetailContext.getRemainQtyCached(), containerPackageDetailContext.getRemainQty()) == 0) continue;
dispatchFsmBusiData(organizeCode, containerPackageDetailContext.getRemainKey(), containerPackageDetailContext.getRemainQty().toString(), MesPcnEnumUtil.EXPIRE_TIME.DEFAULT.getValue());
}
}
} }

@ -593,7 +593,7 @@ public class MesProductionDispatchContextStepService extends BaseStepService imp
@Override @Override
public Double getOrderQtyDialogContext(StationRequestBean reqBean) { public Double getOrderQtyDialogContext(StationRequestBean reqBean) {
String orderQty = getFsmBusiData(reqBean.getOrganizeCode(), getContextKey(reqBean), MesPcnExtConstWords.ORDER_QTY_DIALOG_CONTEXT); String orderQty = getFsmBusiData(reqBean.getOrganizeCode(), getContextKey(reqBean), MesPcnExtConstWords.ORDER_QTY_DIALOG_CONTEXT);
return StringUtils.isEmpty(orderQty) ? new Double(0) : new Double(orderQty); return StringUtils.isEmpty(orderQty) ? new Double(1) : new Double(orderQty);
} }
//获取弹框输入的工单数量 //获取弹框输入的工单数量

@ -28,10 +28,16 @@ public class MesContainerPackageDetailContext extends MesContainerPackageDetail
@ApiParam(value = "主表创建日期") @ApiParam(value = "主表创建日期")
private String createDatetime2Package; private String createDatetime2Package;
@ApiParam("库存") @ApiParam("库存数量")
private Double remainQty; private Double remainQty;
@ApiParam("库存") @ApiParam("库存KEY")
private String remainKey;
@ApiParam("缓存的库存数量")
private Double remainQtyCached;
@ApiParam("扣减数量")
private Double deductionQty; private Double deductionQty;
@ApiParam(name = "设备代码") @ApiParam(name = "设备代码")
@ -49,6 +55,10 @@ public class MesContainerPackageDetailContext extends MesContainerPackageDetail
BeanUtils.copyProperties(containerPackageDetail, this); BeanUtils.copyProperties(containerPackageDetail, this);
} }
public MesContainerPackageDetailContext(MesContainerPackageDetailContext containerPackageDetailContext) {
BeanUtils.copyProperties(containerPackageDetailContext, this);
}
public MesContainerPackageDetailContext containerSnStation(MesContainerSnStation containerSnStation) { public MesContainerPackageDetailContext containerSnStation(MesContainerSnStation containerSnStation) {
this.station = containerSnStation.getStation(); this.station = containerSnStation.getStation();
this.seq = !StringUtils.isEmpty(containerSnStation.getSeq()) ? containerSnStation.getSeq() : MesPcnExtConstWords.ZERO; this.seq = !StringUtils.isEmpty(containerSnStation.getSeq()) ? containerSnStation.getSeq() : MesPcnExtConstWords.ZERO;
@ -72,6 +82,21 @@ public class MesContainerPackageDetailContext extends MesContainerPackageDetail
return this; return this;
} }
public MesContainerPackageDetailContext remainQtyCached(Double remainQtyCached) {
this.remainQtyCached = remainQtyCached;
return this;
}
public MesContainerPackageDetailContext deductionQty(Double deductionQty) {
this.deductionQty = deductionQty;
return this;
}
public MesContainerPackageDetailContext remainKey(String remainKey) {
this.remainKey = remainKey;
return this;
}
public MesStation getStationInfo() { public MesStation getStationInfo() {
MesStation station = new MesStation(); MesStation station = new MesStation();
station.setEquipmentCode(this.equipmentCode); station.setEquipmentCode(this.equipmentCode);

Loading…
Cancel
Save