工业互联网平台2.0版本后端代码
潘志宝
2024-11-14 21427594e600cf501e227706f229b7b767d8db4c
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/impl/MmPredictItemServiceImpl.java
@@ -1,5 +1,6 @@
package com.iailab.module.model.mcs.pre.service.impl;
import com.baomidou.dynamic.datasource.annotation.DSTransactional;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -61,14 +62,20 @@
    public PageResult<MmPredictItemRespVO> queryPage(MmPredictItemPageReqVO reqVO) {
        IPage<MmPredictItemRespVO> page = mmPredictItemDao.selectPage(reqVO);
        return  new PageResult<MmPredictItemRespVO>(page.getRecords(), page.getTotal());
        return new PageResult<>(page.getRecords(), page.getTotal());
    }
    @Override
    public List<MmPredictItemEntity> list() {
        return mmPredictItemDao.selectList(new QueryWrapper<>());
    public List<MmPredictItemRespVO> list(Map<String, Object> params) {
        return mmPredictItemDao.queryList(params);
    }
    @Override
    public MmPredictItemEntity getById(String id) {
        return  mmPredictItemDao.selectById(id);
    }
    @DSTransactional(rollbackFor = Exception.class)
    @Override
    public void add(MmPredictItemDTO mmPredictItemDto) {
        MmPredictItemEntity predictItem = mmPredictItemDto.getMmPredictItem();
@@ -114,11 +121,15 @@
        dmModuleItem.setItemid(predictItem.getId());
        dmModuleItemService.saveModuleItem(dmModuleItem);
        MmItemOutputEntity mmItemOutput = mmPredictItemDto.getMmItemOutput();
        mmItemOutput.setItemid(predictItem.getId());
        List<MmItemOutputEntity> mmItemOutput = mmPredictItemDto.getMmItemOutputList();
        mmItemOutput.forEach(e -> {
            e.setId(UUID.randomUUID().toString());
            e.setItemid(predictItem.getId());
        });
        mmItemOutputService.saveMmItemOutput(mmItemOutput);
    }
    @DSTransactional(rollbackFor = Exception.class)
    @Override
    public void update(MmPredictItemDTO mmPredictItemDto) {
        MmPredictItemEntity predictItem = mmPredictItemDto.getMmPredictItem();
@@ -145,15 +156,19 @@
            mmPredictMergeItemService.update(mMmPredictMergeItem);
        }
        DmModuleItemEntity dmModuleItem = mmPredictItemDto.getDmModuleItem();
        if(!"".equals(dmModuleItem.getId()) && dmModuleItem.getId() != null){
        if (!"".equals(dmModuleItem.getId()) && dmModuleItem.getId() != null) {
            dmModuleItemService.update(dmModuleItem);
        }
        MmItemOutputEntity mmItemOutput = mmPredictItemDto.getMmItemOutput();
        if(!"".equals(mmItemOutput.getId()) && dmModuleItem.getId() != null){
            mmItemOutputService.update(mmItemOutput);
        }
        mmItemOutputService.deleteByItemId(predictItem.getId());
        List<MmItemOutputEntity> mmItemOutput = mmPredictItemDto.getMmItemOutputList();
        mmItemOutput.forEach(e -> {
            e.setId(UUID.randomUUID().toString());
            e.setItemid(predictItem.getId());
        });
        mmItemOutputService.saveMmItemOutput(mmItemOutput);
    }
    @DSTransactional(rollbackFor = Exception.class)
    @Override
    public void deleteBatch(String[] itemIds) {
        mmPredictItemDao.deleteBatchIds(Arrays.asList(itemIds));
@@ -168,14 +183,19 @@
        MmPredictItemDTO mmPredictItemDto = BeanUtils.toBean(predictItem, MmPredictItemDTO.class);
        mmPredictItemDto.setMmPredictItem(predictItem);
        mmPredictItemDto.setDmModuleItem(dmModuleItemService.getByItemid(id));
        mmPredictItemDto.setMmItemOutput(mmItemOutputService.getByItemid(id));
        mmPredictItemDto.setMmItemOutputList(mmItemOutputService.getByItemid(id));
        MmItemTypeEntity itemType = mmItemTypeImpl.getById(predictItem.getItemtypeid());
        if (itemType != null && ItemTypeEnum.NORMAL_ITEM.getName().equals(itemType.getItemtypename())) {
            MmPredictModelEntity mmPredictModel = mmPredictModelService.getByItemid(id);
            mmPredictItemDto.setMmPredictModel(mmPredictModel);
            mmPredictItemDto.setMmModelArithSettingsList(mmModelArithSettingsService.getByModelid(mmPredictModel.getId()));
            mmPredictItemDto.setMmModelArithSettingsList(mmModelArithSettingsService.getByModelId(mmPredictModel.getId()));
            mmPredictItemDto.setMmModelParamList(mmModelParamService.getByModelid(mmPredictModel.getId()));
            mmPredictItemDto.setMmPredictMergeItem(new MmPredictMergeItemEntity());
        } else if (itemType != null && ItemTypeEnum.MERGE_ITEM.getName().equals(itemType.getItemtypename())) {
            mmPredictItemDto.setMmPredictModel(new MmPredictModelEntity());
            mmPredictItemDto.setMmModelArithSettingsList(new ArrayList<>());
            mmPredictItemDto.setMmModelParamList(new ArrayList<>());
            mmPredictItemDto.setMmPredictMergeItem(new MmPredictMergeItemEntity());
            mmPredictItemDto.setMmPredictMergeItem(mmPredictMergeItemService.getByItemid(id));
        }
        return mmPredictItemDto;
@@ -196,7 +216,7 @@
    @Override
    public List<ItemVO> getByModuleId(String moduleId) {
        Map<String, Object> params = new HashMap<>();
        params.put("MODULEID",moduleId);
        return mmPredictItemDao.getByModuleId(params);
    }