|
@@ -6,17 +6,28 @@ import com.github.pagehelper.PageHelper; |
|
@@ -6,17 +6,28 @@ import com.github.pagehelper.PageHelper; |
|
6
|
import com.github.pagehelper.PageInfo;
|
6
|
import com.github.pagehelper.PageInfo;
|
|
7
|
import com.sunyo.energy.location.controller.response.ResultJson;
|
7
|
import com.sunyo.energy.location.controller.response.ResultJson;
|
|
8
|
import com.sunyo.energy.location.dao.LocationMapper;
|
8
|
import com.sunyo.energy.location.dao.LocationMapper;
|
|
|
|
9
|
+import com.sunyo.energy.location.dao.WaterMeterMapper;
|
|
|
|
10
|
+import com.sunyo.energy.location.dao.WaterMeterSaccMapper;
|
|
9
|
import com.sunyo.energy.location.model.Location;
|
11
|
import com.sunyo.energy.location.model.Location;
|
|
|
|
12
|
+import com.sunyo.energy.location.model.WaterMeter;
|
|
|
|
13
|
+import com.sunyo.energy.location.model.WaterMeterSacc;
|
|
|
|
14
|
+import com.sunyo.energy.location.service.WaterMeterService;
|
|
|
|
15
|
+import com.sunyo.energy.location.utils.AllUtils;
|
|
|
|
16
|
+import com.sunyo.energy.location.utils.HttpsUtils;
|
|
10
|
import io.swagger.annotations.ApiOperation;
|
17
|
import io.swagger.annotations.ApiOperation;
|
|
|
|
18
|
+import lombok.extern.log4j.Log4j;
|
|
|
|
19
|
+import lombok.extern.slf4j.Slf4j;
|
|
11
|
import org.apache.ibatis.annotations.Param;
|
20
|
import org.apache.ibatis.annotations.Param;
|
|
|
|
21
|
+import org.omg.CORBA.OBJECT_NOT_EXIST;
|
|
12
|
import org.springframework.beans.factory.annotation.Autowired;
|
22
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
13
|
import org.springframework.util.StringUtils;
|
23
|
import org.springframework.util.StringUtils;
|
|
14
|
import org.springframework.web.bind.annotation.*;
|
24
|
import org.springframework.web.bind.annotation.*;
|
|
15
|
|
25
|
|
|
|
|
26
|
+import java.math.BigDecimal;
|
|
16
|
import java.util.HashMap;
|
27
|
import java.util.HashMap;
|
|
17
|
import java.util.List;
|
28
|
import java.util.List;
|
|
18
|
import java.util.Map;
|
29
|
import java.util.Map;
|
|
19
|
-
|
30
|
+@Slf4j
|
|
20
|
@RestController
|
31
|
@RestController
|
|
21
|
@RequestMapping("/location")
|
32
|
@RequestMapping("/location")
|
|
22
|
public class LocationController {
|
33
|
public class LocationController {
|
|
@@ -24,6 +35,12 @@ public class LocationController { |
|
@@ -24,6 +35,12 @@ public class LocationController { |
|
24
|
@Autowired
|
35
|
@Autowired
|
|
25
|
private LocationMapper locationMapper;
|
36
|
private LocationMapper locationMapper;
|
|
26
|
|
37
|
|
|
|
|
38
|
+ @Autowired
|
|
|
|
39
|
+ private WaterMeterSaccMapper waterMeterSaccMapper;
|
|
|
|
40
|
+
|
|
|
|
41
|
+ @Autowired
|
|
|
|
42
|
+ private WaterMeterService waterMeterService;
|
|
|
|
43
|
+
|
|
27
|
@ApiOperation(value = "查询楼层")
|
44
|
@ApiOperation(value = "查询楼层")
|
|
28
|
@RequestMapping(value = "/list", method = RequestMethod.GET)
|
45
|
@RequestMapping(value = "/list", method = RequestMethod.GET)
|
|
29
|
public ResultJson startActivityDemo(@RequestParam(value = "pageNum", required = false, defaultValue = "1")
|
46
|
public ResultJson startActivityDemo(@RequestParam(value = "pageNum", required = false, defaultValue = "1")
|
|
@@ -106,16 +123,49 @@ public class LocationController { |
|
@@ -106,16 +123,49 @@ public class LocationController { |
|
106
|
|
123
|
|
|
107
|
@ApiOperation(value = "修改楼层")
|
124
|
@ApiOperation(value = "修改楼层")
|
|
108
|
@PutMapping(value = "/edit")
|
125
|
@PutMapping(value = "/edit")
|
|
109
|
- public ResultJson editLocation(@RequestBody Location location) {
|
126
|
+ public ResultJson editLocation(@RequestBody Location location) throws Exception {
|
|
110
|
|
127
|
|
|
111
|
ResultJson resultJson = new ResultJson();
|
128
|
ResultJson resultJson = new ResultJson();
|
|
112
|
-
|
|
|
|
113
|
- if (locationMapper.updateByPrimaryKeySelective(location) > 0) {
|
129
|
+ String wmId = locationMapper.findWmId(location.getAdrname());
|
|
|
|
130
|
+ WaterMeterSacc waterMeterSacc = new WaterMeterSacc();
|
|
|
|
131
|
+ waterMeterSacc.setOrderWmId(wmId);
|
|
|
|
132
|
+ waterMeterSacc.setWmId(location.getWmid());
|
|
|
|
133
|
+ // 查询旧表实施数据
|
|
|
|
134
|
+ WaterMeter realTime = waterMeterService.findRealTime(wmId);
|
|
|
|
135
|
+ // 计算旧表余量 新表累计充值量 = 旧表余量
|
|
|
|
136
|
+ String newWmIdSacc = AllUtils.nubmerSubtraction(realTime.getWmSacc(), realTime.getWmLacc());
|
|
|
|
137
|
+ log.info("旧表余量:{}",newWmIdSacc);
|
|
|
|
138
|
+ waterMeterSacc.setWmSacc(new BigDecimal(newWmIdSacc));
|
|
|
|
139
|
+ // 充值新表水量
|
|
|
|
140
|
+ Map<String, Object> datas = new HashMap<>();
|
|
|
|
141
|
+ datas.put("MtId", wmId);
|
|
|
|
142
|
+ datas.put("Add_sacc", newWmIdSacc);
|
|
|
|
143
|
+ datas.put("Add_addmode", "2");
|
|
|
|
144
|
+ String status = HttpsUtils.httpRequest("http://123.56.159.203:8023/mtfmset/allWMadd", datas);
|
|
|
|
145
|
+ datas.put("status", status);
|
|
|
|
146
|
+ log.info("新表充值:{}",status);
|
|
|
|
147
|
+ log.info("充值成功更新水表");
|
|
|
|
148
|
+ if (locationMapper.updateByPrimaryKeySelective(location) > 0 && waterMeterSaccMapper.updateWater(waterMeterSacc) > 0) {
|
|
|
|
149
|
+ log.info("更新成功");
|
|
114
|
resultJson.setCode("200");
|
150
|
resultJson.setCode("200");
|
|
115
|
} else {
|
151
|
} else {
|
|
116
|
resultJson.setCode("201");
|
152
|
resultJson.setCode("201");
|
|
117
|
}
|
153
|
}
|
|
118
|
-
|
|
|
|
119
|
return resultJson;
|
154
|
return resultJson;
|
|
120
|
}
|
155
|
}
|
|
|
|
156
|
+
|
|
|
|
157
|
+ @ApiOperation(value = "远程水表阀开")
|
|
|
|
158
|
+ @GetMapping(value = "/allAddMtfmset")
|
|
|
|
159
|
+ public ResultJson allAddMtfmset(@RequestParam("MtId") String mtId,
|
|
|
|
160
|
+ @RequestParam("MtFm") String mtFm) throws Exception {
|
|
|
|
161
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
|
162
|
+ map.put("MtId", mtId);
|
|
|
|
163
|
+ map.put("MtFm", mtFm);
|
|
|
|
164
|
+
|
|
|
|
165
|
+ String s = HttpsUtils.httpRequest("http://123.56.159.203:8023/mtfmset/allAddMtfmset", map);
|
|
|
|
166
|
+ if (s.contains("0")){
|
|
|
|
167
|
+ return new ResultJson("200", "success");
|
|
|
|
168
|
+ }
|
|
|
|
169
|
+ return new ResultJson("201", "error");
|
|
|
|
170
|
+ }
|
|
121
|
} |
171
|
} |