...
|
...
|
@@ -6,24 +6,18 @@ import com.github.pagehelper.PageHelper; |
|
|
import com.github.pagehelper.PageInfo;
|
|
|
import com.sunyo.energy.location.controller.response.ResultJson;
|
|
|
import com.sunyo.energy.location.dao.LocationMapper;
|
|
|
import com.sunyo.energy.location.dao.WaterMeterMapper;
|
|
|
import com.sunyo.energy.location.dao.WaterMeterSaccMapper;
|
|
|
import com.sunyo.energy.location.model.Location;
|
|
|
import com.sunyo.energy.location.model.WaterMeter;
|
|
|
import com.sunyo.energy.location.model.WaterMeterSacc;
|
|
|
import com.sunyo.energy.location.service.WaterMeterService;
|
|
|
import com.sunyo.energy.location.utils.AllUtils;
|
|
|
import com.sunyo.energy.location.utils.HttpsUtils;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import lombok.extern.log4j.Log4j;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.ibatis.annotations.Param;
|
|
|
import org.omg.CORBA.OBJECT_NOT_EXIST;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.util.StringUtils;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
...
|
...
|
@@ -126,29 +120,37 @@ public class LocationController { |
|
|
public ResultJson editLocation(@RequestBody Location location) throws Exception {
|
|
|
|
|
|
ResultJson resultJson = new ResultJson();
|
|
|
// 旧表 表号
|
|
|
String wmId = locationMapper.findWmId(location.getAdrname());
|
|
|
// 水表 累计充值量记录表
|
|
|
WaterMeterSacc waterMeterSacc = new WaterMeterSacc();
|
|
|
waterMeterSacc.setOrderWmId(wmId);
|
|
|
// 判断是否存在 存在修改楼层 不存在修改水表
|
|
|
if (!StringUtils.isEmpty(wmId)){
|
|
|
// 修改 房间号
|
|
|
int i1 = locationMapper.updateByPrimaryKeySelective(location);
|
|
|
log.info("楼层编辑:{}", i1);
|
|
|
}else {
|
|
|
// 查询旧表 实时数据
|
|
|
WaterMeter realTime = waterMeterService.findRealTime(wmId);
|
|
|
log.info("旧表累计充值量:{}",realTime.getWmSacc());
|
|
|
// 充值新表
|
|
|
Map<String, Object> datas = new HashMap<>();
|
|
|
datas.put("MtId", location.getWmid());
|
|
|
datas.put("Add_sacc", realTime.getWmSacc());
|
|
|
datas.put("Add_lacc", realTime.getWmLacc());
|
|
|
datas.put("Add_addmode", "3");
|
|
|
String status = HttpsUtils.httpRequest("http://123.56.159.203:8023/mtfmset/allWMadd", datas);
|
|
|
datas.put("status", status);
|
|
|
log.info("新表充值:{}",status);
|
|
|
log.info("充值成功更新水表");
|
|
|
}
|
|
|
waterMeterSacc.setWmId(location.getWmid());
|
|
|
// 查询旧表实施数据
|
|
|
WaterMeter realTime = waterMeterService.findRealTime(wmId);
|
|
|
// 计算旧表余量 新表累计充值量 = 旧表余量
|
|
|
// String newWmIdSacc = AllUtils.nubmerSubtraction(realTime.getWmSacc(), realTime.getWmLacc());
|
|
|
log.info("旧表累计充值量:{}",realTime.getWmSacc());
|
|
|
// waterMeterSacc.setWmSacc(new BigDecimal(newWmIdSacc));
|
|
|
// 充值新表水量
|
|
|
Map<String, Object> datas = new HashMap<>();
|
|
|
datas.put("MtId", wmId);
|
|
|
datas.put("Add_sacc", realTime.getWmSacc());
|
|
|
datas.put("Add_addmode", "2");
|
|
|
String status = HttpsUtils.httpRequest("http://123.56.159.203:8023/mtfmset/allWMadd", datas);
|
|
|
datas.put("status", status);
|
|
|
log.info("新表充值:{}",status);
|
|
|
log.info("充值成功更新水表");
|
|
|
if (locationMapper.updateByPrimaryKeySelective(location) > 0 && waterMeterSaccMapper.updateWater(waterMeterSacc) > 0) {
|
|
|
waterMeterSacc.setOrderWmId(wmId);
|
|
|
// 更新表号 累计充值量 记录表
|
|
|
if (waterMeterSaccMapper.updateWater(waterMeterSacc) > 0) {
|
|
|
log.info("更新成功");
|
|
|
resultJson.setCode("200");
|
|
|
} else {
|
|
|
}else {
|
|
|
resultJson.setCode("201");
|
|
|
}
|
|
|
return resultJson;
|
...
|
...
|
|