liurunyu
2025-02-26 5599ea07c557223e5a8f0acae755de852d2fe008
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
package com.dy.pipIrrWechat.irrigatePlan;
 
import com.dy.common.webUtil.QueryResultVo;
import com.dy.pipIrrGlobal.daoIr.*;
import com.dy.pipIrrGlobal.pojoIr.IrIrrigatePlan;
import com.dy.pipIrrGlobal.pojoIr.IrIrrigateSchedule;
import com.dy.pipIrrGlobal.pojoIr.IrOpeningSchedule;
import com.dy.pipIrrGlobal.pojoIr.IrPlanOperate;
import com.dy.pipIrrGlobal.voIr.VoIrrigatePlan;
import com.dy.pipIrrGlobal.voIr.VoIrrigateSchedule;
import com.dy.pipIrrWechat.irrigatePlan.qo.QoIrrigatePlan;
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.List;
import java.util.Map;
 
/**
 * @author ZhuBaoMin
 * @date 2025-02-20 15:27
 * @LastEditTime 2025-02-20 15:27
 * @Description
 */
 
@Slf4j
@Service
public class IrrigatePlanSv {
    @Autowired
    private IrIrrigatePlanMapper irrigatePlanMapper;
 
    @Autowired
    private IrPlanOperateMapper irPlanOperateMapper;
 
    @Autowired
    private IrIrrigateScheduleMapper irIrrigateScheduleMapper;
 
    @Autowired
    private IrOpeningScheduleMapper irOpeningScheduleMapper;
 
    @Autowired
    private IrIrrigateGroupMapper irIrrigateGroupMapper;
 
    @Autowired
    private IrIrrigateUnitMapper irIrrigateUnitMapper;
 
    /**
     * 添加灌溉计划
     * @param po
     * @return
     */
    public Long addIrrigatePlan(IrIrrigatePlan po) {
        irrigatePlanMapper.insert(po);
        return po.getId();
    }
 
    /**
     * 根据指定的条件获取计划列表
     * @param queryVo
     * @return
     */
    public QueryResultVo<List<VoIrrigatePlan>> getIrrigatePlans(QoIrrigatePlan queryVo) {
        Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(queryVo);
 
        Long itemTotal = irrigatePlanMapper.getIrrigatePlanCount(params);
 
        QueryResultVo<List<VoIrrigatePlan>> rsVo = new QueryResultVo<>();
        rsVo.pageSize = queryVo.pageSize;
        rsVo.pageCurr = queryVo.pageCurr;
 
        rsVo.calculateAndSet(itemTotal, params);
        rsVo.obj = irrigatePlanMapper.getIrrigatePlans(params);
        return rsVo;
    }
 
    /**
     * 发布指定的灌溉计划
     * @param planId
     * @return
     */
    public Integer publishIrrigatePlan(Long planId) {
        return irrigatePlanMapper.publishIrrigatePlan(planId);
    }
 
    /**
     * 添加灌溉计划操作记录
     * @param po
     * @return
     */
    public Long addPlanOperate(IrPlanOperate po) {
        irPlanOperateMapper.insert(po);
        return po.getId();
    }
 
    /**
     * 添加灌溉次序记录
     * @param po
     * @return
     */
    public Long addIrrigateSchedule(IrIrrigateSchedule po) {
        irIrrigateScheduleMapper.insert(po);
        return po.getId();
    }
 
    /**
     * 根据计划ID获取灌溉次序
     * @param planId
     * @return
     */
    public List<VoIrrigateSchedule> getIrrigateSchedules(Long planId) {
        return irIrrigateScheduleMapper.getIrrigateSchedules(planId);
    }
 
    /**
     * 添加开阀计划
     * @param po
     * @return
     */
    public Long addOpeningSchedule(IrOpeningSchedule po) {
        irOpeningScheduleMapper.insert(po);
        return po.getId();
    }
 
    /**
     * 根据轮灌组ID获取取水口ID列表
     * @param groupId
     * @return
     */
    public List<Long> getIntakesByGroupId(Long groupId) {
        return irIrrigateGroupMapper.getIntakesByGroupId(groupId);
    }
 
    /**
     * 根据灌溉单元ID获取取水口ID
     * @param unitId
     * @return
     */
    public Long getIntakeIdByUnitId(Long unitId) {
        return irIrrigateUnitMapper.getIntakeIdByUnitId(unitId);
    }
}