package com.iailab.module.model.mcs.sche.service.impl; import com.alibaba.fastjson.JSON; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.iailab.framework.common.service.impl.BaseServiceImpl; import com.iailab.module.model.mcs.sche.dao.StScheduleRecordDetailDao; import com.iailab.module.model.mcs.sche.entity.StScheduleRecordDetailEntity; import com.iailab.module.model.mcs.sche.service.StScheduleRecordDetailService; import com.iailab.module.model.mdk.vo.ScheduleResultVO; import org.springframework.stereotype.Service; import org.springframework.util.CollectionUtils; import java.util.List; import java.util.Map; import java.util.UUID; /** * @author PanZhibao * @Description * @createTime 2024年09月06日 */ @Service public class StScheduleRecordDetailServiceImpl extends BaseServiceImpl implements StScheduleRecordDetailService { @Override public void create(String recordId, ScheduleResultVO resultVO) { if (CollectionUtils.isEmpty(resultVO.getResult())) { return; } for (Map.Entry entry: resultVO.getResult().entrySet()) { StScheduleRecordDetailEntity entity = new StScheduleRecordDetailEntity(); entity.setId(UUID.randomUUID().toString()); entity.setRecordId(recordId); entity.setSchemeId(resultVO.getSchemeId()); entity.setModelId(resultVO.getModelId()); entity.setScheduleTime(resultVO.getScheduleTime()); entity.setResultKey(entry.getKey()); entity.setResultValue(JSON.toJSONString(entry.getValue())); baseDao.insert(entity); } } @Override public List getByRecordId(String recordId) { QueryWrapper queryWrapper = new QueryWrapper<>(); queryWrapper.eq("record_id", recordId); queryWrapper.orderByAsc("result_key"); return baseDao.selectList(queryWrapper); } }