forked from I3-YF/i3plus-mes-pcn-yfai
匹配原料站点工步
parent
fbea1bb2f3
commit
07ff755b9c
@ -0,0 +1,46 @@
|
||||
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.pojo.util.MesPcnExtConstWords;
|
||||
import cn.estsh.i3plus.mes.pcn.serviceimpl.fsm.BaseStepService;
|
||||
import cn.estsh.i3plus.mes.pcn.serviceimpl.fsm.IStepService;
|
||||
import cn.estsh.i3plus.pojo.base.enumutil.MesPcnEnumUtil;
|
||||
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.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("mesStationFeedContainerSnByAssemblyStepService")
|
||||
public class MesStationFeedContainerSnByAssemblyStepService extends BaseStepService {
|
||||
|
||||
@Autowired
|
||||
private IMesProductionCustomContextStepService productionCustomContextStepService;
|
||||
|
||||
@Override
|
||||
public StepResult guide(StationRequestBean reqBean) {
|
||||
|
||||
//发送工步内容
|
||||
productionCustomContextStepService.sendStepContextMessage(reqBean);
|
||||
|
||||
return stepSuccessCompleteAndSendGuideReturn(reqBean, new StationResultBean().writeDbLog(MesPcnEnumUtil.WORK_CELL_SCAN_MONITOR_LOG_TYPE.PROCESS.getValue()), "请扫描容器条码!");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public StepResult execute(StationRequestBean reqBean) {
|
||||
|
||||
reqBean.getDataMap().put(MesPcnExtConstWords.MATCH_STATION_CONTEXT_FLAG, MesPcnExtConstWords.MATCH_STATION_ASSEMBLY_CONTEXT);
|
||||
|
||||
return ((IStepService) SpringContextsUtil.getBean("mesStationFeedContainerSnByFlagStepService")).executeInState(reqBean);
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,73 @@
|
||||
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.IMesProductionDispatchContextStepService;
|
||||
import cn.estsh.i3plus.ext.mes.pcn.pojo.util.MesPcnExtConstWords;
|
||||
import cn.estsh.i3plus.mes.pcn.serviceimpl.fsm.BaseStepService;
|
||||
import cn.estsh.i3plus.pojo.base.enumutil.MesPcnEnumUtil;
|
||||
import cn.estsh.i3plus.pojo.mes.bean.MesStation;
|
||||
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;
|
||||
|
||||
/**
|
||||
* @Description : 站点上料扫描容器条码工步
|
||||
* @Author : wangjie
|
||||
**/
|
||||
@Slf4j
|
||||
@Service("mesStationFeedContainerSnByFlagStepService")
|
||||
public class MesStationFeedContainerSnByFlagStepService extends BaseStepService {
|
||||
|
||||
@Autowired
|
||||
private IMesProductionDispatchContextStepService productionDispatchContextStepService;
|
||||
|
||||
@Autowired
|
||||
private IMesProductionCustomContextStepService productionCustomContextStepService;
|
||||
|
||||
@Override
|
||||
public StepResult guide(StationRequestBean reqBean) {
|
||||
|
||||
//发送工步内容
|
||||
productionCustomContextStepService.sendStepContextMessage(reqBean);
|
||||
|
||||
return stepSuccessCompleteAndSendGuideReturn(reqBean, new StationResultBean().writeDbLog(MesPcnEnumUtil.WORK_CELL_SCAN_MONITOR_LOG_TYPE.PROCESS.getValue()), "请扫描容器条码!");
|
||||
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public StepResult execute(StationRequestBean reqBean) {
|
||||
//
|
||||
// StationResultBean resultBean = new StationResultBean();
|
||||
//
|
||||
// StepResult stepResult = StepResult.getSuccessComplete();
|
||||
//
|
||||
// //投料站点标识
|
||||
// String flag = (String) reqBean.getDataMap().get(MesPcnExtConstWords.MATCH_STATION_CONTEXT_FLAG);
|
||||
//
|
||||
// if (StringUtils.isEmpty(flag)) stepExpSendMsgAndThrowEx(reqBean, resultBean.writeDbLog(), "站点上料扫描容器条码时验证缺失必要flag参数!");
|
||||
//
|
||||
// if (StringUtils.isEmpty(reqBean.getScanInfo())) stepSendGuideAndThrowEx(reqBean, resultBean.writeDbLog(MesPcnEnumUtil.WORK_CELL_SCAN_MONITOR_LOG_TYPE.PROCESS.getValue()), "请扫描容器条码!");
|
||||
//
|
||||
// //获取站点用于缺料时进行上料绑定
|
||||
// List<MesStation> stationList = productionDispatchContextStepService.getMatchStationContext(reqBean, flag);
|
||||
// if (CollectionUtils.isEmpty(stationList)) stepExpSendMsgAndThrowEx(reqBean, resultBean.writeDbLog(), "站点上料扫描容器条码时验证缺失站点信息!");
|
||||
//
|
||||
// //删除源工步传过来的参数标识
|
||||
// reqBean.getDataMap().remove(MesPcnExtConstWords.MATCH_STATION_CONTEXT_FLAG);
|
||||
//
|
||||
// MesStation station = stationList.get(0);
|
||||
//
|
||||
// Integer packageStatus = flag.equals(MesPcnExtConstWords.MATCH_STATION_ASSEMBLY_CONTEXT) ? MesExtEnumUtil.CONTAINER_PACKAGE_STATUS.STATUS_20.getValue() :
|
||||
// station
|
||||
//
|
||||
// }
|
||||
|
||||
}
|
@ -0,0 +1,46 @@
|
||||
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.pojo.util.MesPcnExtConstWords;
|
||||
import cn.estsh.i3plus.mes.pcn.serviceimpl.fsm.BaseStepService;
|
||||
import cn.estsh.i3plus.mes.pcn.serviceimpl.fsm.IStepService;
|
||||
import cn.estsh.i3plus.pojo.base.enumutil.MesPcnEnumUtil;
|
||||
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.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("mesStationFeedContainerSnByPsInStepService")
|
||||
public class MesStationFeedContainerSnByPsInStepService extends BaseStepService {
|
||||
|
||||
@Autowired
|
||||
private IMesProductionCustomContextStepService productionCustomContextStepService;
|
||||
|
||||
@Override
|
||||
public StepResult guide(StationRequestBean reqBean) {
|
||||
|
||||
//发送工步内容
|
||||
productionCustomContextStepService.sendStepContextMessage(reqBean);
|
||||
|
||||
return stepSuccessCompleteAndSendGuideReturn(reqBean, new StationResultBean().writeDbLog(MesPcnEnumUtil.WORK_CELL_SCAN_MONITOR_LOG_TYPE.PROCESS.getValue()), "请扫描容器条码!");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public StepResult execute(StationRequestBean reqBean) {
|
||||
|
||||
reqBean.getDataMap().put(MesPcnExtConstWords.MATCH_STATION_CONTEXT_FLAG, MesPcnExtConstWords.MATCH_STATION_PRODUCT_SN_CONTEXT);
|
||||
|
||||
return ((IStepService) SpringContextsUtil.getBean("mesStationFeedContainerSnByFlagStepService")).executeInState(reqBean);
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -1,123 +0,0 @@
|
||||
package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.step;
|
||||
|
||||
import cn.estsh.i3plus.ext.mes.pcn.api.busi.*;
|
||||
import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesProductionProcessContext;
|
||||
import cn.estsh.i3plus.ext.mes.pcn.pojo.util.MesPcnExtConstWords;
|
||||
import cn.estsh.i3plus.mes.pcn.serviceimpl.fsm.BaseStepService;
|
||||
import cn.estsh.i3plus.pojo.mes.bean.MesContainerPackage;
|
||||
import cn.estsh.i3plus.pojo.mes.bean.MesContainerSnStation;
|
||||
import cn.estsh.i3plus.pojo.mes.bean.MesStation;
|
||||
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.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.StringJoiner;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/**
|
||||
* @Description : 站点匹配进料工步
|
||||
* @Author : wangjie
|
||||
**/
|
||||
@Slf4j
|
||||
@Service("mesStationMatchProductSnInStepService")
|
||||
public class MesStationMatchProductSnInStepService extends BaseStepService {
|
||||
|
||||
@Autowired
|
||||
private IMesProductionProcessContextStepService productionProcessContextStepService;
|
||||
|
||||
@Autowired
|
||||
private IMesProductionDispatchContextStepService productionDispatchContextStepService;
|
||||
|
||||
@Autowired
|
||||
private IMesProductionCustomContextStepService productionCustomContextStepService;
|
||||
|
||||
@Autowired
|
||||
private IMesStationContainerSnExtService stationContainerSnExtService;
|
||||
|
||||
@Autowired
|
||||
private IMesTimeEfficientCfgMatchService timeEfficientCfgMatchService;
|
||||
|
||||
@Override
|
||||
public StepResult execute(StationRequestBean reqBean) {
|
||||
|
||||
StationResultBean resultBean = new StationResultBean();
|
||||
|
||||
StepResult stepResult = StepResult.getSuccessComplete();
|
||||
|
||||
//获取工位当前设备信息
|
||||
MesProductionProcessContext productionProcessContext = productionProcessContextStepService.dispatchCurCellEquipment(reqBean);
|
||||
|
||||
//配置错误 抛出异常
|
||||
if (!productionProcessContext.getSuccess()) stepExpSendMsgAndThrowEx(reqBean, resultBean.writeDbLog(), productionProcessContext.getMessage());
|
||||
|
||||
//处理设备站点【原料站点&&混料站点&&成品站点&&可疑站点】
|
||||
List<MesStation> stationList = productionProcessContextStepService.dispatchEquipmentStationContext(reqBean, productionProcessContext.getCurCellEquip().getEquipmentCode(),
|
||||
Stream.of(MesExtEnumUtil.STATION_TYPE.STATION_TYPE_10.getValue(), MesExtEnumUtil.STATION_TYPE.STATION_TYPE_40.getValue(),
|
||||
MesExtEnumUtil.STATION_TYPE.STATION_TYPE_30.getValue(), MesExtEnumUtil.STATION_TYPE.STATION_TYPE_50.getValue()).collect(Collectors.toList()));
|
||||
|
||||
//搜集设备站点 【进料】【原料站点&&混料站点】
|
||||
String suffix = new StringJoiner(MesPcnExtConstWords.SLANT_R).add(MesExtEnumUtil.STATION_TYPE.STATION_TYPE_10.getDescription()).add(MesExtEnumUtil.STATION_TYPE.STATION_TYPE_40.getDescription()).toString();
|
||||
List<MesStation> stationList2PsIn = productionProcessContextStepService.dispatchEquipmentStationContext(stationList,
|
||||
Stream.of(MesExtEnumUtil.STATION_TYPE.STATION_TYPE_10.getValue(), MesExtEnumUtil.STATION_TYPE.STATION_TYPE_40.getValue()).collect(Collectors.toList()));
|
||||
if (CollectionUtils.isEmpty(stationList2PsIn)) stepExpSendMsgAndThrowEx(reqBean, resultBean.writeDbLog(), String.format("站点匹配进料时验证设备未关联[%s]站点!", suffix));
|
||||
|
||||
//验证【原料站点&&混料站点】是否存在【已关箱】的容器条码
|
||||
if (!checkIsFeedContainerSn(reqBean, resultBean, stepResult, stationList2PsIn, suffix, MesExtEnumUtil.CONTAINER_PACKAGE_STATUS.STATUS_20).isCompleted()) return stepResult;
|
||||
|
||||
//验证【成品站点】是否存在【未关箱】的容器条码
|
||||
if (!checkIsFeedContainerSn(reqBean, resultBean, stepResult,
|
||||
productionProcessContextStepService.dispatchEquipmentStationContext(stationList, Stream.of(MesExtEnumUtil.STATION_TYPE.STATION_TYPE_30.getValue()).collect(Collectors.toList())),
|
||||
MesExtEnumUtil.STATION_TYPE.STATION_TYPE_30.getDescription(), MesExtEnumUtil.CONTAINER_PACKAGE_STATUS.STATUS_10).isCompleted()) return stepResult;
|
||||
|
||||
//验证【可疑站点】是否存在【未关箱】的容器条码
|
||||
if (!checkIsFeedContainerSn(reqBean, resultBean, stepResult,
|
||||
productionProcessContextStepService.dispatchEquipmentStationContext(stationList, Stream.of(MesExtEnumUtil.STATION_TYPE.STATION_TYPE_50.getValue()).collect(Collectors.toList())),
|
||||
MesExtEnumUtil.STATION_TYPE.STATION_TYPE_50.getDescription(), MesExtEnumUtil.CONTAINER_PACKAGE_STATUS.STATUS_10).isCompleted()) return stepResult;
|
||||
|
||||
//验证【混料站点】是否存在容器条码
|
||||
if (!checkIsFeedContainerSn(reqBean, resultBean, stepResult,
|
||||
productionProcessContextStepService.dispatchEquipmentStationContext(stationList, Stream.of(MesExtEnumUtil.STATION_TYPE.STATION_TYPE_40.getValue()).collect(Collectors.toList())),
|
||||
MesExtEnumUtil.STATION_TYPE.STATION_TYPE_40.getDescription(), null).isCompleted()) return stepResult;
|
||||
|
||||
return stepSuccessCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog(), stepResult, "站点匹配进料验证成功!");
|
||||
|
||||
}
|
||||
|
||||
private StepResult checkIsFeedContainerSn(StationRequestBean reqBean, StationResultBean resultBean, StepResult stepResult,
|
||||
List<MesStation> stationList, String suffix, MesExtEnumUtil.CONTAINER_PACKAGE_STATUS containerPackageStatus) {
|
||||
//获取站点关联的容器条码【进料】
|
||||
Map<String, List<MesContainerSnStation>> containerSnStationMap = stationContainerSnExtService.getContainerSnStationMap(reqBean.getOrganizeCode(), stationList);
|
||||
//获取容器条码上料主表信息【进料】 除了混料不带状态查询, 其他均查询【已关箱】的数据
|
||||
List<MesContainerPackage> containerPackageList = stationContainerSnExtService.getContainerPackageListByContainerSn(reqBean.getOrganizeCode(),
|
||||
CollectionUtils.isEmpty(containerSnStationMap) ? null : new ArrayList<>(containerSnStationMap.keySet()),
|
||||
null != containerPackageStatus ? MesExtEnumUtil.CONTAINER_PACKAGE_STATUS.STATUS_20.getValue() : null);
|
||||
if (CollectionUtils.isEmpty(stationList)) return stepResult;
|
||||
//混料站点 或 判断已关箱的情况下 , containerPackageList 存在数据则通过
|
||||
if ((null == containerPackageStatus || MesExtEnumUtil.CONTAINER_PACKAGE_STATUS.STATUS_20.getValue() == containerPackageStatus.getValue())
|
||||
&& !CollectionUtils.isEmpty(containerPackageList)) return stepResult;
|
||||
//判断未关箱的情况下,需要看当前的容器条码是否全部是已关箱的,如果是则验证不通过 【不存在已关箱状态的数据就默认是未关箱的, 及不存在数据也默认是未关箱的】
|
||||
if (null != containerPackageStatus && MesExtEnumUtil.CONTAINER_PACKAGE_STATUS.STATUS_10.getValue() == containerPackageStatus.getValue()) {
|
||||
List<String> containerSnList = CollectionUtils.isEmpty(containerPackageList) ? null :
|
||||
(containerPackageList.stream().filter(o -> null != o).map(MesContainerPackage::getContainerSn).collect(Collectors.toList()))
|
||||
.stream().filter(o -> !StringUtils.isEmpty(o)).distinct().collect(Collectors.toList());
|
||||
if (CollectionUtils.isEmpty(containerSnList) || containerSnList.size() != containerSnStationMap.keySet().size()) return stepResult;
|
||||
}
|
||||
|
||||
//保存站点用于绑定进料容器条码
|
||||
productionDispatchContextStepService.dispatchPsMatchStationContext(reqBean, stationList);
|
||||
return stepNonCompleteAndSendMsgReturn(reqBean, resultBean, stepResult.nextTriggerEvent(MesPcnExtConstWords.NEXT_TRIGGER_EVENT_FEEDING),
|
||||
String.format("站点匹配进料时验证[%s]站点未绑定[%s]的容器条码!", suffix, containerPackageStatus.getDescription()));
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,303 @@
|
||||
package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.step;
|
||||
|
||||
import cn.estsh.i3plus.ext.mes.pcn.api.base.IMesProdShiftRecordService;
|
||||
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.IMesStationContainerSnExtService;
|
||||
import cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.step.method.stationpm.IMesStationMatchPsProcessMethodStrategyStepService;
|
||||
import cn.estsh.i3plus.ext.mes.pcn.apiservice.util.MesReentrantLockUtil;
|
||||
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.mes.pcn.serviceimpl.fsm.IStepService;
|
||||
import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
|
||||
import cn.estsh.i3plus.pojo.base.enumutil.MesPcnEnumUtil;
|
||||
import cn.estsh.i3plus.pojo.mes.bean.*;
|
||||
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;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/**
|
||||
* @Description : 匹配原料站点工步
|
||||
* @Author : wangjie
|
||||
**/
|
||||
@Slf4j
|
||||
@Service("mesStationMatchProductSnStepService")
|
||||
public class MesStationMatchProductSnStepService extends BaseStepService {
|
||||
|
||||
@Autowired
|
||||
private IMesProductionProcessContextStepService productionProcessContextStepService;
|
||||
|
||||
@Autowired
|
||||
private IMesProductionDispatchContextStepService productionDispatchContextStepService;
|
||||
|
||||
@Autowired
|
||||
private MesProductSnCheckStepService productSnCheckStepService;
|
||||
|
||||
@Autowired
|
||||
private MesAssemblyShowNosortStepService assemblyShowNosortStepService;
|
||||
|
||||
@Autowired
|
||||
private MesProductSnGenerateStepService productSnGenerateStepService;
|
||||
|
||||
@Autowired
|
||||
private IMesStationContainerSnExtService stationContainerSnExtService;
|
||||
|
||||
@Autowired
|
||||
private IMesProdShiftRecordService prodShiftRecordService;
|
||||
|
||||
@Autowired
|
||||
private IFsmCommonService fsmCommonService;
|
||||
|
||||
@Override
|
||||
public StepResult init(StationRequestBean reqBean) {
|
||||
|
||||
StepResult stepResult = StepResult.getSuccessComplete();
|
||||
|
||||
String endlessLoopReadTimes = fsmCommonService.handleFsmWcpcMapDataForDoScanThenBackValue(reqBean, MesPcnExtConstWords.ENDLESS_LOOP_READ_TIMES);
|
||||
if (StringUtils.isEmpty(endlessLoopReadTimes)) endlessLoopReadTimes = MesPcnExtConstWords.ENDLESS_LOOP_READ_TIMES_DEFAULT;
|
||||
if (productionDispatchContextStepService.dispatchOverEndlessLoopReadTimes(reqBean, endlessLoopReadTimes)) {
|
||||
stepThreadSleepAndSendTaskCompleteAndThrowEx(reqBean, new StationResultBean().isWs(false).writeDbLog().checkRepeat(),
|
||||
stepResult.isCompleted(false).msg(String.format("当前未能执行完成匹配原料站点超过[%s]次!", endlessLoopReadTimes)),
|
||||
MesPcnEnumUtil.STATION_BUSI_TYPE.RUNNING_INFO, MesPcnEnumUtil.STATION_DATA_TYPE.TEXT, getStepParams(reqBean), MesPcnExtConstWords.READ_FAILURE_SLEEP, MesPcnExtConstWords.READ_FAILURE_SLEEP_DEFAULT_TIME);
|
||||
}
|
||||
|
||||
return stepResult;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public StepResult execute(StationRequestBean reqBean) {
|
||||
|
||||
StationResultBean resultBean = new StationResultBean();
|
||||
|
||||
StepResult stepResult = StepResult.getSuccessComplete();
|
||||
|
||||
//获取工位当前设备信息
|
||||
MesProductionProcessContext productionProcessContext = productionProcessContextStepService.dispatchCurCellEquipment(reqBean);
|
||||
|
||||
//配置错误 抛出异常
|
||||
if (!productionProcessContext.getSuccess()) stepExpSendMsgAndThrowEx(reqBean, resultBean.writeDbLog(), productionProcessContext.getMessage());
|
||||
|
||||
//获取生产线的当前班组班次信息
|
||||
MesProdShiftContext prodShiftContext = prodShiftRecordService.getMesProdShiftKvBean(reqBean.getOrganizeCode(), reqBean.getWorkCenterCode());
|
||||
if (null == prodShiftContext) stepExpSendMsgAndThrowEx(reqBean, resultBean.writeDbLog(), "当前不存在生产开班记录,请重新开班!");
|
||||
|
||||
//处理设备站点【原料站点&&混料站点&&成品站点&&可疑站点】
|
||||
List<MesStation> stationList = productionProcessContextStepService.dispatchEquipmentStationContext(reqBean, productionProcessContext.getCurCellEquip().getEquipmentCode(),
|
||||
Stream.of(MesExtEnumUtil.STATION_TYPE.STATION_TYPE_10.getValue(), MesExtEnumUtil.STATION_TYPE.STATION_TYPE_40.getValue(),
|
||||
MesExtEnumUtil.STATION_TYPE.STATION_TYPE_30.getValue(), MesExtEnumUtil.STATION_TYPE.STATION_TYPE_50.getValue()).collect(Collectors.toList()));
|
||||
|
||||
//搜集设备站点 【进料】【原料站点&&混料站点】
|
||||
List<MesStation> stationList2Ps = filterStationList2Ps(reqBean, resultBean, stationList);
|
||||
|
||||
//验证【成品站点】是否存在【未关箱】的容器条码
|
||||
if (!beforeCheckIsExistContainerSn(reqBean, resultBean, stepResult,
|
||||
productionProcessContextStepService.dispatchEquipmentStationContext(stationList, Stream.of(MesExtEnumUtil.STATION_TYPE.STATION_TYPE_30.getValue()).collect(Collectors.toList())),
|
||||
MesExtEnumUtil.STATION_TYPE.STATION_TYPE_30.getDescription(), MesExtEnumUtil.CONTAINER_PACKAGE_STATUS.STATUS_10).isCompleted()) return stepResult;
|
||||
|
||||
//验证【可疑站点】是否存在【未关箱】的容器条码
|
||||
if (!beforeCheckIsExistContainerSn(reqBean, resultBean, stepResult,
|
||||
productionProcessContextStepService.dispatchEquipmentStationContext(stationList, Stream.of(MesExtEnumUtil.STATION_TYPE.STATION_TYPE_50.getValue()).collect(Collectors.toList())),
|
||||
MesExtEnumUtil.STATION_TYPE.STATION_TYPE_50.getDescription(), MesExtEnumUtil.CONTAINER_PACKAGE_STATUS.STATUS_10).isCompleted()) return stepResult;
|
||||
|
||||
//验证【混料站点】是否存在容器条码
|
||||
if (!beforeCheckIsExistContainerSn(reqBean, resultBean, stepResult,
|
||||
productionProcessContextStepService.dispatchEquipmentStationContext(stationList, Stream.of(MesExtEnumUtil.STATION_TYPE.STATION_TYPE_40.getValue()).collect(Collectors.toList())),
|
||||
MesExtEnumUtil.STATION_TYPE.STATION_TYPE_40.getDescription(), null).isCompleted()) return stepResult;
|
||||
|
||||
//加工模式策略
|
||||
IMesStationMatchPsProcessMethodStrategyStepService strategyService = (IMesStationMatchPsProcessMethodStrategyStepService) SpringContextsUtil.getBean(MesExtEnumUtil.STATION_PROCESS_METHOD.valueOfStrategyClass(stationList.get(0).getProcessMethod()));
|
||||
|
||||
//【原料站点】获取容器条码上料明细表信息
|
||||
MesContainerPackageDetailStationContext containerPackageDetailStationContext = strategyService.getContainerPackageDetailStationContext(reqBean.getOrganizeCode(), stationList2Ps);
|
||||
if (null == containerPackageDetailStationContext) {
|
||||
return stepNonCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog(), stepResult.nextTriggerEvent(MesPcnExtConstWords.NEXT_TRIGGER_EVENT_FEEDING), "匹配原料站点时验证[原料]站点当前已无进料信息!");
|
||||
}
|
||||
|
||||
//从上下文中取出生产线对象
|
||||
MesWorkCenter workCenter = productionProcessContext.getWorkCenter();
|
||||
//从上下文中取出工位当前要使用的设备
|
||||
MesCellEquipContext cellEquipContext = productionProcessContext.getCurCellEquip();
|
||||
|
||||
//获取上下文产出零件信息
|
||||
List<MesProductionPartContext> productionPartContextList = productionDispatchContextStepService.getProductionPartContext(reqBean);
|
||||
//剔除空腔
|
||||
List<MesProductionPartContext> productionPartContextList2UnFinish = 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> productionPsInContextList = null;
|
||||
//加工规则数据信息集合
|
||||
List<MesProdRuleContext> prodRuleContextList = new ArrayList<>();
|
||||
|
||||
//获取工步参数
|
||||
Optional<Map<String, MesProdRouteOptParam>> stepParamMap = getStepParams(reqBean);
|
||||
//是否验证工艺路线配置
|
||||
String isCheckCraft = (null != stepParamMap && stepParamMap.isPresent() && stepParamMap.get().containsKey(MesPcnExtConstWords.IS_CHECK_CRAFT_CFG)) ? stepParamMap.get().get(MesPcnExtConstWords.IS_CHECK_CRAFT_CFG).getParamValue() : null;
|
||||
|
||||
List<String> stationNameList = containerPackageDetailStationContext.getStationList().stream().filter(o -> null != o).map(MesStation::getStation).collect(Collectors.toList());
|
||||
|
||||
List<ReentrantLock> acquiredLocks = new ArrayList<>();
|
||||
try {
|
||||
if (!MesReentrantLockUtil.tryLock(acquiredLocks, stationNameList, MesPcnExtConstWords.MATCH_STATION_PRODUCT_SN_CONTEXT + MesPcnExtConstWords.COLON, 3000L)) {
|
||||
return stepDynamicsCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog().checkRepeat(), stepResult, false,
|
||||
MesPcnEnumUtil.STATION_BUSI_TYPE.RUNNING_INFO, MesPcnEnumUtil.STATION_DATA_TYPE.TEXT, "匹配原料站点时LOCK失败,即将重试!");
|
||||
}
|
||||
|
||||
// 结尾需要缓存锁定的数据
|
||||
List<MesContainerPackageDetailContext> needCachedList = null;
|
||||
|
||||
//循环到全部验证成功或根据场景验证失败结束
|
||||
for (int i = 0; i >= 0; i ++) {
|
||||
|
||||
stepResult = StepResult.getSuccessComplete();
|
||||
|
||||
//【原料站点】获取进料主条码信息
|
||||
List<MesContainerPackageDetailContext> containerPackageDetailContextList = strategyService.getContainerPackageDetailContext(reqBean, containerPackageDetailStationContext, cellEquipContext.getCavity(), !CollectionUtils.isEmpty(productionPartContextList2UnFinish));
|
||||
|
||||
//验证是否满足腔数【前置验证】
|
||||
if (!strategyService.checkIsMatchCavity(getListSize(containerPackageDetailContextList), getListSize(prodRuleContextList), getListSize(productionPartContextList2UnFinish), cellEquipContext.getCavity(), true)) {
|
||||
return stepNonCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog(), stepResult.nextTriggerEvent(MesPcnExtConstWords.NEXT_TRIGGER_EVENT_FEEDING), "匹配原料站点时验证[原料]站点当前进料不足!");
|
||||
}
|
||||
|
||||
//封装主条码信息上下文
|
||||
List<MesEquipVariableCollectContext> equipVariableCollectContextList = new ArrayList<>();
|
||||
containerPackageDetailContextList.stream().filter(o -> null != o).forEach(o ->
|
||||
equipVariableCollectContextList.add(new MesEquipVariableCollectContext(reqBean.getOrganizeCode(), o.getBarCode(), MesExtEnumUtil.CELL_MESSAGE_SOURCE.READ.getValue()).qty(o.getQty())));
|
||||
|
||||
//处理条码验证逻辑 【条码验证失败直接抛出异常】
|
||||
productionPsInContextList = productSnCheckStepService.checkProduceSnValid(reqBean, resultBean, stepResult, productionProcessContext, equipVariableCollectContextList, productionPsInContextList);
|
||||
if (!stepResult.isCompleted()) stepSendGuideAndThrowEx(reqBean, new StationResultBean(), "主条码验证失败!请人工处理!");
|
||||
|
||||
//显示装配件扫描项工步【非排序】【业务处理】
|
||||
assemblyShowNosortStepService.doHandleProdRuleContext(reqBean, new StationResultBean().isIgnore(true), stepResult, workCenter, productionProcessContext, cellEquipContext, prodRuleContextList, productionPartContextList, productionPsInContextList);
|
||||
|
||||
//前道工艺防错工步【非排序】
|
||||
if (stepResult.isCompleted() && !StringUtils.isEmpty(isCheckCraft) && !(((IStepService) SpringContextsUtil.getBean("mesProdCraftRouteCheckNosortStepService")).executeInState(reqBean)).isCompleted()) {
|
||||
stepSendGuideAndThrowEx(reqBean, new StationResultBean(), "主条码前道工艺防错验证失败!请人工处理!");
|
||||
}
|
||||
|
||||
//验证是否满足腔数【后置验证】
|
||||
Boolean result = strategyService.checkIsMatchCavity(getListSize(containerPackageDetailContextList), getListSize(prodRuleContextList), getListSize(productionPartContextList2UnFinish), cellEquipContext.getCavity(), false);
|
||||
if (null != result && !result) {
|
||||
stepNonCompleteAndSendMsg(reqBean, resultBean.writeDbLog(), stepResult, stepResult.getMsg());
|
||||
stepSendGuideAndThrowEx(reqBean, new StationResultBean(), "加工规则匹配失败!请人工处理!");
|
||||
}
|
||||
|
||||
if (stepResult.isCompleted()) {
|
||||
if (CollectionUtils.isEmpty(needCachedList)) needCachedList = new ArrayList<>();
|
||||
needCachedList.addAll(containerPackageDetailContextList);
|
||||
}
|
||||
|
||||
if (null != result && result) break;
|
||||
|
||||
//result为null需要继续循环处理
|
||||
containerPackageDetailContextList.get(0).matchResult(stepResult.isCompleted() ? CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValueStr() : CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValueStr());
|
||||
|
||||
}
|
||||
|
||||
//锁定当前已被验证了的主条码或容器条码
|
||||
strategyService.dispatchContainerPackageDetailPs(reqBean, needCachedList);
|
||||
|
||||
} catch (InterruptedException e) {
|
||||
Thread.currentThread().interrupt();
|
||||
return stepDynamicsCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog().checkRepeat(), stepResult, false,
|
||||
MesPcnEnumUtil.STATION_BUSI_TYPE.RUNNING_INFO, MesPcnEnumUtil.STATION_DATA_TYPE.TEXT, "匹配原料站点异常,即将重试!");
|
||||
} finally {
|
||||
MesReentrantLockUtil.unLockAll(acquiredLocks);
|
||||
}
|
||||
|
||||
//显示装配件扫描项
|
||||
assemblyShowNosortStepService.showProductionAssembly(reqBean, resultBean, workCenter, prodRuleContextList);
|
||||
|
||||
//生产零件条码业务处理
|
||||
productSnGenerateStepService.doHandleProductSnGenerate(reqBean, resultBean, stepResult, productionProcessContext, productionPartContextList, productionPsInContextList, prodRuleContextList, prodShiftContext);
|
||||
|
||||
return stepSuccessCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog(), stepResult, "匹配原料站点验证成功!", MesPcnEnumUtil.PROMPT_SOUND.SUCCESS.getValue());
|
||||
|
||||
}
|
||||
|
||||
//获取集合的个数
|
||||
private Integer getListSize(List list) { return CollectionUtils.isEmpty(list) ? MesPcnExtConstWords.ZERO : list.size(); }
|
||||
|
||||
//搜集设备站点 【进料】【原料站点&&混料站点】
|
||||
private List<MesStation> filterStationList2Ps(StationRequestBean reqBean, StationResultBean resultBean, List<MesStation> stationList) {
|
||||
|
||||
//剔除没有加工模式的站点数据
|
||||
List<MesStation> filterList = stationList.stream().filter(o -> (null != o && !StringUtils.isEmpty(o.getProcessMethod()))).collect(Collectors.toList());
|
||||
|
||||
//原料站点
|
||||
List<MesStation> stationList10 = productionProcessContextStepService.dispatchEquipmentStationContext(filterList, Stream.of(MesExtEnumUtil.STATION_TYPE.STATION_TYPE_10.getValue()).collect(Collectors.toList()));
|
||||
//混料站点
|
||||
List<MesStation> stationList40 = productionProcessContextStepService.dispatchEquipmentStationContext(filterList, Stream.of(MesExtEnumUtil.STATION_TYPE.STATION_TYPE_40.getValue()).collect(Collectors.toList()));
|
||||
|
||||
//原料站点根据加工模式分组
|
||||
Map<Integer, List<MesStation>> processMethodMap10 = CollectionUtils.isEmpty(stationList10) ? null : stationList10.stream().filter(o -> null != o).collect(Collectors.groupingBy(MesStation::getProcessMethod));
|
||||
//混料站点根据加工模式分组
|
||||
Map<Integer, List<MesStation>> processMethodMap40 = CollectionUtils.isEmpty(stationList40) ? null : stationList40.stream().filter(o -> null != o).collect(Collectors.groupingBy(MesStation::getProcessMethod));
|
||||
|
||||
if (CollectionUtils.isEmpty(processMethodMap10) && CollectionUtils.isEmpty(processMethodMap40)) stepExpSendMsgAndThrowEx(reqBean, resultBean.writeDbLog(), String.format("匹配原料站点时验证设备未关联有效的[%s]站点!",
|
||||
new StringJoiner(MesPcnExtConstWords.SLANT_R).add(MesExtEnumUtil.STATION_TYPE.STATION_TYPE_10.getDescription()).add(MesExtEnumUtil.STATION_TYPE.STATION_TYPE_40.getDescription()).toString()));
|
||||
|
||||
//验证加工模式, 原料站点只能维护一种加工模式
|
||||
if (!CollectionUtils.isEmpty(processMethodMap10) && processMethodMap10.size() != 1) stepExpSendMsgAndThrowEx(reqBean, resultBean.writeDbLog(), "匹配原料站点时验证设备关联的原料站点的加工模式配置错误!");
|
||||
//验证加工模式, 原料站点不存在的时候, 混料站点只能维护一种加工模式
|
||||
if (CollectionUtils.isEmpty(processMethodMap10) && processMethodMap40.size() != 1) stepExpSendMsgAndThrowEx(reqBean, resultBean.writeDbLog(), "匹配原料站点时验证设备关联的混料站点的加工模式配置错误!");
|
||||
|
||||
//存在原料站点时,合并跟原料站点相同加工模式的混料站点
|
||||
if (!CollectionUtils.isEmpty(stationList10)) {
|
||||
stationList40 = CollectionUtils.isEmpty(stationList40) ? null : stationList40.stream().filter(o -> (null != o && !StringUtils.isEmpty(o.getProcessMethod()) && o.getProcessMethod().compareTo(stationList10.get(0).getProcessMethod()) == 0)).collect(Collectors.toList());
|
||||
if (!CollectionUtils.isEmpty(stationList40)) stationList10.addAll(stationList40);
|
||||
return stationList10;
|
||||
}
|
||||
|
||||
//不存在原料站点时, 返回混料站点
|
||||
return stationList40;
|
||||
|
||||
}
|
||||
|
||||
//前置验证不同类型的站点是否至少存在一个保底的容器条码用于存放产成品
|
||||
private StepResult beforeCheckIsExistContainerSn(StationRequestBean reqBean, StationResultBean resultBean, StepResult stepResult,
|
||||
List<MesStation> stationList, String suffix, MesExtEnumUtil.CONTAINER_PACKAGE_STATUS containerPackageStatus) {
|
||||
if (CollectionUtils.isEmpty(stationList)) return stepResult;
|
||||
|
||||
//获取站点关联的容器条码【进料】
|
||||
Map<String, List<MesContainerSnStation>> containerSnStationMap = stationContainerSnExtService.getContainerSnStationTopMap(reqBean.getOrganizeCode(), stationList);
|
||||
List<String> containerSnList = CollectionUtils.isEmpty(containerSnStationMap) ? null : new ArrayList<>(containerSnStationMap.keySet());
|
||||
|
||||
//获取容器条码上料主表信息【进料】的一条数据
|
||||
MesContainerPackage containerPackage = stationContainerSnExtService.getContainerPackageByContainerSn(
|
||||
reqBean.getOrganizeCode(), containerSnList, null == containerPackageStatus ? null : containerPackageStatus.getValue());
|
||||
if (null != containerPackage) return stepResult;
|
||||
|
||||
//成品|可疑场景下,如果上面查询的containerPackage不存在, 需要判断当前所有容器条码是否全部是已封箱的, 如果是则验证不通过 【不存在已关箱状态的数据即默认是未关箱的】
|
||||
if (null != containerPackageStatus && MesExtEnumUtil.CONTAINER_PACKAGE_STATUS.STATUS_10.getValue() == containerPackageStatus.getValue()) {
|
||||
List<MesContainerPackage> containerPackageList = stationContainerSnExtService.getContainerPackageListByContainerSn(
|
||||
reqBean.getOrganizeCode(), containerSnList, MesExtEnumUtil.CONTAINER_PACKAGE_STATUS.STATUS_20.getValue());
|
||||
List<String> containerSnListDistinct = CollectionUtils.isEmpty(containerPackageList) ? null :
|
||||
(containerPackageList.stream().filter(o -> null != o).map(MesContainerPackage::getContainerSn).collect(Collectors.toList()))
|
||||
.stream().filter(o -> !StringUtils.isEmpty(o)).distinct().collect(Collectors.toList());
|
||||
if (!CollectionUtils.isEmpty(containerSnList) && (CollectionUtils.isEmpty(containerSnListDistinct) || containerSnListDistinct.size() != containerSnList.size())) return stepResult;
|
||||
}
|
||||
|
||||
//保存站点用于绑定进料容器条码
|
||||
productionDispatchContextStepService.dispatchMatchStationProductSnContext(reqBean, stationList);
|
||||
return stepNonCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog(), stepResult.nextTriggerEvent(MesPcnExtConstWords.NEXT_TRIGGER_EVENT_FEEDING),
|
||||
String.format("匹配原料站点时验证[%s]站点未绑定%s容器条码!", suffix, null == containerPackageStatus ? MesPcnExtConstWords.EMPTY : String.format("[%s]状态的", containerPackageStatus.getDescription())));
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.step.method.stationpm;
|
||||
|
||||
import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesContainerPackageDetailContext;
|
||||
import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesContainerPackageDetailStationContext;
|
||||
import cn.estsh.i3plus.pojo.mes.bean.MesStation;
|
||||
import cn.estsh.i3plus.pojo.mes.model.StationRequestBean;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface IMesStationMatchPsProcessMethodStrategyStepService {
|
||||
|
||||
@ApiOperation(value = "【原料站点】获取容器条码上料明细表信息")
|
||||
default MesContainerPackageDetailStationContext getContainerPackageDetailStationContext(String organizeCode, List<MesStation> stationList) { return null; }
|
||||
|
||||
@ApiOperation(value = "【原料站点】获取容器条码上料明细表信息")
|
||||
default MesContainerPackageDetailStationContext getContainerPackageDetailStationContext(IMesStationMatchPsProcessMethodStrategyStepService decoratorService, String organizeCode, List<MesStation> stationList) { return null; }
|
||||
|
||||
@ApiOperation(value = "【原料站点】获取进料主条码信息")
|
||||
default List<MesContainerPackageDetailContext> getContainerPackageDetailContext(StationRequestBean reqBean, MesContainerPackageDetailStationContext context, Integer cavity, Boolean isExistProductionPart) { return null; }
|
||||
|
||||
@ApiOperation(value = "【原料站点】验证进料主条码个数是否满足腔数 【count1=进料主条码个数 count2=加工规则对象个数 count3=产成零件个数[腔数] cavity=设备腔数】")
|
||||
default Boolean checkIsMatchCavity(Integer count1, Integer count2, Integer count3, Integer cavity, Boolean isBeforeCheck) { return true; }
|
||||
|
||||
@ApiOperation(value = "【原料站点】锁定进料主条码信息")
|
||||
default void dispatchContainerPackageDetailPs(StationRequestBean reqBean, List<MesContainerPackageDetailContext> needCachedList) {}
|
||||
|
||||
}
|
@ -0,0 +1,92 @@
|
||||
package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.step.method.stationpm;
|
||||
|
||||
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesProductionCustomContextStepService;
|
||||
import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesContainerPackageDetailContext;
|
||||
import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesContainerPackageDetailStationContext;
|
||||
import cn.estsh.i3plus.ext.mes.pcn.pojo.util.MesPcnExtConstWords;
|
||||
import cn.estsh.i3plus.mes.pcn.serviceimpl.fsm.BaseStepService;
|
||||
import cn.estsh.i3plus.pojo.mes.bean.MesStation;
|
||||
import cn.estsh.i3plus.pojo.mes.model.StationRequestBean;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @Description : 加工模式 - 整箱
|
||||
* @Author : wangjie
|
||||
**/
|
||||
@Slf4j
|
||||
@Service("mesStationMatchPsProcessMethodContainerStepService")
|
||||
public class MesStationMatchPsProcessMethodContainerStepService extends BaseStepService implements IMesStationMatchPsProcessMethodStrategyStepService {
|
||||
|
||||
@Autowired
|
||||
private IMesStationMatchPsProcessMethodStrategyStepService defaultDecoratorService;
|
||||
|
||||
@Autowired
|
||||
private IMesProductionCustomContextStepService productionCustomContextStepService;
|
||||
|
||||
//【原料站点】获取容器条码上料明细表信息
|
||||
@Override
|
||||
public MesContainerPackageDetailStationContext getContainerPackageDetailStationContext(String organizeCode, List<MesStation> stationList) {
|
||||
return getContainerPackageDetailStationContext(defaultDecoratorService, organizeCode, stationList);
|
||||
}
|
||||
|
||||
//【原料站点】获取容器条码上料明细表信息
|
||||
@Override
|
||||
public MesContainerPackageDetailStationContext getContainerPackageDetailStationContext(IMesStationMatchPsProcessMethodStrategyStepService decoratorService, String organizeCode, List<MesStation> stationList) {
|
||||
MesContainerPackageDetailStationContext decoratorContext = decoratorService.getContainerPackageDetailStationContext(organizeCode, stationList);
|
||||
if (null == decoratorContext) return decoratorContext;
|
||||
return new MesContainerPackageDetailStationContext().addStationList(decoratorContext.getStationList()).addStationContainerSnDetailList(decoratorContext);
|
||||
}
|
||||
|
||||
//【原料站点】获取进料主条码信息
|
||||
@Override
|
||||
public List<MesContainerPackageDetailContext> getContainerPackageDetailContext(StationRequestBean reqBean, MesContainerPackageDetailStationContext context, Integer cavity, Boolean isExistProductionPart) {
|
||||
if (null == context) return null;
|
||||
List<MesContainerPackageDetailStationContext> containerPackageDetailStationContextList = context.getStationContainerSnDetailList();
|
||||
for (MesContainerPackageDetailStationContext containerPackageDetailStationContext : containerPackageDetailStationContextList) {
|
||||
if (null == containerPackageDetailStationContext) continue;
|
||||
LinkedHashMap<String, List<MesContainerPackageDetailContext>> containerSnDataMap = containerPackageDetailStationContext.getTopContainerSnDetailMap2Sort();
|
||||
for (Map.Entry<String, List<MesContainerPackageDetailContext>> entry : containerSnDataMap.entrySet()) {
|
||||
if (null == entry || !StringUtils.isEmpty(entry.getValue().get(0).getIsUsed())) continue;
|
||||
//验证是否被使用
|
||||
if (productionCustomContextStepService.checkContainerPackageDetailPsIsUsed(reqBean, MesPcnExtConstWords.CONTAINER_SN, entry.getKey())) {
|
||||
//标记被使用
|
||||
entry.getValue().get(0).isUsed();
|
||||
continue;
|
||||
}
|
||||
//返回整箱
|
||||
return entry.getValue();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
//【原料站点】验证进料主条码个数是否满足腔数
|
||||
// count1=进料主条码个数 count2=加工规则对象个数 count3=产成零件个数[腔数] cavity=设备腔数
|
||||
@Override
|
||||
public Boolean checkIsMatchCavity(Integer count1, Integer count2, Integer count3, Integer cavity, Boolean isBeforeCheck) {
|
||||
//前置验证
|
||||
if (isBeforeCheck) {
|
||||
//不存在产成,按箱加工则不验证腔数,箱内条数即腔数
|
||||
if (count3.compareTo(MesPcnExtConstWords.ZERO) == 0) return true;
|
||||
//存在产成, 验证进料是否满足产成腔数
|
||||
return count1.compareTo(count3) == 0;
|
||||
}
|
||||
|
||||
//后置验证 为true或者false 均退出循环
|
||||
return count1.compareTo(count2) == 0;
|
||||
}
|
||||
|
||||
//【原料站点】锁定进料主条码信息
|
||||
@Override
|
||||
public void dispatchContainerPackageDetailPs(StationRequestBean reqBean, List<MesContainerPackageDetailContext> needCachedList) {
|
||||
productionCustomContextStepService.dispatchContainerPackageDetailPs(reqBean, MesPcnExtConstWords.CONTAINER_SN, needCachedList.get(0).getTopContainerSnKey());
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,124 @@
|
||||
package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.step.method.stationpm;
|
||||
|
||||
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.MesContainerPackageDetailStationContext;
|
||||
import cn.estsh.i3plus.mes.pcn.serviceimpl.fsm.BaseStepService;
|
||||
import cn.estsh.i3plus.pojo.mes.bean.MesContainerPackage;
|
||||
import cn.estsh.i3plus.pojo.mes.bean.MesContainerPackageDetail;
|
||||
import cn.estsh.i3plus.pojo.mes.bean.MesContainerSnStation;
|
||||
import cn.estsh.i3plus.pojo.mes.bean.MesStation;
|
||||
import cn.estsh.i3plus.pojo.mes.util.MesExtEnumUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Primary;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Propagation;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @Description : 加工模式 - Decorator
|
||||
* @Author : wangjie
|
||||
**/
|
||||
@Slf4j
|
||||
@Primary
|
||||
@Service("mesStationMatchPsProcessMethodDecoratorStepService")
|
||||
public class MesStationMatchPsProcessMethodDecoratorStepService extends BaseStepService implements IMesStationMatchPsProcessMethodStrategyStepService {
|
||||
|
||||
@Autowired
|
||||
private IMesStationContainerSnExtService stationContainerSnExtService;
|
||||
|
||||
@Override
|
||||
@Transactional(propagation = Propagation.NOT_SUPPORTED)
|
||||
public MesContainerPackageDetailStationContext getContainerPackageDetailStationContext(String organizeCode, List<MesStation> stationList) {
|
||||
|
||||
//获取站点关联的容器条码
|
||||
List<MesContainerSnStation> containerSnStationList = stationContainerSnExtService.getContainerSnStationList(organizeCode, stationList);
|
||||
containerSnStationList = CollectionUtils.isEmpty(containerSnStationList) ? null :
|
||||
containerSnStationList.stream().filter(o -> (null != o && !StringUtils.isEmpty(o.getContainerSn()) && !StringUtils.isEmpty(o.getTopContainerSn()))).collect(Collectors.toList());
|
||||
if (CollectionUtils.isEmpty(containerSnStationList)) return null;
|
||||
|
||||
//容器条码根据TOP容器条码分组
|
||||
Map<String, List<MesContainerSnStation>> topContainerSnMap = CollectionUtils.isEmpty(containerSnStationList) ? null :
|
||||
containerSnStationList.stream().filter(o -> null != o).collect(Collectors.groupingBy(MesContainerSnStation::getTopContainerSn));
|
||||
//容器条码根据容器条码分组
|
||||
Map<String, List<MesContainerSnStation>> containerSnMap = CollectionUtils.isEmpty(containerSnStationList) ? null :
|
||||
containerSnStationList.stream().filter(o -> null != o).collect(Collectors.groupingBy(MesContainerSnStation::getContainerSn));
|
||||
|
||||
//容器条码根据创建时间正序 【暂不考虑seq, 因为站点没有顺序, 没法比较多站点的情况, 一个站点的情况下, 创建时间正序正常情况下等同于seq正序】
|
||||
containerSnStationList = containerSnStationList.stream().filter(o -> null != o).sorted(Comparator.comparing(MesContainerSnStation::getCreateDatetime)).collect(Collectors.toList());
|
||||
//根据TOP去重
|
||||
List<MesContainerSnStation> containerSnStationList2TopDistinct = containerSnStationList.stream().filter(o -> (null != o && !StringUtils.isEmpty(o.getTopContainerSn())))
|
||||
.distinct().collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(MesContainerSnStation::getTopContainerSn))), ArrayList::new));
|
||||
//搜集料架车容器条码
|
||||
List<String> topContainerSnList = containerSnStationList2TopDistinct.stream().filter(o -> (null != o && !o.getTopContainerSn().equals(o.getContainerSn()))).map(MesContainerSnStation::getTopContainerSn).collect(Collectors.toList());
|
||||
|
||||
//料桶容器条码
|
||||
List<String> containerSnList = new ArrayList<>(containerSnMap.keySet());
|
||||
//最外层料架车与料桶容器条码
|
||||
List<String> allContainerSnList = new ArrayList<>(containerSnList);
|
||||
//合并
|
||||
if (!CollectionUtils.isEmpty(topContainerSnList)) allContainerSnList.addAll(topContainerSnList);
|
||||
//去重
|
||||
allContainerSnList = allContainerSnList.stream().filter(o -> !StringUtils.isEmpty(o)).distinct().collect(Collectors.toList());
|
||||
|
||||
//获取合并的容器条码上料主表信息【已关箱】
|
||||
List<MesContainerPackage> containerPackageList = stationContainerSnExtService.getContainerPackageListByContainerSn(organizeCode, allContainerSnList, MesExtEnumUtil.CONTAINER_PACKAGE_STATUS.STATUS_20.getValue());
|
||||
//料桶对应的上料主表数据
|
||||
List<MesContainerPackage> containerPackageList2Detail = CollectionUtils.isEmpty(containerPackageList) ? null :
|
||||
containerPackageList.stream().filter(o -> (null != o && containerSnList.contains(o.getContainerSn()))).collect(Collectors.toList());
|
||||
if (CollectionUtils.isEmpty(containerPackageList) || CollectionUtils.isEmpty(containerPackageList2Detail)) return null;
|
||||
|
||||
//获取料桶对应的上料明细表信息【可扣减】
|
||||
List<MesContainerPackageDetail> containerPackageDetailList = stationContainerSnExtService.getContainerPackageDetailList(organizeCode, containerPackageList2Detail);
|
||||
if (CollectionUtils.isEmpty(containerPackageDetailList)) return null;
|
||||
|
||||
//已关箱的容器条码信息根据条码分组
|
||||
Map<String, List<MesContainerPackage>> containerPackageMap = containerPackageList.stream().filter(o -> null != o).collect(Collectors.groupingBy(MesContainerPackage::getContainerSn));
|
||||
|
||||
//站点根据名称分组
|
||||
Map<String, List<MesStation>> stationMap = stationList.stream().filter(o -> null != o).collect(Collectors.groupingBy(MesStation::getStation));
|
||||
Map<String, MesStation> stationMap2Back = new HashMap<>();
|
||||
//封装容器条码对应的【可扣减】的上料明细表信息
|
||||
List<MesContainerPackageDetailContext> containerSnStationContextList = new ArrayList<>();
|
||||
for (MesContainerPackageDetail containerPackageDetail : containerPackageDetailList) {
|
||||
if (null == containerPackageDetail) continue;
|
||||
MesContainerSnStation containerSnStation = containerSnMap.get(containerPackageDetail.getContainerSn()).get(0);
|
||||
containerSnStationContextList.add(
|
||||
new MesContainerPackageDetailContext(containerPackageDetail)
|
||||
.containerSnStation(containerSnStation, containerPackageMap.get(containerSnStation.getTopContainerSn()).get(0).getId())
|
||||
.station(stationMap.get(containerSnStation.getStation()).get(0))
|
||||
);
|
||||
if (!stationMap2Back.containsKey(containerSnStation.getStation())) stationMap2Back.put(containerSnStation.getStation(), stationMap.get(containerSnStation.getStation()).get(0));
|
||||
}
|
||||
|
||||
//上料明细数据根据TOP容器条码分组
|
||||
Map<String, List<MesContainerPackageDetailContext>> topContainerSnDetailMap = containerSnStationContextList.stream().filter(o -> null != o).collect(Collectors.groupingBy(MesContainerPackageDetailContext::getTopContainerSn));
|
||||
|
||||
//已关箱的料架车容器条码
|
||||
List<String> topContainerSnList2Colsed = (CollectionUtils.isEmpty(containerPackageList) || CollectionUtils.isEmpty(topContainerSnList)) ? null :
|
||||
containerPackageList.stream().filter(o -> (null != o && topContainerSnList.contains(o.getContainerSn()))).map(MesContainerPackage::getContainerSn).collect(Collectors.toList());
|
||||
|
||||
LinkedHashMap<String, List<MesContainerPackageDetailContext>> topContainerSnDetailMap2Sort = new LinkedHashMap<>();
|
||||
//遍历 根据创建时间正序,TOP去重后的容器条码
|
||||
for (MesContainerSnStation containerSnStation : containerSnStationList2TopDistinct) {
|
||||
//跳过被扣减完的容器条码
|
||||
if (null == containerSnStation || !topContainerSnDetailMap.containsKey(containerSnStation.getTopContainerSn())) continue;
|
||||
//跳过未封箱的料架车
|
||||
if (!containerSnStation.getTopContainerSn().equals(containerSnStation.getContainerSn()) && !topContainerSnList2Colsed.contains(containerSnStation.getTopContainerSn())) continue;
|
||||
//将明细数据按照主表createDatetime,明细表createDatetime 正序 后, 存入有序集合内
|
||||
List<MesContainerPackageDetailContext> detailList2Sort = topContainerSnDetailMap.get(containerSnStation.getTopContainerSn()).stream().filter(o -> null != o)
|
||||
.sorted(Comparator.comparing(MesContainerPackageDetailContext::getCreateDatetime2Package).thenComparing(MesContainerPackageDetailContext::getCreateDatetime)).collect(Collectors.toList());
|
||||
topContainerSnDetailMap2Sort.put(detailList2Sort.get(0).getTopContainerSnKey(), detailList2Sort);
|
||||
}
|
||||
|
||||
return new MesContainerPackageDetailStationContext((List<MesStation>) stationMap2Back.values(), topContainerSnDetailMap2Sort);
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.step.method.stationpm;
|
||||
|
||||
import cn.estsh.i3plus.mes.pcn.serviceimpl.fsm.BaseStepService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @Description : 加工模式 - 整摞
|
||||
* @Author : wangjie
|
||||
**/
|
||||
@Slf4j
|
||||
@Service("mesStationMatchPsProcessMethodManyContainerStepService")
|
||||
public class MesStationMatchPsProcessMethodManyContainerStepService extends BaseStepService implements IMesStationMatchPsProcessMethodStrategyStepService {
|
||||
//TODO
|
||||
}
|
@ -0,0 +1,129 @@
|
||||
package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.step.method.stationpm;
|
||||
|
||||
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesProductionCustomContextStepService;
|
||||
import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesContainerPackageDetailContext;
|
||||
import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesContainerPackageDetailStationContext;
|
||||
import cn.estsh.i3plus.ext.mes.pcn.pojo.util.MesPcnExtConstWords;
|
||||
import cn.estsh.i3plus.mes.pcn.serviceimpl.fsm.BaseStepService;
|
||||
import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
|
||||
import cn.estsh.i3plus.pojo.mes.bean.MesStation;
|
||||
import cn.estsh.i3plus.pojo.mes.model.StationRequestBean;
|
||||
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.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/**
|
||||
* @Description : 加工模式 - 单件
|
||||
* @Author : wangjie
|
||||
**/
|
||||
@Slf4j
|
||||
@Service("mesStationMatchPsProcessMethodSingleStepService")
|
||||
public class MesStationMatchPsProcessMethodSingleStepService extends BaseStepService implements IMesStationMatchPsProcessMethodStrategyStepService {
|
||||
|
||||
@Autowired
|
||||
private IMesStationMatchPsProcessMethodStrategyStepService defaultDecoratorService;
|
||||
|
||||
@Autowired
|
||||
private IMesProductionCustomContextStepService productionCustomContextStepService;
|
||||
|
||||
//【原料站点】获取容器条码上料明细表信息
|
||||
@Override
|
||||
public MesContainerPackageDetailStationContext getContainerPackageDetailStationContext(String organizeCode, List<MesStation> stationList) {
|
||||
return getContainerPackageDetailStationContext(defaultDecoratorService, organizeCode, stationList);
|
||||
}
|
||||
|
||||
//【原料站点】获取容器条码上料明细表信息
|
||||
@Override
|
||||
public MesContainerPackageDetailStationContext getContainerPackageDetailStationContext(IMesStationMatchPsProcessMethodStrategyStepService decoratorService, String organizeCode, List<MesStation> stationList) {
|
||||
MesContainerPackageDetailStationContext containerPackageDetailStationContext = null;
|
||||
for (MesStation station : stationList) {
|
||||
if (null == station) continue;
|
||||
MesContainerPackageDetailStationContext decoratorContext = decoratorService.getContainerPackageDetailStationContext(organizeCode, stationList);
|
||||
if (null == decoratorContext) continue;
|
||||
if (null == containerPackageDetailStationContext) containerPackageDetailStationContext = new MesContainerPackageDetailStationContext();
|
||||
containerPackageDetailStationContext.addStationList(decoratorContext.getStationList()).addStationContainerSnDetailList(decoratorContext);
|
||||
}
|
||||
return containerPackageDetailStationContext;
|
||||
}
|
||||
|
||||
//【原料站点】获取进料主条码信息
|
||||
@Override
|
||||
public List<MesContainerPackageDetailContext> getContainerPackageDetailContext(StationRequestBean reqBean, MesContainerPackageDetailStationContext context, Integer cavity, Boolean isExistProductionPart) {
|
||||
List<MesContainerPackageDetailContext> resultList = null;
|
||||
if (null == context) return resultList;
|
||||
List<MesContainerPackageDetailStationContext> containerPackageDetailStationContextList = context.getStationContainerSnDetailList();
|
||||
for (MesContainerPackageDetailStationContext containerPackageDetailStationContext : containerPackageDetailStationContextList) {
|
||||
if (null == containerPackageDetailStationContext) continue;
|
||||
LinkedHashMap<String, List<MesContainerPackageDetailContext>> containerSnDataMap = containerPackageDetailStationContext.getTopContainerSnDetailMap2Sort();
|
||||
LOOP:
|
||||
for (Map.Entry<String, List<MesContainerPackageDetailContext>> entry : containerSnDataMap.entrySet()) {
|
||||
if (null == entry) continue;
|
||||
List<MesContainerPackageDetailContext> containerSnDetailList = entry.getValue();
|
||||
for (MesContainerPackageDetailContext containerPackageDetailContext : containerSnDetailList) {
|
||||
//验证是否已经被使用
|
||||
if (null == containerPackageDetailContext || !StringUtils.isEmpty(containerPackageDetailContext.getIsUsed())) continue;
|
||||
//已经被匹配成功 matchResult不为空只会是在存在产成的情况下, 下面会先标记为0
|
||||
if (!StringUtils.isEmpty(containerPackageDetailContext.getMatchResult()) && containerPackageDetailContext.getMatchResult().equals(CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValueStr())) continue;
|
||||
//已经被匹配失败, 跳到下个站点进行验证第一个未匹配的进料主条码
|
||||
if (!StringUtils.isEmpty(containerPackageDetailContext.getMatchResult()) && containerPackageDetailContext.getMatchResult().equals(CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValueStr())) break LOOP;
|
||||
//验证是否被使用
|
||||
if (productionCustomContextStepService.checkContainerPackageDetailPsIsUsed(reqBean, MesPcnExtConstWords.PRODUCT_SN, containerPackageDetailContext.getBarCodeKey())) {
|
||||
//标记被使用
|
||||
containerPackageDetailContext.isUsed();
|
||||
continue;
|
||||
}
|
||||
|
||||
//如果存在产成, 标记即将进行匹配, 直接返回进行单腔验证, 支持跨站点按照站点内的容器条码顺序进行一个个匹配
|
||||
if (isExistProductionPart) {
|
||||
//一个个匹配才需要标记为0, 匹配完成之后需要将0的数据标记为1或者2
|
||||
containerPackageDetailContext.matchResult(MesPcnExtConstWords.ZERO_STR);
|
||||
return Stream.of(containerPackageDetailContext).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
//不存在产成, 按顺序添加进料主条码,直到满足设备腔数
|
||||
if (CollectionUtils.isEmpty(resultList)) resultList = new ArrayList<>();
|
||||
resultList.add(containerPackageDetailContext);
|
||||
if (resultList.size() == cavity) return resultList;
|
||||
}
|
||||
}
|
||||
}
|
||||
return resultList;
|
||||
}
|
||||
|
||||
//【原料站点】验证进料主条码个数是否满足腔数
|
||||
// count1=进料主条码个数 count2=加工规则对象个数 count3=产成零件个数[腔数] cavity=设备腔数
|
||||
@Override
|
||||
public Boolean checkIsMatchCavity(Integer count1, Integer count2, Integer count3, Integer cavity, Boolean isBeforeCheck) {
|
||||
|
||||
//前置验证
|
||||
if (isBeforeCheck) {
|
||||
//不存在产成, 需要一次取出满足设备腔数个数的进料, 验证进料是否满足设备腔数
|
||||
if (count3.compareTo(MesPcnExtConstWords.ZERO) == 0) return count1.compareTo(cavity) == 0;
|
||||
//存在产成, 进料等于0则是一定不够腔数的,因为后面满足腔数就进入下一个工步集了
|
||||
return count1.compareTo(MesPcnExtConstWords.ZERO) > 0;
|
||||
}
|
||||
|
||||
//后置验证, 为true或者false 均退出循环
|
||||
//不存在产成, 验证加工规则是否满足设备腔数
|
||||
if (count3.compareTo(MesPcnExtConstWords.ZERO) == 0) return count2.compareTo(cavity) == 0;
|
||||
//存在产成, 验证加工规则是否满足产成腔数, 为null继续循环处理
|
||||
return count2.compareTo(count3) == 0 ? true : null;
|
||||
}
|
||||
|
||||
//【原料站点】锁定进料主条码信息
|
||||
@Override
|
||||
public void dispatchContainerPackageDetailPs(StationRequestBean reqBean, List<MesContainerPackageDetailContext> needCachedList) {
|
||||
needCachedList.forEach(o -> productionCustomContextStepService.dispatchContainerPackageDetailPs(reqBean, MesPcnExtConstWords.PRODUCT_SN, o.getBarCodeKey()));
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,46 @@
|
||||
package cn.estsh.i3plus.ext.mes.pcn.apiservice.util;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
|
||||
@Component
|
||||
public class MesReentrantLockUtil {
|
||||
|
||||
private final static Map<String, ReentrantLock> lockMap = new ConcurrentHashMap<>();
|
||||
|
||||
public static Boolean tryLock(List<ReentrantLock> acquiredLocks, List<String> keyList, String prefix, Long milliseconds) throws InterruptedException {
|
||||
|
||||
Collections.sort(keyList);
|
||||
|
||||
long remaining = TimeUnit.MILLISECONDS.toNanos(milliseconds);
|
||||
long endTime = System.nanoTime() + remaining;
|
||||
|
||||
for (String key : keyList) {
|
||||
|
||||
if (StringUtils.isEmpty(key)) continue;
|
||||
|
||||
ReentrantLock lock = lockMap.computeIfAbsent(prefix + key, o -> new ReentrantLock());
|
||||
|
||||
if (!lock.tryLock(remaining, TimeUnit.NANOSECONDS)) return false;
|
||||
|
||||
acquiredLocks.add(lock);
|
||||
|
||||
remaining = endTime - System.nanoTime();
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
public static void unLockAll(List<ReentrantLock> acquiredLocks) {
|
||||
for (int i = acquiredLocks.size() - 1; i >= 0; i --) acquiredLocks.get(i).unlock();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,51 @@
|
||||
package cn.estsh.i3plus.ext.mes.pcn.pojo.context;
|
||||
|
||||
import cn.estsh.i3plus.pojo.mes.bean.MesStation;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
import lombok.Data;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 生产过程上下文对象-站点容器条码上料明细
|
||||
*/
|
||||
@Data
|
||||
public class MesContainerPackageDetailStationContext implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -6056654777597346815L;
|
||||
|
||||
@ApiParam(name = "站点信息")
|
||||
private List<MesStation> stationList;
|
||||
|
||||
@ApiParam(name = "站点信息")
|
||||
private LinkedHashMap<String, List<MesContainerPackageDetailContext>> topContainerSnDetailMap2Sort;
|
||||
|
||||
//从这个里面存取数据
|
||||
@ApiParam(name = "多个站点的容器条码上料明细")
|
||||
private List<MesContainerPackageDetailStationContext> stationContainerSnDetailList;
|
||||
|
||||
public MesContainerPackageDetailStationContext() {}
|
||||
|
||||
public MesContainerPackageDetailStationContext(List<MesStation> stationList,
|
||||
LinkedHashMap<String, List<MesContainerPackageDetailContext>> topContainerSnDetailMap2Sort) {
|
||||
this.stationList = stationList;
|
||||
this.topContainerSnDetailMap2Sort = topContainerSnDetailMap2Sort;
|
||||
}
|
||||
|
||||
public MesContainerPackageDetailStationContext addStationList(List<MesStation> stationList) {
|
||||
if (CollectionUtils.isEmpty(this.stationList)) this.stationList = new ArrayList<>();
|
||||
this.stationList.addAll(stationList);
|
||||
return this;
|
||||
}
|
||||
|
||||
public MesContainerPackageDetailStationContext addStationContainerSnDetailList(MesContainerPackageDetailStationContext containerPackageDetailStationContext) {
|
||||
if (CollectionUtils.isEmpty(this.stationContainerSnDetailList)) this.stationContainerSnDetailList = new ArrayList<>();
|
||||
this.stationContainerSnDetailList.add(containerPackageDetailStationContext);
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue