forked from I3-YF/i3plus-mes-pcn-yfai
Merge branch 'dev-temp-wj-2024150000-00000' into dev
commit
49716d9adb
@ -1,33 +0,0 @@
|
|||||||
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);
|
|
||||||
|
|
||||||
}
|
|
@ -1,162 +0,0 @@
|
|||||||
package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.rulematch;
|
|
||||||
|
|
||||||
|
|
||||||
import cn.estsh.i3plus.ext.mes.pcn.api.busi.*;
|
|
||||||
import cn.estsh.i3plus.ext.mes.pcn.apiservice.schedulejob.BaseMesScheduleJob;
|
|
||||||
import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesProdShiftContext;
|
|
||||||
import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesProductionPartContext;
|
|
||||||
import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesProductionPsInContext;
|
|
||||||
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 cn.hutool.core.date.DatePattern;
|
|
||||||
import cn.hutool.core.date.DateUtil;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
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.Date;
|
|
||||||
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;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private IMesProductionDispatchContextStepService productionDispatchContextStepService;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private IMesProductionCustomContextStepService productionCustomContextStepService;
|
|
||||||
/**
|
|
||||||
* 写值
|
|
||||||
* @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);
|
|
||||||
if (StringUtils.isEmpty(newValue)) {
|
|
||||||
LOGGER.info("发送的值为空,不予发送");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
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);
|
|
||||||
List<MesProductionPsInContext> productionPsInContexts = mesProductionDispatchContextStepService.getProductionPsInContext(reqBean);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
String productResult = productionDispatchContextStepService.getProductResultContext(reqBean);
|
|
||||||
MesProdShiftContext mesProdShiftKvBean = productionCustomContextStepService.getMesProdShiftKvBean(reqBean.getOrganizeCode(), reqBean.getWorkCenterCode());
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
MesProductionPartContext mesProductionPartContext = null;
|
|
||||||
MesProductionPsOutContext productionPsOutSn = null;
|
|
||||||
|
|
||||||
if (!Objects.isNull(foreignKey)) {
|
|
||||||
if (!CollectionUtils.isEmpty(productionPartContextList)) {
|
|
||||||
mesProductionPartContext = productionPartContextList.stream().filter(context -> Objects.equals(context.getForeignKey(), foreignKey)).findFirst().orElse(null);
|
|
||||||
}
|
|
||||||
if (!CollectionUtils.isEmpty(productionPsOutContexts)) {
|
|
||||||
productionPsOutSn = productionPsOutContexts.stream().filter(context -> Objects.equals(context.getForeignKey(), foreignKey)).findFirst().orElse(null);
|
|
||||||
}
|
|
||||||
String newValue = "";
|
|
||||||
if (StringUtils.isEmpty(value)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (mesProductionPartContext == null) {
|
|
||||||
mesProductionPartContext = new MesProductionPartContext();
|
|
||||||
}
|
|
||||||
if (productionPsOutSn == null) {
|
|
||||||
productionPsOutSn = new MesProductionPsOutContext();
|
|
||||||
}
|
|
||||||
switch (value.toUpperCase()) {
|
|
||||||
case "%RESULT%" : newValue = mesProductionPartContext.getPartNo(); break;
|
|
||||||
case "%PARAM%": newValue = mesProductionPartContext.getWorkOrderNo(); break;
|
|
||||||
case "%ORDERCODE%": newValue = mesProductionPartContext.getWorkOrderNo(); break;
|
|
||||||
case "%CUSTPARTNO%": newValue = mesProductionPartContext.getCustPartNo(); break;
|
|
||||||
case "%EMPLOYEENO%": newValue = reqBean.getUserInfo(); break;///当前操作员工号 用户名
|
|
||||||
case "%BARCODE%": newValue = productionPsOutSn.getProductSn(); break;// 条码
|
|
||||||
case "%BARCODE2%": newValue = productionPsOutContexts.get(1).getProductSn(); break;///条码
|
|
||||||
case "%BARCODE3%": newValue = productionPsOutContexts.get(2).getProductSn(); break;///条码
|
|
||||||
case "%BARCODE4%": newValue = productionPsOutContexts.get(3).getProductSn(); break;///条码
|
|
||||||
case "%BARCODE5%": newValue = productionPsOutContexts.get(4).getProductSn(); break;///条码
|
|
||||||
case "%BARCODE6%": newValue = productionPsOutContexts.get(5).getProductSn(); break;///条码
|
|
||||||
case "%BARCODE7%": newValue = productionPsOutContexts.get(6).getProductSn(); break;///条码
|
|
||||||
case "%BARCODE8%": newValue = productionPsOutContexts.get(7).getProductSn(); break;///条码
|
|
||||||
case "%BARCODE9%": newValue = productionPsOutContexts.get(8).getProductSn(); break;///条码
|
|
||||||
case "%BARCODE10%": newValue = productionPsOutContexts.get(9).getProductSn(); break;///条码
|
|
||||||
case "%BARCODE11%": newValue = productionPsOutContexts.get(10).getProductSn(); break;///条码
|
|
||||||
case "%BARCODE12%": newValue = productionPsOutContexts.get(11).getProductSn(); break;///条码
|
|
||||||
case "%BARCODE13%": newValue = productionPsOutContexts.get(12).getProductSn(); break;///条码
|
|
||||||
case "%BARCODE14%": newValue = productionPsOutContexts.get(13).getProductSn(); break;///条码
|
|
||||||
case "%BARCODE15%": newValue = productionPsOutContexts.get(14).getProductSn(); break;///条码
|
|
||||||
case "%BARCODE16%": newValue = productionPsOutContexts.get(15).getProductSn(); break;///条码
|
|
||||||
case "%BARCODE17%": newValue = productionPsOutContexts.get(16).getProductSn(); break;///条码
|
|
||||||
case "%BARCODE18%": newValue = productionPsOutContexts.get(17).getProductSn(); break;///条码
|
|
||||||
case "%BARCODE19%": newValue = productionPsOutContexts.get(18).getProductSn(); break;///条码
|
|
||||||
case "%BARCODE20%": newValue = productionPsOutContexts.get(19).getProductSn(); break;///条码
|
|
||||||
case "%CREATEDATE%": newValue = DateUtil.format(new Date(), DatePattern.NORM_DATETIME_PATTERN); break;///加工记录的创建时间
|
|
||||||
case "%CREATEUSER%": newValue = reqBean.getUserInfo(); break;///当前操作员工号 用户名
|
|
||||||
case "%SHIFT%": newValue = mesProdShiftKvBean.getShiftGroup(); break;///当前操作员工号 用户名
|
|
||||||
//case "%STATUS%": newValue = productionPsInContexts.get(0).get() +"" ; break;//进料条码状态
|
|
||||||
// case "%CUSTORDERCOD%": newValue = mesProductionPartContext.getCustOrderNo(); break;///客户订单号
|
|
||||||
case "%PARTNO%": newValue = mesProductionPartContext.getPartNo(); break;///工单对应的零件号
|
|
||||||
//case "%VINCODE%": newValue = mesProductionPartContext.getv(); break;///工单对应的vincode
|
|
||||||
case "%SEQUENCE%": newValue = reqBean.getUserInfo(); break;///工单顺序号 不是生产顺序号
|
|
||||||
case "%CUSTBARCODE%": newValue = productionPsOutSn.getCustSn(); break;///客户条码
|
|
||||||
case "%GETDATE%": newValue = DateUtil.format(new Date(), DatePattern.NORM_DATETIME_PATTERN); break;///客户条码
|
|
||||||
|
|
||||||
default:
|
|
||||||
newValue = value;
|
|
||||||
}
|
|
||||||
return newValue;
|
|
||||||
} 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