From ed4f78cccbb2cf672d6b3230069979288232ab4a Mon Sep 17 00:00:00 2001 From: 潘志宝 <979469083@qq.com> Date: 星期一, 04 十一月 2024 08:25:28 +0800 Subject: [PATCH] 计划数据 --- iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/impl/MmPredictItemServiceImpl.java | 88 ++++++++++++++++++++++++------------------- 1 files changed, 49 insertions(+), 39 deletions(-) diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/impl/MmPredictItemServiceImpl.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/impl/MmPredictItemServiceImpl.java index 0af6c44..7c2a365 100644 --- a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/impl/MmPredictItemServiceImpl.java +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/impl/MmPredictItemServiceImpl.java @@ -1,16 +1,19 @@ 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; import com.iailab.framework.common.pojo.PageResult; import com.iailab.framework.common.util.object.BeanUtils; +import com.iailab.module.data.api.point.DataPointApi; import com.iailab.module.model.mcs.pre.dao.MmPredictItemDao; import com.iailab.module.model.mcs.pre.dto.MmPredictItemDTO; import com.iailab.module.model.mcs.pre.entity.*; import com.iailab.module.model.mcs.pre.enums.ItemIncreaseCodeEnum; import com.iailab.module.model.mcs.pre.enums.ItemTypeEnum; import com.iailab.module.model.mcs.pre.service.MmPredictItemService; -import com.iailab.module.model.mcs.pre.service.SequenceNumService; +import com.iailab.module.model.mcs.pre.service.MmSequenceNumService; import com.iailab.module.model.mcs.pre.vo.MmPredictItemPageReqVO; import com.iailab.module.model.mcs.pre.vo.MmPredictItemRespVO; import com.iailab.module.model.mdk.vo.ItemVO; @@ -18,11 +21,8 @@ import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; import org.springframework.util.CollectionUtils; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; import java.util.*; /** @@ -54,41 +54,53 @@ private MmItemTypeImpl mmItemTypeImpl; @Autowired - private SequenceNumService sequenceNumService; + private MmSequenceNumService sequenceNumService; @Autowired private MmPredictItemDao mmPredictItemDao; + @Autowired + private DataPointApi dataPointApi; + @Override - public PageResult<MmPredictItemEntity> queryPage(MmPredictItemPageReqVO reqVO) { - return mmPredictItemDao.selectPage(reqVO); + public PageResult<MmPredictItemRespVO> queryPage(MmPredictItemPageReqVO reqVO) { + IPage<MmPredictItemRespVO> page = mmPredictItemDao.selectPage(reqVO); + + return new PageResult<MmPredictItemRespVO>(page.getRecords(), page.getTotal()); } @Override - public void add(MmPredictItemEntity mmPredictItemEntity) { - mmPredictItemDao.insert(mmPredictItemEntity); + public List<MmPredictItemRespVO> list(Map<String, Object> params) { + return mmPredictItemDao.queryList(params); } @Override - public void update(MmPredictItemEntity mmPredictItemEntity) { - mmPredictItemDao.updateById(mmPredictItemEntity); + public MmPredictItemEntity getById(String id) { + return mmPredictItemDao.selectById(id); } - /* - public void savePredictItem(MmPredictItemDTO mmPredictItemDto) { + @Override + public List<Object[]> getHisData(String itemId, Date startTime, Date endTime) { + List<Object[]> result = new ArrayList<>(); + return result; + } + + @DSTransactional(rollbackFor = Exception.class) + @Override + public void add(MmPredictItemDTO mmPredictItemDto) { MmPredictItemEntity predictItem = mmPredictItemDto.getMmPredictItem(); predictItem.setId(UUID.randomUUID().toString()); predictItem.setCreateTime(new Date()); predictItem.setUpdateTime(new Date()); MmItemTypeEntity itemType = mmItemTypeImpl.getById(predictItem.getItemtypeid()); - if (ItemTypeEnum.NORMAL_ITEM.getName().equals(itemType.getItemtypename())) { - SequenceNumEntity sequenceNumEntity = sequenceNumService.getAndIncreaseByCode(ItemIncreaseCodeEnum.IM.toString()); + if (itemType != null && ItemTypeEnum.NORMAL_ITEM.getName().equals(itemType.getItemtypename())) { + MmSequenceNumEntity sequenceNumEntity = sequenceNumService.getAndIncreaseByCode(ItemIncreaseCodeEnum.IM.toString()); String str = String.format("%010d", sequenceNumEntity.getSequenceNum()); predictItem.setItemno(sequenceNumEntity.getPrefix() + str); MmPredictModelEntity mmPredictModel = mmPredictItemDto.getMmPredictModel(); - SequenceNumEntity preMdlSequenceNumEntity = sequenceNumService.getAndIncreaseByCode(ItemIncreaseCodeEnum.PRE_MDL.toString()); + MmSequenceNumEntity preMdlSequenceNumEntity = sequenceNumService.getAndIncreaseByCode(ItemIncreaseCodeEnum.PRE_MDL.toString()); String preMdlStr = String.format("%04d", preMdlSequenceNumEntity.getSequenceNum()); mmPredictModel.setModelno(preMdlSequenceNumEntity.getPrefix() + preMdlStr); mmPredictModel.setItemid(predictItem.getId()); @@ -105,8 +117,8 @@ item.setModelid(mmPredictModel.getId()); }); mmModelParamService.saveList(mmModelParamList); - } else if (ItemTypeEnum.MERGE_ITEM.getName().equals(itemType.getItemtypename())) { - SequenceNumEntity sequenceNumEntity = sequenceNumService.getAndIncreaseByCode(ItemIncreaseCodeEnum.IC.toString()); + } else if (itemType != null && ItemTypeEnum.MERGE_ITEM.getName().equals(itemType.getItemtypename())) { + MmSequenceNumEntity sequenceNumEntity = sequenceNumService.getAndIncreaseByCode(ItemIncreaseCodeEnum.IC.toString()); String str = String.format("%010d", sequenceNumEntity.getSequenceNum()); predictItem.setItemno(sequenceNumEntity.getPrefix() + str); @@ -122,15 +134,16 @@ MmItemOutputEntity mmItemOutput = mmPredictItemDto.getMmItemOutput(); mmItemOutput.setItemid(predictItem.getId()); mmItemOutputService.saveMmItemOutput(mmItemOutput); - }*/ -/* + } + + @DSTransactional(rollbackFor = Exception.class) @Override public void update(MmPredictItemDTO mmPredictItemDto) { MmPredictItemEntity predictItem = mmPredictItemDto.getMmPredictItem(); predictItem.setUpdateTime(new Date()); - this.updateById(predictItem); + mmPredictItemDao.updateById(predictItem); MmItemTypeEntity itemType = mmItemTypeImpl.getById(predictItem.getItemtypeid()); - if (ItemTypeEnum.NORMAL_ITEM.getName().equals(itemType.getItemtypename())) { + if (itemType != null && ItemTypeEnum.NORMAL_ITEM.getName().equals(itemType.getItemtypename())) { MmPredictModelEntity mmPredictModel = mmPredictItemDto.getMmPredictModel(); mmPredictModelService.update(mmPredictModel); @@ -145,16 +158,21 @@ item.setModelid(mmPredictModel.getId()); }); mmModelParamService.saveList(mmModelParamList); - } else if (ItemTypeEnum.MERGE_ITEM.getName().equals(itemType.getItemtypename())) { + } else if (itemType != null && ItemTypeEnum.MERGE_ITEM.getName().equals(itemType.getItemtypename())) { MmPredictMergeItemEntity mMmPredictMergeItem = mmPredictItemDto.getMmPredictMergeItem(); mmPredictMergeItemService.update(mMmPredictMergeItem); } DmModuleItemEntity dmModuleItem = mmPredictItemDto.getDmModuleItem(); - dmModuleItemService.update(dmModuleItem); - + if (!"".equals(dmModuleItem.getId()) && dmModuleItem.getId() != null) { + dmModuleItemService.update(dmModuleItem); + } MmItemOutputEntity mmItemOutput = mmPredictItemDto.getMmItemOutput(); - mmItemOutputService.update(mmItemOutput); - }*/ + if (!"".equals(mmItemOutput.getId()) && dmModuleItem.getId() != null) { + mmItemOutputService.update(mmItemOutput); + } + } + + @DSTransactional(rollbackFor = Exception.class) @Override public void deleteBatch(String[] itemIds) { mmPredictItemDao.deleteBatchIds(Arrays.asList(itemIds)); @@ -167,29 +185,21 @@ public MmPredictItemDTO info(String id) { MmPredictItemEntity predictItem = mmPredictItemDao.selectById(id); MmPredictItemDTO mmPredictItemDto = BeanUtils.toBean(predictItem, MmPredictItemDTO.class); - return mmPredictItemDto; - } -/* - - @Override - public MmPredictItemDTO info(String id) { - MmPredictItemEntity predictItem = mmPredictItemDao.selectById(id); - MmPredictItemDTO mmPredictItemDto = BeanUtils.toBean(predictItem, MmPredictItemDTO.class); mmPredictItemDto.setMmPredictItem(predictItem); mmPredictItemDto.setDmModuleItem(dmModuleItemService.getByItemid(id)); mmPredictItemDto.setMmItemOutput(mmItemOutputService.getByItemid(id)); MmItemTypeEntity itemType = mmItemTypeImpl.getById(predictItem.getItemtypeid()); - if (ItemTypeEnum.NORMAL_ITEM.getName().equals(itemType.getItemtypename())) { + 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.setMmModelParamList(mmModelParamService.getByModelid(mmPredictModel.getId())); - } else if (ItemTypeEnum.MERGE_ITEM.getName().equals(itemType.getItemtypename())) { + mmPredictItemDto.setMmPredictMergeItem(new MmPredictMergeItemEntity()); + } else if (itemType != null && ItemTypeEnum.MERGE_ITEM.getName().equals(itemType.getItemtypename())) { mmPredictItemDto.setMmPredictMergeItem(mmPredictMergeItemService.getByItemid(id)); } return mmPredictItemDto; } -*/ @Override public int check(MmPredictItemEntity mmPredictItem) { @@ -206,7 +216,7 @@ @Override public List<ItemVO> getByModuleId(String moduleId) { Map<String, Object> params = new HashMap<>(); - + params.put("MODULEID",moduleId); return mmPredictItemDao.getByModuleId(params); } -- Gitblit v1.9.3