|
@@ -1,5 +1,6 @@
|
|
|
package com.ruoyi.web.controller.zhdd;
|
|
|
|
|
|
+import cn.hutool.core.date.DateUtil;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.ruoyi.common.annotation.Log;
|
|
|
import com.ruoyi.common.annotation.RepeatSubmit;
|
|
@@ -31,7 +32,10 @@ import org.springframework.web.bind.annotation.RestController;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
import javax.validation.constraints.NotEmpty;
|
|
|
import javax.validation.constraints.NotNull;
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.Arrays;
|
|
|
+import java.util.Date;
|
|
|
+import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.stream.Collectors;
|
|
@@ -60,9 +64,49 @@ public class DutyEmpController extends BaseController {
|
|
|
List<DutyEmpVo> dutyEmpVos = iDutyEmpService.listVo(Wrappers.<DutyEmp>lambdaQuery().orderByAsc(DutyEmp::getPeriod).orderByAsc(DutyEmp::getPeriodTime));
|
|
|
// 分组
|
|
|
Map<Integer, List<DutyEmpVo>> collect = dutyEmpVos.stream().collect(Collectors.groupingBy(DutyEmpVo::getPeriod));
|
|
|
+ // 排查1~7都有key
|
|
|
+ for (int i = 1; i < 8; i++) {
|
|
|
+ if (!collect.containsKey(i)) {
|
|
|
+ collect.put(i, new ArrayList<>());
|
|
|
+ }
|
|
|
+ }
|
|
|
return AjaxResult.success(collect);
|
|
|
}
|
|
|
|
|
|
+ @ApiOperation("查询当前时间的排班人员")
|
|
|
+ @GetMapping("/queryNowDutyEmp")
|
|
|
+ public AjaxResult queryDutyEmpNow() {
|
|
|
+ Map<String, Object> result = new HashMap<>();
|
|
|
+ // 当前星期
|
|
|
+ int week = DateUtil.thisDayOfWeek() - 1;
|
|
|
+ if (week == 0) {
|
|
|
+ week = 7;
|
|
|
+ }
|
|
|
+ // 当前时间
|
|
|
+ int nowTime = DateUtil.timeToSecond(DateUtil.formatTime(new Date()).substring(0, 5));
|
|
|
+ // 查询所有的排班数据
|
|
|
+ List<DutyEmpVo> dutyEmpVos = iDutyEmpService.listVo(Wrappers.<DutyEmp>lambdaQuery().orderByAsc(DutyEmp::getPeriod).orderByAsc(DutyEmp::getPeriodTime));
|
|
|
+ // 分组
|
|
|
+ Map<Integer, List<DutyEmpVo>> collect = dutyEmpVos.stream().collect(Collectors.groupingBy(DutyEmpVo::getPeriod));
|
|
|
+ for (int i = 1; i < 8; i++) {
|
|
|
+ if (!collect.containsKey(i)) {
|
|
|
+ collect.put(i, new ArrayList<>());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ result.put("all", collect);
|
|
|
+ result.put("current", null);
|
|
|
+ List<DutyEmpVo> currentWeekList = collect.get(week);
|
|
|
+ for (DutyEmpVo dutyEmpVo : currentWeekList) {
|
|
|
+ int startTime = DateUtil.timeToSecond(dutyEmpVo.getPeriodTime().split("~")[0]);
|
|
|
+ int endTime = DateUtil.timeToSecond(dutyEmpVo.getPeriodTime().split("~")[1]);
|
|
|
+ if (nowTime >= startTime && nowTime <= endTime) {
|
|
|
+ result.put("current", dutyEmpVo);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return AjaxResult.success(result);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 导出值班排班信息列表
|
|
|
*/
|
|
@@ -116,4 +160,5 @@ public class DutyEmpController extends BaseController {
|
|
|
@PathVariable String[] ids) {
|
|
|
return toAjax(iDutyEmpService.deleteWithValidByIds(Arrays.asList(ids), true) ? 1 : 0);
|
|
|
}
|
|
|
+
|
|
|
}
|