package org.jeecg.modules.mdcJc.service.impl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.jeecg.modules.mdc.util.DateUtils; import org.jeecg.modules.mdcJc.entity.ClassMonthlyschedule; import org.jeecg.modules.mdcJc.entity.MdcClassMonthlyschedule; import org.jeecg.modules.mdcJc.mapper.MdcClassMonthlyscheduleMapper; import org.jeecg.modules.mdcJc.service.IClassMonthlyScheduleService; import org.jeecg.modules.mdcJc.service.IMdcClassMonthService; import org.jeecg.modules.utils.BeanMapper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.ArrayList; import java.util.List; /** * @author clown * * @date 2024/7/16 */ @Service public class MdcClassMonthServiceImpl extends ServiceImpl implements IMdcClassMonthService { @Autowired private IClassMonthlyScheduleService classMonthlyScheduleService; @Override public boolean saveOrUpdateClassMonthSchedule() { String date = DateUtils.format(DateUtils.getNow(),DateUtils.STR_YEAR_MONTH); List list = classMonthlyScheduleService.findListClass(date); if (list == null || list.isEmpty()) { return true; } List mdcListIds = super.baseMapper.selectDateList(date); if (mdcListIds != null && !mdcListIds.isEmpty()) { this.removeBatchByIds(mdcListIds); } List mesC = new ArrayList<>(); for (ClassMonthlyschedule c : list) { MdcClassMonthlyschedule mdc = new MdcClassMonthlyschedule(); BeanMapper.copy(c,mdc); mdc.setPlanCount(c.getPlanCont()); mesC.add(mdc); } boolean b = this.saveBatch(mesC); return b; } }