RosteringServiceImpl.java 1.57 KB
package com.pipihelper.project.rostering.service.impl;

import com.pipihelper.project.rostering.model.DateRuleModel;
import com.pipihelper.project.rostering.model.RosteringModel;
import com.pipihelper.project.rostering.model.ShiftRuleModel;
import com.pipihelper.project.rostering.model.StaffRuleModel;
import com.pipihelper.project.rostering.service.RosteringService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @description:
 * @author: zsw
 * @create: 2022-10-14 16:51
 **/
@Service
public class RosteringServiceImpl implements RosteringService {

    @Override
    public List<RosteringModel> gen(List<String> staffs,
                                    List<String> shifts,
                                    List<ShiftRuleModel> shiftRuleModels,
                                    List<StaffRuleModel> staffRuleModels,
                                    List<DateRuleModel> dateRuleModels) {
        //校验
        verify(staffs, shifts, shiftRuleModels, staffRuleModels);





        return null;
    }


    private void verify(List<String> staffs,
                        List<String> shifts,
                        List<ShiftRuleModel> shiftRuleModels,
                        List<StaffRuleModel> staffRuleModels) {

        if (shiftRuleModels.stream().noneMatch(e -> shifts.contains(e.getName()))) {
            throw new RuntimeException("班次配置不合法");
        }

        if (staffRuleModels.stream().noneMatch(e -> staffs.contains(e.getName()))) {
            throw new RuntimeException("员工配置不合法");
        }




    }

}