dengzedong
5 天以前 2e0e42583419225b5dd38e97594de82accd594ad
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
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);
    }
}