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 io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; 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 = "入场表管理") @Tag(description = "ffzf/enterpark" , name = "入场表记录" ) 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 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") @Operation(summary = "分页查询" , description = "分页查询" ) 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 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}" ) @Operation(summary = "根据id查询" , description = "根据id查询" ) public R getById(@PathVariable("id" ) Integer id) { return R.ok(enterParkService.getById(id)); } /** * 新增入场表 * @param enterPark 入场表 * @return R */ @ApiOperation(value = "新增入场表", notes = "新增入场表") @PostMapping @Operation(summary = "新增入场" , description = "新增入场" ) public R save(@RequestBody EnterPark enterPark) { return R.ok(enterParkService.save(enterPark)); } /** * 修改入场表 * @param enterPark 入场表 * @return R */ @ApiOperation(value = "修改入场表", notes = "修改入场表") @PutMapping @Operation(summary = "修改入场" , description = "修改入场" ) 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}" ) @Operation(summary = "删除入场" , description = "删除入场" ) public R removeById(@PathVariable Integer id) { return R.ok(enterParkService.removeById(id)); } /** * 导出excel 表格 * @param enterPark 查询条件 * @return excel 文件流 */ @GetMapping("/export") @Operation(summary = "导出入场" , description = "导出入场" ) public List export(EnterPark enterPark) { return enterParkService.list(Wrappers.query(enterPark)); } }