潘志宝
2024-12-25 8a6b19bf5c50ebb54e965645a9366f6cfea02351
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
53
54
55
56
57
58
59
60
61
62
63
64
package com.iailab.module.model.mcs.sche.service.impl;
 
import com.alibaba.fastjson.JSON;
import com.baomidou.dynamic.datasource.annotation.DSTransactional;
import com.iailab.framework.common.pojo.PageResult;
import com.iailab.framework.common.service.impl.BaseServiceImpl;
import com.iailab.framework.common.util.object.ConvertUtils;
import com.iailab.module.model.mcs.sche.dao.StScheduleRecordDao;
import com.iailab.module.model.mcs.sche.entity.StScheduleRecordDetailEntity;
import com.iailab.module.model.mcs.sche.entity.StScheduleRecordEntity;
import com.iailab.module.model.mcs.sche.service.StScheduleRecordDetailService;
import com.iailab.module.model.mcs.sche.service.StScheduleRecordService;
import com.iailab.module.model.mcs.sche.vo.StScheduleRecordDetailRespVO;
import com.iailab.module.model.mcs.sche.vo.StScheduleRecordPageReqVO;
import com.iailab.module.model.mcs.sche.vo.StScheduleRecordRespVO;
import com.iailab.module.model.mdk.vo.ScheduleResultVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
 
import java.util.Date;
import java.util.List;
import java.util.UUID;
 
/**
 * @author PanZhibao
 * @Description
 * @createTime 2024年09月06日
 */
@Service
public class StScheduleRecordServiceImpl extends BaseServiceImpl<StScheduleRecordDao, StScheduleRecordEntity>
        implements StScheduleRecordService {
 
    @Autowired
    private StScheduleRecordDetailService stScheduleRecordDetailService;
 
    @Override
    public PageResult<StScheduleRecordEntity> page(StScheduleRecordPageReqVO reqVO) {
        return baseDao.selectPage(reqVO);
    }
 
    @Override
    public StScheduleRecordRespVO getInfo(String id) {
        StScheduleRecordEntity entity = baseDao.selectById(id);
        StScheduleRecordRespVO respVO = ConvertUtils.sourceToTarget(entity, StScheduleRecordRespVO.class);
        List<StScheduleRecordDetailEntity> list = stScheduleRecordDetailService.getByRecordId(id);
        respVO.setDetailList(ConvertUtils.sourceToTarget(list, StScheduleRecordDetailRespVO.class));
        return respVO;
    }
 
    @Override
    @DSTransactional(rollbackFor = Exception.class)
    public void create(ScheduleResultVO resultVO) {
        StScheduleRecordEntity entity = new StScheduleRecordEntity();
        entity.setId(UUID.randomUUID().toString());
        entity.setCreateTime(new Date());
        entity.setSchemeId(resultVO.getSchemeId());
        entity.setScheduleTime(resultVO.getScheduleTime());
        entity.setModelId(resultVO.getModelId());
        entity.setResultCode(resultVO.getResultCode());
        entity.setResultData(JSON.toJSONString(resultVO.getResult()));
        baseDao.insert(entity);
        stScheduleRecordDetailService.create(entity.getId(), resultVO);
    }
}