forked from 15166072824/NO6
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathYishengyuyueController.java
More file actions
448 lines (383 loc) · 17.7 KB
/
YishengyuyueController.java
File metadata and controls
448 lines (383 loc) · 17.7 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
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
package com.cl.controller;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.text.ParseException;
import java.util.*;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import com.cl.utils.ValidatorUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.cl.annotation.IgnoreAuth;
import com.cl.annotation.SysLog;
import com.cl.entity.YishengyuyueEntity;
import com.cl.entity.view.YishengyuyueView;
import com.cl.entity.JiuzhentongzhiEntity;
import com.cl.entity.TongzhifasongEntity;
import com.cl.service.YishengyuyueService;
import com.cl.service.JiuzhentongzhiService;
import com.cl.service.TongzhifasongService;
import com.cl.service.TokenService;
import com.cl.utils.PageUtils;
import com.cl.utils.R;
import com.cl.utils.MPUtil;
import com.cl.utils.MapUtils;
import com.cl.utils.CommonUtil;
/**
* 医生预约
* 后端接口
* @author
* @email
* @date 2025-03-27 15:44:15
*/
@RestController
@RequestMapping("/yishengyuyue")
public class YishengyuyueController {
@Autowired
private YishengyuyueService yishengyuyueService;
@Autowired
private JiuzhentongzhiService jiuzhentongzhiService;
@Autowired
private TongzhifasongService tongzhifasongService;
/**
* 后台列表
*/
@RequestMapping("/page")
public R page(@RequestParam Map<String, Object> params,YishengyuyueEntity yishengyuyue,
HttpServletRequest request){
String tableName = request.getSession().getAttribute("tableName").toString();
if(tableName.equals("yisheng")) {
yishengyuyue.setYishengzhanghao((String)request.getSession().getAttribute("username"));
}
if(tableName.equals("yonghu")) {
yishengyuyue.setZhanghao((String)request.getSession().getAttribute("username"));
}
EntityWrapper<YishengyuyueEntity> ew = new EntityWrapper<YishengyuyueEntity>();
PageUtils page = yishengyuyueService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, yishengyuyue), params), params));
return R.ok().put("data", page);
}
/**
* 前端列表
*/
@IgnoreAuth
@RequestMapping("/list")
public R list(@RequestParam Map<String, Object> params,YishengyuyueEntity yishengyuyue,
HttpServletRequest request){
EntityWrapper<YishengyuyueEntity> ew = new EntityWrapper<YishengyuyueEntity>();
PageUtils page = yishengyuyueService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, yishengyuyue), params), params));
return R.ok().put("data", page);
}
/**
* 列表
*/
@RequestMapping("/lists")
public R list( YishengyuyueEntity yishengyuyue){
EntityWrapper<YishengyuyueEntity> ew = new EntityWrapper<YishengyuyueEntity>();
ew.allEq(MPUtil.allEQMapPre( yishengyuyue, "yishengyuyue"));
return R.ok().put("data", yishengyuyueService.selectListView(ew));
}
/**
* 查询
*/
@RequestMapping("/query")
public R query(YishengyuyueEntity yishengyuyue){
EntityWrapper< YishengyuyueEntity> ew = new EntityWrapper< YishengyuyueEntity>();
ew.allEq(MPUtil.allEQMapPre( yishengyuyue, "yishengyuyue"));
YishengyuyueView yishengyuyueView = yishengyuyueService.selectView(ew);
return R.ok("查询医生预约成功").put("data", yishengyuyueView);
}
/**
* 后端详情
*/
@RequestMapping("/info/{id}")
public R info(@PathVariable("id") Long id){
YishengyuyueEntity yishengyuyue = yishengyuyueService.selectById(id);
yishengyuyue = yishengyuyueService.selectView(new EntityWrapper<YishengyuyueEntity>().eq("id", id));
return R.ok().put("data", yishengyuyue);
}
/**
* 前端详情
*/
@IgnoreAuth
@RequestMapping("/detail/{id}")
public R detail(@PathVariable("id") Long id){
YishengyuyueEntity yishengyuyue = yishengyuyueService.selectById(id);
yishengyuyue = yishengyuyueService.selectView(new EntityWrapper<YishengyuyueEntity>().eq("id", id));
return R.ok().put("data", yishengyuyue);
}
/**
* 后端保存
*/
@RequestMapping("/save")
@SysLog("新增医生预约")
public R save(@RequestBody YishengyuyueEntity yishengyuyue, HttpServletRequest request){
//ValidatorUtils.validateEntity(yishengyuyue);
yishengyuyueService.insert(yishengyuyue);
createNotifications(yishengyuyue);
return R.ok();
}
/**
* 前端保存
*/
@SysLog("新增医生预约")
@RequestMapping("/add")
public R add(@RequestBody YishengyuyueEntity yishengyuyue, HttpServletRequest request){
//ValidatorUtils.validateEntity(yishengyuyue);
yishengyuyueService.insert(yishengyuyue);
createNotifications(yishengyuyue);
return R.ok();
}
private void createNotifications(YishengyuyueEntity yishengyuyue) {
String notificationNo = System.currentTimeMillis() + "";
List<String> notificationTypes = Arrays.asList("就诊前1天提醒", "就诊当天提醒");
for (String type : notificationTypes) {
JiuzhentongzhiEntity notification = new JiuzhentongzhiEntity();
notification.setTongzhibianhao(notificationNo + "-" + type);
notification.setYishengzhanghao(yishengyuyue.getYishengzhanghao());
notification.setDianhua(yishengyuyue.getDianhua());
notification.setJiuzhenshijian(yishengyuyue.getYuyueshijian());
notification.setTongzhishijian(new Date());
notification.setZhanghao(yishengyuyue.getZhanghao());
notification.setShouji(yishengyuyue.getShouji());
notification.setTongzhibeizhu(type);
jiuzhentongzhiService.insert(notification);
TongzhifasongEntity sendRecord = new TongzhifasongEntity();
sendRecord.setTongzhibianhao(notification.getTongzhibianhao());
sendRecord.setZhanghao(yishengyuyue.getZhanghao());
sendRecord.setShouji(yishengyuyue.getShouji());
sendRecord.setTongzhileixing(type);
sendRecord.setFasongzhuangtai("发送成功");
sendRecord.setChongshicishu(0);
sendRecord.setAddtime(new Date());
tongzhifasongService.insert(sendRecord);
}
}
/**
* 修改
*/
@RequestMapping("/update")
@Transactional
@SysLog("修改医生预约")
public R update(@RequestBody YishengyuyueEntity yishengyuyue, HttpServletRequest request){
//ValidatorUtils.validateEntity(yishengyuyue);
yishengyuyueService.updateById(yishengyuyue);//全部更新
return R.ok();
}
/**
* 审核
*/
@RequestMapping("/shBatch")
@Transactional
@SysLog("审核医生预约")
public R update(@RequestBody Long[] ids, @RequestParam String sfsh, @RequestParam String shhf){
List<YishengyuyueEntity> list = new ArrayList<YishengyuyueEntity>();
for(Long id : ids) {
YishengyuyueEntity yishengyuyue = yishengyuyueService.selectById(id);
yishengyuyue.setSfsh(sfsh);
yishengyuyue.setShhf(shhf);
list.add(yishengyuyue);
}
yishengyuyueService.updateBatchById(list);
return R.ok();
}
/**
* 删除
*/
@RequestMapping("/delete")
@SysLog("删除医生预约")
public R delete(@RequestBody Long[] ids){
yishengyuyueService.deleteBatchIds(Arrays.asList(ids));
return R.ok();
}
/**
* (按值统计)
*/
@RequestMapping("/value/{xColumnName}/{yColumnName}")
public R value(@PathVariable("yColumnName") String yColumnName, @PathVariable("xColumnName") String xColumnName,HttpServletRequest request) {
Map<String, Object> params = new HashMap<String, Object>();
params.put("xColumn", MPUtil.camelToSnake(xColumnName));
params.put("yColumn", MPUtil.camelToSnake(yColumnName));
EntityWrapper<YishengyuyueEntity> ew = new EntityWrapper<YishengyuyueEntity>();
String tableName = request.getSession().getAttribute("tableName").toString();
if(tableName.equals("yisheng")) {
ew.eq("yishengzhanghao", (String)request.getSession().getAttribute("username"));
}
if(tableName.equals("yonghu")) {
ew.eq("zhanghao", (String)request.getSession().getAttribute("username"));
}
List<Map<String, Object>> result = MPUtil.snakeListToCamel(yishengyuyueService.selectValue(params, ew));
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
for(Map<String, Object> m : result) {
for(String k : m.keySet()) {
if(m.get(k) instanceof Date) {
m.put(k, sdf.format((Date)m.get(k)));
}
}
}
Collections.sort(result, (map1, map2) -> {
// 假设 total 总是存在并且是数值类型
Number total1 = (Number) map1.get("total");
Number total2 = (Number) map2.get("total");
if(total1==null)
{
total1 = 0;
}
if(total2==null)
{
total2 = 0;
}
String order = request.getParameter("order");
if(StringUtils.isNotBlank(order)&&order.equals("desc")){
return Double.compare(total2.doubleValue(), total1.doubleValue());
}
return Double.compare(total1.doubleValue(), total2.doubleValue());
});
return R.ok().put("data", result);
}
/**
* (按值统计(多))
*/
@RequestMapping("/valueMul/{xColumnName}")
public R valueMul(@PathVariable("xColumnName") String xColumnName,@RequestParam String yColumnNameMul, HttpServletRequest request) {
String[] yColumnNames = MPUtil.camelToSnake(yColumnNameMul).split(",");
Map<String, Object> params = new HashMap<String, Object>();
params.put("xColumn", MPUtil.camelToSnake(xColumnName));
List<List<Map<String, Object>>> result2 = new ArrayList<List<Map<String,Object>>>();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
EntityWrapper<YishengyuyueEntity> ew = new EntityWrapper<YishengyuyueEntity>();
String tableName = request.getSession().getAttribute("tableName").toString();
if(tableName.equals("yisheng")) {
ew.eq("yishengzhanghao", (String)request.getSession().getAttribute("username"));
}
if(tableName.equals("yonghu")) {
ew.eq("zhanghao", (String)request.getSession().getAttribute("username"));
}
for(int i=0;i<yColumnNames.length;i++) {
params.put("yColumn", yColumnNames[i]);
List<Map<String, Object>> result = MPUtil.snakeListToCamel(yishengyuyueService.selectValue(params, ew));
for(Map<String, Object> m : result) {
for(String k : m.keySet()) {
if(m.get(k) instanceof Date) {
m.put(k, sdf.format((Date)m.get(k)));
}
}
}
result2.add(result);
}
return R.ok().put("data", result2);
}
/**
* (按值统计)时间统计类型
*/
@RequestMapping("/value/{xColumnName}/{yColumnName}/{timeStatType}")
public R valueDay(@PathVariable("yColumnName") String yColumnName, @PathVariable("xColumnName") String xColumnName, @PathVariable("timeStatType") String timeStatType,HttpServletRequest request) {
Map<String, Object> params = new HashMap<String, Object>();
params.put("xColumn", MPUtil.camelToSnake(xColumnName));
params.put("yColumn", MPUtil.camelToSnake(yColumnName));
params.put("timeStatType", timeStatType);
EntityWrapper<YishengyuyueEntity> ew = new EntityWrapper<YishengyuyueEntity>();
String tableName = request.getSession().getAttribute("tableName").toString();
if(tableName.equals("yisheng")) {
ew.eq("yishengzhanghao", (String)request.getSession().getAttribute("username"));
}
if(tableName.equals("yonghu")) {
ew.eq("zhanghao", (String)request.getSession().getAttribute("username"));
}
List<Map<String, Object>> result = MPUtil.snakeListToCamel(yishengyuyueService.selectTimeStatValue(params, ew));
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
for(Map<String, Object> m : result) {
for(String k : m.keySet()) {
if(m.get(k) instanceof Date) {
m.put(k, sdf.format((Date)m.get(k)));
}
}
}
return R.ok().put("data", result);
}
/**
* (按值统计)时间统计类型(多)
*/
@RequestMapping("/valueMul/{xColumnName}/{timeStatType}")
public R valueMulDay(@PathVariable("xColumnName") String xColumnName, @PathVariable("timeStatType") String timeStatType,@RequestParam String yColumnNameMul,HttpServletRequest request) {
String[] yColumnNames = MPUtil.camelToSnake(yColumnNameMul).split(",");
Map<String, Object> params = new HashMap<String, Object>();
params.put("xColumn", xColumnName);
params.put("timeStatType", timeStatType);
List<List<Map<String, Object>>> result2 = new ArrayList<List<Map<String,Object>>>();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
EntityWrapper<YishengyuyueEntity> ew = new EntityWrapper<YishengyuyueEntity>();
String tableName = request.getSession().getAttribute("tableName").toString();
if(tableName.equals("yisheng")) {
ew.eq("yishengzhanghao", (String)request.getSession().getAttribute("username"));
}
if(tableName.equals("yonghu")) {
ew.eq("zhanghao", (String)request.getSession().getAttribute("username"));
}
for(int i=0;i<yColumnNames.length;i++) {
params.put("yColumn", yColumnNames[i]);
List<Map<String, Object>> result = MPUtil.snakeListToCamel(yishengyuyueService.selectTimeStatValue(params, ew));
for(Map<String, Object> m : result) {
for(String k : m.keySet()) {
if(m.get(k) instanceof Date) {
m.put(k, sdf.format((Date)m.get(k)));
}
}
}
result2.add(result);
}
return R.ok().put("data", result2);
}
/**
* 分组统计
*/
@RequestMapping("/group/{columnName}")
public R group(@PathVariable("columnName") String columnName,HttpServletRequest request) {
Map<String, Object> params = new HashMap<String, Object>();
params.put("column", MPUtil.camelToSnake(columnName));
EntityWrapper<YishengyuyueEntity> ew = new EntityWrapper<YishengyuyueEntity>();
String tableName = request.getSession().getAttribute("tableName").toString();
if(tableName.equals("yisheng")) {
ew.eq("yishengzhanghao", (String)request.getSession().getAttribute("username"));
}
if(tableName.equals("yonghu")) {
ew.eq("zhanghao", (String)request.getSession().getAttribute("username"));
}
List<Map<String, Object>> result = MPUtil.snakeListToCamel(yishengyuyueService.selectGroup(params, ew));
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
for(Map<String, Object> m : result) {
for(String k : m.keySet()) {
if(m.get(k) instanceof Date) {
m.put(k, sdf.format((Date)m.get(k)));
}
}
}
return R.ok().put("data", result);
}
/**
* 总数量
*/
@RequestMapping("/count")
public R count(@RequestParam Map<String, Object> params,YishengyuyueEntity yishengyuyue, HttpServletRequest request){
String tableName = request.getSession().getAttribute("tableName").toString();
if(tableName.equals("yisheng")) {
yishengyuyue.setYishengzhanghao((String)request.getSession().getAttribute("username"));
}
if(tableName.equals("yonghu")) {
yishengyuyue.setZhanghao((String)request.getSession().getAttribute("username"));
}
EntityWrapper<YishengyuyueEntity> ew = new EntityWrapper<YishengyuyueEntity>();
int count = yishengyuyueService.selectCount(MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, yishengyuyue), params), params));
return R.ok().put("data", count);
}
}