|
1
2
3
4
5
|
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;
|
|
6
|
import com.huaheng.common.utils.Wrappers;
|
|
7
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
8
|
import com.huaheng.common.support.Convert;
|
|
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
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;
|
|
25
|
import io.swagger.annotations.ApiParam;
|
|
26
27
28
29
30
31
|
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;
|
|
32
|
import java.time.LocalDate;
|
|
33
34
|
import java.time.LocalDateTime;
import java.time.LocalTime;
|
|
35
36
|
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
|
|
37
|
import java.util.Arrays;
|
|
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
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;
|
|
52
|
private String prefix = "receipt/reservation";
|
|
53
54
55
56
57
58
59
|
@RequiresPermissions("reservation:view")
@GetMapping()
public String reservation() {
return prefix + "/reservation";
}
|
|
60
61
62
63
64
65
|
@GetMapping("/selectWarehouse")
public String selectWarehouse() {
return prefix + "/selectWarehouse";
}
@RequiresPermissions("reservation:view")
|
|
66
67
|
@GetMapping("/view/{warehouseCode}")
public String view(@PathVariable("warehouseCode") String warehouseCode, ModelMap modelMap) {
|
|
68
69
|
LocalDate date2 = LocalDate.now();
List<LocalDate> localDateList = new ArrayList<>();
|
|
70
|
for (int i = 0; i < 7; i++) {
|
|
71
72
73
74
75
76
77
|
localDateList.add(date2.plusDays(i));
}
modelMap.put("localDateList", localDateList);
modelMap.put("warehouseCode", warehouseCode);
return prefix + "/view";
}
|
|
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
/**
* 查询预约
*/
@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())
|
|
93
94
95
96
97
98
99
100
|
.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)) {
|
|
101
102
103
104
105
|
/**
* 使用分页查询
*/
Page<Reservation> page = new Page<>(pageNum, pageSize);
IPage<Reservation> iPage = reservationService.page(page, lambdaQueryWrapper);
|
|
106
|
return getMpDataTable(iPage.getRecords(), iPage.getTotal());
|
|
107
108
109
110
111
112
|
} else {
List<Reservation> list = reservationService.list(lambdaQueryWrapper);
return getDataTable(list);
}
}
|
|
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
|
/**
* 删除预约单
*/
@ApiOperation(value="删除预约单", notes="删除预约单", httpMethod = "POST")
@RequiresPermissions("receipt:receiptHeader:remove")
@Log(title = "预约-预约列表 ",operating = "预约单删除", action = BusinessType.UPDATE)
@PostMapping("/remove")
@ResponseBody
public AjaxResult remove(@ApiParam(name = "id", value = "预约头表id字符串")String ids){
if (StringUtils.isNull(ids)){
return AjaxResult.error("id为空");
}
return toAjax(reservationService.removeByIds(Arrays.asList(Convert.toIntArray(ids))));
}
|
|
129
130
131
|
/**
* 新增预约
*/
|
|
132
133
134
135
136
137
138
139
140
141
142
143
|
@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));
|
|
144
145
146
147
148
149
|
return prefix + "/add";
}
/**
* 新增保存预约
*/
|
|
150
151
|
@ApiOperation(value = "新增预约 ", notes = "新增预约 ", httpMethod = "POST")
@Log(title = "预约 ", operating = "新增预约 ", action = BusinessType.INSERT)
|
|
152
153
|
@PostMapping("/add")
@ResponseBody
|
|
154
155
156
157
|
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));
|
|
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
|
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";
}
/**
* 修改保存预约
*/
|
|
174
|
@ApiOperation(value = "修改预约", notes = "修改预约", httpMethod = "POST")
|
|
175
|
@RequiresPermissions("reservation:edit")
|
|
176
|
@Log(title = "预约 ", operating = "修改预约 ", action = BusinessType.UPDATE)
|
|
177
178
179
180
181
182
|
@PostMapping("/edit")
@ResponseBody
public AjaxResult editSave(Reservation reservation) {
return toAjax(reservationService.updateById(reservation));
}
|
|
183
|
@ApiOperation(value = "修改预约状态", notes = "修改预约状态", httpMethod = "POST")
|
|
184
185
186
187
188
189
190
191
|
@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));
}
|
|
192
193
194
195
196
197
198
199
|
@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));
}
|
|
200
|
}
|