# ScheduleInternalController.java

    package cloud.wconnect.workperformance.controller.schedule.internal;

    import cloud.wconnect.commonlib.cons.BaseConstant;
    import cloud.wconnect.commonlib.controller.BaseInternalController;
    import cloud.wconnect.commonlib.pojo.dto.PropertyDTO;
    import cloud.wconnect.commonlib.service.PropertyInternalService;
    import cloud.wconnect.workperformance.pojo.bo.schedule.ScheduleBO;
    import cloud.wconnect.workperformance.pojo.dto.schedule.ScheduleWorkDayDTO;
    import cloud.wconnect.workperformance.service.schedule.IScheduleInfoService;
    import cloud.wconnect.workperformance.service.schedule.IScheduleWorkDayService;
    import jakarta.validation.Valid;
    import org.springframework.beans.factory.annotation.Autowired;
    import org.springframework.beans.factory.annotation.Value;
    import org.springframework.validation.annotation.Validated;
    import org.springframework.web.bind.annotation.*;

    import java.util.Collections;
    import java.util.List;
    import java.util.Map;

    /**
     * 控制层：Schedule
     *
     * @author yyt
     * 2023/7/13
     */
    @Validated
    @RestController
    @RequestMapping("/internal/schedule")
    public class ScheduleInternalController extends BaseInternalController {

        @Autowired
        private IScheduleWorkDayService scheduleWorkDayService;
        @Autowired
        private PropertyInternalService propertyInternalService;
        @Autowired
        private IScheduleInfoService scheduleInfoService;
        @Value("${internal.service.auth-key.basic}")
        private String authKey;

        /**
         * 获取周起始日
         * <P>采集程序使用</P>
         *
         * @param sign     签名
         * @param tenant   租户标识
         * @param property 资产标识
         * @return 周起始日
         * @author yyt
         * @date 2023/7/13
         */
        @GetMapping("/work-day")
        public ScheduleWorkDayDTO getWorkDay(@RequestParam String sign, @RequestParam String tenant, @RequestParam String property) {
            checkIntranetParams(authKey, sign, tenant, property);

            PropertyDTO propertyDTO = propertyInternalService.getOne(property, tenant);
            return scheduleWorkDayService.getWorkDayDTO(propertyDTO.getId());
        }

        /**
         * 保存采集排班数据
         *
         * @param tenant    租户标识
         * @param property  资产标识
         * @param schedules 排班数据
         * @param sign      签名
         * @return {}
         * @author yyt
         * @date 2023/9/5
         */
        @PostMapping
        public Map save(@RequestParam String tenant, @RequestParam String property,
                        @RequestBody List<@Valid ScheduleBO> schedules, @RequestHeader String sign) {
            checkIntranetParams(authKey, sign, tenant, property);

            // 处理数据
            PropertyDTO propertyDTO = propertyInternalService.getOne(property, tenant);
            scheduleInfoService.handleInsertSchedule(propertyDTO, schedules, BaseConstant.ZERO);

            return Collections.emptyMap();
        }

    }