潘志宝
2024-12-25 874dd8d939b4ae61efbb799855c9ddf328722972
提交 | 用户 | 时间
bbc1ee 1 package com.iailab.module.model.mcs.sche.service.impl;
2
8a6b19 3 import com.alibaba.fastjson.JSON;
3de266 4 import com.baomidou.dynamic.datasource.annotation.DSTransactional;
bbc1ee 5 import com.iailab.framework.common.pojo.PageResult;
6 import com.iailab.framework.common.service.impl.BaseServiceImpl;
b8ecc0 7 import com.iailab.framework.common.util.object.ConvertUtils;
bbc1ee 8 import com.iailab.module.model.mcs.sche.dao.StScheduleRecordDao;
b8ecc0 9 import com.iailab.module.model.mcs.sche.entity.StScheduleRecordDetailEntity;
bbc1ee 10 import com.iailab.module.model.mcs.sche.entity.StScheduleRecordEntity;
11 import com.iailab.module.model.mcs.sche.service.StScheduleRecordDetailService;
12 import com.iailab.module.model.mcs.sche.service.StScheduleRecordService;
b8ecc0 13 import com.iailab.module.model.mcs.sche.vo.StScheduleRecordDetailRespVO;
bbc1ee 14 import com.iailab.module.model.mcs.sche.vo.StScheduleRecordPageReqVO;
b8ecc0 15 import com.iailab.module.model.mcs.sche.vo.StScheduleRecordRespVO;
bbc1ee 16 import com.iailab.module.model.mdk.vo.ScheduleResultVO;
17 import org.springframework.beans.factory.annotation.Autowired;
18 import org.springframework.stereotype.Service;
19
20 import java.util.Date;
b8ecc0 21 import java.util.List;
bbc1ee 22 import java.util.UUID;
23
24 /**
25  * @author PanZhibao
26  * @Description
27  * @createTime 2024年09月06日
28  */
29 @Service
30 public class StScheduleRecordServiceImpl extends BaseServiceImpl<StScheduleRecordDao, StScheduleRecordEntity>
31         implements StScheduleRecordService {
32
33     @Autowired
34     private StScheduleRecordDetailService stScheduleRecordDetailService;
35
36     @Override
37     public PageResult<StScheduleRecordEntity> page(StScheduleRecordPageReqVO reqVO) {
38         return baseDao.selectPage(reqVO);
39     }
40
41     @Override
b8ecc0 42     public StScheduleRecordRespVO getInfo(String id) {
43         StScheduleRecordEntity entity = baseDao.selectById(id);
44         StScheduleRecordRespVO respVO = ConvertUtils.sourceToTarget(entity, StScheduleRecordRespVO.class);
45         List<StScheduleRecordDetailEntity> list = stScheduleRecordDetailService.getByRecordId(id);
46         respVO.setDetailList(ConvertUtils.sourceToTarget(list, StScheduleRecordDetailRespVO.class));
47         return respVO;
48     }
49
50     @Override
3de266 51     @DSTransactional(rollbackFor = Exception.class)
bbc1ee 52     public void create(ScheduleResultVO resultVO) {
53         StScheduleRecordEntity entity = new StScheduleRecordEntity();
54         entity.setId(UUID.randomUUID().toString());
55         entity.setCreateTime(new Date());
56         entity.setSchemeId(resultVO.getSchemeId());
57         entity.setScheduleTime(resultVO.getScheduleTime());
58         entity.setModelId(resultVO.getModelId());
8a6b19 59         entity.setResultCode(resultVO.getResultCode());
60         entity.setResultData(JSON.toJSONString(resultVO.getResult()));
bbc1ee 61         baseDao.insert(entity);
62         stScheduleRecordDetailService.create(entity.getId(), resultVO);
63     }
64 }