|
|
@ -1,203 +0,0 @@
|
|
|
|
/*
|
|
|
|
|
|
|
|
package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.busi.step;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import cn.estsh.i3plus.mes.pcn.serviceimpl.base.BaseStepService;
|
|
|
|
|
|
|
|
import cn.estsh.i3plus.platform.common.exception.ImppExceptionEnum;
|
|
|
|
|
|
|
|
import cn.estsh.i3plus.platform.common.util.MesConstWords;
|
|
|
|
|
|
|
|
import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
|
|
|
|
|
|
|
|
import cn.estsh.i3plus.pojo.mes.bean.MesEquipment;
|
|
|
|
|
|
|
|
import cn.estsh.i3plus.pojo.mes.bean.MesEquipmentInterfaceInfo;
|
|
|
|
|
|
|
|
import cn.estsh.i3plus.pojo.mes.bean.MesEquipmentParam;
|
|
|
|
|
|
|
|
import cn.estsh.i3plus.pojo.mes.bean.MesWcEquipment;
|
|
|
|
|
|
|
|
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.repository.MesEquipmentInterfaceInfoRepository;
|
|
|
|
|
|
|
|
import cn.estsh.i3plus.pojo.mes.repository.MesEquipmentParamRepository;
|
|
|
|
|
|
|
|
import cn.estsh.i3plus.pojo.mes.repository.MesEquipmentRepository;
|
|
|
|
|
|
|
|
import cn.estsh.i3plus.pojo.mes.repository.MesWcEquipmentRepository;
|
|
|
|
|
|
|
|
import cn.estsh.impp.framework.boot.auth.AuthUtil;
|
|
|
|
|
|
|
|
import cn.estsh.impp.framework.boot.exception.ImppExceptionBuilder;
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
import java.util.Objects;
|
|
|
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* @Description : 读取加工结果
|
|
|
|
|
|
|
|
* @Reference :
|
|
|
|
|
|
|
|
* @Author : xiangwei.zhang
|
|
|
|
|
|
|
|
* @CreateDate : 2024-04-22
|
|
|
|
|
|
|
|
* @Modify:
|
|
|
|
|
|
|
|
**//*
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Slf4j
|
|
|
|
|
|
|
|
@Service("jxSnLineOnCheckMcOrPsStepService")
|
|
|
|
|
|
|
|
public class ReadWorkResultStepService extends BaseStepService {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
|
|
private MesWcEquipmentRepository wcEquipmentRepository;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
|
|
private MesEquipmentRepository equipmentRepository;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
|
|
private MesEquipmentParamRepository equipmentParamRepository;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
|
|
private MesEquipmentInterfaceInfoRepository mesEquipmentInterfaceInfoRepository;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public StepResult init(StationRequestBean reqBean) {
|
|
|
|
|
|
|
|
reqBean.setSerialNumber(null);
|
|
|
|
|
|
|
|
reqBean.setProductSn(null);
|
|
|
|
|
|
|
|
reqBean.setTray(null);
|
|
|
|
|
|
|
|
clearStepContent(reqBean);
|
|
|
|
|
|
|
|
return super.init(reqBean);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* ⑴ 根据工序对应的设备获取设备参数, 查询条件: 变量类型 ---> equParamList。
|
|
|
|
|
|
|
|
* ⑵ 从equParamList中筛选 一个点位: 加工模式, 条件: 二级类别。
|
|
|
|
|
|
|
|
* ⑶ 从equParamList中筛选 多个点位: 加工结果, 条件: 二级类别。
|
|
|
|
|
|
|
|
* 点位结果类型:成功, 失败, 报废, 可疑。
|
|
|
|
|
|
|
|
* 一个类型对应一个点位, 最多包含四个, 至少包含成功类型。
|
|
|
|
|
|
|
|
* ⑷ 分别根据 设备对应的变量配置类型+二级类别+变量类型获取各个点位的接口逻辑配置信息。
|
|
|
|
|
|
|
|
* ⑸ 读取设备ID对应的DB设备分表的数据, 查询条件: 点位+状态。
|
|
|
|
|
|
|
|
* 判断接口逻辑是否打勾常变值, 打勾查询条件带上 状态等于0 (暂定0)。
|
|
|
|
|
|
|
|
* 不打勾无需带上状态条件,且只读一次。
|
|
|
|
|
|
|
|
* ⑹ 根据加工模式点位读取数据,判断值是否匹配接口逻辑的参考值。执行逻辑详见流程图。
|
|
|
|
|
|
|
|
* ⑺根据类型结果点位读取数据, 轮询读取, 有值时判断是否匹配参考值, 不匹配继续轮询读取, 匹配则结
|
|
|
|
|
|
|
|
* 束本次读取逻辑, 如果匹配的类型是成功/报废/可疑类型则可进入下个工步, 否则从头开始, 无值继续
|
|
|
|
|
|
|
|
* 轮询读取。执行逻辑详见流程图。
|
|
|
|
|
|
|
|
* ⑻每次读取有值时均需要直接修改当前点位数据的状态改为1(暂定1)与时间改为当前时间。
|
|
|
|
|
|
|
|
* @param reqBean
|
|
|
|
|
|
|
|
* @return
|
|
|
|
|
|
|
|
*//*
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public StepResult execute(StationRequestBean reqBean) {
|
|
|
|
|
|
|
|
// 1 获取工位信息
|
|
|
|
|
|
|
|
String workCell = reqBean.getWorkCellCode();
|
|
|
|
|
|
|
|
// 2 根据工位在组织模型中获取设备信息编号
|
|
|
|
|
|
|
|
MesWcEquipment mesWcEquipment = wcEquipmentRepository.getByProperty(
|
|
|
|
|
|
|
|
new String[]{MesConstWords.ORGANIZE_CODE, MesConstWords.IS_DELETED, MesConstWords.IS_VALID, "workCellCode"},
|
|
|
|
|
|
|
|
new Object[]{AuthUtil.getOrganizeCode(), CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue(),
|
|
|
|
|
|
|
|
CommonEnumUtil.IS_VAILD.VAILD.getValue(), workCell});
|
|
|
|
|
|
|
|
if (null == mesWcEquipment) {
|
|
|
|
|
|
|
|
throw ImppExceptionBuilder.newInstance()
|
|
|
|
|
|
|
|
.setSystemID(CommonEnumUtil.SOFT_TYPE.MES.getCode())
|
|
|
|
|
|
|
|
.setErrorCode(ImppExceptionEnum.VARIFY_EXCEPTION.getCode())
|
|
|
|
|
|
|
|
.setErrorDetail("工位代码【%s】无效", workCell)
|
|
|
|
|
|
|
|
.build();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// 3 查询设备信息
|
|
|
|
|
|
|
|
MesEquipment mesEquipmentDb = equipmentRepository.getByProperty(
|
|
|
|
|
|
|
|
new String[]{MesConstWords.ORGANIZE_CODE, MesConstWords.IS_DELETED, MesConstWords.IS_VALID, "equipmentCode"},
|
|
|
|
|
|
|
|
new Object[]{mesWcEquipment.getOrganizeCode(), CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue(),
|
|
|
|
|
|
|
|
CommonEnumUtil.IS_VAILD.VAILD.getValue(), mesWcEquipment.getEquipmentCode()});
|
|
|
|
|
|
|
|
if (null == mesEquipmentDb) {
|
|
|
|
|
|
|
|
throw ImppExceptionBuilder.newInstance()
|
|
|
|
|
|
|
|
.setSystemID(CommonEnumUtil.SOFT_TYPE.MES.getCode())
|
|
|
|
|
|
|
|
.setErrorCode(ImppExceptionEnum.VARIFY_EXCEPTION.getCode())
|
|
|
|
|
|
|
|
.setErrorDetail("设备代码【%s】无效", mesWcEquipment.getEquipmentCode())
|
|
|
|
|
|
|
|
.build();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//4 查询设备参数信息
|
|
|
|
|
|
|
|
List<MesEquipmentParam> mesEquipmentParamList = equipmentParamRepository.findByProperty(
|
|
|
|
|
|
|
|
new String[]{MesConstWords.ORGANIZE_CODE, MesConstWords.IS_DELETED, MesConstWords.IS_VALID, "equipmentCode"},
|
|
|
|
|
|
|
|
new Object[]{mesWcEquipment.getOrganizeCode(), CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue(),
|
|
|
|
|
|
|
|
CommonEnumUtil.IS_VAILD.VAILD.getValue(), mesWcEquipment.getEquipmentCode()});
|
|
|
|
|
|
|
|
if (CollectionUtils.isEmpty(mesEquipmentParamList)) {
|
|
|
|
|
|
|
|
throw ImppExceptionBuilder.newInstance()
|
|
|
|
|
|
|
|
.setSystemID(CommonEnumUtil.SOFT_TYPE.MES.getCode())
|
|
|
|
|
|
|
|
.setErrorCode(ImppExceptionEnum.VARIFY_EXCEPTION.getCode())
|
|
|
|
|
|
|
|
.setErrorDetail("设备代码【%s】无效", mesWcEquipment.getEquipmentCode())
|
|
|
|
|
|
|
|
.build();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
List<MesEquipmentParam> mesEquipmentParams = mesEquipmentParamList.stream().filter(mesEquipParam -> Objects.equals(mesEquipParam.getVariableType(), cn.estsh.i3plus.ext.mes.pojo.util.MesPcnExtEnumUtil.EQUIPMENT_VARIABLE_TYPE.PRODUCTION_PARAM.getValue())).collect(Collectors.toList());
|
|
|
|
|
|
|
|
if (CollectionUtils.isEmpty(mesEquipmentParams)) {
|
|
|
|
|
|
|
|
throw ImppExceptionBuilder.newInstance()
|
|
|
|
|
|
|
|
.setSystemID(CommonEnumUtil.SOFT_TYPE.MES.getCode())
|
|
|
|
|
|
|
|
.setErrorCode(ImppExceptionEnum.VARIFY_EXCEPTION.getCode())
|
|
|
|
|
|
|
|
.setErrorDetail("未配置加工结果", mesWcEquipment.getEquipmentCode())
|
|
|
|
|
|
|
|
.build();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// 从equParamList中筛选 一个点位: 加工模式, 条件: 二级类别。
|
|
|
|
|
|
|
|
List<MesEquipmentParam> mesEquipmentParamsModel = mesEquipmentParamList.stream().filter(mesEquipParam -> Objects.equals(mesEquipParam.getVariableType(), cn.estsh.i3plus.ext.mes.pojo.util.MesPcnExtEnumUtil.EQUIPMENT_VARIABLE_TYPE.PRODUCTION_PARAM.getValue())).collect(Collectors.toList());
|
|
|
|
|
|
|
|
if (CollectionUtils.isEmpty(mesEquipmentParams)) {
|
|
|
|
|
|
|
|
throw ImppExceptionBuilder.newInstance()
|
|
|
|
|
|
|
|
.setSystemID(CommonEnumUtil.SOFT_TYPE.MES.getCode())
|
|
|
|
|
|
|
|
.setErrorCode(ImppExceptionEnum.VARIFY_EXCEPTION.getCode())
|
|
|
|
|
|
|
|
.setErrorDetail("未配置加工模式", mesWcEquipment.getEquipmentCode())
|
|
|
|
|
|
|
|
.build();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// 从equParamList中筛选 多个点位: 加工结果, 条件: 二级类别。
|
|
|
|
|
|
|
|
List<MesEquipmentParam> mesEquipmentParamsResult = mesEquipmentParamList.stream().filter(mesEquipParam -> Objects.equals(mesEquipParam.getVariableType(), cn.estsh.i3plus.ext.mes.pojo.util.MesPcnExtEnumUtil.EQUIPMENT_VARIABLE_TYPE.PRODUCTION_PARAM.getValue())).collect(Collectors.toList());
|
|
|
|
|
|
|
|
if (CollectionUtils.isEmpty(mesEquipmentParams)) {
|
|
|
|
|
|
|
|
throw ImppExceptionBuilder.newInstance()
|
|
|
|
|
|
|
|
.setSystemID(CommonEnumUtil.SOFT_TYPE.MES.getCode())
|
|
|
|
|
|
|
|
.setErrorCode(ImppExceptionEnum.VARIFY_EXCEPTION.getCode())
|
|
|
|
|
|
|
|
.setErrorDetail("未配置加工结果", mesWcEquipment.getEquipmentCode())
|
|
|
|
|
|
|
|
.build();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
for (MesEquipmentParam mesEquipmentParam : mesEquipmentParamsModel) {
|
|
|
|
|
|
|
|
// 查询设备接口逻辑维护(可以拿到 查询的值以及对应的参考值) 有4个点位 成功 失败 报废 可疑
|
|
|
|
|
|
|
|
List<MesEquipmentInterfaceInfo> mesEquipmentInterfaceInfoList = mesEquipmentInterfaceInfoRepository.findByProperty(
|
|
|
|
|
|
|
|
new String[]{MesConstWords.ORGANIZE_CODE, MesConstWords.IS_DELETED, MesConstWords.IS_VALID, "variableConfigType", "secondCategory"},
|
|
|
|
|
|
|
|
new Object[]{mesWcEquipment.getOrganizeCode(), CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue(),
|
|
|
|
|
|
|
|
CommonEnumUtil.IS_VAILD.VAILD.getValue(), mesEquipmentDb.getVariableConfigType(), mesEquipmentParam.getSecondCategory()});
|
|
|
|
|
|
|
|
if (CollectionUtils.isEmpty(mesEquipmentInterfaceInfoList)) {
|
|
|
|
|
|
|
|
throw ImppExceptionBuilder.newInstance()
|
|
|
|
|
|
|
|
.setSystemID(CommonEnumUtil.SOFT_TYPE.MES.getCode())
|
|
|
|
|
|
|
|
.setErrorCode(ImppExceptionEnum.VARIFY_EXCEPTION.getCode())
|
|
|
|
|
|
|
|
.setErrorDetail("设备接口逻辑维护信息缺失", mesWcEquipment.getEquipmentCode())
|
|
|
|
|
|
|
|
.build();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
MesEquipmentInterfaceInfo mesEquipmentInterfaceInfo = mesEquipmentInterfaceInfoList.get(0);
|
|
|
|
|
|
|
|
// 查询设备数据采集表
|
|
|
|
|
|
|
|
boolean flag = Objects.equals(mesEquipmentInterfaceInfo.getIsOftenChangeValue(), 1);
|
|
|
|
|
|
|
|
Integer status = 1;
|
|
|
|
|
|
|
|
if (flag) {
|
|
|
|
|
|
|
|
status = 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//根据加工模式点位读取数据,判断值是否匹配接口逻辑的参考值 需要带条件 状态=0
|
|
|
|
|
|
|
|
// readEquipmentInfo();
|
|
|
|
|
|
|
|
String res = "";
|
|
|
|
|
|
|
|
//res = readEquipmentInfo();
|
|
|
|
|
|
|
|
if (StringUtils.isEmpty(res)) {
|
|
|
|
|
|
|
|
// 无结果
|
|
|
|
|
|
|
|
} else if (Objects.equals(res, mesEquipmentInterfaceInfo.getReferValue())) {
|
|
|
|
|
|
|
|
// 手动
|
|
|
|
|
|
|
|
// todo 修改状态为1 进入下一个工步
|
|
|
|
|
|
|
|
return StepResult.getSuccessComplete("");
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
// 自动/半自动
|
|
|
|
|
|
|
|
// todo 修改状态为1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// todo 查询数据库看设备的返回信息 与 逻辑维护的数据进行匹配,匹配成功则直接
|
|
|
|
|
|
|
|
//todo 根据设备id找到分表,然后查询
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return stepResult;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
*/
|
|
|
|
|