| | |
| | | |
| | | import com.iailab.framework.common.pojo.PageResult; |
| | | import com.iailab.framework.common.service.impl.BaseServiceImpl; |
| | | import com.iailab.framework.common.util.collection.CollectionUtils; |
| | | import com.iailab.framework.common.util.object.BeanUtils; |
| | | import com.iailab.module.model.mcs.sche.dao.StSuggestOperationRecordDao; |
| | | import com.iailab.module.model.mcs.sche.entity.StSuggestOperationRecordEntity; |
| | | import com.iailab.module.model.mcs.sche.service.StSuggestOperationRecordService; |
| | | import com.iailab.module.model.mcs.sche.vo.StSuggestOperationRecordPageReqVO; |
| | | import com.iailab.module.model.mcs.sche.vo.StSuggestOperationRecordReqVO; |
| | | import com.iailab.module.model.mcs.sche.service.StSuggestSnapshotConfDetService; |
| | | import com.iailab.module.model.mcs.sche.service.StSuggestSnapshotConfMainService; |
| | | import com.iailab.module.model.mcs.sche.service.StSuggestSnapshotRecordService; |
| | | import com.iailab.module.model.mcs.sche.vo.*; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.time.LocalDateTime; |
| | | import java.time.ZoneId; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.UUID; |
| | | |
| | | |
| | |
| | | public class StSuggestOperationRecordServiceImpl extends BaseServiceImpl<StSuggestOperationRecordDao, StSuggestOperationRecordEntity> |
| | | implements StSuggestOperationRecordService { |
| | | |
| | | @Autowired |
| | | private StSuggestSnapshotConfMainService stSuggestSnapshotConfMainService; |
| | | |
| | | @Autowired |
| | | private StSuggestSnapshotConfDetService stSuggestSnapshotConfDetService; |
| | | |
| | | @Autowired |
| | | private StSuggestSnapshotRecordService stSuggestSnapshotRecordService; |
| | | |
| | | @Override |
| | | public PageResult<StSuggestOperationRecordEntity> page(StSuggestOperationRecordPageReqVO reqVO) { |
| | | return baseDao.selectPage(reqVO); |
| | |
| | | public void create(StSuggestOperationRecordReqVO reqVo) { |
| | | StSuggestOperationRecordEntity entity = BeanUtils.toBean(reqVo, StSuggestOperationRecordEntity.class); |
| | | entity.setId(UUID.randomUUID().toString()); |
| | | entity.setHandleTime(new Date()); |
| | | baseDao.insert(entity); |
| | | if (!"采纳建议".equals(reqVo.getOperate())){ |
| | | return; |
| | | } |
| | | //获取调度建议快照配置表信息 |
| | | StSuggestSnapshotConfMainRespVO confMain = stSuggestSnapshotConfMainService.getByModelIdAndScheduleObj(reqVo.getModelId(), reqVo.getScheduleObj()); |
| | | if (confMain == null) { |
| | | return; |
| | | } |
| | | List<StSuggestSnapshotConfDetRespVO> confDetList = stSuggestSnapshotConfDetService.getByConfId(confMain.getId()); |
| | | if (CollectionUtils.isAnyEmpty(confDetList)) { |
| | | return; |
| | | } |
| | | confDetList.forEach(confDet -> { |
| | | StSuggestSnapshotRecordSaveReqVO snapshotRecordSaveReqVO = new StSuggestSnapshotRecordSaveReqVO(); |
| | | snapshotRecordSaveReqVO.setModelId(entity.getModelId()); |
| | | snapshotRecordSaveReqVO.setOperationId(entity.getId()); |
| | | snapshotRecordSaveReqVO.setDataNo(confDet.getDataNo()); |
| | | snapshotRecordSaveReqVO.setDataType(confDet.getDataType()); |
| | | snapshotRecordSaveReqVO.setDataName(confDet.getDataName()); |
| | | snapshotRecordSaveReqVO.setScheduleTime(entity.getScheduleTime()); |
| | | //计算开始时间,开始时间为当前调度时间减去快照配置表配置的左侧时间长度 |
| | | LocalDateTime localStartDateTime = entity.getScheduleTime().toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime().minusMinutes(confDet.getLeftLength() == null ? 60 : confDet.getLeftLength()); |
| | | Date startTime = Date.from(localStartDateTime.atZone(ZoneId.systemDefault()).toInstant()); |
| | | snapshotRecordSaveReqVO.setStartTime(startTime); |
| | | //计算结束时间,结束时间为当前调度时间加上快照配置表配置的右侧时间长度 |
| | | LocalDateTime localEndDateTime = entity.getScheduleTime().toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime().plusMinutes(confDet.getRightLength() == null ? 60 : confDet.getLeftLength()); |
| | | Date endTime = Date.from(localEndDateTime.atZone(ZoneId.systemDefault()).toInstant()); |
| | | snapshotRecordSaveReqVO.setEndTime(endTime); |
| | | stSuggestSnapshotRecordService.create(snapshotRecordSaveReqVO); |
| | | }); |
| | | } |
| | | |
| | | } |