kongdeqiang
2023-06-05 a41b28d983f46f90a41ff7d2aa47179541c1be99
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
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));
    }
}