| | |
| | | package com.xiaopeng.operation.controller; |
| | | |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| | | import com.xiaopeng.api.dto.map.XpPointExportExcelQuery; |
| | | import com.xiaopeng.api.dto.operation.PointAddDto; |
| | | import com.xiaopeng.api.dto.operation.PointUpdateDto; |
| | | import com.xiaopeng.api.dto.operation.XpPointEnableDisableDto; |
| | | import com.xiaopeng.api.model.operation.*; |
| | | import com.xiaopeng.api.query.operation.PointPageListListQuery; |
| | | import com.xiaopeng.common.core.domain.R; |
| | | import com.xiaopeng.common.core.web.controller.BaseController; |
| | | import com.xiaopeng.api.query.operation.PointPageListQuery; |
| | | import com.xiaopeng.api.query.operation.PointListQuery; |
| | | import com.xiaopeng.common.core.web.page.PageInfo; |
| | | import com.xiaopeng.operation.dto.XpPointSpecialDto; |
| | | import com.xiaopeng.operation.service.IXpElectronicFenceAreaService; |
| | | import com.xiaopeng.operation.service.IXpElectronicFenceService; |
| | | import com.xiaopeng.operation.service.XpPointService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.shardingsphere.transaction.annotation.ShardingSphereTransactionType; |
| | | import org.apache.shardingsphere.transaction.core.TransactionType; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | |
| | | } |
| | | @ApiOperation(value = "点位管理列表", response = XpPoint.class) |
| | | @PostMapping("/listPoint") |
| | | public R<List<XpPoint>> list(@RequestBody PointPageListQuery query) { |
| | | public R<List<XpPoint>> list(@RequestBody PointListQuery query) { |
| | | List<XpPoint> pageList = xpPointService.listAll(query); |
| | | return R.ok(pageList); |
| | | } |
| | | @ApiOperation(value = "点位管理分页列表", response = XpPoint.class) |
| | | @PostMapping("/pageList") |
| | | public R<PageInfo<XpPoint>> pageList(@RequestBody PointPageListListQuery query) { |
| | | PageInfo<XpPoint> pageList = xpPointService.pageList(query); |
| | | return R.ok(pageList); |
| | | } |
| | | @PostMapping("/getByIds") |
| | | public R<List<XpPoint>> getByIds(@RequestBody XpPointExportExcelQuery query){ |
| | | List<XpPoint> list = xpPointService.lambdaQuery().in(XpPoint::getId, query.getPointIds()).list(); |
| | | return R.ok(list); |
| | | } |
| | | /** |
| | | * 新增点位 |
| | | */ |
| | | @PostMapping("/addPoint") |
| | | @ResponseBody |
| | | @Transactional |
| | | @ShardingSphereTransactionType(TransactionType.BASE) |
| | | @ApiOperation(value = "新增点位") |
| | | public R add(@Validated @RequestBody PointAddDto pointAddDto) { |
| | | XpPoint xpPoint = new XpPoint(); |
| | |
| | | return R.ok(); |
| | | } |
| | | /** |
| | | * 批量删除点位 |
| | | */ |
| | | @GetMapping("/deletePoint") |
| | | @ResponseBody |
| | | @ApiOperation(value = "删除点位") |
| | | @Transactional |
| | | @ShardingSphereTransactionType(TransactionType.BASE) |
| | | public R deletePoint(@RequestParam("ids") String ids) { |
| | | xpPointService.removeBatchByIds(Arrays.stream(ids.split(",")).map(Long::parseLong).collect(Collectors.toList())); |
| | | return R.ok(); |
| | | } |
| | | /** |
| | | * 编辑点位 |
| | | */ |
| | | @PostMapping("/editPoint") |
| | | @ApiOperation(value = "编辑点位") |
| | | @Transactional |
| | | @ShardingSphereTransactionType(TransactionType.BASE) |
| | | public R edit(@Validated@RequestBody PointUpdateDto pointAddDto) { |
| | | XpPoint xpPoint = new XpPoint(); |
| | | BeanUtils.copyProperties(pointAddDto, xpPoint); |
| | |
| | | */ |
| | | @PostMapping("/enableDisablePoint") |
| | | @ApiOperation(value = "启用/禁用") |
| | | @Transactional |
| | | @ShardingSphereTransactionType(TransactionType.BASE) |
| | | public R enableDisable(@RequestBody XpPointEnableDisableDto dto) { |
| | | XpPoint xpPoint = xpPointService.getById(dto.getId()); |
| | | xpPoint.setOperationStatus(dto.getOperationStatus()); |
| | | xpPoint.setElectronicAreaId(null); |
| | | xpPointService.updateById(xpPoint); |
| | | return R.ok(); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 设置特殊点位 |
| | | */ |
| | | @PostMapping("/setSpecialPoint") |
| | | @ApiOperation(value = "设置特殊点位",tags = "后台管理-特殊点位") |
| | | public R setSpecialPoint(@RequestBody XpPointSpecialDto dto) { |
| | | xpPointService.update(new LambdaUpdateWrapper<XpPoint>().set(XpPoint::getChargePoint, 0).set(XpPoint::getParkingPoint,0)); |
| | | xpPointService.update(new LambdaUpdateWrapper<XpPoint>().in(XpPoint::getId,dto.getChargePoints()).set(XpPoint::getChargePoint,1)); |
| | | xpPointService.update(new LambdaUpdateWrapper<XpPoint>().in(XpPoint::getId,dto.getParkingPoints()).set(XpPoint::getParkingPoint,2)); |
| | | return R.ok(); |
| | | } |
| | | } |