xinwei #4

Merged
root merged 9 commits from xinwei into master 2024-08-19 09:48:44 +08:00
6 changed files with 33 additions and 18 deletions
Showing only changes of commit 088fd9df0f - Show all commits

View File

@ -57,7 +57,7 @@ public class AreaController {
@Operation(summary = "删除区域列表")
@Parameter(name = "id", description = "编号", required = true)
@PreAuthorize("@ss.hasPermission('parking:area:delete')")
public CommonResult<Boolean> deleteArea(@RequestParam("id") Integer id) {
public CommonResult<Boolean> 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<AreaRespVO> getArea(@RequestParam("id") Integer id) {
public CommonResult<AreaRespVO> getArea(@RequestParam("id") Long id) {
AreaDO area = areaService.getArea(id);
return success(BeanUtils.toBean(area, AreaRespVO.class));
}

View File

@ -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;

View File

@ -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<AreaDO> {
.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);
}

View File

@ -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<AreaDO> getAreaPage(AreaPageReqVO pageReqVO);
/**
* 创建或更新区域批量
* 根据场库编号创建或更新区域批量
* @param areaList
* @return java.lang.Boolean
*/
Boolean createOrUpdateAreaBatch(ArrayList<AreaSaveReqVO> areaList);
Boolean updateAreaBatchByParkNumber(ArrayList<AreaSaveReqVO> areaList);
}

View File

@ -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<AreaSaveReqVO> areaList) {
return areaMapper.insertOrUpdateBatch(BeanUtils.toBean(areaList, AreaDO.class));
@Transactional(rollbackFor = Exception.class)
public Boolean updateAreaBatchByParkNumber(ArrayList<AreaSaveReqVO> areaList) {
if (areaList == null || areaList.isEmpty()){
return false;
}
areaMapper.physicalDeleteByParkNumber(areaList.get(0).getParkNumber());
areaMapper.insertBatch(BeanUtils.toBean(areaList, AreaDO.class));
return true;
}
}

View File

@ -85,7 +85,7 @@ public class HeartbeatServiceImpl implements HeartbeatService {
}
@Override
@Transactional
@Transactional(rollbackFor = Exception.class)
public BlueCardResult doHeartbeat(HeartbeatReqDataVO blueCardHeartbeat) {
try {
ArrayList<AreaSaveReqVO> 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) {
// 手动设置回滚