Administrator
2024-05-27 42f5453644c41d3b6ac9e381f931efdfc9da8178
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
package com.dy.pipIrrIrrigate.irrigateScheduling;
 
import com.dy.common.webUtil.QueryResultVo;
import com.dy.pipIrrGlobal.daoIr.IrIrrigateSchedulingMapper;
import com.dy.pipIrrGlobal.pojoIr.IrIrrigateScheduling;
import com.dy.pipIrrGlobal.voIr.VoScheduling;
import com.dy.pipIrrGlobal.voIr.VoSchedulingOne;
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 java.util.Date;
import java.util.List;
import java.util.Map;
 
/**
 * @author :WuZeYu
 * @Date :2024/5/27  10:12
 * @LastEditTime :2024/5/27  10:12
 * @Description
 */
@Slf4j
@Service
public class IrIrrigateSchedulingSv {
 
    @Autowired
    private IrIrrigateSchedulingMapper irIrrigateSchedulingMapper;
 
    /**
     * 添加作物灌溉制度
     *
     * @param po
     * @return
     */
    public Integer addScheduling(IrIrrigateScheduling po) {
        po.setDeleted((byte) 0);
        po.setOperateDt(new Date());
        int rows = irIrrigateSchedulingMapper.insertSelective(po);
        if (rows == 0) {
            return 0;
        }
        return 1;
    }
    /**
     * 删除作物灌溉制度
     *
     * @param id
     */
    public Integer deleteScheduling(Long id) {
        int rows = irIrrigateSchedulingMapper.deleteLogicById(id);
        if (rows == 0) {
            return 0;
        }
        return 1;
    }
 
    /**
     * 修改作物灌溉制度
     * @param po
     * @return
     */
    public Integer updateScheduling(IrIrrigateScheduling po){
        int rows = irIrrigateSchedulingMapper.updateByPrimaryKeySelective(po);
        if (rows == 0){
            return 0;
        }
        return 1;
    }
 
    /**
     * 分页查询作物灌溉制度
     * @param queryVo
     * @return
     */
    public QueryResultVo<List<VoScheduling>> getSchedulings(QueryVo queryVo){
        Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(queryVo);
        Long itemTotal = irIrrigateSchedulingMapper.getRecordCount(params);
 
        QueryResultVo<List<VoScheduling>> rsVo = new QueryResultVo<>();
        rsVo.pageSize = queryVo.pageSize;
        rsVo.pageCurr = queryVo.pageCurr;
        rsVo.calculateAndSet(itemTotal, params);
        rsVo.obj = irIrrigateSchedulingMapper.getSchedulings(params);
        return rsVo;
    }
 
    /**
     * 获取一个作物灌溉制度数据
     * @param id
     * @return
     */
    public VoSchedulingOne selectById(Long id){
        VoSchedulingOne irCrop = irIrrigateSchedulingMapper.selectById(id);
        return irCrop;
    }
}