lyh
2025-07-08 d4c5f8e7bf9b2bb48922396d1be5b2f274d8effb
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
package org.jeecg.modules.system.service.impl;
 
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.jeecg.modules.system.entity.BaseFactoryUser;
import org.jeecg.modules.system.entity.BaseFactory;
import org.jeecg.modules.system.entity.BaseFactoryUser;
import org.jeecg.modules.system.mapper.BaseFactoryUserMapper;
import org.jeecg.modules.system.model.EamBaseFactoryIdModel;
import org.jeecg.modules.system.model.EamBaseFactoryIdModel;
import org.jeecg.modules.system.service.IBaseFactoryService;
import org.jeecg.modules.system.service.IBaseFactoryUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
 
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 
import java.util.ArrayList;
import java.util.List;
 
/**
 * @Description: 设备车间管理与用户
 * @Author: jeecg-boot
 * @Date:   2025-06-30
 * @Version: V1.0
 */
@Service
public class BaseFactoryUserServiceImpl extends ServiceImpl<BaseFactoryUserMapper, BaseFactoryUser> implements IBaseFactoryUserService {
    @Autowired
    private IBaseFactoryService iBaseFactoryService;
 
    /**
     * 根据指定用户id查询产线信息
     */
    @Override
    public List<EamBaseFactoryIdModel> queryEamBaseFactoryIdsOfUser(String userId){
        LambdaQueryWrapper<BaseFactoryUser> queryUserRepDep = new LambdaQueryWrapper<>();
        LambdaQueryWrapper<BaseFactory> queryRepDep = new LambdaQueryWrapper<>();
        try {
            queryUserRepDep.eq(BaseFactoryUser::getUserId, userId);
            List<String> repRepDepIdList = new ArrayList<>();
            List<EamBaseFactoryIdModel> repDepIdModelList = new ArrayList<>();
            List<BaseFactoryUser> userRepDepList = this.list(queryUserRepDep);
            if (userRepDepList != null && !userRepDepList.isEmpty()) {
                for (BaseFactoryUser BaseFactoryUser : userRepDepList) {
                    repRepDepIdList.add(BaseFactoryUser.getFactoryId());
                }
                queryRepDep.in(BaseFactory::getId, repRepDepIdList);
                List<BaseFactory> repDepList = iBaseFactoryService.list(queryRepDep);
                if (repDepList != null && !repDepList.isEmpty()) {
                    for (BaseFactory BaseFactory : repDepList) {
                        repDepIdModelList.add(new EamBaseFactoryIdModel().convertByUserProduction(BaseFactory));
                    }
                }
                return repDepIdModelList;
            }
        } catch (Exception e) {
            e.fillInStackTrace();
        }
        return null;
    }
}