package com.boying.controller;
|
|
import cn.hutool.core.date.DateUtil;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.boying.common.R;
|
import com.boying.entity.Barrier;
|
import com.boying.entity.EnterPark;
|
import com.boying.entity.OutPark;
|
import com.boying.service.BarrierService;
|
import com.boying.service.EnterParkService;
|
import com.boying.service.ParkService;
|
import io.swagger.annotations.Api;
|
import io.swagger.annotations.ApiOperation;
|
import lombok.RequiredArgsConstructor;
|
|
import org.springframework.web.bind.annotation.*;
|
|
import java.text.ParseException;
|
import java.text.SimpleDateFormat;
|
import java.util.Date;
|
import java.util.List;
|
|
/**
|
* 入场表
|
*
|
* @author kdq
|
* @date 2023-01-23 09:46:32
|
*/
|
@RestController
|
@RequiredArgsConstructor
|
@RequestMapping("ffzf/enterpark" )
|
@Api(value = "enterpark", tags = "入场表管理")
|
public class EnterParkController {
|
|
private final EnterParkService enterParkService;
|
private final BarrierService barrierService;
|
private final ParkService parkService;
|
|
/**
|
* 分页查询
|
* @param page 泊车分页对象
|
* @param
|
* @return
|
*/
|
// @ApiOperation(value = "分页查询", notes = "分页查询")
|
// @GetMapping("/page" )
|
// public R getEnterParkPage(Page page, EnterPark enterPark, String date) throws ParseException {
|
// List<EnterPark> list = enterParkService.getList(page.getCurrent(), page.getSize(), enterPark.getCarNo(),enterPark.getParkId(), date);
|
// long count = enterParkService.getCount(enterPark.getCarNo(), enterPark.getParkId(), date);
|
// Page page1 = new Page();
|
// for (EnterPark record : list) {
|
// record.setParkName(parkService.getById(record.getParkId()).getName());
|
// if(record.getImgId() != null){
|
// record.setImgPath("/ffzf/fileinfo/showImgById/"+record.getImgId());
|
// }
|
// }
|
// page1.setRecords(list);
|
// page1.setCurrent(page.getCurrent());
|
// page1.setSize(page.getSize());
|
// page1.setTotal(count);
|
// return R.ok(page1);
|
// }
|
|
@PostMapping("/findPage")
|
public Object findPage(Page page, String carNo,Integer parkId,String date) throws ParseException {
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
if(StringUtils.isNotBlank(date)){
|
System.out.println(date);
|
Date parse = sdf.parse(date);
|
date = sdf.format(parse);
|
}
|
List<EnterPark> list = enterParkService.getList(page.getCurrent(), page.getSize(), carNo,parkId, date);
|
long count = enterParkService.getCount(carNo,parkId, date);
|
for (EnterPark record : list) {
|
record.setParkName(parkService.getById(record.getParkId()).getName());
|
if(record.getImgId() != null){
|
record.setImgPath("/ffzf/fileinfo/showImgById/"+record.getImgId());
|
}
|
}
|
page.setRecords(list);
|
page.setTotal(count);
|
return R.ok(page);
|
}
|
|
/**
|
* 通过id查询入场表
|
* @param id id
|
* @return R
|
*/
|
@ApiOperation(value = "通过id查询", notes = "通过id查询")
|
@GetMapping("/{id}" )
|
public R getById(@PathVariable("id" ) Integer id) {
|
return R.ok(enterParkService.getById(id));
|
}
|
|
/**
|
* 新增入场表
|
* @param enterPark 入场表
|
* @return R
|
*/
|
@ApiOperation(value = "新增入场表", notes = "新增入场表")
|
@PostMapping
|
public R save(@RequestBody EnterPark enterPark) {
|
return R.ok(enterParkService.save(enterPark));
|
}
|
|
/**
|
* 修改入场表
|
* @param enterPark 入场表
|
* @return R
|
*/
|
@ApiOperation(value = "修改入场表", notes = "修改入场表")
|
@PutMapping
|
public R updateById(@RequestBody EnterPark enterPark) {
|
return R.ok(enterParkService.updateById(enterPark));
|
}
|
|
/**
|
* 通过id删除入场表
|
* @param id id
|
* @return R
|
*/
|
@ApiOperation(value = "通过id删除入场表", notes = "通过id删除入场表")
|
@DeleteMapping("/{id}" )
|
public R removeById(@PathVariable Integer id) {
|
return R.ok(enterParkService.removeById(id));
|
}
|
|
|
/**
|
* 导出excel 表格
|
* @param enterPark 查询条件
|
* @return excel 文件流
|
*/
|
@GetMapping("/export")
|
public List<EnterPark> export(EnterPark enterPark) {
|
return enterParkService.list(Wrappers.query(enterPark));
|
}
|
}
|