|
@@ -1,18 +1,19 @@
|
|
package com.ruoyi.web.controller.zhdd;
|
|
package com.ruoyi.web.controller.zhdd;
|
|
|
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
|
+import cn.hutool.core.util.ObjectUtil;
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
import com.ruoyi.common.annotation.Log;
|
|
import com.ruoyi.common.annotation.Log;
|
|
import com.ruoyi.common.annotation.RepeatSubmit;
|
|
import com.ruoyi.common.annotation.RepeatSubmit;
|
|
import com.ruoyi.common.core.controller.BaseController;
|
|
import com.ruoyi.common.core.controller.BaseController;
|
|
import com.ruoyi.common.core.domain.AjaxResult;
|
|
import com.ruoyi.common.core.domain.AjaxResult;
|
|
import com.ruoyi.common.core.validate.AddGroup;
|
|
import com.ruoyi.common.core.validate.AddGroup;
|
|
-import com.ruoyi.common.core.validate.EditGroup;
|
|
|
|
import com.ruoyi.common.core.validate.QueryGroup;
|
|
import com.ruoyi.common.core.validate.QueryGroup;
|
|
import com.ruoyi.common.enums.BusinessType;
|
|
import com.ruoyi.common.enums.BusinessType;
|
|
import com.ruoyi.common.utils.poi.ExcelUtil;
|
|
import com.ruoyi.common.utils.poi.ExcelUtil;
|
|
import com.ruoyi.zhdd.domain.DutyEmp;
|
|
import com.ruoyi.zhdd.domain.DutyEmp;
|
|
import com.ruoyi.zhdd.domain.bo.DutyEmpBo;
|
|
import com.ruoyi.zhdd.domain.bo.DutyEmpBo;
|
|
|
|
+import com.ruoyi.zhdd.domain.bo.DutyEmpSaveBo;
|
|
import com.ruoyi.zhdd.domain.vo.DutyEmpVo;
|
|
import com.ruoyi.zhdd.domain.vo.DutyEmpVo;
|
|
import com.ruoyi.zhdd.service.IDutyEmpService;
|
|
import com.ruoyi.zhdd.service.IDutyEmpService;
|
|
import io.swagger.annotations.Api;
|
|
import io.swagger.annotations.Api;
|
|
@@ -24,7 +25,6 @@ import org.springframework.web.bind.annotation.DeleteMapping;
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
import org.springframework.web.bind.annotation.PathVariable;
|
|
import org.springframework.web.bind.annotation.PathVariable;
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
-import org.springframework.web.bind.annotation.PutMapping;
|
|
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
@@ -96,13 +96,43 @@ public class DutyEmpController extends BaseController {
|
|
result.put("all", collect);
|
|
result.put("all", collect);
|
|
result.put("current", null);
|
|
result.put("current", null);
|
|
List<DutyEmpVo> currentWeekList = collect.get(week);
|
|
List<DutyEmpVo> currentWeekList = collect.get(week);
|
|
|
|
+ DutyEmpVo tempEmp = null;
|
|
for (DutyEmpVo dutyEmpVo : currentWeekList) {
|
|
for (DutyEmpVo dutyEmpVo : currentWeekList) {
|
|
int startTime = DateUtil.timeToSecond(dutyEmpVo.getPeriodTime().split("~")[0]);
|
|
int startTime = DateUtil.timeToSecond(dutyEmpVo.getPeriodTime().split("~")[0]);
|
|
int endTime = DateUtil.timeToSecond(dutyEmpVo.getPeriodTime().split("~")[1]);
|
|
int endTime = DateUtil.timeToSecond(dutyEmpVo.getPeriodTime().split("~")[1]);
|
|
if (nowTime >= startTime && nowTime <= endTime) {
|
|
if (nowTime >= startTime && nowTime <= endTime) {
|
|
result.put("current", dutyEmpVo);
|
|
result.put("current", dutyEmpVo);
|
|
- break;
|
|
|
|
|
|
+ continue;
|
|
}
|
|
}
|
|
|
|
+ if (nowTime > endTime && tempEmp == null) {
|
|
|
|
+ tempEmp = dutyEmpVo;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (ObjectUtil.isNull(result.get("current")) && tempEmp != null) {
|
|
|
|
+ result.put("current", tempEmp);
|
|
|
|
+ return AjaxResult.success(result);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 如果当前星期没有,则往下查询最近一个
|
|
|
|
+ if (ObjectUtil.isNull(result.get("current"))) {
|
|
|
|
+ for (int i = week + 1; i < 8; i++) {
|
|
|
|
+ List<DutyEmpVo> nextniWeekList = collect.get(i);
|
|
|
|
+ if (nextniWeekList != null && nextniWeekList.size() > 0) {
|
|
|
|
+ tempEmp = nextniWeekList.get(0);
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (tempEmp == null) {
|
|
|
|
+ // 如果还是为空,则从周一开始继续查询
|
|
|
|
+ for (int i = 1; i < 8; i++) {
|
|
|
|
+ List<DutyEmpVo> nextniWeekList = collect.get(i);
|
|
|
|
+ if (nextniWeekList != null && nextniWeekList.size() > 0) {
|
|
|
|
+ tempEmp = nextniWeekList.get(0);
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ result.put("current", tempEmp);
|
|
}
|
|
}
|
|
return AjaxResult.success(result);
|
|
return AjaxResult.success(result);
|
|
}
|
|
}
|
|
@@ -135,22 +165,11 @@ public class DutyEmpController extends BaseController {
|
|
@Log(title = "值班排班信息", businessType = BusinessType.INSERT)
|
|
@Log(title = "值班排班信息", businessType = BusinessType.INSERT)
|
|
@RepeatSubmit()
|
|
@RepeatSubmit()
|
|
@PostMapping()
|
|
@PostMapping()
|
|
- public AjaxResult<Void> add(@Validated(AddGroup.class) @RequestBody DutyEmpBo bo) {
|
|
|
|
|
|
+ public AjaxResult<Void> add(@Validated(AddGroup.class) @RequestBody DutyEmpSaveBo bo) {
|
|
return toAjax(iDutyEmpService.insertByBo(bo) ? 1 : 0);
|
|
return toAjax(iDutyEmpService.insertByBo(bo) ? 1 : 0);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
- * 修改值班排班信息
|
|
|
|
- */
|
|
|
|
- @ApiOperation("修改值班排班信息")
|
|
|
|
- @Log(title = "值班排班信息", businessType = BusinessType.UPDATE)
|
|
|
|
- @RepeatSubmit()
|
|
|
|
- @PutMapping()
|
|
|
|
- public AjaxResult<Void> edit(@Validated(EditGroup.class) @RequestBody DutyEmpBo bo) {
|
|
|
|
- return toAjax(iDutyEmpService.updateByBo(bo) ? 1 : 0);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
* 删除值班排班信息
|
|
* 删除值班排班信息
|
|
*/
|
|
*/
|
|
@ApiOperation("删除值班排班信息")
|
|
@ApiOperation("删除值班排班信息")
|