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;
|
}
|
}
|