|
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+package api.controller.scheduling;
|
|
|
2
|
+
|
|
|
3
|
+import api.entity.database.scheduling.SchedulingClass;
|
|
|
4
|
+import api.entity.database.system.User;
|
|
|
5
|
+import api.entity.input.scheduling.SchedulingCopy;
|
|
|
6
|
+import api.entity.input.scheduling.SchedulingPreference;
|
|
|
7
|
+import api.entity.view.scheduling.SchedulingClassView;
|
|
|
8
|
+import api.entity.view.scheduling.SchedulingManageView;
|
|
|
9
|
+import api.entity.view.system.UserView;
|
|
|
10
|
+import api.mapper.system.UserMapper;
|
|
|
11
|
+import api.service.scheduling.ISchedulingClassService;
|
|
|
12
|
+import api.service.system.IUserService;
|
|
|
13
|
+import com.alibaba.fastjson2.JSON;
|
|
|
14
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
15
|
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
16
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
17
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
18
|
+import api.controller.BaseController;
|
|
|
19
|
+import api.entity.database.scheduling.SchedulingManage;
|
|
|
20
|
+import api.entity.input.PageInput;
|
|
|
21
|
+import api.model.AjaxResult;
|
|
|
22
|
+import api.service.scheduling.ISchedulingManageService;
|
|
|
23
|
+import api.util.annotation.Log;
|
|
|
24
|
+import api.util.enums.BusinessType;
|
|
|
25
|
+import api.util.helper.StringHelper;
|
|
|
26
|
+import io.swagger.annotations.Api;
|
|
|
27
|
+import io.swagger.annotations.ApiOperation;
|
|
|
28
|
+import lombok.var;
|
|
|
29
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
30
|
+import org.springframework.web.bind.annotation.*;
|
|
|
31
|
+
|
|
|
32
|
+import java.util.ArrayList;
|
|
|
33
|
+import java.util.Arrays;
|
|
|
34
|
+import java.util.List;
|
|
|
35
|
+
|
|
|
36
|
+@Api(value = "排班管理",tags = "排班管理")
|
|
|
37
|
+@RestController
|
|
|
38
|
+@RequestMapping("/scheduling/schedulingmanage")
|
|
|
39
|
+public class SchedulingManageController extends BaseController {
|
|
|
40
|
+ @Autowired
|
|
|
41
|
+ private ISchedulingManageService schedulingmanageService;
|
|
|
42
|
+
|
|
|
43
|
+ @Autowired
|
|
|
44
|
+ private UserMapper userMapper;
|
|
|
45
|
+
|
|
|
46
|
+
|
|
|
47
|
+ @Autowired
|
|
|
48
|
+ private ISchedulingClassService schedulingClassService;
|
|
|
49
|
+
|
|
|
50
|
+ @Autowired
|
|
|
51
|
+ private IUserService userService;
|
|
|
52
|
+ @ApiOperation("列表")
|
|
|
53
|
+ @Log(title = "查询排班列表",businessType = BusinessType.QUERY)
|
|
|
54
|
+ @GetMapping
|
|
|
55
|
+ public AjaxResult getList(SchedulingManage input, PageInput pageInput) {
|
|
|
56
|
+ LambdaQueryWrapper<SchedulingManage> qw = new LambdaQueryWrapper();
|
|
|
57
|
+ qw.eq(input.getId() != null && input.getId() > 0, SchedulingManage::getId, input.getId());
|
|
|
58
|
+ qw.eq(input.getSchedulingDate() != null , SchedulingManage::getSchedulingDate, input.getSchedulingDate());
|
|
|
59
|
+ qw.like(!StringHelper.isEmpty(input.getSchedulingStaff()), SchedulingManage::getSchedulingStaff, input.getSchedulingStaff());
|
|
|
60
|
+ qw.eq(input.getClassId() != null && input.getClassId() > 0, SchedulingManage::getClassId, input.getClassId());
|
|
|
61
|
+ qw.eq(input.getDeptId() != null && input.getDeptId() > 0, SchedulingManage::getDeptId, input.getDeptId());
|
|
|
62
|
+ qw.like(!StringHelper.isEmpty(input.getCreateUser()), SchedulingManage::getCreateUser, input.getCreateUser());
|
|
|
63
|
+ qw.eq(input.getCreateTime() != null , SchedulingManage::getCreateTime, input.getCreateTime());
|
|
|
64
|
+ qw.like(!StringHelper.isEmpty(input.getUpdateUser()), SchedulingManage::getUpdateUser, input.getUpdateUser());
|
|
|
65
|
+ qw.eq(input.getUpdateTime() != null , SchedulingManage::getUpdateTime, input.getUpdateTime());
|
|
|
66
|
+ Page<SchedulingManage> page = GetPage(pageInput);
|
|
|
67
|
+ List<SchedulingManage> list;Long total = null;
|
|
|
68
|
+ if (page != null) {
|
|
|
69
|
+ IPage<SchedulingManage> iPage = schedulingmanageService.getListPage(page, qw);
|
|
|
70
|
+ list=iPage.getRecords();total=iPage.getTotal();
|
|
|
71
|
+ } else {
|
|
|
72
|
+ list=schedulingmanageService.getList(qw);
|
|
|
73
|
+ }
|
|
|
74
|
+ List<SchedulingManageView> schedulingManageViews= JSON.parseArray(JSON.toJSONString(list), SchedulingManageView.class);
|
|
|
75
|
+ if (schedulingManageViews!=null && schedulingManageViews.size()>0)
|
|
|
76
|
+ {
|
|
|
77
|
+ for (SchedulingManageView item : schedulingManageViews) {
|
|
|
78
|
+ if (StringHelper.isNotEmpty(item.getCreateUser()) )
|
|
|
79
|
+ {
|
|
|
80
|
+ item.setCreateUserName(userMapper.selectName(item.getCreateUser()));
|
|
|
81
|
+ }
|
|
|
82
|
+ if (StringHelper.isNotEmpty(item.getUpdateUser()) )
|
|
|
83
|
+ {
|
|
|
84
|
+ item.setUpdateUserName(userMapper.selectName(item.getUpdateUser()));
|
|
|
85
|
+ }
|
|
|
86
|
+ if (item.getClassId()!=null &&item.getClassId()>0)
|
|
|
87
|
+ {
|
|
|
88
|
+ var SchedulingClass=schedulingClassService.getEntity(item.getClassId());
|
|
|
89
|
+ if (SchedulingClass!=null)
|
|
|
90
|
+ {
|
|
|
91
|
+ item.setSchedulingClass(SchedulingClass);
|
|
|
92
|
+ }
|
|
|
93
|
+ }
|
|
|
94
|
+ }
|
|
|
95
|
+ }
|
|
|
96
|
+ if (total!=null)
|
|
|
97
|
+ {
|
|
|
98
|
+ return Success("成功", schedulingManageViews, total);
|
|
|
99
|
+ }
|
|
|
100
|
+ else {
|
|
|
101
|
+ return Success("成功", schedulingManageViews);
|
|
|
102
|
+ }
|
|
|
103
|
+ }
|
|
|
104
|
+
|
|
|
105
|
+ @ApiOperation("详情")
|
|
|
106
|
+ @Log(title = "查询排班详情",businessType = BusinessType.QUERY)
|
|
|
107
|
+ @GetMapping("/{id}")
|
|
|
108
|
+ public AjaxResult getInfo(@PathVariable long id) {
|
|
|
109
|
+
|
|
|
110
|
+ var schedulingmanage= schedulingmanageService.getEntity(id);
|
|
|
111
|
+ SchedulingManageView schedulingManageViews= JSON.parseObject(JSON.toJSONString(schedulingmanage), SchedulingManageView.class);
|
|
|
112
|
+ if (schedulingManageViews!=null )
|
|
|
113
|
+ {
|
|
|
114
|
+ if (StringHelper.isNotEmpty(schedulingManageViews.getCreateUser()) )
|
|
|
115
|
+ {
|
|
|
116
|
+ schedulingManageViews.setCreateUserName(userMapper.selectName(schedulingManageViews.getCreateUser()));
|
|
|
117
|
+ }
|
|
|
118
|
+ if (StringHelper.isNotEmpty(schedulingManageViews.getUpdateUser()) )
|
|
|
119
|
+ {
|
|
|
120
|
+ schedulingManageViews.setUpdateUserName(userMapper.selectName(schedulingManageViews.getUpdateUser()));
|
|
|
121
|
+ }
|
|
|
122
|
+ if (schedulingManageViews.getClassId()!=null &&schedulingManageViews.getClassId()>0)
|
|
|
123
|
+ {
|
|
|
124
|
+ var SchedulingClass=schedulingClassService.getEntity(schedulingManageViews.getClassId());
|
|
|
125
|
+ if (SchedulingClass!=null)
|
|
|
126
|
+ {
|
|
|
127
|
+ schedulingManageViews.setSchedulingClass(SchedulingClass);
|
|
|
128
|
+ }
|
|
|
129
|
+ }
|
|
|
130
|
+ }
|
|
|
131
|
+ return Success("成功",schedulingManageViews);
|
|
|
132
|
+ }
|
|
|
133
|
+
|
|
|
134
|
+ @ApiOperation("新增")
|
|
|
135
|
+ @Log(title = "新增排班",businessType = BusinessType.INSERT)
|
|
|
136
|
+ @PostMapping
|
|
|
137
|
+ public AjaxResult add(@RequestBody SchedulingManage input) {
|
|
|
138
|
+ if (input.getClassId()==null||input.getClassId()==0)
|
|
|
139
|
+ {
|
|
|
140
|
+ return Error("请选择班别");
|
|
|
141
|
+ }
|
|
|
142
|
+ if (StringHelper.isEmpty(input.getSchedulingStaff()))
|
|
|
143
|
+ {
|
|
|
144
|
+ return Error("请选择排班人员");
|
|
|
145
|
+ }
|
|
|
146
|
+ input.setCreateUser(CurrentUser().getUserName());
|
|
|
147
|
+ boolean result = schedulingmanageService.insert(input);
|
|
|
148
|
+ if (result) {
|
|
|
149
|
+ return Success("成功");
|
|
|
150
|
+ } else {
|
|
|
151
|
+ return Error("新增失败");
|
|
|
152
|
+ }
|
|
|
153
|
+ }
|
|
|
154
|
+
|
|
|
155
|
+ @ApiOperation("编辑")
|
|
|
156
|
+ @Log(title = "编辑排班",businessType = BusinessType.UPDATE)
|
|
|
157
|
+ @PutMapping
|
|
|
158
|
+ public AjaxResult edit(@RequestBody SchedulingManage input) {
|
|
|
159
|
+ if (input.getClassId()==null||input.getClassId()==0)
|
|
|
160
|
+ {
|
|
|
161
|
+ return Error("请选择班别");
|
|
|
162
|
+ }
|
|
|
163
|
+ if (StringHelper.isEmpty(input.getSchedulingStaff()))
|
|
|
164
|
+ {
|
|
|
165
|
+ return Error("请选择排班人员");
|
|
|
166
|
+ }
|
|
|
167
|
+ input.setUpdateUser(CurrentUser().getUserName());
|
|
|
168
|
+ boolean result = schedulingmanageService.update(input);
|
|
|
169
|
+ if (result) {
|
|
|
170
|
+ return Success("成功");
|
|
|
171
|
+ } else {
|
|
|
172
|
+ return Error("修改失败");
|
|
|
173
|
+ }
|
|
|
174
|
+ }
|
|
|
175
|
+
|
|
|
176
|
+ @ApiOperation("设置偏好")
|
|
|
177
|
+ @Log(title = "设置偏好",businessType = BusinessType.UPDATE)
|
|
|
178
|
+ @PutMapping("/preference")
|
|
|
179
|
+ public AjaxResult preference(@RequestBody SchedulingPreference input) {
|
|
|
180
|
+ User user=userMapper.selectUser(input.getUserCode());
|
|
|
181
|
+ if (user!=null)
|
|
|
182
|
+ {
|
|
|
183
|
+ user.setPreference(input.getClassId());
|
|
|
184
|
+ if (userService.update(user))
|
|
|
185
|
+ {
|
|
|
186
|
+ return Success("设置成功");
|
|
|
187
|
+ }
|
|
|
188
|
+ else
|
|
|
189
|
+ {
|
|
|
190
|
+ return Error("设置失败");
|
|
|
191
|
+ }
|
|
|
192
|
+ }
|
|
|
193
|
+ else
|
|
|
194
|
+ {
|
|
|
195
|
+ return Error("该用户不存在");
|
|
|
196
|
+ }
|
|
|
197
|
+
|
|
|
198
|
+ }
|
|
|
199
|
+ @ApiOperation("排班复制")
|
|
|
200
|
+ @Log(title = "排班复制",businessType = BusinessType.UPDATE)
|
|
|
201
|
+ @PutMapping("/copy")
|
|
|
202
|
+ public AjaxResult copy(@RequestBody SchedulingCopy input) {
|
|
|
203
|
+ if (input.getStartTime()==null||input.getEndTime()==null)
|
|
|
204
|
+ {
|
|
|
205
|
+ return Error("请选择复制时间段");
|
|
|
206
|
+ }
|
|
|
207
|
+ if(StringHelper.isEmpty(input.getCopiedUser())||StringHelper.isEmpty(input.getCopyUser()))
|
|
|
208
|
+ {
|
|
|
209
|
+ return Error("请选择人员");
|
|
|
210
|
+ }
|
|
|
211
|
+ LambdaUpdateWrapper<SchedulingManage> qw =new LambdaUpdateWrapper<>();
|
|
|
212
|
+ qw.eq(SchedulingManage::getSchedulingStaff,input.getCopiedUser());
|
|
|
213
|
+ qw.eq(SchedulingManage::getIsDelete,0);
|
|
|
214
|
+ qw.ge (SchedulingManage::getSchedulingDate,input.getStartTime());
|
|
|
215
|
+ qw.le (SchedulingManage::getSchedulingDate,input.getEndTime());
|
|
|
216
|
+ var list=schedulingmanageService.getList(qw);
|
|
|
217
|
+ if (list!=null&&list.size()>0)
|
|
|
218
|
+ {
|
|
|
219
|
+ if(input.getIsReplace()!=null&&input.getIsReplace()>0)
|
|
|
220
|
+ {
|
|
|
221
|
+ //删除现有排班
|
|
|
222
|
+ LambdaUpdateWrapper<SchedulingManage> ManageUpdate =new LambdaUpdateWrapper<>();
|
|
|
223
|
+ ManageUpdate.eq(SchedulingManage::getSchedulingStaff,input.getCopyUser());
|
|
|
224
|
+ ManageUpdate.eq(SchedulingManage::getIsDelete,0);
|
|
|
225
|
+ ManageUpdate.ge (SchedulingManage::getSchedulingDate,input.getStartTime());
|
|
|
226
|
+ ManageUpdate.le (SchedulingManage::getSchedulingDate,input.getEndTime());
|
|
|
227
|
+ ManageUpdate.set(SchedulingManage::getIsDelete,1);
|
|
|
228
|
+ schedulingmanageService.updateBatch(ManageUpdate);
|
|
|
229
|
+ }
|
|
|
230
|
+ List<SchedulingManage> schedulingManageList=new ArrayList<>();
|
|
|
231
|
+ for (SchedulingManage item :list)
|
|
|
232
|
+ {
|
|
|
233
|
+ SchedulingManage manage=new SchedulingManage();
|
|
|
234
|
+ manage.setSchedulingDate(item.getSchedulingDate());
|
|
|
235
|
+ manage.setSchedulingStaff(input.getCopyUser());
|
|
|
236
|
+ manage.setClassId(item.getClassId());
|
|
|
237
|
+ manage.setDeptId(item.getDeptId());
|
|
|
238
|
+ schedulingManageList.add(manage);
|
|
|
239
|
+ }
|
|
|
240
|
+ if (schedulingmanageService.insert(schedulingManageList))
|
|
|
241
|
+ {
|
|
|
242
|
+ return Success("成功");
|
|
|
243
|
+ }
|
|
|
244
|
+ else
|
|
|
245
|
+ {
|
|
|
246
|
+ return Error("复制失败");
|
|
|
247
|
+ }
|
|
|
248
|
+ }
|
|
|
249
|
+ else
|
|
|
250
|
+ {
|
|
|
251
|
+ return Error("被复制人员暂无排班");
|
|
|
252
|
+ }
|
|
|
253
|
+ }
|
|
|
254
|
+
|
|
|
255
|
+
|
|
|
256
|
+ @ApiOperation("删除")
|
|
|
257
|
+ @Log(title = "删除排班",businessType = BusinessType.DELETE)
|
|
|
258
|
+ @DeleteMapping("/{ids}")
|
|
|
259
|
+ public AjaxResult delete(@PathVariable Long[] ids) {
|
|
|
260
|
+ LambdaUpdateWrapper<SchedulingManage> qw = new LambdaUpdateWrapper<>();
|
|
|
261
|
+ qw.in(SchedulingManage::getId, ids);
|
|
|
262
|
+ qw.set(SchedulingManage::getIsDelete, 1);
|
|
|
263
|
+ boolean result = schedulingmanageService.updateBatch(qw);
|
|
|
264
|
+ if(result){
|
|
|
265
|
+ return Success("成功");
|
|
|
266
|
+ } else {
|
|
|
267
|
+ return Error("删除失败");
|
|
|
268
|
+ }
|
|
|
269
|
+ }
|
|
|
270
|
+
|
|
|
271
|
+}
|