diff --git a/ludu-module-parking/ludu-module-parking-biz/src/main/java/cn/iocoder/yudao/module/parking/controller/admin/area/AreaController.java b/ludu-module-parking/ludu-module-parking-biz/src/main/java/cn/iocoder/yudao/module/parking/controller/admin/area/AreaController.java index 0b2f3fada..fefcd1da6 100644 --- a/ludu-module-parking/ludu-module-parking-biz/src/main/java/cn/iocoder/yudao/module/parking/controller/admin/area/AreaController.java +++ b/ludu-module-parking/ludu-module-parking-biz/src/main/java/cn/iocoder/yudao/module/parking/controller/admin/area/AreaController.java @@ -57,7 +57,7 @@ public class AreaController { @Operation(summary = "删除区域列表") @Parameter(name = "id", description = "编号", required = true) @PreAuthorize("@ss.hasPermission('parking:area:delete')") - public CommonResult deleteArea(@RequestParam("id") Integer id) { + public CommonResult deleteArea(@RequestParam("id") Long id) { areaService.deleteArea(id); return success(true); } @@ -66,7 +66,7 @@ public class AreaController { @Operation(summary = "获得区域列表") @Parameter(name = "id", description = "编号", required = true, example = "1024") @PreAuthorize("@ss.hasPermission('parking:area:query')") - public CommonResult getArea(@RequestParam("id") Integer id) { + public CommonResult getArea(@RequestParam("id") Long id) { AreaDO area = areaService.getArea(id); return success(BeanUtils.toBean(area, AreaRespVO.class)); } diff --git a/ludu-module-parking/ludu-module-parking-biz/src/main/java/cn/iocoder/yudao/module/parking/controller/admin/area/vo/AreaPageReqVO.java b/ludu-module-parking/ludu-module-parking-biz/src/main/java/cn/iocoder/yudao/module/parking/controller/admin/area/vo/AreaPageReqVO.java index a789186d3..e0d031666 100644 --- a/ludu-module-parking/ludu-module-parking-biz/src/main/java/cn/iocoder/yudao/module/parking/controller/admin/area/vo/AreaPageReqVO.java +++ b/ludu-module-parking/ludu-module-parking-biz/src/main/java/cn/iocoder/yudao/module/parking/controller/admin/area/vo/AreaPageReqVO.java @@ -15,6 +15,9 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_ @ToString(callSuper = true) public class AreaPageReqVO extends PageParam { + @Schema(description = "区域Id", example = "27272") + private Integer areaId; + @Schema(description = "场库编号") private String parkNumber; diff --git a/ludu-module-parking/ludu-module-parking-biz/src/main/java/cn/iocoder/yudao/module/parking/dal/mysql/area/AreaMapper.java b/ludu-module-parking/ludu-module-parking-biz/src/main/java/cn/iocoder/yudao/module/parking/dal/mysql/area/AreaMapper.java index ef506e92a..c7fe27ea2 100644 --- a/ludu-module-parking/ludu-module-parking-biz/src/main/java/cn/iocoder/yudao/module/parking/dal/mysql/area/AreaMapper.java +++ b/ludu-module-parking/ludu-module-parking-biz/src/main/java/cn/iocoder/yudao/module/parking/dal/mysql/area/AreaMapper.java @@ -6,8 +6,10 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; import cn.iocoder.yudao.module.parking.dal.dataobject.area.AreaDO; +import org.apache.ibatis.annotations.Delete; import org.apache.ibatis.annotations.Mapper; import cn.iocoder.yudao.module.parking.controller.admin.area.vo.*; +import org.apache.ibatis.annotations.Param; /** * 区域列表 Mapper @@ -26,7 +28,9 @@ public interface AreaMapper extends BaseMapperX { .eqIfPresent(AreaDO::getBookSpaceCount, reqVO.getBookSpaceCount()) .eqIfPresent(AreaDO::getBookInParkCount, reqVO.getBookInParkCount()) .betweenIfPresent(AreaDO::getCreateTime, reqVO.getCreateTime()) - .orderByDesc(AreaDO::getAreaId)); + .eqIfPresent(AreaDO::getAreaId, reqVO.getAreaId()) + .orderByDesc(AreaDO::getId)); } - + @Delete("DELETE FROM `area` WHERE `park_number` = #{parkNumber}") + int physicalDeleteByParkNumber(@Param("parkNumber") String parkNumber); } \ No newline at end of file diff --git a/ludu-module-parking/ludu-module-parking-biz/src/main/java/cn/iocoder/yudao/module/parking/service/area/AreaService.java b/ludu-module-parking/ludu-module-parking-biz/src/main/java/cn/iocoder/yudao/module/parking/service/area/AreaService.java index 355dc4239..f8cb49e08 100644 --- a/ludu-module-parking/ludu-module-parking-biz/src/main/java/cn/iocoder/yudao/module/parking/service/area/AreaService.java +++ b/ludu-module-parking/ludu-module-parking-biz/src/main/java/cn/iocoder/yudao/module/parking/service/area/AreaService.java @@ -41,7 +41,7 @@ public interface AreaService { * * @param id 编号 */ - void deleteArea(Integer id); + void deleteArea(Long id); /** * 获得区域列表 @@ -49,7 +49,7 @@ public interface AreaService { * @param id 编号 * @return 区域列表 */ - AreaDO getArea(Integer id); + AreaDO getArea(Long id); /** * 获得区域列表分页 @@ -59,10 +59,11 @@ public interface AreaService { */ PageResult getAreaPage(AreaPageReqVO pageReqVO); + /** - * 创建或更新区域(批量) + * 根据场库编号创建或更新区域(批量) * @param areaList * @return java.lang.Boolean */ - Boolean createOrUpdateAreaBatch(ArrayList areaList); + Boolean updateAreaBatchByParkNumber(ArrayList areaList); } \ No newline at end of file diff --git a/ludu-module-parking/ludu-module-parking-biz/src/main/java/cn/iocoder/yudao/module/parking/service/area/AreaServiceImpl.java b/ludu-module-parking/ludu-module-parking-biz/src/main/java/cn/iocoder/yudao/module/parking/service/area/AreaServiceImpl.java index fd93f4aa3..f6d30dcfd 100644 --- a/ludu-module-parking/ludu-module-parking-biz/src/main/java/cn/iocoder/yudao/module/parking/service/area/AreaServiceImpl.java +++ b/ludu-module-parking/ludu-module-parking-biz/src/main/java/cn/iocoder/yudao/module/parking/service/area/AreaServiceImpl.java @@ -1,5 +1,6 @@ package cn.iocoder.yudao.module.parking.service.area; +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; import org.springframework.stereotype.Service; import javax.annotation.Resource; import org.springframework.validation.annotation.Validated; @@ -48,28 +49,28 @@ public class AreaServiceImpl implements AreaService { @Override public void updateArea(AreaSaveReqVO updateReqVO) { // 校验存在 - validateAreaExists(updateReqVO.getAreaId()); + validateAreaExists(updateReqVO.getId()); // 更新 AreaDO updateObj = BeanUtils.toBean(updateReqVO, AreaDO.class); areaMapper.updateById(updateObj); } @Override - public void deleteArea(Integer id) { + public void deleteArea(Long id) { // 校验存在 validateAreaExists(id); // 删除 areaMapper.deleteById(id); } - private void validateAreaExists(Integer id) { + private void validateAreaExists(Long id) { if (areaMapper.selectById(id) == null) { throw exception(AREA_NOT_EXISTS); } } @Override - public AreaDO getArea(Integer id) { + public AreaDO getArea(Long id) { return areaMapper.selectById(id); } @@ -79,8 +80,15 @@ public class AreaServiceImpl implements AreaService { } @Override - public Boolean createOrUpdateAreaBatch(ArrayList areaList) { - return areaMapper.insertOrUpdateBatch(BeanUtils.toBean(areaList, AreaDO.class)); + @Transactional(rollbackFor = Exception.class) + public Boolean updateAreaBatchByParkNumber(ArrayList areaList) { + if (areaList == null || areaList.isEmpty()){ + return false; + } + areaMapper.physicalDeleteByParkNumber(areaList.get(0).getParkNumber()); + areaMapper.insertBatch(BeanUtils.toBean(areaList, AreaDO.class)); + return true; } + } \ No newline at end of file diff --git a/ludu-module-parking/ludu-module-parking-biz/src/main/java/cn/iocoder/yudao/module/parking/service/heartbeat/HeartbeatServiceImpl.java b/ludu-module-parking/ludu-module-parking-biz/src/main/java/cn/iocoder/yudao/module/parking/service/heartbeat/HeartbeatServiceImpl.java index de337778d..23b136b41 100644 --- a/ludu-module-parking/ludu-module-parking-biz/src/main/java/cn/iocoder/yudao/module/parking/service/heartbeat/HeartbeatServiceImpl.java +++ b/ludu-module-parking/ludu-module-parking-biz/src/main/java/cn/iocoder/yudao/module/parking/service/heartbeat/HeartbeatServiceImpl.java @@ -85,7 +85,7 @@ public class HeartbeatServiceImpl implements HeartbeatService { } @Override - @Transactional + @Transactional(rollbackFor = Exception.class) public BlueCardResult doHeartbeat(HeartbeatReqDataVO blueCardHeartbeat) { try { ArrayList areaList = blueCardHeartbeat.getAreaList(); @@ -104,9 +104,8 @@ public class HeartbeatServiceImpl implements HeartbeatService { if (!areaList.isEmpty()){ // 对区域都添加停车场库编号 areaList.forEach(item -> item.setParkNumber(blueCardHeartbeat.getParkNumber())); - // 写入区域信息 - // TODO 判断重复及处理方式 - areaService.createOrUpdateAreaBatch(areaList); + // 更新区域信息 + areaService.updateAreaBatchByParkNumber(areaList); } } catch (Exception e) { // 手动设置回滚