Lius
2025-01-02 2152f2f0138730c76df82ff947e5aa27e6a2abff
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
package org.jeecg.modules.system.service.impl;
 
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.jeecg.modules.system.entity.MdcProduction;
import org.jeecg.modules.system.entity.MdcUserProduction;
import org.jeecg.modules.system.mapper.MdcUserProductionMapper;
import org.jeecg.modules.system.model.ProductionIdModel;
import org.jeecg.modules.system.service.IMdcProductionService;
import org.jeecg.modules.system.service.IMdcUserProductionService;
import org.springframework.stereotype.Service;
 
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
 
/**
 * @Description: 用户产线表
 * @author: LiuS
 * @create: 2023-03-27 11:58
 */
@Service
public class MdcUserProductionServiceImpl extends ServiceImpl<MdcUserProductionMapper, MdcUserProduction> implements IMdcUserProductionService {
 
    @Resource
    private IMdcProductionService mdcProductionService;
 
    /**
     * 根据用户id查询产线信息
     */
    @Override
    public List<ProductionIdModel> queryProductionIdsOfUser(String userId) {
        LambdaQueryWrapper<MdcUserProduction> queryUserPro = new LambdaQueryWrapper<>();
        LambdaQueryWrapper<MdcProduction> queryPro = new LambdaQueryWrapper<>();
        try {
            queryUserPro.eq(MdcUserProduction::getUserId, userId);
            List<String> proIdList = new ArrayList<>();
            List<ProductionIdModel> proIdModelList = new ArrayList<>();
            List<MdcUserProduction> userProList = this.list(queryUserPro);
            if (userProList != null && !userProList.isEmpty()) {
                for (MdcUserProduction userProduction : userProList) {
                    proIdList.add(userProduction.getProId());
                }
                queryPro.in(MdcProduction::getId, proIdList);
                List<MdcProduction> proList = mdcProductionService.list(queryPro);
                if (proList != null && !proList.isEmpty()) {
                    for (MdcProduction mdcProduction : proList) {
                        proIdModelList.add(new ProductionIdModel().convertByUserProduction(mdcProduction));
                    }
                }
                return proIdModelList;
            }
        } catch (Exception e) {
            e.fillInStackTrace();
        }
        return null;
    }
 
    /**
     * 根据指定用户id查询产线id集合
     */
    @Override
    public List<String> queryProductionIdsByUserId(String userId) {
        return this.baseMapper.queryProductionIdsByUserId(userId);
    }
}