新火炬后端单体项目初始化代码
cuijian
2025-06-26 2166b1661ca1e94fae6e4631799a9997418bff43
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
package org.jeecg.modules.base.service.impl;
 
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.jeecg.modules.base.entity.Factory;
import org.jeecg.modules.base.entity.UserFactory;
import org.jeecg.modules.base.mapper.UserFactoryMapper;
import org.jeecg.modules.base.model.FactoryIdModel;
import org.jeecg.modules.base.service.IFactoryService;
import org.jeecg.modules.base.service.IUserFactoryService;
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-24
 * @Version: V1.0
 */
@Service
public class UserFactoryServiceImpl extends ServiceImpl<UserFactoryMapper, UserFactory> implements IUserFactoryService {
 
    @Autowired
    private IFactoryService factoryService;
    /**
     * 根据用户id查询产线信息
     */
    @Override
    public List<FactoryIdModel> queryFactoryIdsOfUser(String userId) {
        LambdaQueryWrapper<UserFactory> queryUserFactory = new LambdaQueryWrapper<>();
        LambdaQueryWrapper<Factory> queryFactory = new LambdaQueryWrapper<>();
        try {
            queryUserFactory.eq(UserFactory::getUserId, userId);
            List<String> factoryIdList = new ArrayList<>();
            List<FactoryIdModel> factoryIdModelList = new ArrayList<>();
            List<UserFactory> userFactoryList = this.list(queryUserFactory);
            if (userFactoryList != null && !userFactoryList.isEmpty()) {
                for (UserFactory userFactory : userFactoryList) {
                    factoryIdList.add(userFactory.getFactoryId());
                }
                queryFactory.in(Factory::getId, factoryIdList);
                List<Factory> factoryList = factoryService.list(queryFactory);
                if (factoryList != null && !factoryList.isEmpty()) {
                    for (Factory factory : factoryList) {
                        factoryIdModelList.add(new FactoryIdModel().convertByUserFactory(factory));
                    }
                }
                return factoryIdModelList;
            }
        } catch (Exception e) {
            e.fillInStackTrace();
        }
        return null;
    }
}