Эх сурвалжийг харах

fix: dept del flag add to agent

shc 11 сар өмнө
parent
commit
9b002a5711

+ 4 - 0
hnqz-common/hnqz-common-data/src/main/java/com/qunzhixinxi/hnqz/common/data/datascope/DataScopeMapper.java

@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.toolkit.Constants;
 import org.apache.ibatis.annotations.Param;
 
+import java.io.Serializable;
 import java.util.List;
 
 /**
@@ -42,4 +43,7 @@ public interface DataScopeMapper<T> extends BaseMapper<T> {
 	 */
 	Integer selectCountByScope(@Param(Constants.WRAPPER) Wrapper<T> queryWrapper, DataScope scope);
 
+
+	T selectRealById(Serializable id);
+
 }

+ 9 - 8
hnqz-common/hnqz-common-data/src/main/java/com/qunzhixinxi/hnqz/common/data/datascope/DataScopeSqlInjector.java

@@ -13,13 +13,14 @@ import java.util.List;
  */
 public class DataScopeSqlInjector extends DefaultSqlInjector {
 
-	@Override
-	public List<AbstractMethod> getMethodList(Class<?> mapperClass) {
-		List<AbstractMethod> methodList = super.getMethodList(mapperClass);
-		methodList.add(new SelectListByScope());
-		methodList.add(new SelectPageByScope());
-		methodList.add(new SelectCountByScope());
-		return methodList;
-	}
+    @Override
+    public List<AbstractMethod> getMethodList(Class<?> mapperClass) {
+        List<AbstractMethod> methodList = super.getMethodList(mapperClass);
+        methodList.add(new SelectListByScope());
+        methodList.add(new SelectPageByScope());
+        methodList.add(new SelectCountByScope());
+        methodList.add(new SelectRealById());
+        return methodList;
+    }
 
 }

+ 35 - 0
hnqz-common/hnqz-common-data/src/main/java/com/qunzhixinxi/hnqz/common/data/datascope/SelectRealById.java

@@ -0,0 +1,35 @@
+package com.qunzhixinxi.hnqz.common.data.datascope;
+
+import com.baomidou.mybatisplus.core.injector.AbstractMethod;
+import com.baomidou.mybatisplus.core.metadata.TableInfo;
+import org.apache.ibatis.mapping.MappedStatement;
+import org.apache.ibatis.mapping.SqlSource;
+import org.apache.ibatis.scripting.defaults.RawSqlSource;
+
+/**
+ * 忽略逻辑查询
+ *
+ * @author jimmy
+ * @date 2024-08-19 17:52
+ */
+public class SelectRealById extends AbstractMethod {
+
+    /**
+     * 注入自定义 MappedStatement
+     *
+     * @param mapperClass mapper 接口
+     * @param modelClass  mapper 泛型
+     * @param tableInfo   数据库表反射信息
+     * @return MappedStatement
+     */
+    @Override
+    public MappedStatement injectMappedStatement(Class<?> mapperClass, Class<?> modelClass, TableInfo tableInfo) {
+
+        SqlSource sqlSource = new RawSqlSource(configuration,
+                String.format("SELECT %s FROM %s WHERE %s=#{%s}", sqlSelectColumns(tableInfo, false),
+                tableInfo.getTableName(), tableInfo.getKeyColumn(), tableInfo.getKeyProperty()), Object.class
+        );
+
+        return this.addSelectMappedStatementForTable(mapperClass, "selectRealById", sqlSource, tableInfo);
+    }
+}

+ 11 - 10
hnqz-upms/hnqz-upms-biz/src/main/java/com/qunzhixinxi/hnqz/admin/service/impl/SysDeptServiceImpl.java

@@ -122,7 +122,7 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
             this.removeByIds(idList);
         }
 
-        //删除组织机构
+        // 删除组织机构
         sysDeptRelationService.deleteDeptById(id);
 
         // 删除部门级联关系
@@ -445,14 +445,14 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
     @Override
     public List<SysDept> getAllParentDept(SysDept sysDept) {
         List<SysDept> deptList = deptMapper.getAllParentDept(sysDept);
-        //一个机构同时是一级cso和二级cso时,可以自己给自己发包
+        // 一个机构同时是一级cso和二级cso时,可以自己给自己发包
         Map<Integer, SysDept> partsMap = deptList.stream().collect(
                 Collectors.toMap(SysDept::getLevel, Function.identity(), (dto1, dto2) -> dto1));
-        //没有药企,有一级cso和二级cso时,这个时候不返回二级cso
+        // 没有药企,有一级cso和二级cso时,这个时候不返回二级cso
         if ((!partsMap.containsKey(2)) && partsMap.containsKey(3) && partsMap.containsKey(4)) {
             deptList.remove(partsMap.get(4));
         }
-        //二级CSO只展示上级一级CSO
+        // 二级CSO只展示上级一级CSO
         if (partsMap.containsKey(2) && partsMap.containsKey(3) && partsMap.containsKey(4)) {
             SysDept sysDept1 = this.getById(SecurityUtils.getUser().getDeptId());
             if (sysDept1.getLevel() == 4) {
@@ -561,16 +561,17 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
     }
 
     @Override
-    public Map<Integer, SysDept> mapConsignee(Set<Integer> consigneeIds,  boolean ignoreDel) {
-
-        LambdaQueryWrapper<SysDept> wrapper = Wrappers.<SysDept>lambdaQuery().in(SysDept::getDeptId, consigneeIds);
+    public Map<Integer, SysDept> mapConsignee(Set<Integer> consigneeIds, boolean ignoreDel) {
 
+        List<SysDept> list;
         if (ignoreDel) {
-            wrapper.and(i -> i.eq(SysDept::getDelFlag, DelEnum.NOT_DEL.getVal()).or().eq(SysDept::getDelFlag, DelEnum.DELETED.getVal()));
+            list = consigneeIds.stream().map(id -> this.getBaseMapper().selectRealById(id)).collect(Collectors.toList());
+
+        } else {
+            list = this.list(Wrappers.<SysDept>lambdaQuery().in(SysDept::getDeptId, consigneeIds));
         }
 
-        List<SysDept> list = this.list(wrapper);
 
-        return list.stream().collect(Collectors.toMap(SysDept::getDeptId, Function.identity()));
+        return CollUtil.isNotEmpty(list) ? list.stream().collect(Collectors.toMap(SysDept::getDeptId, Function.identity())) : Collections.emptyMap();
     }
 }