Lius
2024-11-07 81eae83295642387de38a97fdc5a35f485307587
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
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.MdcQualityMonth;
import org.jeecg.modules.mdcJc.entity.QualityMonth;
import org.jeecg.modules.mdcJc.mapper.MdcQualityMonthMapper;
import org.jeecg.modules.mdcJc.service.IClassMonthlyScheduleService;
import org.jeecg.modules.mdcJc.service.IMdcQualityMonthService;
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/17
 */
@Service
public class MdcQualityMonthServiceImpl extends ServiceImpl<MdcQualityMonthMapper,MdcQualityMonth> implements IMdcQualityMonthService {
 
    @Autowired
    private IClassMonthlyScheduleService classMonthlyScheduleService;
 
    @Override
    public boolean saveQualityMonth() {
        String date = DateUtils.format(DateUtils.getNow(),DateUtils.STR_YEAR_MONTH);
        List<QualityMonth> list = classMonthlyScheduleService.findListQualityMonth(date);
        if (list == null || list.isEmpty()) {
            return true;
        }
        List<String> mdcListIds = super.baseMapper.selectDateList(date);
        if (mdcListIds != null && !mdcListIds.isEmpty()) {
            this.removeBatchByIds(mdcListIds);
        }
        List<MdcQualityMonth> mesC = new ArrayList<>();
        for ( QualityMonth c : list) {
            MdcQualityMonth mdc = new MdcQualityMonth();
            BeanMapper.copy(c,mdc);
            mesC.add(mdc);
        }
        boolean b = this.saveBatch(mesC);
        return b;
    }
}