dengzedong
6 天以前 a6e46fe2b5729e7468b6f3c4e079232801c22520
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
package com.iailab.module.model.mcs.sche.service.impl;
 
import com.iailab.framework.common.service.impl.BaseServiceImpl;
import com.iailab.framework.common.util.object.BeanUtils;
import com.iailab.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.iailab.module.model.mcs.sche.dao.StScheduleModelSettingDao;
import com.iailab.module.model.mcs.sche.entity.StScheduleModelSettingEntity;
import com.iailab.module.model.mcs.sche.service.StScheduleModelSettingService;
import com.iailab.module.model.mcs.sche.vo.StScheduleModelSettingSaveReqVO;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
 
import java.util.List;
import java.util.UUID;
 
/**
 * @author PanZhibao
 * @Description
 * @createTime 2024年09月06日
 */
@Service
public class StScheduleModelSettingServiceImpl extends BaseServiceImpl<StScheduleModelSettingDao, StScheduleModelSettingEntity>
        implements StScheduleModelSettingService {
 
    @Override
    public List<StScheduleModelSettingEntity> getByModelId(String modelId) {
        return baseDao.selectList(
                new LambdaQueryWrapperX<StScheduleModelSettingEntity>()
                        .likeIfPresent(StScheduleModelSettingEntity::getModelid, modelId)
                        .orderByAsc(StScheduleModelSettingEntity::getSort)
        );
    }
 
    @Override
    public void deleteByModelId(String modelId) {
        baseDao.delete(new LambdaQueryWrapperX<StScheduleModelSettingEntity>()
                .likeIfPresent(StScheduleModelSettingEntity::getModelid, modelId)
        );
    }
 
    @Override
    public void saveList(String modelId, List<StScheduleModelSettingSaveReqVO> saveList) {
        deleteByModelId(modelId);
        if (CollectionUtils.isEmpty(saveList)) {
            return;
        }
        for (int i = 0; i < saveList.size(); i++) {
            StScheduleModelSettingSaveReqVO item = saveList.get(i);
            StScheduleModelSettingEntity entity = BeanUtils.toBean(item, StScheduleModelSettingEntity.class);
            entity.setId(UUID.randomUUID().toString());
            entity.setModelid(modelId);
            entity.setSort(i);
            baseDao.insert(entity);
        }
    }
 
    @Override
    public void updatePyFile(String pyModule, String fileName) {
        baseDao.updatePyFile(pyModule + "." + fileName.substring(0,fileName.lastIndexOf("_")+1),pyModule + "." + fileName);
    }
}