forked from I3-YF/i3plus-mes-pcn-yfai
展示组件
parent
2438909a65
commit
02d5c0ed65
@ -0,0 +1,33 @@
|
|||||||
|
package cn.estsh.i3plus.ext.mes.pcn.api.busi;
|
||||||
|
|
||||||
|
|
||||||
|
import cn.estsh.i3plus.pojo.mes.bean.MesEquipmentVariable;
|
||||||
|
import cn.estsh.i3plus.pojo.mes.model.MesEquipVariableRwResult;
|
||||||
|
import cn.estsh.i3plus.pojo.mes.model.StationRequestBean;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description : 发送加工参数的抽象类
|
||||||
|
* @Author : zxw
|
||||||
|
**/
|
||||||
|
public interface IWriteVariableService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 写值
|
||||||
|
* @param value
|
||||||
|
* @param equipmentVariable
|
||||||
|
* @param kepwareFlag
|
||||||
|
*/
|
||||||
|
MesEquipVariableRwResult writeVariable(StationRequestBean reqBean, String value, MesEquipmentVariable equipmentVariable, String kepwareFlag, Integer foreignKey, Integer index,Integer maxRetryTimes);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 转成需要的值
|
||||||
|
* @param reqBean
|
||||||
|
* @param value
|
||||||
|
* @param foreignKey
|
||||||
|
* @param index
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
String transferValue(StationRequestBean reqBean, String value, Integer foreignKey, Integer index);
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,98 @@
|
|||||||
|
package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.rulematch;
|
||||||
|
|
||||||
|
|
||||||
|
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesEquipVariableRwExtService;
|
||||||
|
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesProductionDispatchContextStepService;
|
||||||
|
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IWriteVariableService;
|
||||||
|
import cn.estsh.i3plus.ext.mes.pcn.apiservice.schedulejob.BaseMesScheduleJob;
|
||||||
|
import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesProductionPartContext;
|
||||||
|
import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesProductionPsOutContext;
|
||||||
|
import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
|
||||||
|
import cn.estsh.i3plus.pojo.mes.bean.MesEquipmentVariable;
|
||||||
|
import cn.estsh.i3plus.pojo.mes.model.MesEquipVariableRwResult;
|
||||||
|
import cn.estsh.i3plus.pojo.mes.model.StationRequestBean;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description : 发送加工参数的抽象类
|
||||||
|
* @Author : zxw
|
||||||
|
**/
|
||||||
|
@Service
|
||||||
|
public class WriteVariableService implements IWriteVariableService {
|
||||||
|
|
||||||
|
public static final Logger LOGGER = LoggerFactory.getLogger(WriteVariableService.class);
|
||||||
|
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IMesEquipVariableRwExtService equipVariableRwExtService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IMesProductionDispatchContextStepService mesProductionDispatchContextStepService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 写值
|
||||||
|
* @param value
|
||||||
|
* @param equipmentVariable
|
||||||
|
* @param kepwareFlag
|
||||||
|
*/
|
||||||
|
public MesEquipVariableRwResult writeVariable(StationRequestBean reqBean, String value, MesEquipmentVariable equipmentVariable, String kepwareFlag, Integer foreignKey, Integer index, Integer maxTimes) {
|
||||||
|
// 需要不同的策略不同的转换方式
|
||||||
|
String newValue = transferValue(reqBean, value, foreignKey, index);
|
||||||
|
MesEquipVariableRwResult mesEquipVariableRwResult = equipVariableRwExtService.writeVariable(newValue, equipmentVariable, kepwareFlag);
|
||||||
|
if (!mesEquipVariableRwResult.getIsSuccessed() && mesEquipVariableRwResult.getIsNoCfg()) {
|
||||||
|
for (int i = 0;i < maxTimes; i++) {
|
||||||
|
|
||||||
|
mesEquipVariableRwResult = equipVariableRwExtService.writeVariable(newValue, equipmentVariable, kepwareFlag);
|
||||||
|
if (mesEquipVariableRwResult.getIsSuccessed()){
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return mesEquipVariableRwResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String transferValue(StationRequestBean reqBean, String value, Integer foreignKey, Integer index) {
|
||||||
|
List<MesProductionPartContext> productionPartContextList = mesProductionDispatchContextStepService.getProductionPartContext(reqBean);
|
||||||
|
List<MesProductionPsOutContext> productionPsOutContexts = mesProductionDispatchContextStepService.getProductionPsOutContext(reqBean);
|
||||||
|
|
||||||
|
MesProductionPartContext mesProductionPartContext;
|
||||||
|
MesProductionPsOutContext productionPsOutSn;
|
||||||
|
|
||||||
|
if (!Objects.isNull(foreignKey)) {
|
||||||
|
mesProductionPartContext = productionPartContextList.stream().filter(context -> Objects.equals(context.getForeignKey(), foreignKey)).findFirst().orElse(null);
|
||||||
|
productionPsOutSn = productionPsOutContexts.stream().filter(context -> Objects.equals(context.getForeignKey(), foreignKey)).findFirst().orElse(null);
|
||||||
|
String newValue = "";
|
||||||
|
if (value.contains("%")) {
|
||||||
|
if (value.contains("partNo")) {
|
||||||
|
newValue = mesProductionPartContext.getPartNo();
|
||||||
|
} else if (value.contains("orderNo")) {
|
||||||
|
newValue = mesProductionPartContext.getWorkOrderNo();
|
||||||
|
} else if (value.contains("sn")) {
|
||||||
|
newValue = productionPsOutSn.getCustSn();
|
||||||
|
}
|
||||||
|
return newValue;
|
||||||
|
} else {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (index != null && foreignKey == null) {
|
||||||
|
mesProductionPartContext = productionPartContextList.get(index);
|
||||||
|
if (mesProductionPartContext == null || Objects.equals(CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue(), mesProductionPartContext.getIsFinishCode())) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue