吸塑扣料装配件

mes-uat-changshu0609^2
王杰 3 weeks ago
parent 38cc443854
commit c180720114

@ -18,6 +18,7 @@ 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 com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
@ -29,6 +30,7 @@ import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.ReentrantLock;
import java.util.stream.Collectors;
/**
* @Description :
@ -114,12 +116,18 @@ public class MesStationDeductionAssemblyStepService extends BaseStepService {
Map<String, MesContainerPackageDetailContext> remainQtyMap2Cache = new HashMap<>();
//执行容器装配件的缓存扣减
dispatchStationDeductionAssembly(reqBean, resultBean, stepResult, workCenter, prodRuleContextList, remainQtyMap2Cache);
if (!stepResult.isCompleted()) return stepNonCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog(), stepResult.nextTriggerEvent(MesPcnExtConstWords.NEXT_TRIGGER_EVENT_FEEDING), stepResult.getMsg());
Boolean isNeedSavePrc = dispatchStationDeductionAssembly(reqBean, resultBean, stepResult, workCenter, prodRuleContextList, remainQtyMap2Cache);
//保存上下文产品加工规则信息集合
productionDispatchContextStepService.dispatchProdRuleDataContext(reqBean, prodRuleContextList);
if (isNeedSavePrc) {
productionDispatchContextStepService.dispatchProdRuleDataContext(reqBean, prodRuleContextList);
if (workCenter.getCenterType().compareTo(MesExtEnumUtil.WORK_CENTER_TYPE.NOSORT.getValue()) == 0)
((MesAssemblyShowNosortStepService) SpringContextsUtil.getBean("mesAssemblyShowNosortStepService")).showProductionAssembly(reqBean, resultBean, workCenter, prodRuleContextList);
else
((MesAssemblyShowSortStepService) SpringContextsUtil.getBean("mesAssemblyShowSortStepService")).showProductionAssembly(reqBean, resultBean, workCenter, prodRuleContextList, true, true);
}
if (!stepResult.isCompleted()) return stepNonCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog(), stepResult.nextTriggerEvent(MesPcnExtConstWords.NEXT_TRIGGER_EVENT_FEEDING), stepResult.getMsg());
//重置原料条码的缓存库存
productionCustomContextStepService.dispatchContainerPackageDetailContext(reqBean.getOrganizeCode(), remainQtyMap2Cache);
@ -138,21 +146,27 @@ public class MesStationDeductionAssemblyStepService extends BaseStepService {
}
//执行容器装配件的缓存扣减
private void dispatchStationDeductionAssembly(StationRequestBean reqBean, StationResultBean resultBean, StepResult stepResult, MesWorkCenter workCenter,
private Boolean dispatchStationDeductionAssembly(StationRequestBean reqBean, StationResultBean resultBean, StepResult stepResult, MesWorkCenter workCenter,
List<MesProdRuleContext> prodRuleContextList, Map<String, MesContainerPackageDetailContext> remainQtyMap2Cache) {
Boolean isNeedSavePrc = false;
List<String> needFeedPartNoList = new ArrayList<>();
for (MesProdRuleContext prodRuleContext : prodRuleContextList) {
if (null == prodRuleContext || StringUtils.isEmpty(prodRuleContext.getIsMatchContainer())) continue;
List<MesProductionAssemblyContext> productionAssemblyContextList = dispatchStationDeductionAssembly(reqBean, resultBean, stepResult, workCenter, prodRuleContext, remainQtyMap2Cache);
if (!stepResult.isCompleted()) break;
prodRuleContext.assemblyDataJson(productionAssemblyContextList);
if (dispatchStationDeductionAssembly(reqBean, resultBean, workCenter, prodRuleContext, remainQtyMap2Cache, needFeedPartNoList)) isNeedSavePrc = true;
}
if (!CollectionUtils.isEmpty(needFeedPartNoList)) {
stepResult.isCompleted(false)
.msg(String.format("站点匹配装配件时验证零件号%s当前缺料,请扫描上料条码!",
(needFeedPartNoList.stream().filter(o -> !StringUtils.isEmpty(o)).distinct().collect(Collectors.toList())).toString()));
}
return isNeedSavePrc;
}
//执行容器装配件的缓存扣减
private List<MesProductionAssemblyContext> dispatchStationDeductionAssembly(StationRequestBean reqBean, StationResultBean resultBean, StepResult stepResult, MesWorkCenter workCenter,
MesProdRuleContext prodRuleContext, Map<String, MesContainerPackageDetailContext> remainQtyMap2Cache) {
private Boolean dispatchStationDeductionAssembly(StationRequestBean reqBean, StationResultBean resultBean, MesWorkCenter workCenter,
MesProdRuleContext prodRuleContext, Map<String, MesContainerPackageDetailContext> remainQtyMap2Cache, List<String> needFeedPartNoList) {
Boolean isNeedSavePrc = false;
List<MesProductionAssemblyContext> productionAssemblyContextList = prodRuleContext.getAssemblyDataContext(workCenter);
for (MesProductionAssemblyContext productionAssemblyContext : productionAssemblyContextList) {
@ -214,17 +228,20 @@ public class MesStationDeductionAssemblyStepService extends BaseStepService {
productionAssemblyContext.setAssemblyStatus(MesExtEnumUtil.ASSEMBLY_STATUS.ASSEMBLY_STATUS_30.getValue());
productionAssemblyContext.setAssemblySn(null);
productionAssemblyContext.setMatchDatetime(null);
isNeedSavePrc = true;
}
stepResult.isCompleted(false).msg(String.format("站点扣减装配件时验证零件号[%s]当前缺料,请扫描上料条码!", productionAssemblyContext.getAssemblyPartNo()));
break;
needFeedPartNoList.add(productionAssemblyContext.getPartNo());
} else {
productionAssemblyContext.setAssemblySn(barCodeList.get(0));
productionAssemblyContext.setContainerSnData(JSONObject.toJSONString(deductionContextList));
isNeedSavePrc = true;
}
}
return productionAssemblyContextList;
if (isNeedSavePrc) prodRuleContext.assemblyDataJson(productionAssemblyContextList);
return isNeedSavePrc;
}

@ -99,40 +99,49 @@ public class MesStationMatchAssemblyStepService extends BaseStepService {
Map<String, MesStation> stationMap2Lock = new HashMap<>();
//匹配装配件的工序用量
dispatchStationMatchAssembly(reqBean, resultBean, stepResult, workCenter, prodRuleContextList, containerPackageDetailContextList, stationMap2Lock);
Boolean isNeedSavePrc = dispatchStationMatchAssembly(reqBean, resultBean, stepResult, workCenter, prodRuleContextList, containerPackageDetailContextList, stationMap2Lock);
//保存上下文产品加工规则信息集合
if (isNeedSavePrc) {
productionDispatchContextStepService.dispatchProdRuleDataContext(reqBean, prodRuleContextList);
if (workCenter.getCenterType().compareTo(MesExtEnumUtil.WORK_CENTER_TYPE.NOSORT.getValue()) == 0)
((MesAssemblyShowNosortStepService) SpringContextsUtil.getBean("mesAssemblyShowNosortStepService")).showProductionAssembly(reqBean, resultBean, workCenter, prodRuleContextList);
else
((MesAssemblyShowSortStepService) SpringContextsUtil.getBean("mesAssemblyShowSortStepService")).showProductionAssembly(reqBean, resultBean, workCenter, prodRuleContextList, true, true);
}
if (!stepResult.isCompleted()) return stepNonCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog(), stepResult.nextTriggerEvent(MesPcnExtConstWords.NEXT_TRIGGER_EVENT_FEEDING), stepResult.getMsg());
//保存上下文产品加工规则信息集合
productionDispatchContextStepService.dispatchProdRuleDataContext(reqBean, prodRuleContextList);
//保存站点用于后面扣料业务中进行LOCK
productionDispatchContextStepService.dispatchLockStationContext(reqBean, stationMap2Lock);
if (workCenter.getCenterType().compareTo(MesExtEnumUtil.WORK_CENTER_TYPE.NOSORT.getValue()) == 0)
((MesAssemblyShowNosortStepService) SpringContextsUtil.getBean("mesAssemblyShowNosortStepService")).showProductionAssembly(reqBean, resultBean, workCenter, prodRuleContextList);
else
((MesAssemblyShowSortStepService) SpringContextsUtil.getBean("mesAssemblyShowSortStepService")).showProductionAssembly(reqBean, resultBean, workCenter, prodRuleContextList, true, true);
return stepSuccessCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog(), stepResult, "站点匹配装配件验证成功!");
}
//匹配装配件的工序用量【遍历加工规则】
private void dispatchStationMatchAssembly(StationRequestBean reqBean, StationResultBean resultBean, StepResult stepResult, MesWorkCenter workCenter,
private Boolean dispatchStationMatchAssembly(StationRequestBean reqBean, StationResultBean resultBean, StepResult stepResult, MesWorkCenter workCenter,
List<MesProdRuleContext> prodRuleContextList, List<MesContainerPackageDetailContext> containerPackageDetailContextList,
Map<String, MesStation> stationMap2Lock) {
Boolean isNeedSavePrc = false;
List<String> needFeedPartNoList = new ArrayList<>();
for (MesProdRuleContext prodRuleContext : prodRuleContextList) {
if (null == prodRuleContext || StringUtils.isEmpty(prodRuleContext.getIsMatchContainer())) continue;
List<MesProductionAssemblyContext> productionAssemblyContextList = dispatchStationMatchAssembly(reqBean, resultBean, stepResult, workCenter, prodRuleContext, containerPackageDetailContextList, stationMap2Lock);
if (!stepResult.isCompleted()) break;
prodRuleContext.assemblyDataJson(productionAssemblyContextList);
if (dispatchStationMatchAssembly(reqBean, resultBean, workCenter, prodRuleContext, containerPackageDetailContextList, stationMap2Lock, needFeedPartNoList)) isNeedSavePrc = true;
}
if (!CollectionUtils.isEmpty(needFeedPartNoList)) {
stepResult.isCompleted(false)
.msg(String.format("站点匹配装配件时验证零件号%s当前缺料,请扫描上料条码!",
(needFeedPartNoList.stream().filter(o -> !StringUtils.isEmpty(o)).distinct().collect(Collectors.toList())).toString()));
}
return isNeedSavePrc;
}
//匹配装配件的工序用量【遍历装配件】
private List<MesProductionAssemblyContext> dispatchStationMatchAssembly(StationRequestBean reqBean, StationResultBean resultBean, StepResult stepResult, MesWorkCenter workCenter,
MesProdRuleContext prodRuleContext, List<MesContainerPackageDetailContext> containerPackageDetailContextList,
Map<String, MesStation> stationMap2Lock) {
private Boolean dispatchStationMatchAssembly(StationRequestBean reqBean, StationResultBean resultBean, MesWorkCenter workCenter,
MesProdRuleContext prodRuleContext, List<MesContainerPackageDetailContext> containerPackageDetailContextList,
Map<String, MesStation> stationMap2Lock, List<String> needFeedPartNoList) {
Boolean isNeedSavePrc = false;
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;
@ -180,21 +189,26 @@ public class MesStationMatchAssemblyStepService extends BaseStepService {
}
if (MathOperation.compareTo(unMatchQty, new Double(0)) > 0) {
productionAssemblyContext.setAssemblyStatus(MesExtEnumUtil.ASSEMBLY_STATUS.ASSEMBLY_STATUS_30.getValue());
productionAssemblyContext.setAssemblySn(null);
productionAssemblyContext.setMatchDatetime(null);
stepResult.isCompleted(false).msg(String.format("站点匹配装配件时验证零件号[%s]当前缺料,请扫描上料条码!", productionAssemblyContext.getAssemblyPartNo()));
break;
if (!StringUtils.isEmpty(productionAssemblyContext.getAssemblySn())) {
productionAssemblyContext.setAssemblyStatus(MesExtEnumUtil.ASSEMBLY_STATUS.ASSEMBLY_STATUS_30.getValue());
productionAssemblyContext.setAssemblySn(null);
productionAssemblyContext.setMatchDatetime(null);
isNeedSavePrc = true;
}
needFeedPartNoList.add(productionAssemblyContext.getPartNo());
} else {
productionAssemblyContext.setAssemblyStatus(MesExtEnumUtil.ASSEMBLY_STATUS.ASSEMBLY_STATUS_10.getValue());
productionAssemblyContext.setAssemblySn(barCodeList.get(0));
productionAssemblyContext.setMatchDatetime((new SimpleDateFormat(MesPcnExtConstWords.DATE_FORMAT_SSS)).format(new Date()));
productionAssemblyContext.setContainerSnData(JSONObject.toJSONString(containerSnDataList));
isNeedSavePrc = true;
}
}
return productionAssemblyContextList;
if (isNeedSavePrc) prodRuleContext.assemblyDataJson(productionAssemblyContextList);
return isNeedSavePrc;
}
}

Loading…
Cancel
Save