diff --git a/op-modules/op-mes/src/main/java/com/op/mes/mapper/MesPrepareDetailMapper.java b/op-modules/op-mes/src/main/java/com/op/mes/mapper/MesPrepareDetailMapper.java index ded1e74f..94088b91 100644 --- a/op-modules/op-mes/src/main/java/com/op/mes/mapper/MesPrepareDetailMapper.java +++ b/op-modules/op-mes/src/main/java/com/op/mes/mapper/MesPrepareDetailMapper.java @@ -3,6 +3,7 @@ package com.op.mes.mapper; import java.util.List; import com.op.mes.domain.MesPrepareDetail; +import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; /** @@ -11,6 +12,7 @@ import org.apache.ibatis.annotations.Param; * @author Open Platform * @date 2023-08-04 */ +@Mapper public interface MesPrepareDetailMapper { /** * 查询mes备料单明细 diff --git a/op-modules/op-mes/src/main/java/com/op/mes/mapper/MesPrepareMapper.java b/op-modules/op-mes/src/main/java/com/op/mes/mapper/MesPrepareMapper.java index 57aba9a8..3d7e2795 100644 --- a/op-modules/op-mes/src/main/java/com/op/mes/mapper/MesPrepareMapper.java +++ b/op-modules/op-mes/src/main/java/com/op/mes/mapper/MesPrepareMapper.java @@ -3,6 +3,7 @@ package com.op.mes.mapper; import java.util.List; import com.op.mes.domain.MesPrepare; +import org.apache.ibatis.annotations.Mapper; /** * 备料单Mapper接口 @@ -10,6 +11,7 @@ import com.op.mes.domain.MesPrepare; * @author Open Platform * @date 2023-08-03 */ +@Mapper public interface MesPrepareMapper { /** * 查询备料单 diff --git a/op-modules/op-mes/src/main/java/com/op/mes/service/impl/MesPrepareServiceImpl.java b/op-modules/op-mes/src/main/java/com/op/mes/service/impl/MesPrepareServiceImpl.java index 99a4a442..b463a6dd 100644 --- a/op-modules/op-mes/src/main/java/com/op/mes/service/impl/MesPrepareServiceImpl.java +++ b/op-modules/op-mes/src/main/java/com/op/mes/service/impl/MesPrepareServiceImpl.java @@ -151,7 +151,7 @@ public class MesPrepareServiceImpl implements IMesPrepareService { } public void getMesPrepareByFactory(String poolName) { - DynamicDataSourceContextHolder.push(poolName);// 这是数据源的key + DynamicDataSourceContextHolder.push("ds_"+poolName);// 这是数据源的key // List list = sapMaterialPreparationList.stream() // .filter(a->a.getWERKS().equals(poolName)) // .collect(Collectors.toList()); diff --git a/op-modules/op-system/src/main/java/com/op/system/service/impl/SysUserServiceImpl.java b/op-modules/op-system/src/main/java/com/op/system/service/impl/SysUserServiceImpl.java index 6f860394..a12e690e 100644 --- a/op-modules/op-system/src/main/java/com/op/system/service/impl/SysUserServiceImpl.java +++ b/op-modules/op-system/src/main/java/com/op/system/service/impl/SysUserServiceImpl.java @@ -5,6 +5,9 @@ import java.util.List; import java.util.Map; import java.util.stream.Collectors; import javax.validation.Validator; + +import com.op.system.domain.SysDatasource; +import com.op.system.mapper.*; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -23,11 +26,6 @@ import com.op.system.api.domain.SysUser; import com.op.system.domain.SysPost; import com.op.system.domain.SysUserPost; import com.op.system.domain.SysUserRole; -import com.op.system.mapper.SysPostMapper; -import com.op.system.mapper.SysRoleMapper; -import com.op.system.mapper.SysUserMapper; -import com.op.system.mapper.SysUserPostMapper; -import com.op.system.mapper.SysUserRoleMapper; import com.op.system.service.ISysConfigService; import com.op.system.service.ISysUserService; @@ -60,6 +58,8 @@ public class SysUserServiceImpl implements ISysUserService { @Autowired protected Validator validator; + @Autowired + private SysDatasourceMapper sysDatasourceMapper; /** * 根据条件分页查询用户列表 @@ -241,9 +241,24 @@ public class SysUserServiceImpl implements ISysUserService { insertUserPost(user); // 新增用户与角色管理 insertUserRole(user); + // 加工厂数据权限 + insertUserDB(user); return rows; } - + public void insertUserDB(SysUser user) { + // 新增用户与园区数据源 + SysDatasource qo = new SysDatasource(); + qo.setDeptId(user.getDeptId());// + List dbs = sysDatasourceMapper.selectDBListByDept(qo); + List list = new ArrayList(); + for (SysDatasource db : dbs) { + SysDatasource ur = new SysDatasource(); + ur.setUserId(user.getUserId().toString()); + ur.setDatasourceId(db.getId()); + list.add(ur); + } + sysDatasourceMapper.batchUserDB(list); + } /** * 注册用户信息 * @@ -273,6 +288,8 @@ public class SysUserServiceImpl implements ISysUserService { userPostMapper.deleteUserPostByUserId(userId); // 新增用户与岗位管理 insertUserPost(user); + // 加工厂数据权限 + insertUserDB(user); return userMapper.updateUser(user); }