liyong
2026-01-30 069c5ab23fcbd02144079c4df0fd8183b22b1e04
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
58
59
60
61
62
63
package com.ruoyi.business.service.impl;
 
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.basic.entity.CoalInfo;
import com.ruoyi.basic.mapper.CoalInfoMapper;
import com.ruoyi.business.entity.CarbonCubes;
import com.ruoyi.business.entity.PurchaseRegistration;
import com.ruoyi.business.mapper.CarbonCubesMapper;
import com.ruoyi.business.service.CarbonCubesService;
import com.ruoyi.common.core.domain.R;
import lombok.RequiredArgsConstructor;
import org.checkerframework.checker.units.qual.A;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
 
import java.time.LocalDate;
 
@Service
@RequiredArgsConstructor
public class CarbonCubesServiceImpl extends ServiceImpl<CarbonCubesMapper, CarbonCubes> implements CarbonCubesService {
    @Autowired
    private final CoalInfoMapper coalInfoMapper;
    @Autowired
    private CarbonCubesMapper carbonCubesMapper;
 
 
    @Override
    public R addCarbonCubes(CarbonCubes carbonCubes) {
        CoalInfo oldCoalInfo = coalInfoMapper.selectOne(new QueryWrapper<CoalInfo>().lambda().eq(CoalInfo::getCoal, carbonCubes.getCoal()));
        CoalInfo coalInfo = new CoalInfo();
        if (ObjectUtils.isEmpty(oldCoalInfo)) {
            //新增煤种信息
            coalInfo.setCoal(carbonCubes.getCoal());
            coalInfo.setMaintainerId(1L);
            coalInfo.setMaintenanceDate(LocalDate.now());
            coalInfoMapper.insert(coalInfo);
        }else {
            coalInfo = oldCoalInfo;
        }
        carbonCubes.setCreateTime(LocalDate.now());
        carbonCubes.setCoalId(coalInfo.getId());
        CarbonCubes one = this.getOne(new QueryWrapper<CarbonCubes>().lambda()
                .eq(CarbonCubes::getBillNumber, carbonCubes.getBillNumber()));
        if (ObjectUtils.isEmpty(one)) {
            // 新增
            this.save(carbonCubes);
        }else {
            // 修改
            this.update(carbonCubes, new QueryWrapper<CarbonCubes>().lambda()
                    .eq(CarbonCubes::getBillNumber, carbonCubes.getBillNumber()));
        }
        return R.ok();
    }
 
    @Override
    public IPage<CarbonCubes> pageCarbonCubes(Page<CarbonCubes> page, CarbonCubes carbonCubes) {
        return carbonCubesMapper.pageCarbonCubes(page, carbonCubes);
    }
}