在IWmsAttendanceScheduleService接口、WmsAttendanceScheduleController控制器和WmsAttendanceScheduleServiceImpl服务实现类中新增batchUpdateShiftByIds方法,支持通过主键ID列表批量更新排班记录的班次。新增BatchUpdateScheduleItemBo业务对象用于接收批量更新项,包含scheduleId和shiftId字段并进行非空校验。Controller层提供/batchUpdateShift端点,使用PUT请求并应用防重复提交和操作日志注解。Service层实现遍历列表并利用MyBatis-Plus的UpdateWrapper进行批量更新,确保事务一致性。
135 lines
4.7 KiB
Java
135 lines
4.7 KiB
Java
package com.klp.controller;
|
|
|
|
import java.util.List;
|
|
import java.util.Arrays;
|
|
|
|
import lombok.RequiredArgsConstructor;
|
|
import javax.servlet.http.HttpServletResponse;
|
|
import javax.validation.constraints.*;
|
|
import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.validation.annotation.Validated;
|
|
import com.klp.common.annotation.RepeatSubmit;
|
|
import com.klp.common.annotation.Log;
|
|
import com.klp.common.core.controller.BaseController;
|
|
import com.klp.common.core.domain.PageQuery;
|
|
import com.klp.common.core.domain.R;
|
|
import com.klp.common.core.validate.AddGroup;
|
|
import com.klp.common.core.validate.EditGroup;
|
|
import com.klp.common.enums.BusinessType;
|
|
import com.klp.common.utils.poi.ExcelUtil;
|
|
import com.klp.domain.vo.WmsAttendanceScheduleVo;
|
|
import com.klp.domain.bo.WmsAttendanceScheduleBo;
|
|
import com.klp.domain.bo.GenerateScheduleBo;
|
|
import com.klp.domain.bo.BatchUpdateScheduleBo;
|
|
import com.klp.domain.bo.BatchUpdateScheduleItemBo;
|
|
import com.klp.service.IWmsAttendanceScheduleService;
|
|
import com.klp.common.core.page.TableDataInfo;
|
|
|
|
/**
|
|
* 排班(谁在哪天上班)
|
|
*
|
|
* @author klp
|
|
* @date 2026-05-08
|
|
*/
|
|
@Validated
|
|
@RequiredArgsConstructor
|
|
@RestController
|
|
@RequestMapping("/wms/attendanceSchedule")
|
|
public class WmsAttendanceScheduleController extends BaseController {
|
|
|
|
private final IWmsAttendanceScheduleService iWmsAttendanceScheduleService;
|
|
|
|
/**
|
|
* 查询排班(谁在哪天上班)列表
|
|
*/
|
|
@GetMapping("/list")
|
|
public TableDataInfo<WmsAttendanceScheduleVo> list(WmsAttendanceScheduleBo bo, PageQuery pageQuery) {
|
|
return iWmsAttendanceScheduleService.queryPageList(bo, pageQuery);
|
|
}
|
|
|
|
/**
|
|
* 导出排班(谁在哪天上班)列表
|
|
*/
|
|
@Log(title = "排班(谁在哪天上班)", businessType = BusinessType.EXPORT)
|
|
@PostMapping("/export")
|
|
public void export(WmsAttendanceScheduleBo bo, HttpServletResponse response) {
|
|
List<WmsAttendanceScheduleVo> list = iWmsAttendanceScheduleService.queryList(bo);
|
|
ExcelUtil.exportExcel(list, "排班(谁在哪天上班)", WmsAttendanceScheduleVo.class, response);
|
|
}
|
|
|
|
/**
|
|
* 获取排班(谁在哪天上班)详细信息
|
|
*
|
|
* @param scheduleId 主键
|
|
*/
|
|
@GetMapping("/{scheduleId}")
|
|
public R<WmsAttendanceScheduleVo> getInfo(@NotNull(message = "主键不能为空")
|
|
@PathVariable Long scheduleId) {
|
|
return R.ok(iWmsAttendanceScheduleService.queryById(scheduleId));
|
|
}
|
|
|
|
/**
|
|
* 新增排班(谁在哪天上班)
|
|
*/
|
|
@Log(title = "排班(谁在哪天上班)", businessType = BusinessType.INSERT)
|
|
@RepeatSubmit()
|
|
@PostMapping()
|
|
public R<Void> add(@Validated(AddGroup.class) @RequestBody WmsAttendanceScheduleBo bo) {
|
|
return toAjax(iWmsAttendanceScheduleService.insertByBo(bo));
|
|
}
|
|
|
|
/**
|
|
* 修改排班(谁在哪天上班)
|
|
*/
|
|
@Log(title = "排班(谁在哪天上班)", businessType = BusinessType.UPDATE)
|
|
@RepeatSubmit()
|
|
@PutMapping()
|
|
public R<Void> edit(@Validated(EditGroup.class) @RequestBody WmsAttendanceScheduleBo bo) {
|
|
return toAjax(iWmsAttendanceScheduleService.updateByBo(bo));
|
|
}
|
|
|
|
/**
|
|
* 删除排班(谁在哪天上班)
|
|
*
|
|
* @param scheduleIds 主键串
|
|
*/
|
|
@Log(title = "排班(谁在哪天上班)", businessType = BusinessType.DELETE)
|
|
@DeleteMapping("/{scheduleIds}")
|
|
public R<Void> remove(@NotEmpty(message = "主键不能为空")
|
|
@PathVariable Long[] scheduleIds) {
|
|
return toAjax(iWmsAttendanceScheduleService.deleteWithValidByIds(Arrays.asList(scheduleIds), true));
|
|
}
|
|
|
|
/**
|
|
* 生成排班
|
|
*/
|
|
@Log(title = "生成排班", businessType = BusinessType.INSERT)
|
|
@PostMapping("/generate")
|
|
public R<Void> generateSchedule(@Validated @RequestBody List<GenerateScheduleBo> boList) {
|
|
iWmsAttendanceScheduleService.generateSchedule(boList);
|
|
return R.ok();
|
|
}
|
|
|
|
/**
|
|
* 批量修改指定日期多个员工的班次
|
|
*/
|
|
@Log(title = "排班批量修改", businessType = BusinessType.UPDATE)
|
|
@RepeatSubmit()
|
|
@PutMapping("/batchUpdate")
|
|
public R<Void> batchUpdateSchedule(@Validated @RequestBody BatchUpdateScheduleBo bo) {
|
|
iWmsAttendanceScheduleService.batchUpdateSchedule(bo);
|
|
return R.ok();
|
|
}
|
|
|
|
/**
|
|
* 批量修改排班班次(按主键)
|
|
*/
|
|
@Log(title = "排班班次批量修改", businessType = BusinessType.UPDATE)
|
|
@RepeatSubmit()
|
|
@PutMapping("/batchUpdateShift")
|
|
public R<Void> batchUpdateShiftByIds(@Validated @RequestBody List<BatchUpdateScheduleItemBo> list) {
|
|
iWmsAttendanceScheduleService.batchUpdateShiftByIds(list);
|
|
return R.ok();
|
|
}
|
|
}
|