Browse Source

电签配置库优化

lvy 2 months ago
parent
commit
fba39d2fde

+ 2 - 2
blade-service/blade-manager/src/main/java/org/springblade/manager/controller/SignConfigController.java

@@ -63,8 +63,8 @@ public class SignConfigController extends BladeController {
     @GetMapping("/list")
     @ApiOperationSupport(order = 2)
     @ApiOperation(value = "分页", notes = "传入excelTab")
-    public R<IPage<SignConfigVO>> list(@ApiParam(value = "岗位id") @RequestParam(required = false) Long roleId, @ApiParam(value = "搜索keyword") @RequestParam(required = false) String keyword, Query query) {
-        return R.data(signConfigService.selectPageByRoleId(Condition.getPage(query), roleId, keyword));
+    public R<IPage<SignConfigVO>> list(@ApiParam(value = "岗位id") @RequestParam(required = false) Long roleId, @ApiParam(value = "搜索keyword") @RequestParam(required = false) String keyword, Query query, @RequestParam() Integer type) {
+        return R.data(signConfigService.selectPageByRoleId(Condition.getPage(query), roleId, keyword, type));
     }
 
     /**

+ 1 - 1
blade-service/blade-manager/src/main/java/org/springblade/manager/mapper/SignConfigMapper.java

@@ -38,7 +38,7 @@ public interface SignConfigMapper extends BaseMapper<SignConfig> {
     List<RoleVO2> getRoleList(@Param("relationType") Integer relationType,@Param("roleName") String roleName);
     List<SignConfigRelation> getSignConfigRelationListByConfId(@Param("confId") Long confId, @Param("type") Integer type);
 
-    List<SignConfig> selectPageByRoleId(IPage<SignConfig> page,@Param("roleId") Long roleId,@Param("keyword") String keyword);
+    List<SignConfig> selectPageByRoleId(IPage<SignConfig> page, @Param("roleId") Long roleId, @Param("keyword") String keyword, @Param("relationType") Integer relationType);
 
     List<SignConfigVO> getConfigByENames(@Param("names") Set<String> names);
 }

+ 8 - 3
blade-service/blade-manager/src/main/java/org/springblade/manager/mapper/SignConfigMapper.xml

@@ -59,11 +59,16 @@
         </if>
     </select>
     <select id="selectPageByRoleId" resultType="org.springblade.manager.entity.SignConfig">
-        select a.id,a.e_name,a.e_id,a.e_key,a.table_type,a.element_type,a.tenant_id,a.create_user,a.create_dept,a.create_time,a.update_user,a.update_time,a.status,a.is_deleted from m_sign_config a LEFT JOIN m_sign_config_relation b
-            on a.id = b.conf_id WHERE b.type = 1 and a.is_deleted = 0
+        select a.id,a.e_name,a.e_id,a.e_key,a.table_type,a.element_type,a.tenant_id,a.create_user,a.create_dept,a.create_time,a.update_user,a.update_time,a.status,a.is_deleted
+        from m_sign_config a WHERE a.is_deleted = 0
+        and ( SELECT count(1) from m_sign_config_relation  where type = 1 and is_deleted = 0 and conf_id = a.id
         <if test="roleId != null">
-            and b.relation_id = #{roleId}
+            and relation_id = #{roleId}
         </if>
+        <if test="relationType != null">
+            and relation_type = #{relationType}
+        </if>
+        limit 1 ) > 0
         <if test="keyword != null and keyword != ''">
             and a.e_name like concat('%',#{keyword},'%')
         </if>

+ 1 - 1
blade-service/blade-manager/src/main/java/org/springblade/manager/service/ISignConfigService.java

@@ -24,7 +24,7 @@ public interface ISignConfigService extends BaseService<SignConfig> {
 
     List<WbsFormElementVO3> elementList();
 
-    IPage<SignConfigVO> selectPageByRoleId(IPage<SignConfig> page, Long roleId, String keyword);
+    IPage<SignConfigVO> selectPageByRoleId(IPage<SignConfig> page, Long roleId, String keyword, Integer relationType);
 
     List<RoleVO> queryAllRoleList(Integer type, String roleName);
 

+ 3 - 8
blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/SignConfigServiceImpl.java

@@ -25,7 +25,6 @@ import org.springblade.core.mp.base.BaseServiceImpl;
 import org.springblade.core.secure.utils.AuthUtil;
 import org.springblade.core.tool.api.R;
 import org.springblade.core.tool.utils.BeanUtil;
-import org.springblade.core.tool.utils.Func;
 import org.springblade.core.tool.utils.StringUtil;
 import org.springblade.manager.dto.SignConfigDTO;
 import org.springblade.manager.entity.SignConfig;
@@ -210,13 +209,9 @@ public class SignConfigServiceImpl extends BaseServiceImpl<SignConfigMapper, Sig
     }
 
     @Override
-    public IPage<SignConfigVO> selectPageByRoleId(IPage<SignConfig> page, Long roleId, String keyword) {
-        if (roleId == null && (keyword == null || keyword.trim().isEmpty())) {
-            page = this.page(page);
-        } else {
-            List<SignConfig> signConfigs = baseMapper.selectPageByRoleId(page, roleId, keyword);
-            page.setRecords(signConfigs);
-        }
+    public IPage<SignConfigVO> selectPageByRoleId(IPage<SignConfig> page, Long roleId, String keyword, Integer relationType) {
+        List<SignConfig> signConfigs = baseMapper.selectPageByRoleId(page, roleId, keyword, relationType);
+        page.setRecords(signConfigs);
         IPage<SignConfigVO> pageVO = SignConfigWrapper.build().pageVO(page);
         List<SignConfigVO> records = pageVO.getRecords();
         List<Long> ids = records.stream().map(SignConfigVO::getId).collect(Collectors.toList());

+ 24 - 13
blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/TextdictInfoServiceImpl.java

@@ -82,19 +82,12 @@ public class TextdictInfoServiceImpl extends ServiceImpl<TextdictInfoMapper, Tex
                     }else {
                         textdict = new ArrayList<>();
                     }
-                }else{
-                    textdict = baseMapper.selectTextdictInfoByExcelId(page, textdictInfo);
-                }
-                if (textdict != null && !keys.isEmpty()) {
-                    for (TextdictInfoVO vo : textdict) {
-                        if (!(privateInfo.getPKeyId() + "").equals(vo.getTabId())) {
-                            vo.setIsSystem(1);
-                        }
-                        keys.remove(vo.getColKey());
-                    }
-                    if (Func.isNotEmpty(keys)) {
+                    if (!keys.isEmpty()) {
                         // 查询系统级电签配置
-                        TextdictInfoVO temp = textdict.stream().findFirst().orElse(null);
+                        TextdictInfoVO temp = null;
+                        if (textdict != null && !textdict.isEmpty()) {
+                            temp = textdict.get(0);
+                        }
                         if (temp == null) {
                             temp = new TextdictInfoVO();
                             temp.setProjectId(privateInfo.getProjectId());
@@ -103,8 +96,26 @@ public class TextdictInfoServiceImpl extends ServiceImpl<TextdictInfoMapper, Tex
                             temp.setType(2);
                         }
                         List<TextdictInfoVO> textdictList = iSignConfigService.hasSignConfig(privateInfo.getInitTableName(), keys, temp);
-                        textdict.addAll(textdictList);
+                        if (textdict == null || textdict.isEmpty()) {
+                            textdict = textdictList;
+                        } else {
+                            Map<String, TextdictInfoVO> map = textdict.stream().collect(Collectors.toMap(TextdictInfoVO::getColKey, TextdictInfoVO -> TextdictInfoVO, (v1, v2) -> v1));
+                            List<TextdictInfoVO> collect = textdictList.stream().filter(textdictInfoVO -> {
+                                TextdictInfoVO vo = map.get(textdictInfoVO.getColKey());
+                                if (vo != null && vo.getSigRoleId() != null && !vo.getSigRoleId().isEmpty()) {
+                                    List<String> projectRoleIds = Arrays.asList(vo.getSigRoleId().split(","));
+                                    List<String> systemRoleIds = new ArrayList<>(Arrays.asList(textdictInfoVO.getSigRoleId().split(",")));
+                                    // 如果 projectRoleIds 包含所有  systemRoleIds,则返回 false
+                                    systemRoleIds.removeAll(projectRoleIds);
+                                    return !systemRoleIds.isEmpty();
+                                }
+                                return true;
+                            }).collect(Collectors.toList());
+                            textdict.addAll(collect);
+                        }
                     }
+                }else{
+                    textdict = baseMapper.selectTextdictInfoByExcelId(page, textdictInfo);
                 }
             } catch (Exception e) {
                 throw new RuntimeException(e);