guoshilong
2024-02-22 9a1fc806b7cd4e4e11778f9d3bf51987f8b7908b
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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
package cn.gistack.sm.sjztmd.service.impl;
 
 
import cn.gistack.sm.sjztmd.entity.AttResDangerManageSpecial;
import cn.gistack.sm.sjztmd.entity.AttResFlseLim;
import cn.gistack.sm.sjztmd.entity.AttResStagChar;
import cn.gistack.sm.sjztmd.entity.AttResWaterBlock;
import cn.gistack.sm.sjztmd.mapper.AttResFlseLimMapper;
import cn.gistack.sm.sjztmd.service.IAttResDangerManageSpecialService;
import cn.gistack.sm.sjztmd.service.IAttResFlseLimService;
import cn.gistack.sm.sjztmd.service.IAttResStagCharService;
import cn.gistack.sm.sjztmd.service.IAttResWaterBlockService;
import cn.gistack.sm.sjztmd.vo.EditResInfoVO;
import cn.gistack.system.user.feign.IUserClient;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.baomidou.mybatisplus.extension.toolkit.SqlHelper;
import org.springblade.core.secure.utils.AuthUtil;
import org.springblade.core.tool.utils.DateUtil;
import org.springblade.core.tool.utils.StringUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
 
import java.util.Date;
 
/**
 * @PROJECT_NAME: skjcmanager
 * @DESCRIPTION:
 * @USER: aix
 * @DATE: 2023/5/22 21:26
 */
@Service
@DS("zt")
public class AttResFlseLimServiceImpl extends ServiceImpl<AttResFlseLimMapper, AttResFlseLim> implements IAttResFlseLimService {
 
    @Autowired
    private IAttResStagCharService attResStagCharService;
 
    @Autowired
    private IAttResWaterBlockService attResWaterBlockService;
 
    @Autowired
    private IAttResDangerManageSpecialService attResDangerManageSpecialService;
 
    @Autowired
    private IUserClient userClient;
 
