feat(wms/attendance): 新增排班批量修改功能
- 新增BatchUpdateScheduleBo类,用于接收批量修改排班的请求参数 - 在IWmsAttendanceScheduleService接口中定义batchUpdateSchedule方法 - 在WmsAttendanceScheduleController中新增批量修改排班的API接口 - 在WmsAttendanceScheduleServiceImpl中实现批量修改排班逻辑,支持更新已有记录和插入新记录
This commit is contained in:
@@ -14,6 +14,7 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import com.klp.domain.bo.WmsAttendanceScheduleBo;
|
||||
import com.klp.domain.bo.GenerateScheduleBo;
|
||||
import com.klp.domain.bo.BatchUpdateScheduleBo;
|
||||
import com.klp.domain.vo.WmsAttendanceScheduleVo;
|
||||
import com.klp.domain.WmsAttendanceSchedule;
|
||||
import com.klp.domain.WmsAttendanceShiftRule;
|
||||
@@ -149,6 +150,48 @@ public class WmsAttendanceScheduleServiceImpl implements IWmsAttendanceScheduleS
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量修改指定日期多个员工的班次
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void batchUpdateSchedule(BatchUpdateScheduleBo bo) {
|
||||
Date workDate = bo.getWorkDate();
|
||||
Long shiftId = bo.getShiftId();
|
||||
String shiftName = bo.getShiftName();
|
||||
List<Long> userIds = bo.getUserIds();
|
||||
|
||||
baseMapper.update(null, Wrappers.<WmsAttendanceSchedule>lambdaUpdate()
|
||||
.in(WmsAttendanceSchedule::getUserId, userIds)
|
||||
.eq(WmsAttendanceSchedule::getWorkDate, workDate)
|
||||
.set(WmsAttendanceSchedule::getShiftId, shiftId)
|
||||
.set(WmsAttendanceSchedule::getShiftName, shiftName));
|
||||
|
||||
Set<Long> existingUserIds = baseMapper.selectList(Wrappers.<WmsAttendanceSchedule>lambdaQuery()
|
||||
.in(WmsAttendanceSchedule::getUserId, userIds)
|
||||
.eq(WmsAttendanceSchedule::getWorkDate, workDate)
|
||||
.select(WmsAttendanceSchedule::getUserId))
|
||||
.stream()
|
||||
.map(WmsAttendanceSchedule::getUserId)
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
List<WmsAttendanceSchedule> insertList = userIds.stream()
|
||||
.filter(uid -> !existingUserIds.contains(uid))
|
||||
.map(uid -> {
|
||||
WmsAttendanceSchedule s = new WmsAttendanceSchedule();
|
||||
s.setUserId(uid);
|
||||
s.setWorkDate(workDate);
|
||||
s.setShiftId(shiftId);
|
||||
s.setShiftName(shiftName);
|
||||
return s;
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
|
||||
if (!insertList.isEmpty()) {
|
||||
baseMapper.insertBatch(insertList);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成正常排班
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user