潘志宝
2025-01-18 e013bf101ad9ab326a85c3811f27e352737c6e81
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/impl/MmPredictItemServiceImpl.java
@@ -78,6 +78,34 @@
        return  mmPredictItemDao.selectById(id);
    }
    @Override
    public List<MmPredictItemRespVO> getDoubleOutPutsByItemNos(List<String> itemNos) {
        List<Integer> resultType = new ArrayList<Integer>(){{
           add(3);
        }};
        return getOutPutsByItemNosAndResultType(itemNos,resultType);
    }
    @Override
    public List<MmPredictItemRespVO> getArrayOutPutsByItemNos(List<String> itemNos) {
        List<Integer> resultType = new ArrayList<Integer>(){{
            add(1);
            add(2);
        }};
        return getOutPutsByItemNosAndResultType(itemNos,resultType);
    }
    public List<MmPredictItemRespVO> getOutPutsByItemNosAndResultType(List<String> itemNos,List<Integer> resultType) {
        if (CollectionUtils.isEmpty(itemNos) || CollectionUtils.isEmpty(resultType)) {
            return new ArrayList<>();
        }
        Map<String, Object> params = new HashMap(1);
        params.put("itemNos", itemNos);
        params.put("resultType", resultType);
        List<MmPredictItemRespVO> list = mmPredictItemDao.getOutPutsByItemNosAndResultType(params);
        return list;
    }
    @DSTransactional(rollbackFor = Exception.class)
    @Override
    public void add(MmPredictItemDTO mmPredictItemDto) {
@@ -118,6 +146,14 @@
            MmPredictMergeItemEntity mMmPredictMergeItem = mmPredictItemDto.getMmPredictMergeItem();
            mMmPredictMergeItem.setItemid(predictItem.getId());
            mmPredictMergeItemService.savePredictMergeItem(mMmPredictMergeItem);
            // 添加一条默认output
            List<MmItemOutputEntity> mergeItemOutput = new ArrayList<>(1);
            MmItemOutputEntity entity = new MmItemOutputEntity();
            entity.setPointid(mmPredictItemDto.getPointId());
            entity.setResultName(mmPredictItemDto.getMmPredictItem().getItemname());
            entity.setResultstr("result");
            mergeItemOutput.add(entity);
            mmPredictItemDto.setMmItemOutputList(mergeItemOutput);
        }
        mmPredictItemDao.insert(predictItem);
        DmModuleItemEntity dmModuleItem = mmPredictItemDto.getDmModuleItem();
@@ -160,6 +196,19 @@
        } else if (itemType != null && ItemTypeEnum.MERGE_ITEM.getName().equals(itemType.getItemtypename())) {
            MmPredictMergeItemEntity mMmPredictMergeItem = mmPredictItemDto.getMmPredictMergeItem();
            mmPredictMergeItemService.update(mMmPredictMergeItem);
            // 修改默认output
            List<MmItemOutputEntity> mmItemOutputList = mmPredictItemDto.getMmItemOutputList();
            if (CollectionUtils.isEmpty(mmItemOutputList)) {
                mmItemOutputList = new ArrayList<>(1);
                MmItemOutputEntity entity = new MmItemOutputEntity();
                entity.setPointid(mmPredictItemDto.getPointId());
                entity.setResultName(mmPredictItemDto.getMmPredictItem().getItemname());
                entity.setResultstr("result");
                mmItemOutputList.add(entity);
                mmPredictItemDto.setMmItemOutputList(mmItemOutputList);
            } else {
                mmPredictItemDto.getMmItemOutputList().forEach(e -> e.setPointid(mmPredictItemDto.getPointId()));
            }
        }
        DmModuleItemEntity dmModuleItem = mmPredictItemDto.getDmModuleItem();
        if (!"".equals(dmModuleItem.getId()) && dmModuleItem.getId() != null) {
@@ -215,6 +264,9 @@
            mmPredictItemDto.setMmModelParamList(new ArrayList<>());
            mmPredictItemDto.setMmPredictMergeItem(new MmPredictMergeItemEntity());
            mmPredictItemDto.setMmPredictMergeItem(mmPredictMergeItemService.getByItemid(id));
            if (!CollectionUtils.isEmpty(mmPredictItemDto.getMmItemOutputList())) {
                mmPredictItemDto.setPointId(mmPredictItemDto.getMmItemOutputList().get(0).getPointid());
            }
        }
        return mmPredictItemDto;
    }