...
|
...
|
@@ -6,17 +6,28 @@ 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;
|
|
|
|
|
|
@Slf4j
|
|
|
@RestController
|
|
|
@RequestMapping("/location")
|
|
|
public class LocationController {
|
...
|
...
|
@@ -24,6 +35,12 @@ public class LocationController { |
|
|
@Autowired
|
|
|
private LocationMapper locationMapper;
|
|
|
|
|
|
@Autowired
|
|
|
private WaterMeterSaccMapper waterMeterSaccMapper;
|
|
|
|
|
|
@Autowired
|
|
|
private WaterMeterService waterMeterService;
|
|
|
|
|
|
@ApiOperation(value = "查询楼层")
|
|
|
@RequestMapping(value = "/list", method = RequestMethod.GET)
|
|
|
public ResultJson startActivityDemo(@RequestParam(value = "pageNum", required = false, defaultValue = "1")
|
...
|
...
|
@@ -106,16 +123,49 @@ public class LocationController { |
|
|
|
|
|
@ApiOperation(value = "修改楼层")
|
|
|
@PutMapping(value = "/edit")
|
|
|
public ResultJson editLocation(@RequestBody Location location) {
|
|
|
public ResultJson editLocation(@RequestBody Location location) throws Exception {
|
|
|
|
|
|
ResultJson resultJson = new ResultJson();
|
|
|
|
|
|
if (locationMapper.updateByPrimaryKeySelective(location) > 0) {
|
|
|
String wmId = locationMapper.findWmId(location.getAdrname());
|
|
|
WaterMeterSacc waterMeterSacc = new WaterMeterSacc();
|
|
|
waterMeterSacc.setOrderWmId(wmId);
|
|
|
waterMeterSacc.setWmId(location.getWmid());
|
|
|
// 查询旧表实施数据
|
|
|
WaterMeter realTime = waterMeterService.findRealTime(wmId);
|
|
|
// 计算旧表余量 新表累计充值量 = 旧表余量
|
|
|
String newWmIdSacc = AllUtils.nubmerSubtraction(realTime.getWmSacc(), realTime.getWmLacc());
|
|
|
log.info("旧表余量:{}",newWmIdSacc);
|
|
|
waterMeterSacc.setWmSacc(new BigDecimal(newWmIdSacc));
|
|
|
// 充值新表水量
|
|
|
Map<String, Object> datas = new HashMap<>();
|
|
|
datas.put("MtId", wmId);
|
|
|
datas.put("Add_sacc", newWmIdSacc);
|
|
|
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) {
|
|
|
log.info("更新成功");
|
|
|
resultJson.setCode("200");
|
|
|
} else {
|
|
|
resultJson.setCode("201");
|
|
|
}
|
|
|
|
|
|
return resultJson;
|
|
|
}
|
|
|
|
|
|
@ApiOperation(value = "远程水表阀开")
|
|
|
@GetMapping(value = "/allAddMtfmset")
|
|
|
public ResultJson allAddMtfmset(@RequestParam("MtId") String mtId,
|
|
|
@RequestParam("MtFm") String mtFm) throws Exception {
|
|
|
Map<String, Object> map = new HashMap<>();
|
|
|
map.put("MtId", mtId);
|
|
|
map.put("MtFm", mtFm);
|
|
|
|
|
|
String s = HttpsUtils.httpRequest("http://123.56.159.203:8023/mtfmset/allAddMtfmset", map);
|
|
|
if (s.contains("0")){
|
|
|
return new ResultJson("200", "success");
|
|
|
}
|
|
|
return new ResultJson("201", "error");
|
|
|
}
|
|
|
} |
...
|
...
|
|