|
@@ -6,24 +6,18 @@ import com.github.pagehelper.PageHelper; |
|
@@ -6,24 +6,18 @@ 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.dao.WaterMeterSaccMapper;
|
11
|
import com.sunyo.energy.location.model.Location;
|
10
|
import com.sunyo.energy.location.model.Location;
|
12
|
import com.sunyo.energy.location.model.WaterMeter;
|
11
|
import com.sunyo.energy.location.model.WaterMeter;
|
13
|
import com.sunyo.energy.location.model.WaterMeterSacc;
|
12
|
import com.sunyo.energy.location.model.WaterMeterSacc;
|
14
|
import com.sunyo.energy.location.service.WaterMeterService;
|
13
|
import com.sunyo.energy.location.service.WaterMeterService;
|
15
|
-import com.sunyo.energy.location.utils.AllUtils;
|
|
|
16
|
import com.sunyo.energy.location.utils.HttpsUtils;
|
14
|
import com.sunyo.energy.location.utils.HttpsUtils;
|
17
|
import io.swagger.annotations.ApiOperation;
|
15
|
import io.swagger.annotations.ApiOperation;
|
18
|
-import lombok.extern.log4j.Log4j;
|
|
|
19
|
import lombok.extern.slf4j.Slf4j;
|
16
|
import lombok.extern.slf4j.Slf4j;
|
20
|
-import org.apache.ibatis.annotations.Param;
|
|
|
21
|
-import org.omg.CORBA.OBJECT_NOT_EXIST;
|
|
|
22
|
import org.springframework.beans.factory.annotation.Autowired;
|
17
|
import org.springframework.beans.factory.annotation.Autowired;
|
23
|
import org.springframework.util.StringUtils;
|
18
|
import org.springframework.util.StringUtils;
|
24
|
import org.springframework.web.bind.annotation.*;
|
19
|
import org.springframework.web.bind.annotation.*;
|
25
|
|
20
|
|
26
|
-import java.math.BigDecimal;
|
|
|
27
|
import java.util.HashMap;
|
21
|
import java.util.HashMap;
|
28
|
import java.util.List;
|
22
|
import java.util.List;
|
29
|
import java.util.Map;
|
23
|
import java.util.Map;
|
|
@@ -126,29 +120,37 @@ public class LocationController { |
|
@@ -126,29 +120,37 @@ public class LocationController { |
126
|
public ResultJson editLocation(@RequestBody Location location) throws Exception {
|
120
|
public ResultJson editLocation(@RequestBody Location location) throws Exception {
|
127
|
|
121
|
|
128
|
ResultJson resultJson = new ResultJson();
|
122
|
ResultJson resultJson = new ResultJson();
|
|
|
123
|
+ // 旧表 表号
|
129
|
String wmId = locationMapper.findWmId(location.getAdrname());
|
124
|
String wmId = locationMapper.findWmId(location.getAdrname());
|
|
|
125
|
+ // 水表 累计充值量记录表
|
130
|
WaterMeterSacc waterMeterSacc = new WaterMeterSacc();
|
126
|
WaterMeterSacc waterMeterSacc = new WaterMeterSacc();
|
131
|
- waterMeterSacc.setOrderWmId(wmId);
|
|
|
132
|
- waterMeterSacc.setWmId(location.getWmid());
|
|
|
133
|
- // 查询旧表实施数据
|
127
|
+ // 判断是否存在 存在修改楼层 不存在修改水表
|
|
|
128
|
+ if (!StringUtils.isEmpty(wmId)){
|
|
|
129
|
+ // 修改 房间号
|
|
|
130
|
+ int i1 = locationMapper.updateByPrimaryKeySelective(location);
|
|
|
131
|
+ log.info("楼层编辑:{}", i1);
|
|
|
132
|
+ }else {
|
|
|
133
|
+ // 查询旧表 实时数据
|
134
|
WaterMeter realTime = waterMeterService.findRealTime(wmId);
|
134
|
WaterMeter realTime = waterMeterService.findRealTime(wmId);
|
135
|
- // 计算旧表余量 新表累计充值量 = 旧表余量
|
|
|
136
|
-// String newWmIdSacc = AllUtils.nubmerSubtraction(realTime.getWmSacc(), realTime.getWmLacc());
|
|
|
137
|
log.info("旧表累计充值量:{}",realTime.getWmSacc());
|
135
|
log.info("旧表累计充值量:{}",realTime.getWmSacc());
|
138
|
-// waterMeterSacc.setWmSacc(new BigDecimal(newWmIdSacc));
|
|
|
139
|
- // 充值新表水量
|
136
|
+ // 充值新表
|
140
|
Map<String, Object> datas = new HashMap<>();
|
137
|
Map<String, Object> datas = new HashMap<>();
|
141
|
- datas.put("MtId", wmId);
|
138
|
+ datas.put("MtId", location.getWmid());
|
142
|
datas.put("Add_sacc", realTime.getWmSacc());
|
139
|
datas.put("Add_sacc", realTime.getWmSacc());
|
143
|
- datas.put("Add_addmode", "2");
|
140
|
+ datas.put("Add_lacc", realTime.getWmLacc());
|
|
|
141
|
+ datas.put("Add_addmode", "3");
|
144
|
String status = HttpsUtils.httpRequest("http://123.56.159.203:8023/mtfmset/allWMadd", datas);
|
142
|
String status = HttpsUtils.httpRequest("http://123.56.159.203:8023/mtfmset/allWMadd", datas);
|
145
|
datas.put("status", status);
|
143
|
datas.put("status", status);
|
146
|
log.info("新表充值:{}",status);
|
144
|
log.info("新表充值:{}",status);
|
147
|
log.info("充值成功更新水表");
|
145
|
log.info("充值成功更新水表");
|
148
|
- if (locationMapper.updateByPrimaryKeySelective(location) > 0 && waterMeterSaccMapper.updateWater(waterMeterSacc) > 0) {
|
146
|
+ }
|
|
|
147
|
+ waterMeterSacc.setWmId(location.getWmid());
|
|
|
148
|
+ waterMeterSacc.setOrderWmId(wmId);
|
|
|
149
|
+ // 更新表号 累计充值量 记录表
|
|
|
150
|
+ if (waterMeterSaccMapper.updateWater(waterMeterSacc) > 0) {
|
149
|
log.info("更新成功");
|
151
|
log.info("更新成功");
|
150
|
resultJson.setCode("200");
|
152
|
resultJson.setCode("200");
|
151
|
- } else {
|
153
|
+ }else {
|
152
|
resultJson.setCode("201");
|
154
|
resultJson.setCode("201");
|
153
|
}
|
155
|
}
|
154
|
return resultJson;
|
156
|
return resultJson;
|