dengzedong
2025-02-27 6205c22a959fbb3b69735f34af8d3316c4082a5d
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,18 @@
            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");
            //累计配置
            entity.setIscumulant(mmPredictItemDto.getIscumulant());
            entity.setCumuldivisor(mmPredictItemDto.getCumuldivisor());
            entity.setCumulpoint(mmPredictItemDto.getCumulpoint());
            mergeItemOutput.add(entity);
            mmPredictItemDto.setMmItemOutputList(mergeItemOutput);
        }
        mmPredictItemDao.insert(predictItem);
        DmModuleItemEntity dmModuleItem = mmPredictItemDto.getDmModuleItem();
@@ -160,6 +200,29 @@
        } 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");
                //累计配置
                entity.setIscumulant(mmPredictItemDto.getIscumulant());
                entity.setCumuldivisor(mmPredictItemDto.getCumuldivisor());
                entity.setCumulpoint(mmPredictItemDto.getCumulpoint());
                mmItemOutputList.add(entity);
                mmPredictItemDto.setMmItemOutputList(mmItemOutputList);
            } else {
                mmPredictItemDto.getMmItemOutputList().forEach(entity -> {
                    entity.setPointid(mmPredictItemDto.getPointId());
                    //累计配置
                    entity.setIscumulant(mmPredictItemDto.getIscumulant());
                    entity.setCumuldivisor(mmPredictItemDto.getCumuldivisor());
                    entity.setCumulpoint(mmPredictItemDto.getCumulpoint());
                });
            }
        }
        DmModuleItemEntity dmModuleItem = mmPredictItemDto.getDmModuleItem();
        if (!"".equals(dmModuleItem.getId()) && dmModuleItem.getId() != null) {
@@ -215,6 +278,13 @@
            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());
                //累计配置
                mmPredictItemDto.setIscumulant(mmPredictItemDto.getMmItemOutputList().get(0).getIscumulant());
                mmPredictItemDto.setCumuldivisor(mmPredictItemDto.getMmItemOutputList().get(0).getCumuldivisor());
                mmPredictItemDto.setCumulpoint(mmPredictItemDto.getMmItemOutputList().get(0).getCumulpoint());
            }
        }
        return mmPredictItemDto;
    }