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<StScheduleRecordDetailDao, StScheduleRecordDetailEntity>
|
implements StScheduleRecordDetailService {
|
|
|
@Override
|
public void create(String recordId, ScheduleResultVO resultVO) {
|
if (CollectionUtils.isEmpty(resultVO.getResult())) {
|
return;
|
}
|
for (Map.Entry<String, Object > 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<StScheduleRecordDetailEntity> getByRecordId(String recordId) {
|
QueryWrapper<StScheduleRecordDetailEntity> queryWrapper = new QueryWrapper<>();
|
queryWrapper.eq("record_id", recordId);
|
queryWrapper.orderByAsc("result_key");
|
return baseDao.selectList(queryWrapper);
|
}
|
}
|