work cell takt collect
parent
30ae5a9eba
commit
a165129bc6
@ -0,0 +1,25 @@
|
|||||||
|
package cn.estsh.i3plus.ext.mes.pcn.api.busi;
|
||||||
|
|
||||||
|
import cn.estsh.i3plus.pojo.mes.model.StepResult;
|
||||||
|
import cn.estsh.impp.framework.boot.exception.ImppBusiException;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import org.springframework.transaction.annotation.Propagation;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: wangjie
|
||||||
|
* @CreateDate: 2021/01/18 11:22 上午
|
||||||
|
* @Description:
|
||||||
|
**/
|
||||||
|
public interface ISxThirdPartyPlcCollectDataStepService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 第三方PLC数据采集定时任务---步骤执行
|
||||||
|
* @param objs 参数
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@ApiOperation(value = "第三方PLC数据采集定时任务---步骤执行", notes = "第三方PLC数据采集定时任务---步骤执行")
|
||||||
|
@Transactional(propagation = Propagation.REQUIRES_NEW, noRollbackFor = {ImppBusiException.class, Exception.class})
|
||||||
|
StepResult exec(Object... objs);
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,73 @@
|
|||||||
|
package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.busi.collect;
|
||||||
|
|
||||||
|
import cn.estsh.i3plus.ext.mes.pcn.pojo.util.MesPcnExtConstWords;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
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.concurrent.ConcurrentHashMap;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 采集工位节拍调度单例模式
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
public class SxCellTaktDispatchSingleton {
|
||||||
|
|
||||||
|
protected volatile static Boolean isInit = false;
|
||||||
|
|
||||||
|
private static class SxCellTaktDispatchHolder { private final static SxCellTaktDispatchSingleton INSTANCE = new SxCellTaktDispatchSingleton(); }
|
||||||
|
|
||||||
|
public static SxCellTaktDispatchSingleton getInstance() { return SxCellTaktDispatchHolder.INSTANCE; }
|
||||||
|
|
||||||
|
private SxCellTaktDispatchSingleton() { isInit = true; }
|
||||||
|
|
||||||
|
private volatile static Map<String, SxCellTaktMonitorHandler> cellTaktMonitorMap = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
|
public static Boolean getIsInit() { return isInit; }
|
||||||
|
|
||||||
|
public static synchronized void execMonitor(String org, Map<String, String> cfgMap) {
|
||||||
|
if (CollectionUtils.isEmpty(cfgMap)) execMonitorRemove(getCellTaktMonitorMapKeyList(org));
|
||||||
|
else execMonitorCompareToCfg(org, cfgMap);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void execMonitorRemove(List<String> removeKeyList) {
|
||||||
|
if (!CollectionUtils.isEmpty(removeKeyList)) removeKeyList.stream().forEach(SxCellTaktDispatchSingleton::execMonitorRemove);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void execMonitorCompareToCfg(String org, Map<String, String> cfgMap) {
|
||||||
|
List<String> cellTaktMonitorMapKeyList = getCellTaktMonitorMapKeyList(org);
|
||||||
|
List<String> removeKeyList = CollectionUtils.isEmpty(cellTaktMonitorMapKeyList) ? null : cellTaktMonitorMapKeyList.stream().filter(o -> (!StringUtils.isEmpty(o) && !cfgMap.containsKey(o))).collect(Collectors.toList());
|
||||||
|
execMonitorRemove(removeKeyList);
|
||||||
|
execMonitorCompute(org, cfgMap);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static List<String> getCellTaktMonitorMapKeyList(String org) {
|
||||||
|
List<String> cellTaktMonitorMapKeyList = CollectionUtils.isEmpty(cellTaktMonitorMap) ? null : new ArrayList<>(cellTaktMonitorMap.keySet());
|
||||||
|
return CollectionUtils.isEmpty(cellTaktMonitorMapKeyList) ? null : cellTaktMonitorMapKeyList.stream().filter(o -> (!StringUtils.isEmpty(o) && o.split(MesPcnExtConstWords.COLON)[0].equals(org))).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void execMonitorRemove(String key) {
|
||||||
|
cellTaktMonitorMap.computeIfPresent(key, (k, v) -> {
|
||||||
|
v.cancel();
|
||||||
|
cellTaktMonitorMap.remove(key);
|
||||||
|
return null;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void execMonitorCompute(String org, Map<String, String> cfgMap) {
|
||||||
|
for (String key : cfgMap.keySet()) {
|
||||||
|
if (StringUtils.isEmpty(key)) continue;
|
||||||
|
String[] plcCodeArr = cfgMap.get(key).split(MesPcnExtConstWords.COMMA);
|
||||||
|
if (null == plcCodeArr || plcCodeArr.length != 2) continue;
|
||||||
|
cellTaktMonitorMap.compute(key, (k, v) -> {
|
||||||
|
if (null == v) v = new SxCellTaktMonitorHandler(org);
|
||||||
|
return v.plcCodeArr(plcCodeArr);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,66 @@
|
|||||||
|
package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.busi.collect;
|
||||||
|
|
||||||
|
import cn.estsh.impp.framework.boot.util.SpringContextsUtil;
|
||||||
|
import com.google.common.util.concurrent.ListenableFuture;
|
||||||
|
import com.google.common.util.concurrent.ListeningExecutorService;
|
||||||
|
import com.google.common.util.concurrent.MoreExecutors;
|
||||||
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
|
import java.util.concurrent.ExecutorService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 采集工位节拍监控处理器
|
||||||
|
*/
|
||||||
|
public class SxCellTaktMonitorHandler {
|
||||||
|
|
||||||
|
private volatile Boolean isOpen = true;
|
||||||
|
|
||||||
|
private volatile String plcCode2Flag;
|
||||||
|
|
||||||
|
private volatile String plcCode2Data;
|
||||||
|
|
||||||
|
private String org;
|
||||||
|
|
||||||
|
private ExecutorService executorService;
|
||||||
|
|
||||||
|
private ListenableFuture<Object> listenFuture;
|
||||||
|
|
||||||
|
public SxCellTaktMonitorHandler(String org) {
|
||||||
|
this.org = org;
|
||||||
|
executorService = SpringContextsUtil.getBean(ExecutorService.class);
|
||||||
|
ListeningExecutorService listenExecutor = MoreExecutors.listeningDecorator(executorService);
|
||||||
|
listenFuture = listenExecutor.submit(() -> {
|
||||||
|
execMonitor();
|
||||||
|
return null;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public SxCellTaktMonitorHandler plcCodeArr(String[] plcCodeArr) {
|
||||||
|
this.plcCode2Flag = plcCodeArr[0];
|
||||||
|
this.plcCode2Data = plcCodeArr[1];
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void cancel() {
|
||||||
|
if (null == this.listenFuture) return;
|
||||||
|
isOpen = false;
|
||||||
|
listenFuture.cancel(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void execMonitor() {
|
||||||
|
|
||||||
|
while (isOpen) {
|
||||||
|
|
||||||
|
if (StringUtils.isEmpty(plcCode2Flag) || StringUtils.isEmpty(plcCode2Data)) continue;
|
||||||
|
|
||||||
|
String plcFlag = plcCode2Flag;
|
||||||
|
|
||||||
|
String plcData = plcCode2Data;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
28
modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/job/SxThirdPartyPlcCollectCellTaktService.java → modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/collect/SxThirdPartyPlcCollectCellTaktService.java
28
modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/job/SxThirdPartyPlcCollectCellTaktService.java → modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/collect/SxThirdPartyPlcCollectCellTaktService.java
@ -0,0 +1,22 @@
|
|||||||
|
package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.busi.collect;
|
||||||
|
|
||||||
|
import cn.estsh.i3plus.ext.mes.pcn.api.busi.ISxThirdPartyPlcCollectDataStepService;
|
||||||
|
import cn.estsh.i3plus.pojo.mes.model.StepResult;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 第三方PLC数据采集定时任务---步骤执行---读PLC
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
public class SxThirdPartyPlcCollectReadPlcStepService implements ISxThirdPartyPlcCollectDataStepService {
|
||||||
|
|
||||||
|
public SxThirdPartyPlcCollectReadPlcStepService() {}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public StepResult exec(Object ... objs) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -1,107 +0,0 @@
|
|||||||
package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.busi.step.jx;
|
|
||||||
|
|
||||||
import cn.estsh.i3plus.ext.mes.pcn.api.base.ISxWorkOrderExtService;
|
|
||||||
import cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.busi.station.jx.JxSnFinalInspectionModuleService;
|
|
||||||
import cn.estsh.i3plus.ext.mes.pcn.pojo.bean.MesWorkOrderExt;
|
|
||||||
import cn.estsh.i3plus.ext.mes.pcn.pojo.model.WorkOrderExtModel;
|
|
||||||
import cn.estsh.i3plus.ext.mes.pcn.pojo.util.MesPcnExtConstWords;
|
|
||||||
import cn.estsh.i3plus.ext.mes.pcn.pojo.util.MesPcnExtEnumUtil;
|
|
||||||
import cn.estsh.i3plus.mes.pcn.serviceimpl.base.BaseStepService;
|
|
||||||
import cn.estsh.i3plus.platform.common.tool.MathOperation;
|
|
||||||
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 lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.springframework.beans.BeanUtils;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
import org.springframework.util.StringUtils;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @Description : 嘉兴条码终检初始化工单工步
|
|
||||||
* @Reference :
|
|
||||||
* @Author : wangjie
|
|
||||||
* @CreateDate : 2019-07-11
|
|
||||||
* @Modify:
|
|
||||||
**/
|
|
||||||
@Slf4j
|
|
||||||
@Service("jxSnFinalInspectionInitOrderStepService")
|
|
||||||
public class JxSnFinalInspectionInitOrderStepService extends BaseStepService {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private JxSnFinalInspectionModuleService snFinalInspectionModuleService;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private ISxWorkOrderExtService workOrderExtService;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public StepResult execute(StationRequestBean reqBean) {
|
|
||||||
|
|
||||||
log.info("工厂{}生产线{}工位{}: --- STEP EXECUTE --- JxSnFinalInspectionInitOrderStepService --- START --- ", reqBean.getOrganizeCode(), reqBean.getWorkCenterCode(), reqBean.getWorkCellCode());
|
|
||||||
|
|
||||||
StepResult stepResult = StepResult.getSuccessComplete();
|
|
||||||
|
|
||||||
StationResultBean resultBean = new StationResultBean();
|
|
||||||
|
|
||||||
String selectWorkOrderNo = (String) snFinalInspectionModuleService.doHandleSelectWorkOrderNo(reqBean, 1, null);
|
|
||||||
String curExecWorkOrderNo = (String) snFinalInspectionModuleService.doHandleCurExecWorkOrder(reqBean, 1, null);
|
|
||||||
|
|
||||||
if (!StringUtils.isEmpty(selectWorkOrderNo)) snFinalInspectionModuleService.doHandleSelectWorkOrderNo(reqBean, 3, null);
|
|
||||||
if (!StringUtils.isEmpty(selectWorkOrderNo) && !StringUtils.isEmpty(curExecWorkOrderNo)) {
|
|
||||||
if (selectWorkOrderNo.equals(curExecWorkOrderNo)) selectWorkOrderNo = null;
|
|
||||||
else curExecWorkOrderNo = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
MesWorkOrderExt workOrderExt = null;
|
|
||||||
|
|
||||||
if (!StringUtils.isEmpty(selectWorkOrderNo)) {
|
|
||||||
workOrderExt = workOrderExtService.getWorkOrderExtByOrderNo(reqBean.getOrganizeCode(), selectWorkOrderNo);
|
|
||||||
checkWorkOrderExtIsValid(reqBean, resultBean, stepResult, workOrderExt, String.format("选择的工单号[%s]", selectWorkOrderNo));
|
|
||||||
doCacheCurExecWorkOrderNo(reqBean, resultBean, stepResult, selectWorkOrderNo);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!StringUtils.isEmpty(curExecWorkOrderNo)) {
|
|
||||||
workOrderExt = workOrderExtService.getWorkOrderExtByOrderNo(reqBean.getOrganizeCode(), curExecWorkOrderNo);
|
|
||||||
checkWorkOrderExtIsValid(reqBean, resultBean, stepResult, workOrderExt, String.format("此前操作的工单号[%s]", curExecWorkOrderNo));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (null == workOrderExt || !stepResult.isCompleted()) execSendGuideAndThrowEx(reqBean, resultBean, "请选择启动状态的生产工单!");
|
|
||||||
|
|
||||||
cacheOrderModel(reqBean, workOrderExt);
|
|
||||||
|
|
||||||
log.info("工厂{}生产线{}工位{}: --- STEP EXECUTE --- JxSnFinalInspectionInitOrderStepService --- SUCCESS --- ", reqBean.getOrganizeCode(), reqBean.getWorkCenterCode(), reqBean.getWorkCellCode());
|
|
||||||
|
|
||||||
return stepResult;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void doCacheCurExecWorkOrderNo(StationRequestBean reqBean, StationResultBean resultBean, StepResult stepResult, String selectWorkOrderNo) {
|
|
||||||
Boolean flag = (Boolean) snFinalInspectionModuleService.doHandleCurExecWorkOrder(reqBean, 2, selectWorkOrderNo);
|
|
||||||
if (!flag) execNonCompleteAndSendMsg(reqBean, resultBean, stepResult, String.format("选择的工单号[%s]初始化失败!", selectWorkOrderNo));
|
|
||||||
else {
|
|
||||||
snFinalInspectionModuleService.execStateModule(reqBean, null, null);
|
|
||||||
if (stepResult.isCompleted()) this.sendMessage(reqBean, resultBean, String.format("选择的工单号[%s]初始化成功!", selectWorkOrderNo), MesPcnEnumUtil.STATION_BUSI_TYPE.MESSAGE, MesPcnEnumUtil.STATION_DATA_TYPE.TEXT);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void checkWorkOrderExtIsValid(StationRequestBean reqBean, StationResultBean resultBean, StepResult stepResult, MesWorkOrderExt workOrderExt, String suffix) {
|
|
||||||
|
|
||||||
if (null == workOrderExt) execNonCompleteAndSendMsg(reqBean, resultBean, stepResult, String.format("%s对应的工单信息不存在!", suffix));
|
|
||||||
|
|
||||||
if (stepResult.isCompleted() && MesPcnExtEnumUtil.WORK_ORDER_STATUS.OPEN.getValue() != workOrderExt.getWorkOrderStatus())
|
|
||||||
execNonCompleteAndSendMsg(reqBean, resultBean, stepResult, String.format("%s状态[%s],不支持在此工位操作!", suffix, MesPcnExtEnumUtil.WORK_ORDER_STATUS.valueOfDescription(workOrderExt.getWorkOrderStatus())));
|
|
||||||
|
|
||||||
if (stepResult.isCompleted() && MathOperation.compareTo(workOrderExt.getQty(), new Double(0)) <= 0)
|
|
||||||
execNonCompleteAndSendMsg(reqBean, resultBean, stepResult, String.format("%s计划数量为[0],不支持在此工位操作!", suffix));
|
|
||||||
|
|
||||||
if (!stepResult.isCompleted()) return;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private void cacheOrderModel(StationRequestBean reqBean, MesWorkOrderExt workOrderExt) {
|
|
||||||
WorkOrderExtModel orderModel = new WorkOrderExtModel();
|
|
||||||
BeanUtils.copyProperties(workOrderExt, orderModel, MesPcnExtConstWords.ID);
|
|
||||||
reqBean.getDataMap().put(MesPcnExtConstWords.WORK_ORDER, orderModel);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,107 +0,0 @@
|
|||||||
package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.busi.step.jx;
|
|
||||||
|
|
||||||
import cn.estsh.i3plus.ext.mes.pcn.api.base.ISxWorkOrderExtService;
|
|
||||||
import cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.busi.station.jx.JxSnLineOnModuleService;
|
|
||||||
import cn.estsh.i3plus.ext.mes.pcn.pojo.bean.MesWorkOrderExt;
|
|
||||||
import cn.estsh.i3plus.ext.mes.pcn.pojo.model.WorkOrderExtModel;
|
|
||||||
import cn.estsh.i3plus.ext.mes.pcn.pojo.util.MesPcnExtConstWords;
|
|
||||||
import cn.estsh.i3plus.ext.mes.pcn.pojo.util.MesPcnExtEnumUtil;
|
|
||||||
import cn.estsh.i3plus.mes.pcn.serviceimpl.base.BaseStepService;
|
|
||||||
import cn.estsh.i3plus.platform.common.tool.MathOperation;
|
|
||||||
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 lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.springframework.beans.BeanUtils;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
import org.springframework.util.StringUtils;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @Description : 嘉兴条码上线初始化工单工步
|
|
||||||
* @Reference :
|
|
||||||
* @Author : wangjie
|
|
||||||
* @CreateDate : 2019-07-11
|
|
||||||
* @Modify:
|
|
||||||
**/
|
|
||||||
@Slf4j
|
|
||||||
@Service("jxSnLineOnInitOrderStepService")
|
|
||||||
public class JxSnLineOnInitOrderStepService extends BaseStepService {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private JxSnLineOnModuleService snLineOnModuleService;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private ISxWorkOrderExtService workOrderExtService;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public StepResult execute(StationRequestBean reqBean) {
|
|
||||||
|
|
||||||
log.info("工厂{}生产线{}工位{}: --- STEP EXECUTE --- JxSnLineOnInitOrderStepService --- START --- ", reqBean.getOrganizeCode(), reqBean.getWorkCenterCode(), reqBean.getWorkCellCode());
|
|
||||||
|
|
||||||
StepResult stepResult = StepResult.getSuccessComplete();
|
|
||||||
|
|
||||||
StationResultBean resultBean = new StationResultBean();
|
|
||||||
|
|
||||||
String selectWorkOrderNo = (String) snLineOnModuleService.doHandleSelectWorkOrderNo(reqBean, 1, null);
|
|
||||||
String curExecWorkOrderNo = (String) snLineOnModuleService.doHandleCurExecWorkOrder(reqBean, 1, null);
|
|
||||||
|
|
||||||
if (!StringUtils.isEmpty(selectWorkOrderNo)) snLineOnModuleService.doHandleSelectWorkOrderNo(reqBean, 3, null);
|
|
||||||
if (!StringUtils.isEmpty(selectWorkOrderNo) && !StringUtils.isEmpty(curExecWorkOrderNo)) {
|
|
||||||
if (selectWorkOrderNo.equals(curExecWorkOrderNo)) selectWorkOrderNo = null;
|
|
||||||
else curExecWorkOrderNo = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
MesWorkOrderExt workOrderExt = null;
|
|
||||||
|
|
||||||
if (!StringUtils.isEmpty(selectWorkOrderNo)) {
|
|
||||||
workOrderExt = workOrderExtService.getWorkOrderExtByOrderNo(reqBean.getOrganizeCode(), selectWorkOrderNo);
|
|
||||||
checkWorkOrderExtIsValid(reqBean, resultBean, stepResult, workOrderExt, String.format("选择的工单号[%s]", selectWorkOrderNo));
|
|
||||||
doCacheCurExecWorkOrderNo(reqBean, resultBean, stepResult, selectWorkOrderNo);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!StringUtils.isEmpty(curExecWorkOrderNo)) {
|
|
||||||
workOrderExt = workOrderExtService.getWorkOrderExtByOrderNo(reqBean.getOrganizeCode(), curExecWorkOrderNo);
|
|
||||||
checkWorkOrderExtIsValid(reqBean, resultBean, stepResult, workOrderExt, String.format("此前操作的工单号[%s]", curExecWorkOrderNo));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (null == workOrderExt || !stepResult.isCompleted()) execSendGuideAndThrowEx(reqBean, resultBean, "请选择启动状态的生产工单!");
|
|
||||||
|
|
||||||
cacheOrderModel(reqBean, workOrderExt);
|
|
||||||
|
|
||||||
log.info("工厂{}生产线{}工位{}: --- STEP EXECUTE --- JxSnLineOnInitOrderStepService --- SUCCESS --- ", reqBean.getOrganizeCode(), reqBean.getWorkCenterCode(), reqBean.getWorkCellCode());
|
|
||||||
|
|
||||||
return stepResult;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void doCacheCurExecWorkOrderNo(StationRequestBean reqBean, StationResultBean resultBean, StepResult stepResult, String selectWorkOrderNo) {
|
|
||||||
Boolean flag = (Boolean) snLineOnModuleService.doHandleCurExecWorkOrder(reqBean, 2, selectWorkOrderNo);
|
|
||||||
if (!flag) execNonCompleteAndSendMsg(reqBean, resultBean, stepResult, String.format("选择的工单号[%s]初始化失败!", selectWorkOrderNo));
|
|
||||||
else {
|
|
||||||
snLineOnModuleService.execStateModule(reqBean, null, null);
|
|
||||||
if (stepResult.isCompleted()) this.sendMessage(reqBean, resultBean, String.format("选择的工单号[%s]初始化成功!", selectWorkOrderNo), MesPcnEnumUtil.STATION_BUSI_TYPE.MESSAGE, MesPcnEnumUtil.STATION_DATA_TYPE.TEXT);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void checkWorkOrderExtIsValid(StationRequestBean reqBean, StationResultBean resultBean, StepResult stepResult, MesWorkOrderExt workOrderExt, String suffix) {
|
|
||||||
|
|
||||||
if (null == workOrderExt) execNonCompleteAndSendMsg(reqBean, resultBean, stepResult, String.format("%s对应的工单信息不存在!", suffix));
|
|
||||||
|
|
||||||
if (stepResult.isCompleted() && MesPcnExtEnumUtil.WORK_ORDER_STATUS.OPEN.getValue() != workOrderExt.getWorkOrderStatus())
|
|
||||||
execNonCompleteAndSendMsg(reqBean, resultBean, stepResult, String.format("%s状态[%s],不支持在此工位操作!", suffix, MesPcnExtEnumUtil.WORK_ORDER_STATUS.valueOfDescription(workOrderExt.getWorkOrderStatus())));
|
|
||||||
|
|
||||||
if (stepResult.isCompleted() && MathOperation.compareTo(workOrderExt.getQty(), new Double(0)) <= 0)
|
|
||||||
execNonCompleteAndSendMsg(reqBean, resultBean, stepResult, String.format("%s计划数量为[0],不支持在此工位操作!", suffix));
|
|
||||||
|
|
||||||
if (!stepResult.isCompleted()) return;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private void cacheOrderModel(StationRequestBean reqBean, MesWorkOrderExt workOrderExt) {
|
|
||||||
WorkOrderExtModel orderModel = new WorkOrderExtModel();
|
|
||||||
BeanUtils.copyProperties(workOrderExt, orderModel, MesPcnExtConstWords.ID);
|
|
||||||
reqBean.getDataMap().put(MesPcnExtConstWords.WORK_ORDER, orderModel);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
Loading…
Reference in New Issue