diff --git a/modules/i3plus-ext-mes-pcn-api/src/main/java/cn/estsh/i3plus/ext/mes/pcn/api/base/IMesEquipmentExtService.java b/modules/i3plus-ext-mes-pcn-api/src/main/java/cn/estsh/i3plus/ext/mes/pcn/api/base/IMesEquipmentExtService.java index d9f2f08..e3556da 100644 --- a/modules/i3plus-ext-mes-pcn-api/src/main/java/cn/estsh/i3plus/ext/mes/pcn/api/base/IMesEquipmentExtService.java +++ b/modules/i3plus-ext-mes-pcn-api/src/main/java/cn/estsh/i3plus/ext/mes/pcn/api/base/IMesEquipmentExtService.java @@ -1,10 +1,7 @@ package cn.estsh.i3plus.ext.mes.pcn.api.base; import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesCellEquipContext; -import cn.estsh.i3plus.pojo.mes.bean.MesCavityGroupDetailCfg; -import cn.estsh.i3plus.pojo.mes.bean.MesEquipmentChannel; -import cn.estsh.i3plus.pojo.mes.bean.MesEquipmentVariable; -import cn.estsh.i3plus.pojo.mes.bean.MesEquipmentVariableCfg; +import cn.estsh.i3plus.pojo.mes.bean.*; import io.swagger.annotations.ApiOperation; import java.util.List; @@ -24,4 +21,7 @@ public interface IMesEquipmentExtService { List getEquipmentChannelList(String organizeCode, String equipmentCode); List getMesCavityGroupDetailCfgList(String organizeCode, String equipmentCode); + + @ApiOperation(value = "根据设备代码查询生产设备信息") + MesEquipment getMesEquipment(String organizeCode, String equipmentCode); } diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/base/MesEquipmentExtService.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/base/MesEquipmentExtService.java index f4deedf..d6e0f42 100644 --- a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/base/MesEquipmentExtService.java +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/base/MesEquipmentExtService.java @@ -98,4 +98,12 @@ public class MesEquipmentExtService implements IMesEquipmentExtService { List mesCavityGroupDetailCfgs = mesCavityGroupDetailCfgRepository.findByHqlWhere(packBean); return mesCavityGroupDetailCfgs; } + + @Override + public MesEquipment getMesEquipment(String organizeCode, String equipmentCode) { + if (StringUtils.isEmpty(organizeCode) || StringUtils.isEmpty(equipmentCode)) return null; + DdlPackBean packBean = DdlPackBean.getDdlPackBean(organizeCode); + DdlPreparedPack.getStringEqualPack(equipmentCode, MesPcnExtConstWords.EQUIPMENT_CODE, packBean); + return equipmentRepository.getByProperty(packBean); + } } diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesSpotCheckOrderService.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesSpotCheckOrderService.java index 15fcb1b..aba549a 100644 --- a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesSpotCheckOrderService.java +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesSpotCheckOrderService.java @@ -1,5 +1,7 @@ package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.busi; +import cn.estsh.i3plus.ext.mes.pcn.api.base.IMesEquipmentExtService; +import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesEquipmentLogExtService; import cn.estsh.i3plus.ext.mes.pcn.api.busi.spot.IMesSpotCheckOrderService; import cn.estsh.i3plus.ext.mes.pcn.pojo.constant.MesCommonConstant; import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesEquipmentSpotCheckModel; @@ -73,6 +75,12 @@ public class MesSpotCheckOrderService implements IMesSpotCheckOrderService { @Autowired private ICoreUtilCloud sysOrderNoRuleCloud; + @Autowired + private IMesEquipmentLogExtService mesEquipmentLogExtService; + + @Autowired + private IMesEquipmentExtService mesEquipmentExtService; + @Override public ListPager querySpotCheckOrder(MesSpotCheckOrder spotCheckOrder, Pager pager) { @@ -171,35 +179,36 @@ public class MesSpotCheckOrderService implements IMesSpotCheckOrderService { throw new ImppBusiException(String.format("剩余物料号【%s】对应的条码未扫描,请扫描完成后再完成质检", partNoList)); } } - - //获取设定值设备变量ID - List setEquipVariableIdList = - model.getOrderResultList().stream().filter(k -> k.getSpotCheckItemType() == MesExtEnumUtil.SPOT_CHECK_ITEM_TYPE.AUTO.getValue()).map(k -> k.getSetEquipVariableId()).collect(Collectors.toList()); - - //获取实际值设备变量ID - List realEquipVariableIdList = - model.getOrderResultList().stream().filter(k -> k.getSpotCheckItemType() == MesExtEnumUtil.SPOT_CHECK_ITEM_TYPE.AUTO.getValue()).map(k -> k.getSetEquipVariableId()).collect(Collectors.toList()); - - //获取设定值设备数据 - List setEquipmentLogList = new ArrayList<>(); - for (List tmp : ListUtils.partition(setEquipVariableIdList, MesCommonConstant.MAX_PAGER_SIZE)) { - DdlPackBean packBean = DdlPackBean.getDdlPackBean(org); - DdlPreparedPack.getInPackList(tmp, "equipVariableId", packBean); - DdlPreparedPack.getNumEqualPack(model.getSpotCheckOrder().getEquipId().intValue(), "equipId", packBean); - setEquipmentLogList.addAll(equipmentLogRepository.findByHqlWhere(packBean)); - } - //设定值地址数据Map - Map> setMap = setEquipmentLogList.stream().collect(Collectors.groupingBy(k -> k.getEquipVariableId())); + //根据设备代码获取EQUIP_ID + MesEquipment mesEquipment = mesEquipmentExtService.getMesEquipment(org, model.getSpotCheckOrder().getEquipCode()); + Map> setMap = null; + //实际值地址数据Map + Map> realMap = null; //获取实际值值设备数据 List realEquipmentLogList = new ArrayList<>(); - for (List tmp : ListUtils.partition(realEquipVariableIdList, MesCommonConstant.MAX_PAGER_SIZE)) { - DdlPackBean packBean = DdlPackBean.getDdlPackBean(org); - DdlPreparedPack.getInPackList(tmp, "equipVariableId", packBean); - DdlPreparedPack.getNumEqualPack(model.getSpotCheckOrder().getEquipId().intValue(), "equipId", packBean); - realEquipmentLogList.addAll(equipmentLogRepository.findByHqlWhere(packBean)); + if(!Objects.isNull(mesEquipment) && StringUtils.isEmpty(mesEquipment.getEquipId())){ + //获取设定值设备变量ID + List setEquipVariableIdList = + model.getOrderResultList().stream().filter(k -> k.getSpotCheckItemType() == MesExtEnumUtil.SPOT_CHECK_ITEM_TYPE.AUTO.getValue()).map(MesSpotCheckOrderResult::getSetEquipVariableId).collect(Collectors.toList()); + + //获取实际值设备变量ID + List realEquipVariableIdList = + model.getOrderResultList().stream().filter(k -> k.getSpotCheckItemType() == MesExtEnumUtil.SPOT_CHECK_ITEM_TYPE.AUTO.getValue()).map(MesSpotCheckOrderResult::getSetEquipVariableId).collect(Collectors.toList()); + + //获取设定值设备数据 + List setEquipmentLogList = new ArrayList<>(); + for (List tmp : ListUtils.partition(setEquipVariableIdList, MesCommonConstant.MAX_PAGER_SIZE)) { + setEquipmentLogList.addAll(mesEquipmentLogExtService.getEquipmentLogList(org,mesEquipment.getEquipId(),MesExtEnumUtil.EQUIP_VARIABLE_NEED_NEW_VALUE.TRUE.getValue(),tmp)); + } + //设定值地址数据Map + setMap = setEquipmentLogList.stream().collect(Collectors.groupingBy(MesEquipmentLog::getEquipVariableId)); + + for (List tmp : ListUtils.partition(realEquipVariableIdList, MesCommonConstant.MAX_PAGER_SIZE)) { + realEquipmentLogList.addAll(mesEquipmentLogExtService.getEquipmentLogList(org,mesEquipment.getEquipId(),MesExtEnumUtil.EQUIP_VARIABLE_NEED_NEW_VALUE.TRUE.getValue(),tmp)); + } + //实际值地址数据Map + realMap = realEquipmentLogList.stream().collect(Collectors.groupingBy(MesEquipmentLog::getEquipVariableId)); } - //实际值地址数据Map - Map> realMap = realEquipmentLogList.stream().collect(Collectors.groupingBy(k -> k.getEquipVariableId())); for (MesSpotCheckOrderResult result : model.getOrderResultList()) { @@ -207,7 +216,7 @@ public class MesSpotCheckOrderService implements IMesSpotCheckOrderService { if (result.getSpotCheckItemType() == MesExtEnumUtil.SPOT_CHECK_ITEM_TYPE.AUTO.getValue()) { //获取设定值地址数据 - if (setMap.containsKey(result.getSetEquipVariableId())) { + if (!Objects.isNull(setMap) && setMap.containsKey(result.getSetEquipVariableId())) { String value = setMap.get(result.getSetEquipVariableId()).get(0).getEquipVariableValue(); result.setSpotCheckSetValue(value); result.setSetValueRecordType(MesExtEnumUtil.SPOT_VALUE_RECORD_TYPE.EQUIPMENT_INPUT.getValue()); @@ -217,7 +226,7 @@ public class MesSpotCheckOrderService implements IMesSpotCheckOrderService { // result.setSetValueRecordType(MesExtEnumUtil.SPOT_VALUE_RECORD_TYPE.ARTIFICIAL_INPUT.getValue()); // } //获取实际值地址数据 - if (realMap.containsKey(result.getRealEquipVariableId())) { + if (!Objects.isNull(realMap) && realMap.containsKey(result.getRealEquipVariableId())) { String value = realMap.get(result.getRealEquipVariableId()).get(0).getEquipVariableValue(); result.setSpotCheckRealValue(value); //根据获取的值判断是否是设备自定义参数 或者认为录入参数