From a9067135f78e2b1c095b183fe0e70726b5dd3b11 Mon Sep 17 00:00:00 2001 From: liwen Date: Tue, 26 Mar 2024 11:53:21 +0800 Subject: [PATCH 1/3] =?UTF-8?q?fix:=20=E8=A7=A3=E5=86=B3=E8=A7=86=E9=A2=91?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E4=B8=AD=E4=BF=AE=E6=94=B9=E7=AB=99=E7=82=B9?= =?UTF-8?q?=E6=8E=92=E5=BA=8F=E6=97=B6=E5=AF=BC=E8=87=B4=E7=AB=99=E7=82=B9?= =?UTF-8?q?=E4=BF=A1=E6=81=AF=E4=B8=A2=E5=A4=B1=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../station/controller/StationController.java | 18 ++++------------- .../station/service/IStationService.java | 23 ++++++++++++++++++++++ .../station/service/impl/StationServiceImpl.java | 15 ++++++++++++++ 3 files changed, 42 insertions(+), 14 deletions(-) diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/controller/StationController.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/controller/StationController.java index 2d358a0..a899a00 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/controller/StationController.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/controller/StationController.java @@ -104,21 +104,11 @@ public class StationController extends BladeController { return R.status(stationService.instanceProject(req)); } - @PostMapping("/updateBatch") + @PostMapping("/updateBatchSort") @ApiOperationSupport(order = 30) - @ApiOperation(value = "批量修改", notes = "传入站点列表") - public R updateBatch(@RequestBody List req) { - for (StationEntity stationEntity : req) { - if (StringUtil.isNotBlank(stationEntity.getCode()) || StringUtil.isNotBlank(stationEntity.getName())) { - List list = stationService.list(new LambdaQueryWrapper() {{ - eq(StationEntity::getCode, stationEntity.getCode()).or().eq(StationEntity::getName, stationEntity.getName()); - }}); - Assert.isTrue(CollectionUtil.isEmpty(list), () -> { - throw new ServiceException(stationEntity.getId() + "下站点名/编码已有对应记录,请找到相应记录做修改处理"); - }); - } - } - return R.status(stationService.updateBatchById(req)); + @ApiOperation(value = "批量修改排序", notes = "传入站点列表") + public R updateBatchSort(@RequestBody List req) { + return R.status(stationService.updateBatchSort(req)); } /** diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/IStationService.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/IStationService.java index 924cb11..19de00a 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/IStationService.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/IStationService.java @@ -1,5 +1,6 @@ package com.hnac.hzims.operational.station.service; +import com.baomidou.mybatisplus.core.conditions.Wrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.hnac.hzims.operational.main.vo.StationCountVo; @@ -38,6 +39,8 @@ public interface IStationService extends BaseService { */ boolean instanceProject(StationEntity req); + boolean instanceFdpStation(StationEntity req); + /** * 删除站点 * @param id 站点ID,按逗号分隔 @@ -127,4 +130,24 @@ public interface IStationService extends BaseService { @Override boolean updateById(StationEntity req); + + List accessHydropower(); + + @Override + @Deprecated + boolean removeByMap(Map columnMap); + + @Override + boolean save(StationEntity entity); + + Boolean createStation(StationEntity station); + + Boolean updateStation(StationEntity station); + + /** + * 批量更新站点排序 + * @param req 站点列表 + * @return 更新是否成功 + */ + boolean updateBatchSort(List req); } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationServiceImpl.java index 79997f8..fbd41c0 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationServiceImpl.java @@ -719,4 +719,19 @@ public class StationServiceImpl extends BaseServiceImpl projectClient.delete()); // } } + + /** + * 批量更新站点排序 + */ + @Override + public boolean updateBatchSort(List req) { + List stations = new ArrayList<>(); + for (StationEntity stationEntity : req) { + // 获取当前的站点信息 + StationEntity station = this.getById(stationEntity.getId()); + station.setSort(stationEntity.getSort()); + stations.add(station); + } + return this.updateBatchById(stations); + } } From 5a6e0f3b7fe39472414fecb74fab95a36623ce15 Mon Sep 17 00:00:00 2001 From: liwen Date: Tue, 26 Mar 2024 11:53:21 +0800 Subject: [PATCH 2/3] =?UTF-8?q?fix:=20=E8=A7=A3=E5=86=B3=E8=A7=86=E9=A2=91?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E4=B8=AD=E4=BF=AE=E6=94=B9=E7=AB=99=E7=82=B9?= =?UTF-8?q?=E6=8E=92=E5=BA=8F=E6=97=B6=E5=AF=BC=E8=87=B4=E7=AB=99=E7=82=B9?= =?UTF-8?q?=E4=BF=A1=E6=81=AF=E4=B8=A2=E5=A4=B1=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../station/controller/StationController.java | 18 ++++-------------- .../operational/station/service/IStationService.java | 11 +++++++++++ .../station/service/impl/StationServiceImpl.java | 15 +++++++++++++++ 3 files changed, 30 insertions(+), 14 deletions(-) diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/controller/StationController.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/controller/StationController.java index 2d358a0..a899a00 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/controller/StationController.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/controller/StationController.java @@ -104,21 +104,11 @@ public class StationController extends BladeController { return R.status(stationService.instanceProject(req)); } - @PostMapping("/updateBatch") + @PostMapping("/updateBatchSort") @ApiOperationSupport(order = 30) - @ApiOperation(value = "批量修改", notes = "传入站点列表") - public R updateBatch(@RequestBody List req) { - for (StationEntity stationEntity : req) { - if (StringUtil.isNotBlank(stationEntity.getCode()) || StringUtil.isNotBlank(stationEntity.getName())) { - List list = stationService.list(new LambdaQueryWrapper() {{ - eq(StationEntity::getCode, stationEntity.getCode()).or().eq(StationEntity::getName, stationEntity.getName()); - }}); - Assert.isTrue(CollectionUtil.isEmpty(list), () -> { - throw new ServiceException(stationEntity.getId() + "下站点名/编码已有对应记录,请找到相应记录做修改处理"); - }); - } - } - return R.status(stationService.updateBatchById(req)); + @ApiOperation(value = "批量修改排序", notes = "传入站点列表") + public R updateBatchSort(@RequestBody List req) { + return R.status(stationService.updateBatchSort(req)); } /** diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/IStationService.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/IStationService.java index 924cb11..7106f30 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/IStationService.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/IStationService.java @@ -1,5 +1,6 @@ package com.hnac.hzims.operational.station.service; +import com.baomidou.mybatisplus.core.conditions.Wrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.hnac.hzims.operational.main.vo.StationCountVo; @@ -127,4 +128,14 @@ public interface IStationService extends BaseService { @Override boolean updateById(StationEntity req); + + @Override + boolean save(StationEntity entity); + + /** + * 批量更新站点排序 + * @param req 站点列表 + * @return 更新是否成功 + */ + boolean updateBatchSort(List req); } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationServiceImpl.java index 79997f8..fbd41c0 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationServiceImpl.java @@ -719,4 +719,19 @@ public class StationServiceImpl extends BaseServiceImpl projectClient.delete()); // } } + + /** + * 批量更新站点排序 + */ + @Override + public boolean updateBatchSort(List req) { + List stations = new ArrayList<>(); + for (StationEntity stationEntity : req) { + // 获取当前的站点信息 + StationEntity station = this.getById(stationEntity.getId()); + station.setSort(stationEntity.getSort()); + stations.add(station); + } + return this.updateBatchById(stations); + } } From 6554520c19965b343ceb06c36c8da0714f385ddd Mon Sep 17 00:00:00 2001 From: liwen Date: Wed, 27 Mar 2024 21:11:55 +0800 Subject: [PATCH 3/3] =?UTF-8?q?fix:=20=E8=A7=A3=E5=86=B3=E7=AB=99=E7=82=B9?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E6=97=B6=E6=8E=92=E5=BA=8F=E4=BC=9A=E9=80=92?= =?UTF-8?q?=E5=A2=9E=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hzims/operational/station/service/impl/StationServiceImpl.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationServiceImpl.java index fbd41c0..f9b8d6b 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationServiceImpl.java @@ -89,8 +89,11 @@ public class StationServiceImpl extends BaseServiceImpl { throw new ServiceException("创建/修改机构失败!"); }); - Optional sort = Optional.ofNullable(this.getStationMaxOrder()); - req.setSort(sort.isPresent() ? sort.get() + 1 : 1); + // 区分新增和修改站点信息,若为新增,则排序递增,否则不变 + if (req.getId() == null) { + Optional sort = Optional.ofNullable(this.getStationMaxOrder()); + req.setSort(sort.isPresent() ? sort.get() + 1 : 1); + } boolean updateResult = this.saveOrUpdate(req); Assert.isTrue(updateResult, () -> { throw new ServiceException("创建/修改站点信息失败!");