# EnrollmentTotalAreaServiceImpl.java

    package cloud.wconnect.frontoffice.service.endofshift.area.impl;

    import cloud.wconnect.commonlib.util.DateTimeUtils;
    import cloud.wconnect.commonlib.util.JsonUtils;
    import cloud.wconnect.frontoffice.cons.endofshift.EndOfShiftAreaEnum;
    import cloud.wconnect.frontoffice.entity.endofshift.ShiftOperationRecord;
    import cloud.wconnect.frontoffice.entity.endofshift.ShiftReportInfo;
    import cloud.wconnect.frontoffice.pojo.dto.endofshift.ShiftEnrollmentTotalDTO;
    import cloud.wconnect.frontoffice.service.endofshift.IShiftOperationRecordService;
    import cloud.wconnect.frontoffice.service.endofshift.IShiftReportInfoService;
    import cloud.wconnect.frontoffice.service.endofshift.area.IEosSave;
    import com.baomidou.dynamic.datasource.annotation.DS;
    import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
    import com.fasterxml.jackson.databind.ObjectMapper;
    import org.springframework.beans.factory.annotation.Autowired;
    import org.springframework.stereotype.Service;
    import org.springframework.transaction.annotation.Transactional;

    /**
     * Enrollment total 区域service
     *
     * @author lichen
     * @date 2025/6/19
     */
    @Service
    @DS("ratelog_manage")
    public class EnrollmentTotalAreaServiceImpl implements IEosSave {

        /**
         * 区域类型
         */
        public static final int ENROLLMENT_TOTAL = EndOfShiftAreaEnum.ENROLLMENT_TOTAL.getAreaId();
        @Autowired
        private IShiftReportInfoService shiftReportInfoService;
        @Autowired
        private IShiftOperationRecordService shiftOperationRecordService;
        @Autowired
        private ObjectMapper objectMapper;

        /**
         * 用于判断是否支持子类执行方法
         *
         * @param type 类型
         * @return java.lang.Boolean
         * @author lichen
         * @date 2025/6/19
         */
        @Override
        public boolean support(Integer type) {
            return type == ENROLLMENT_TOTAL;
        }

        /**
         * 保存排班信息（指定资产指定日期指定排班配置）指定区域的数据
         *
         * @param propertyId      属性ID
         * @param shiftReportInfo 排班基础信息
         * @param object          保存的区域对象
         * @param loginUserId     登录用户id
         * @return void
         */
        @Override
        @Transactional(rollbackFor = Exception.class)
        public void save(Integer propertyId, ShiftReportInfo shiftReportInfo, Object object, int loginUserId) {
            int shiftReportInfoId = shiftReportInfo.getId();
            //当前时间
            long operatorTime = DateTimeUtils.nowTimestamp();

            //更新的wrapper
            LambdaUpdateWrapper<ShiftReportInfo> updateWrapper = new LambdaUpdateWrapper<>();
            updateWrapper.eq(ShiftReportInfo::getId, shiftReportInfoId);
            updateWrapper.set(ShiftReportInfo::getOperateUid, loginUserId);
            updateWrapper.set(ShiftReportInfo::getOperateTime, operatorTime);
            updateWrapper.set(ShiftReportInfo::getCanSend, true);

            ShiftEnrollmentTotalDTO shiftEnrollmentTotalDTO = (ShiftEnrollmentTotalDTO) object;
            shiftEnrollmentTotalDTO.setUid(loginUserId);
            shiftEnrollmentTotalDTO.setUpdateTime(operatorTime);
            updateWrapper.set(ShiftReportInfo::getEnrollmentJson, JsonUtils.convertObjToString(objectMapper, shiftEnrollmentTotalDTO));
            shiftReportInfoService.update(updateWrapper);

            // 插入操作记录
            ShiftOperationRecord shiftOperationRecord = ShiftOperationRecord.builder()
                    .propertyId(propertyId)
                    .shiftId(shiftReportInfoId)
                    .operationType(ENROLLMENT_TOTAL)
                    .operationBy(loginUserId)
                    .operationTime(operatorTime)
                    .build();
            shiftOperationRecordService.save(shiftOperationRecord);
        }
    }