    @Override
    @Transactional
    public Boolean updateAttResFlseLimByGuid(EditResInfoVO editResInfoVO) {
        editResInfoVO.setUpdateTime(DateUtil.now());
 
        // 修改汛期水位
        if (null != editResInfoVO.getXqswObjQ() && StringUtil.isNotBlank(String.valueOf(editResInfoVO.getXqswObjQ().getTbFlseLimStag()))) {
            AttResFlseLim attResFlseLimQ = editResInfoVO.getXqswObjQ();
            attResFlseLimQ.setResGuid(editResInfoVO.getResGuid());
            attResFlseLimQ.setUpdateTime(DateUtil.now());
 
            JSONObject paramJson = new JSONObject();
            paramJson.put("time", DateUtil.format(new Date(),"yyyy-MM-dd"));
            String editPar = "tb_flse_lim_stag:修改值为" + editResInfoVO.getXqswObjQ().getTbFlseLimStag();
            if (StringUtil.isNotBlank(editResInfoVO.getXqswObjQ().getTbFloodSeasonStart()))
                editPar += ",tb_flood_season_start:修改值为" + editResInfoVO.getXqswObjQ().getTbFloodSeasonStart();
            if (StringUtil.isNotBlank(editResInfoVO.getXqswObjQ().getTbFloodSeasonEnd()))
                editPar += ",tb_flood_season_end:修改值为" + editResInfoVO.getXqswObjQ().getTbFloodSeasonEnd();
            paramJson.put("editPar", editPar);
            paramJson.put("ly", "ywxt");
            paramJson.put("user_id", AuthUtil.getUserId());
            paramJson.put("user_name", AuthUtil.getUserName());
            paramJson.put("phone", userClient.userInfoById(AuthUtil.getUserId()).getData().getPhone());
            attResFlseLimQ.setUpdateBy(paramJson.toJSONString());
 
            Integer ret = baseMapper.updateAttResFlseLimByGuid(attResFlseLimQ,"前汛期");
            if (ret == 0) {
                baseMapper.addAttResFlseLim(attResFlseLimQ,"前汛期");
            }
        }
        if (null != editResInfoVO.getXqswObjZ()  && StringUtil.isNotBlank(String.valueOf(editResInfoVO.getXqswObjZ().getTbFlseLimStag()))) {
            AttResFlseLim attResFlseLimZ = editResInfoVO.getXqswObjZ();
            attResFlseLimZ.setResGuid(editResInfoVO.getResGuid());
            attResFlseLimZ.setUpdateTime(DateUtil.now());
 
            JSONObject paramJson = new JSONObject();
            paramJson.put("time", DateUtil.format(new Date(),"yyyy-MM-dd"));
            String editPar = "tb_flse_lim_stag:修改值为" + editResInfoVO.getXqswObjZ().getTbFlseLimStag();
            if (StringUtil.isNotBlank(editResInfoVO.getXqswObjQ().getTbFloodSeasonStart()))
                editPar += ",tb_flood_season_start:修改值为" + editResInfoVO.getXqswObjQ().getTbFloodSeasonStart();
            if (StringUtil.isNotBlank(editResInfoVO.getXqswObjQ().getTbFloodSeasonEnd()))
                editPar += ",tb_flood_season_end:修改值为" + editResInfoVO.getXqswObjQ().getTbFloodSeasonEnd();
            paramJson.put("editPar", editPar);
            paramJson.put("ly", "ywxt");
            paramJson.put("user_id", AuthUtil.getUserId());
            paramJson.put("user_name", AuthUtil.getUserName());
            paramJson.put("phone", userClient.userInfoById(AuthUtil.getUserId()).getData().getPhone());
            attResFlseLimZ.setUpdateBy(paramJson.toJSONString());
 
            Integer ret = baseMapper.updateAttResFlseLimByGuid(attResFlseLimZ,"中汛期");
 
            if (ret == 0) {
                baseMapper.addAttResFlseLim(attResFlseLimZ,"中汛期");
            }
        }
        if (null != editResInfoVO.getXqswObjH() && StringUtil.isNotBlank(String.valueOf(editResInfoVO.getXqswObjH().getTbFlseLimStag()))) {
            AttResFlseLim attResFlseLimH = editResInfoVO.getXqswObjH();
            attResFlseLimH.setResGuid(editResInfoVO.getResGuid());
            attResFlseLimH.setUpdateTime(DateUtil.now());
 
            JSONObject paramJson = new JSONObject();
            paramJson.put("time", DateUtil.format(new Date(),"yyyy-MM-dd"));
            String editPar = "tb_flse_lim_stag:修改值为" + editResInfoVO.getXqswObjH().getTbFlseLimStag();
            if (StringUtil.isNotBlank(editResInfoVO.getXqswObjQ().getTbFloodSeasonStart()))
                editPar += ",tb_flood_season_start:修改值为" + editResInfoVO.getXqswObjQ().getTbFloodSeasonStart();
            if (StringUtil.isNotBlank(editResInfoVO.getXqswObjQ().getTbFloodSeasonEnd()))
                editPar += ",tb_flood_season_end:修改值为" + editResInfoVO.getXqswObjQ().getTbFloodSeasonEnd();
            paramJson.put("editPar", editPar);
            paramJson.put("ly", "ywxt");
            paramJson.put("user_id", AuthUtil.getUserId());
            paramJson.put("user_name", AuthUtil.getUserName());
            paramJson.put("phone", userClient.userInfoById(AuthUtil.getUserId()).getData().getPhone());
            attResFlseLimH.setUpdateBy(paramJson.toJSONString());
 
            Integer ret = baseMapper.updateAttResFlseLimByGuid(attResFlseLimH,"后汛期");
            if (ret == 0) {
                baseMapper.addAttResFlseLim(attResFlseLimH,"后汛期");
            }
        }
 
        // 修改水位特征参数
        AttResStagChar attResStagChar = new AttResStagChar();
        attResStagChar.setResGuid(editResInfoVO.getResGuid());
        if (StringUtil.isNotBlank(editResInfoVO.getChecFlStag()))
            attResStagChar.setTbChecFlStag(editResInfoVO.getChecFlStag());
        if (StringUtil.isNotBlank(editResInfoVO.getDeadCap()))
            attResStagChar.setTbDeadCap(editResInfoVO.getDeadCap());
        if (StringUtil.isNotBlank(editResInfoVO.getDeadStag()))
            attResStagChar.setTbDeadStag(editResInfoVO.getDeadStag());
        if (StringUtil.isNotBlank(editResInfoVO.getFlprHighStag()))
            attResStagChar.setTbFlprHighStag(editResInfoVO.getFlprHighStag());
        if (StringUtil.isNotBlank(editResInfoVO.getNormPoolStag()))
            attResStagChar.setTbNormPoolStag(editResInfoVO.getNormPoolStag());
        if (StringUtil.isNotBlank(editResInfoVO.getDesFlStag()))
            attResStagChar.setTbDesFlStag(editResInfoVO.getDesFlStag());
        if (StringUtil.isNotBlank(editResInfoVO.getTotCap()))
            attResStagChar.setTbTotCap(editResInfoVO.getTotCap());
        if (StringUtil.isNotBlank(editResInfoVO.getWatShedArea()))
            attResStagChar.setWatShedArea(editResInfoVO.getWatShedArea());
 
        // 修改坝顶高程
        if (StringUtil.isNotBlank(editResInfoVO.getTbDamTopElevation())) {
            AttResWaterBlock resWaterBlock = new AttResWaterBlock();
            resWaterBlock.setResGuid(editResInfoVO.getResGuid());
            resWaterBlock.setTbDamTopElevation(editResInfoVO.getTbDamTopElevation());
            attResWaterBlockService.updateAttResWaterBlockByResId(resWaterBlock);
        }
 
        // 修改控制运行水位
        if (StringUtil.isNotBlank(editResInfoVO.getTbControlZ())) {
            AttResDangerManageSpecial attResDangerManageSpecial = new AttResDangerManageSpecial();
            attResDangerManageSpecial.setResGuid(editResInfoVO.getResGuid());
            attResDangerManageSpecial.setTbControlZ(editResInfoVO.getTbControlZ());
            attResDangerManageSpecialService.updateAttResDangerManageSpecialByResId(attResDangerManageSpecial);
        }
 
        return attResStagCharService.customizeUpdateByGuid(attResStagChar);
    }
}