| | |
| | | package com.xiaopeng.operation.controller; |
| | | |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | 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 com.xiaopeng.operation.vo.SpecialPointListVo; |
| | | import com.xiaopeng.operation.vo.SpecialPointVo; |
| | | 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.time.LocalDateTime; |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | |
| | | } |
| | | @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); |
| | | } |
| | | /** |
| | | * 新增点位 |
| | | */ |
| | | @Transactional(rollbackFor = Exception.class) |
| | | @PostMapping("/addPoint") |
| | | @ResponseBody |
| | | @ApiOperation(value = "新增点位") |
| | | // @Transactional |
| | | // @ShardingSphereTransactionType(TransactionType.BASE) |
| | | public R add(@Validated @RequestBody PointAddDto pointAddDto) { |
| | | XpPoint xpPoint = new XpPoint(); |
| | | BeanUtils.copyProperties(pointAddDto, xpPoint); |
| | |
| | | @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)); |
| | | List<XpPoint> list = xpPointService.list(new LambdaQueryWrapper<XpPoint>().in(XpPoint::getId, dto.getChargePoints())); |
| | | list.forEach(e->{ |
| | | e.setChargePoint(1); |
| | | e.setElectronicAreaId(null); |
| | | }); |
| | | xpPointService.updateBatchById(list); |
| | | List<XpPoint> list1 = xpPointService.list(new LambdaQueryWrapper<XpPoint>().in(XpPoint::getId, dto.getParkingPoints())); |
| | | list1.forEach(e->{ |
| | | e.setParkingPoint(1); |
| | | e.setElectronicAreaId(null); |
| | | }); |
| | | xpPointService.updateBatchById(list1); |
| | | return R.ok(); |
| | | } |
| | | |
| | | |
| | | @GetMapping("/listSpecialPoint") |
| | | @ApiOperation(value = "获取特殊点位",tags = "后台管理-特殊点位") |
| | | public R<SpecialPointVo> getSpecialPoint() { |
| | | List<XpPoint> chargePoints = xpPointService.list(new LambdaQueryWrapper<XpPoint>().eq(XpPoint::getChargePoint, 1)); |
| | | List<XpPoint> parkingPoints = xpPointService.list(new LambdaQueryWrapper<XpPoint>().eq(XpPoint::getParkingPoint, 1)); |
| | | |
| | | SpecialPointVo specialPointVo = new SpecialPointVo(); |
| | | ArrayList<SpecialPointListVo> chargePointsList = new ArrayList<>(); |
| | | for (XpPoint chargePoint : chargePoints) { |
| | | SpecialPointListVo specialPointListVo = new SpecialPointListVo(); |
| | | specialPointListVo.setPointName(chargePoint.getPointName()); |
| | | specialPointListVo.setPointAddress(chargePoint.getPointAddress()); |
| | | specialPointListVo.setPointId(chargePoint.getId()); |
| | | chargePointsList.add(specialPointListVo); |
| | | } |
| | | specialPointVo.setChargePoints(chargePointsList); |
| | | |
| | | |
| | | ArrayList<SpecialPointListVo> parkingPointsList = new ArrayList<>(); |
| | | for (XpPoint parkingPoint : parkingPoints) { |
| | | SpecialPointListVo specialPointListVo = new SpecialPointListVo(); |
| | | specialPointListVo.setPointName(parkingPoint.getPointName()); |
| | | specialPointListVo.setPointAddress(parkingPoint.getPointAddress()); |
| | | specialPointListVo.setPointId(parkingPoint.getId()); |
| | | parkingPointsList.add(specialPointListVo); |
| | | } |
| | | specialPointVo.setParkingPoints(parkingPointsList); |
| | | |
| | | return R.ok(specialPointVo); |
| | | } |
| | | } |