|
@@ -392,10 +392,14 @@ public class BerthingServiceImpl implements BerthingService {
|
|
|
if (berthingFloat == null) {
|
|
|
//新增
|
|
|
berthingFloat = new BerthingFloatConfig();
|
|
|
- berthingFloat.setFloatId(0L);
|
|
|
+ berthingFloat.setWlevel(berthingFloatDTO.getWlevel());
|
|
|
berthingFloat.setSiteId(siteInfo.getSiteId());
|
|
|
+ long count = berthingFloatConfigMapper.count(berthingFloat);
|
|
|
+ if (count > 0) {
|
|
|
+ throw new BaseException("起浮水位已存在");
|
|
|
+ }
|
|
|
+ berthingFloat.setFloatId(0L);
|
|
|
berthingFloat.setPlanid(berthingFloatDTO.getPlanid());
|
|
|
- berthingFloat.setWlevel(berthingFloatDTO.getWlevel());
|
|
|
berthingFloat.setCreateTime(new Date());
|
|
|
berthingFloat.setIsDel(0);
|
|
|
berthingFloat.setStatus(1);
|
|
@@ -403,7 +407,7 @@ public class BerthingServiceImpl implements BerthingService {
|
|
|
berthingFloat.setTimespan(berthingFloatDTO.getTimespan());
|
|
|
berthingFloat.setWlevelchange(berthingFloatDTO.getWlevelchange());
|
|
|
berthingFloat.setType(berthingFloatDTO.getType());
|
|
|
- res = berthingFloatConfigMapper.insert(berthingFloat) > 0;
|
|
|
+ res = berthingFloatConfigMapper.insert(berthingFloat) > 0;
|
|
|
} else {
|
|
|
//更新
|
|
|
berthingFloat.setType(berthingFloatDTO.getType());
|
|
@@ -411,20 +415,22 @@ public class BerthingServiceImpl implements BerthingService {
|
|
|
berthingFloat.setWlevel(berthingFloatDTO.getWlevel());
|
|
|
berthingFloat.setTimespan(berthingFloatDTO.getTimespan());
|
|
|
berthingFloat.setWlevelchange(berthingFloatDTO.getWlevelchange());
|
|
|
- res = berthingFloatConfigMapper.update(berthingFloat) > 0;
|
|
|
+ res = berthingFloatConfigMapper.update(berthingFloat) > 0;
|
|
|
}
|
|
|
//TODO 下发配置
|
|
|
String topic = "down/" + siteInfo.getDeviceId() + "/addMode";
|
|
|
HashMap<String, Object> requestMap = new HashMap<>();
|
|
|
- requestMap.put("id",siteInfo.getId());
|
|
|
- requestMap.put("type",berthingFloat.getType());
|
|
|
- requestMap.put("planid",berthingFloat.getPlanid());
|
|
|
- requestMap.put("wlevel",berthingFloat.getWlevel());
|
|
|
- requestMap.put("timespan",berthingFloat.getTimespan());
|
|
|
- requestMap.put("wlevelchange",berthingFloat.getWlevelchange());
|
|
|
+ requestMap.put("id", siteInfo.getId());
|
|
|
+ requestMap.put("type", berthingFloat.getType());
|
|
|
+ requestMap.put("planid", berthingFloat.getPlanid());
|
|
|
+ requestMap.put("wlevel", berthingFloat.getWlevel());
|
|
|
+ requestMap.put("timespan", berthingFloat.getTimespan());
|
|
|
+ requestMap.put("wlevelchange", berthingFloat.getWlevelchange());
|
|
|
String data = JSONUtil.toJsonStr(requestMap);
|
|
|
- log.info("mqtt发送数据:topic:{} data:{}",topic,data);
|
|
|
+ log.info("mqtt发送数据:topic:{} data:{}", topic, data);
|
|
|
mqttGateWayService.sendMessageToMqtt(data, topic);
|
|
|
+ }catch (BaseException e){
|
|
|
+ throw new BaseException(e.getMessage());
|
|
|
} catch (Exception e){
|
|
|
log.error("新增或修改水位变幅策略错误", e);
|
|
|
throw new BaseException("新增或修改水位变幅策略错误");
|