wuzeyu
2024-05-15 2938172b377e5ed7a55e5dde4a218244445e8a6e
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
package com.dy.pipIrrIrrigate.project;
 
 
import com.dy.pipIrrGlobal.daoIr.IrProjectMapper;
import com.dy.pipIrrGlobal.pojoIr.IrProject;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
 
import java.util.Date;
 
/**
 * @author :WuZeYu
 * @Date :2024/5/14  13:56
 * @LastEditTime :2024/5/14  13:56
 * @Description
 */
@Slf4j
@Service
public class ProjectSv {
    @Autowired
    private IrProjectMapper irProjectMapper;
 
    /**
     * 添加项目
     *
     * @param po
     * @return
     */
    public Integer addProject(IrProject po) {
        po.setOperateDt(new Date());
        po.setDeleted((byte) 0);
        if (po.getVillageId() != null) {
            po.setTownId(irProjectMapper.getSupperByVillageId(po.getVillageId()));
            po.setCountyId(irProjectMapper.getSupperByVillageId(po.getTownId()));
            po.setCityId(irProjectMapper.getSupperByVillageId(po.getCountyId()));
            po.setProvinceId(irProjectMapper.getSupperByVillageId(po.getCityId()));
        }
        if (po.getTownId() != null) {
            po.setCountyId(irProjectMapper.getSupperByVillageId(po.getTownId()));
            po.setCityId(irProjectMapper.getSupperByVillageId(po.getCountyId()));
            po.setProvinceId(irProjectMapper.getSupperByVillageId(po.getCityId()));
        }
        if (po.getCountyId() != null) {
            po.setCityId(irProjectMapper.getSupperByVillageId(po.getCountyId()));
            po.setProvinceId(irProjectMapper.getSupperByVillageId(po.getCityId()));
        }
        if (po.getCityId() != null) {
            po.setProvinceId(irProjectMapper.getSupperByVillageId(po.getCityId()));
        }
        int rows = irProjectMapper.insertSelective(po);
        if (rows == 0) {
            return 0;
        }
        return 1;
    }
 
    /**
     * 删除项目
     *
     * @param id
     */
    public Integer deleteProject(Long id) {
        int rows = irProjectMapper.deleteLogicById(id);
        if (rows == 0) {
            return 0;
        }
            return 1;
    }
 
    /**
     * 修改项目信息
     * @param po
     * @return
     */
    public Integer updateProject(IrProject po){
        po.setOperateDt(new Date());
        if (po.getVillageId() != null) {
            po.setTownId(irProjectMapper.getSupperByVillageId(po.getVillageId()));
            po.setCountyId(irProjectMapper.getSupperByVillageId(po.getTownId()));
            po.setCityId(irProjectMapper.getSupperByVillageId(po.getCountyId()));
            po.setProvinceId(irProjectMapper.getSupperByVillageId(po.getCityId()));
        }
        if (po.getTownId() != null) {
            po.setCountyId(irProjectMapper.getSupperByVillageId(po.getTownId()));
            po.setCityId(irProjectMapper.getSupperByVillageId(po.getCountyId()));
            po.setProvinceId(irProjectMapper.getSupperByVillageId(po.getCityId()));
        }
        if (po.getCountyId() != null) {
            po.setCityId(irProjectMapper.getSupperByVillageId(po.getCountyId()));
            po.setProvinceId(irProjectMapper.getSupperByVillageId(po.getCityId()));
        }
        if (po.getCityId() != null) {
            po.setProvinceId(irProjectMapper.getSupperByVillageId(po.getCityId()));
        }
        int rows = irProjectMapper.updateByPrimaryKeySelective(po);
        if (rows == 0){
            return 0;
        }
        return 1;
    }
 
    /**
     * 修改项目状态
     * @param po
     * @return
     */
    public Integer updateProjectState(IrProject po){
        po.setOperateDt(new Date());
        int rows = irProjectMapper.updateProjectState(po);
        if (rows == 0){
            return 0;
        }
        return 1;
    }
}