Browse Source

fix: 解决视频配置中修改站点排序时导致站点信息丢失的问题

zhongwei
liwen 8 months ago
parent
commit
5a6e0f3b7f
  1. 18
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/controller/StationController.java
  2. 11
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/IStationService.java
  3. 15
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationServiceImpl.java

18
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)); return R.status(stationService.instanceProject(req));
} }
@PostMapping("/updateBatch") @PostMapping("/updateBatchSort")
@ApiOperationSupport(order = 30) @ApiOperationSupport(order = 30)
@ApiOperation(value = "批量修改", notes = "传入站点列表") @ApiOperation(value = "批量修改排序", notes = "传入站点列表")
public R updateBatch(@RequestBody List<StationEntity> req) { public R updateBatchSort(@RequestBody List<StationEntity> req) {
for (StationEntity stationEntity : req) { return R.status(stationService.updateBatchSort(req));
if (StringUtil.isNotBlank(stationEntity.getCode()) || StringUtil.isNotBlank(stationEntity.getName())) {
List<StationEntity> list = stationService.list(new LambdaQueryWrapper<StationEntity>() {{
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));
} }
/** /**

11
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; 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.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hnac.hzims.operational.main.vo.StationCountVo; import com.hnac.hzims.operational.main.vo.StationCountVo;
@ -127,4 +128,14 @@ public interface IStationService extends BaseService<StationEntity> {
@Override @Override
boolean updateById(StationEntity req); boolean updateById(StationEntity req);
@Override
boolean save(StationEntity entity);
/**
* 批量更新站点排序
* @param req 站点列表
* @return 更新是否成功
*/
boolean updateBatchSort(List<StationEntity> req);
} }

15
hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationServiceImpl.java

@ -719,4 +719,19 @@ public class StationServiceImpl extends BaseServiceImpl<StationMapper, StationEn
// stationEntityList.stream().map(StationEntity::getCode).forEach(code -> projectClient.delete()); // stationEntityList.stream().map(StationEntity::getCode).forEach(code -> projectClient.delete());
// } // }
} }
/**
* 批量更新站点排序
*/
@Override
public boolean updateBatchSort(List<StationEntity> req) {
List<StationEntity> stations = new ArrayList<>();
for (StationEntity stationEntity : req) {
// 获取当前的站点信息
StationEntity station = this.getById(stationEntity.getId());
station.setSort(stationEntity.getSort());
stations.add(station);
}
return this.updateBatchById(stations);
}
} }

Loading…
Cancel
Save