Lius
2024-08-22 f59452ac384766a21500857e89928a8abc0e75b5
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
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.MdcProductDayschedule;
import org.jeecg.modules.mdcJc.entity.ProductDayschedule;
import org.jeecg.modules.mdcJc.mapper.MdcProductDayscheduleMapper;
import org.jeecg.modules.mdcJc.service.IClassMonthlyScheduleService;
import org.jeecg.modules.mdcJc.service.IMdcProductDayScheduleService;
import org.jeecg.modules.utils.BeanMapper;
import org.springframework.stereotype.Service;
 
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.List;
 
/**
 * @author Lius
 * @date 2024/7/30 15:14
 */
@Service
public class MdcProductDayScheduleServiceImpl extends ServiceImpl<MdcProductDayscheduleMapper, MdcProductDayschedule> implements IMdcProductDayScheduleService {
 
    @Resource
    private IClassMonthlyScheduleService classMonthlyScheduleService;
 
 
    @Override
    public boolean scheduleProductDayList() {
        String date = DateUtils.format(DateUtils.getNow(),DateUtils.STR_DATE);
        List<ProductDayschedule> list = classMonthlyScheduleService.findListProductDay(date);
        if (list == null || list.isEmpty()) {
            return true;
        }
        List<String> mdcListIds = super.baseMapper.selectDateList(date);
        if (mdcListIds != null && !mdcListIds.isEmpty()) {
            this.removeBatchByIds(mdcListIds);
        }
        List<MdcProductDayschedule> mesC = new ArrayList<>();
        for (ProductDayschedule c : list) {
            MdcProductDayschedule mdc = new MdcProductDayschedule();
            BeanMapper.copy(c, mdc);
            mesC.add(mdc);
        }
        boolean b = this.saveBatch(mesC);
        return b;
    }
 
    @Override
    public MdcProductDayschedule findYesterdayData() {
        String date = LocalDate.now().plusDays(-1).toString();
        return classMonthlyScheduleService.findYesterdayData(date);
    }
}