From 9f781d50d96e4193d61f4797b72cd79b5203a764 Mon Sep 17 00:00:00 2001 From: wuzeyu <1223318623@qq.com> Date: 星期四, 28 三月 2024 14:57:39 +0800 Subject: [PATCH] 增加 查询一个监测站接口 条件查询已绑定的流量计接口 查询全部流量计接口 --- pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/intake/IntakeSv.java | 70 +++++++++++++++++++++------------- 1 files changed, 43 insertions(+), 27 deletions(-) diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/intake/IntakeSv.java b/pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/intake/IntakeSv.java index b1f9cfc..7fd8e0b 100644 --- a/pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/intake/IntakeSv.java +++ b/pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/intake/IntakeSv.java @@ -1,6 +1,7 @@ package com.dy.pipIrrProject.intake; import com.dy.common.webUtil.QueryResultVo; +import com.dy.pipIrrGlobal.daoPr.PrDivideMapper; import com.dy.pipIrrGlobal.daoPr.PrIntakeMapper; import com.dy.pipIrrGlobal.pojoPr.PrIntake; import com.dy.pipIrrGlobal.voPr.VoIntake; @@ -12,6 +13,7 @@ import java.util.List; import java.util.Map; +import java.util.Optional; /** * @author wuzeyu @@ -25,6 +27,8 @@ public class IntakeSv { @Autowired private PrIntakeMapper prIntakeMapper; + @Autowired + private PrDivideMapper prDivideMapper; /** * 娣诲姞鍙栨按鍙� @@ -34,41 +38,47 @@ */ @Transactional Integer addIntake(PrIntake po) { - if (po.getTownId()==null||po.getTownId()==0) - { - Long townId=getSupperByVillageId(po.getVillageId()); - po.setTownId(townId); + Long villageId = Optional.ofNullable(po.getVillageId()).orElse(0L); + + if (villageId != 0){ + if (po.getTownId() == null || po.getTownId() == 0) { + Long townId = getSupperByVillageId(po.getVillageId()); + po.setTownId(townId); + } + if (po.getCountyId() == null || po.getCountyId() == 0) { + Long countyId = getSupperByVillageId(getSupperByVillageId(po.getVillageId())); + po.setCountyId(countyId); + } } - if (po.getCountyId()==null||po.getCountyId()==0) - { - Long countyId=getSupperByVillageId(getSupperByVillageId(po.getVillageId())); - po.setCountyId(countyId); + if (po.getBlockId() == null || po.getBlockId() == 0) { + Long blockId = prDivideMapper.getBlockIdById(po.getDivideId()); + po.setBlockId(blockId); } return prIntakeMapper.insertSelective(po); } - public Long getSupperByVillageId(long vaId){ + + public Long getSupperByVillageId(long vaId) { return prIntakeMapper.getSupperByVillageId(vaId); } /** * 淇濆瓨淇敼瀹炰綋 + * * @param po 瀹炰綋 * @return 鏁伴噺 */ - public int update(PrIntake po){ - if (po.getTownId()==null||po.getTownId()==0) - { - Long townId=getSupperByVillageId(po.getVillageId()); + public int update(PrIntake po) { + if (po.getTownId() == null || po.getTownId() == 0) { + Long townId = getSupperByVillageId(po.getVillageId()); po.setTownId(townId); } - if (po.getCountyId()==null||po.getCountyId()==0) - { - Long countyId=getSupperByVillageId(getSupperByVillageId(po.getVillageId())); + if (po.getCountyId() == null || po.getCountyId() == 0) { + Long countyId = getSupperByVillageId(getSupperByVillageId(po.getVillageId())); po.setCountyId(countyId); } - return this.prIntakeMapper.updateByPrimaryKeySelective(po) ; + return this.prIntakeMapper.updateByPrimaryKeySelective(po); // return this.prIntakeMapper.updateByPrimaryKey(po); } @@ -110,35 +120,39 @@ /** * 寰楀埌鎵�鏈夊彇姘村彛 + * * @return 鎵�鏈夊彇姘村彛闆嗗悎 */ public QueryResultVo<List<PrIntake>> selectAll() { - QueryResultVo<List<PrIntake>> rsVo = new QueryResultVo<>() ; - rsVo.obj = this.prIntakeMapper.selectAll() ; - return rsVo ; + QueryResultVo<List<PrIntake>> rsVo = new QueryResultVo<>(); + rsVo.obj = this.prIntakeMapper.selectAll(); + return rsVo; } /** * 寰楀埌涓�涓彇姘村彛 + * * @param id 鍙栨按鍙D * @return 鍙栨按鍙e疄浣� */ public PrIntake selectById(Long id) { - return this.prIntakeMapper.selectByPrimaryKey(id) ; + return this.prIntakeMapper.selectByPrimaryKey(id); } /** * 閫昏緫鍒犻櫎瀹炰綋 + * * @param id 瀹炰綋ID * @return 鏁伴噺 */ @Transactional - public int delete(Long id){ - return this.prIntakeMapper.deleteLogicById(id) ; + public int delete(Long id) { + return this.prIntakeMapper.deleteLogicById(id); } /** * 鏍规嵁鍙栨按鍙g紪鍙疯幏鍙栨湭鍒犻櫎鐨勫彇姘村彛鏁伴噺 + * * @param intakeId * @return */ @@ -148,19 +162,21 @@ /** * 鏍规嵁鏉慖d鑾峰彇鍏ㄩ儴鍦板潃 + * * @param villageId 鏉慖d - * @return address 鍏ㄩ儴浜旂骇鍦板潃 + * @return address 鍏ㄩ儴浜旂骇鍦板潃 */ - public String getAddressByVillageId(long villageId){ + public String getAddressByVillageId(long villageId) { return prIntakeMapper.getAddressByVillageId(villageId); } /** * 鏍规嵁鍖哄煙Id鑾峰彇鍖哄煙绛夌骇 + * * @param regionId 鍖哄煙Id - * @return Level 鍖哄煙绛夌骇 + * @return Level 鍖哄煙绛夌骇 */ - public int getLevelByRegionId(long regionId){ + public int getLevelByRegionId(long regionId) { return prIntakeMapper.getLevelByRegionId(regionId); } } -- Gitblit v1.8.0