ReservationController.java
7.83 KB
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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
package com.huaheng.pc.receipt.reservation.controller;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.huaheng.common.utils.StringUtils;
import com.huaheng.framework.aspectj.lang.annotation.Log;
import com.huaheng.framework.aspectj.lang.constant.BusinessType;
import com.huaheng.framework.web.controller.BaseController;
import com.huaheng.framework.web.domain.AjaxResult;
import com.huaheng.framework.web.page.PageDomain;
import com.huaheng.framework.web.page.TableDataInfo;
import com.huaheng.framework.web.page.TableSupport;
import com.huaheng.pc.receipt.receiptHeader.domain.ReceiptHeader;
import com.huaheng.pc.receipt.receiptHeader.service.ReceiptHeaderService;
import com.huaheng.pc.receipt.reservation.domain.Reservation;
import com.huaheng.pc.receipt.reservation.service.ReservationService;
import com.huaheng.pc.shipment.shipmentHeader.domain.ShipmentHeader;
import com.huaheng.pc.shipment.shipmentHeader.service.ShipmentHeaderService;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.List;
@ApiModel(value = "预约")
@RequestMapping("/reservation")
@Controller
public class ReservationController extends BaseController {
@Resource
private ReservationService reservationService;
@Resource
private ReceiptHeaderService receiptHeaderService;
@Resource
private ShipmentHeaderService shipmentHeaderService;
private String prefix = "receipt/reservation";
@RequiresPermissions("reservation:view")
@GetMapping()
public String reservation() {
return prefix + "/reservation";
}
@GetMapping("/selectWarehouse")
public String selectWarehouse() {
return prefix + "/selectWarehouse";
}
@RequiresPermissions("reservation:view")
@GetMapping("/view/{warehouseCode}")
public String view(@PathVariable("warehouseCode") String warehouseCode, ModelMap modelMap) {
LocalDate date2 = LocalDate.now();
List<LocalDate> localDateList = new ArrayList<>();
for (int i = 0; i < 7; i++) {
localDateList.add(date2.plusDays(i));
}
modelMap.put("localDateList", localDateList);
modelMap.put("warehouseCode", warehouseCode);
return prefix + "/view";
}
/**
* 查询预约
*/
@RequiresPermissions("reservation:list")
@Log(title = "预约-预约查讯", operating = "预约查讯", action = BusinessType.GRANT)
@PostMapping("/list")
@ResponseBody
@ApiOperation("预约查询接口")
public TableDataInfo list(Reservation reservation, String begin, String end) {
LambdaQueryWrapper<Reservation> lambdaQueryWrapper = Wrappers.lambdaQuery();
PageDomain pageDomain = TableSupport.buildPageRequest();
Integer pageNum = pageDomain.getPageNum();
Integer pageSize = pageDomain.getPageSize();
lambdaQueryWrapper.like(StringUtils.isNotEmpty(reservation.getCarPlate()), Reservation::getCarPlate, reservation.getCarPlate())
.like(StringUtils.isNotEmpty(reservation.getName()), Reservation::getName, reservation.getName())
.eq(StringUtils.isNotEmpty(reservation.getStatus()), Reservation::getStatus, reservation.getStatus())
.like(StringUtils.isNotEmpty(reservation.getCode()), Reservation::getCode, reservation.getCode())
.lt(StringUtils.isNotEmpty(begin), Reservation::getBeginTime, begin)
.gt(StringUtils.isNotEmpty(end), Reservation::getEndTime, end)
.eq(StringUtils.isNotEmpty(reservation.getStationCode()), Reservation::getStationCode, reservation.getStationCode());
if (StringUtils.isNotNull(pageNum) && StringUtils.isNotNull(pageSize)) {
/**
* 使用分页查询
*/
Page<Reservation> page = new Page<>(pageNum, pageSize);
IPage<Reservation> iPage = reservationService.page(page, lambdaQueryWrapper);
return getMpDataTable(iPage.getRecords(), iPage.getTotal());
} else {
List<Reservation> list = reservationService.list(lambdaQueryWrapper);
return getDataTable(list);
}
}
/**
* 新增预约
*/
@GetMapping("/add/{warehouseCode}/{date}/{time1}/{time2}")
public String add(@PathVariable("warehouseCode") String warehouseCode, @PathVariable("date") String date,
@PathVariable("time1") String time1, @PathVariable("time2")String time2, ModelMap modelMap) {
DateTimeFormatter fmt = DateTimeFormatter.ofPattern("yyyy-MM-dd");
LocalDate localDate = LocalDate.parse(date, fmt);
DateTimeFormatter fmt1 = DateTimeFormatter.ofPattern("HH:mm");
LocalTime beginTime = LocalTime.parse(time1, fmt1);
LocalTime endTime = LocalTime.parse(time2, fmt1);
DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
modelMap.put("warehouseCode", warehouseCode);
modelMap.put("beginTime", LocalDateTime.of(localDate, beginTime));
modelMap.put("endTime", LocalDateTime.of(localDate, endTime));
return prefix + "/add";
}
/**
* 新增保存预约
*/
@ApiOperation(value = "新增预约 ", notes = "新增预约 ", httpMethod = "POST")
@Log(title = "预约 ", operating = "新增预约 ", action = BusinessType.INSERT)
@PostMapping("/add")
@ResponseBody
public AjaxResult addSave(Reservation reservation, String time1, String time2) {
DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss");
reservation.setBeginTime(LocalDateTime.parse(time1));
reservation.setEndTime(LocalDateTime.parse(time2));
return toAjax(reservationService.save(reservation));
}
/**
* 修改预约
*/
@GetMapping("/edit/{id}")
public String edit(@PathVariable("id") Integer id, ModelMap mmap) {
Reservation reservation = reservationService.getById(id);
mmap.put("reservation", reservation);
return prefix + "/edit";
}
/**
* 修改保存预约
*/
@ApiOperation(value = "修改预约", notes = "修改预约", httpMethod = "POST")
@RequiresPermissions("reservation:edit")
@Log(title = "预约 ", operating = "修改预约 ", action = BusinessType.UPDATE)
@PostMapping("/edit")
@ResponseBody
public AjaxResult editSave(Reservation reservation) {
return toAjax(reservationService.updateById(reservation));
}
@ApiOperation(value = "修改预约状态", notes = "修改预约状态", httpMethod = "POST")
@RequiresPermissions("reservation:change")
@PostMapping("/change")
public AjaxResult changeStatus(Integer id, String status) {
LambdaUpdateWrapper<Reservation> updateWrapper = Wrappers.lambdaUpdate();
updateWrapper.eq(Reservation::getId, id)
.set(Reservation::getStatus, status);
return toAjax(reservationService.update(updateWrapper));
}
@ResponseBody
@GetMapping("/reservation")
public AjaxResult reservation(String localDate, String warehouseCode) {
DateTimeFormatter fmt = DateTimeFormatter.ofPattern("yyyy-MM-dd");
LocalDate date2 = LocalDate.parse(localDate, fmt);
return AjaxResult.success(reservationService.reservationTime(date2, warehouseCode));
}
}