liurunyu
2024-11-14 f628dd00d8f99b37a128243b941bb8cfefd02ac9
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
package com.dy.pipIrrBase.rtuUpgrade.task;
 
import com.dy.common.webUtil.QueryResultVo;
import com.dy.pipIrrGlobal.daoRm.UgRtuControllerMapper;
import com.dy.pipIrrGlobal.pojoUg.UgRtuController;
import com.dy.pipIrrGlobal.voPr.VoController;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.common.utils.PojoUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
 
import java.util.List;
import java.util.Map;
 
/**
 * @Author: liurunyu
 * @Date: 2024/11/7 14:50
 * @Description
 */
@Slf4j
@Service
public class UgRtuControllerSv {
 
    @Autowired
    private UgRtuControllerMapper dao ;
 
 
    /**
     * 分页查询一个升级任务的所有控制器
     * @return 一些控制器信息
     */
    public QueryResultVo<List<VoController>> selectSome(QueryControllerVo queryVo){
        Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(queryVo) ;
        Long itemTotal = this.dao.selectRecordCount(params) ;
 
        QueryResultVo<List<VoController>> rsVo = new QueryResultVo<>() ;
        rsVo.pageSize = queryVo.pageSize ;
        rsVo.pageCurr = queryVo.pageCurr ;
        rsVo.calculateAndSet(itemTotal, params);
        rsVo.obj = this.dao.selectControllers(params) ;
 
        return rsVo ;
    }
 
    /**
     * 查询一个升级任务所有控制器
     * @return 一些一些控制器信息
     */
    public List<UgRtuController> selectAllConByTask(Long taskId){
        List<UgRtuController> list = this.dao.selectAllConByTask(taskId) ;
        return list ;
    }
 
    /**
     * 判断是否存在
     * @param taskId 任务id
     * @param controllerId 控制器ID
     * @return 存在否
     */
    public boolean exist(Long taskId, Long controllerId){
        Long count = this.dao.selectCountByTaskAndCon(taskId, controllerId) ;
        if(count== null || count == 0){
            return false ;
        }else{
            return true ;
        }
    }
 
    /**
     * 新增
     * @param po 实体
     * @return 数量
     */
    @Transactional
    public int save(UgRtuController po){
        return this.dao.insertSelective(po) ;
    }
 
    /**
     * 删除所有
     * @param taskId 任务主键
     * @return 数量
     */
    @Transactional
    public int deleteAll(Long taskId){
        return this.dao.deleteByTaskId(taskId) ;
    }
    /**
     * 删除
     * @param id 主键
     * @return 数量
     */
    @Transactional
    public int deleteOne(Long id){
        return this.dao.deleteByPrimaryKey(id) ;
    }
}