停车场后台-心跳修改
This commit is contained in:
parent
90ecdcfffe
commit
088fd9df0f
@ -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));
|
||||
}
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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);
|
||||
}
|
@ -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);
|
||||
}
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -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) {
|
||||
// 手动设置回滚
|
||||
|
Loading…
Reference in New Issue
Block a user