qushaowei
2023-10-07 3858c775f565df000a45afd9a0c38c7b6bb39069
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
package org.jeecg.modules.eam.service.impl;
 
import java.util.Arrays;
import java.util.List;
 
import org.apache.commons.lang.StringUtils;
import org.jeecg.common.constant.CommonConstant;
import org.jeecg.modules.eam.entity.ProductionLine;
import org.jeecg.modules.eam.mapper.ProductionLineMapper;
import org.jeecg.modules.eam.service.IAreaService;
import org.jeecg.modules.eam.service.IProductionLineService;
import org.jeecg.modules.eam.service.ISiteService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
 
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 
/**
 * 
 * @ClassName: ProductionLineServiceImpl
 * @Description: 产线信息业务接口实现
 * @author Wang Mingchao
 * @date 2020-10-20 09:28:16
 */
@Service
public class ProductionLineServiceImpl extends ServiceImpl<ProductionLineMapper, ProductionLine>
        implements IProductionLineService {
 
    @Autowired
    @Lazy
    private ISiteService siteService;
 
    @Autowired
    @Lazy
    private IAreaService areaService;
 
    @Override
    public List<ProductionLine> list() {
        return super.lambdaQuery().eq(ProductionLine::getStatus, CommonConstant.STATUS_1)
                .orderByAsc(ProductionLine::getNum).list();
    }
 
    @Override
    @Transactional(rollbackFor = { Exception.class })
    public boolean removeByAreaId(String areaId) {
        if (StringUtils.isBlank(areaId)) {
            return false;
        }
        LambdaQueryWrapper<ProductionLine> lambdaQueryWrapper = Wrappers.lambdaQuery();
        lambdaQueryWrapper.eq(ProductionLine::getAreaId, areaId);
        return super.remove(lambdaQueryWrapper);
    }
 
    @Override
    @Transactional(rollbackFor = { Exception.class })
    public boolean removeByAreaIds(String[] areaIds) {
        if (areaIds == null || areaIds.length < 1) {
            return false;
        }
        LambdaQueryWrapper<ProductionLine> lambdaQueryWrapper = Wrappers.lambdaQuery();
        List<String> strings = Arrays.asList(areaIds);
        lambdaQueryWrapper.in(ProductionLine::getAreaId, strings);
        return super.remove(lambdaQueryWrapper);
    }
 
    @Override
    @Transactional(rollbackFor = { Exception.class })
    public boolean removeBySiteId(String siteId) {
        if (StringUtils.isBlank(siteId)) {
            return false;
        }
        LambdaQueryWrapper<ProductionLine> lambdaQueryWrapper = Wrappers.lambdaQuery();
        lambdaQueryWrapper.eq(ProductionLine::getSiteId, siteId);
        return super.remove(lambdaQueryWrapper);
    }
 
    @Override
    @Transactional(rollbackFor = { Exception.class })
    public boolean removeBySiteIds(String[] siteIds) {
        if (siteIds == null || siteIds.length < 1)
            return false;
        LambdaQueryWrapper<ProductionLine> lambdaQueryWrapper = Wrappers.lambdaQuery();
        lambdaQueryWrapper.in(ProductionLine::getSiteId, Arrays.asList(siteIds));
        return super.remove(lambdaQueryWrapper);
    }
 
    @Override
    @Transactional(rollbackFor = { Exception.class })
    public boolean activeByAreaId(String areaId, String status) {
        if (StringUtils.isBlank(areaId) || StringUtils.isBlank(status))
            return false;
        LambdaUpdateWrapper<ProductionLine> updateWrapper = Wrappers.lambdaUpdate();
        updateWrapper.set(ProductionLine::getStatus, status).eq(ProductionLine::getAreaId, areaId);
        return super.update(updateWrapper);
    }
 
    @Override
    @Transactional(rollbackFor = { Exception.class })
    public boolean activeByAreaIds(String[] areaIds, String status) {
        if (areaIds == null || areaIds.length < 1 || StringUtils.isBlank(status))
            return false;
        LambdaUpdateWrapper<ProductionLine> updateWrapper = Wrappers.lambdaUpdate();
        updateWrapper.set(ProductionLine::getStatus, status).in(ProductionLine::getAreaId, Arrays.asList(areaIds));
        return super.update(updateWrapper);
    }
 
    @Override
    @Transactional(rollbackFor = { Exception.class })
    public boolean activeBySiteId(String siteId, String status) {
        if (StringUtils.isBlank(siteId) || StringUtils.isBlank(status))
            return false;
        LambdaUpdateWrapper<ProductionLine> updateWrapper = Wrappers.lambdaUpdate();
        updateWrapper.set(ProductionLine::getStatus, status).eq(ProductionLine::getSiteId, siteId);
        return super.update(updateWrapper);
    }
 
    @Override
    public List<ProductionLine> listByAreaId(String areaId) {
        return super.lambdaQuery().eq(ProductionLine::getAreaId, areaId)
                .eq(ProductionLine::getStatus, CommonConstant.STATUS_1).list();
    }
 
}