From 4e811ec71dba161e13592828a6035e9316b1548e Mon Sep 17 00:00:00 2001
From: wangting <675591594@qq.com>
Date: 星期五, 30 八月 2024 17:15:29 +0800
Subject: [PATCH] 链接类型查询模板
---
Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/frameworkcore/compatibility/impl/SmRoleQueryServiceImpl.java | 426 +++++++++++++++++++++++++++++++++++++++++++++++-----
1 files changed, 380 insertions(+), 46 deletions(-)
diff --git a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/frameworkcore/compatibility/impl/SmRoleQueryServiceImpl.java b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/frameworkcore/compatibility/impl/SmRoleQueryServiceImpl.java
index d225f6e..1c44f0d 100644
--- a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/frameworkcore/compatibility/impl/SmRoleQueryServiceImpl.java
+++ b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/frameworkcore/compatibility/impl/SmRoleQueryServiceImpl.java
@@ -1,32 +1,50 @@
package com.vci.frameworkcore.compatibility.impl;
+import com.vci.constant.FrameWorkBtmTypeConstant;
+import com.vci.corba.common.PLException;
+import com.vci.corba.common.data.UserEntityInfo;
+import com.vci.corba.framework.data.RoleInfo;
+import com.vci.corba.omd.data.BusinessObject;
import com.vci.frameworkcore.compatibility.SmRoleQueryServiceI;
-import com.vci.frameworkcore.constant.FrameWorkBtmTypeConstant;
+import com.vci.constant.FrameWorkBtmTypeConstant;
+import com.vci.dto.SmRoleDTO;
+import com.vci.frameworkcore.compatibility.SmUserQueryServiceI;
import com.vci.frameworkcore.enumpck.RoleClassifyEnum;
import com.vci.frameworkcore.enumpck.RoleControlAreaEnum;
-import com.vci.frameworkcore.model.SmRoleForPlatform1;
-import com.vci.frameworkcore.pagemodel.SmRoleVO;
+import com.vci.model.SmRoleForPlatform1;
+import com.vci.pagemodel.SmUserVO;
+import com.vci.po.SmRolePO;
+import com.vci.pagemodel.SmRoleVO;
+import com.vci.omd.utils.ObjectTool;
+import com.vci.starter.poi.bo.ReadExcelOption;
+import com.vci.starter.poi.constant.ExcelLangCodeConstant;
+import com.vci.starter.poi.util.ExcelUtil;
import com.vci.starter.web.constant.QueryOptionConstant;
import com.vci.starter.web.exception.VciBaseException;
-import com.vci.starter.web.pagemodel.DataGrid;
-import com.vci.starter.web.pagemodel.PageHelper;
-import com.vci.starter.web.pagemodel.Tree;
-import com.vci.starter.web.pagemodel.TreeQueryObject;
+import com.vci.starter.web.pagemodel.*;
+import com.vci.starter.web.util.LangBaseUtil;
+import com.vci.web.util.BeanUtil;
import com.vci.starter.web.util.VciBaseUtil;
+import com.vci.starter.web.util.WebThreadLocalUtil;
import com.vci.starter.web.wrapper.VciQueryWrapperForDO;
-import com.vci.web.properties.WebProperties;
+import com.vci.web.enumpck.UserTypeEnum;
import com.vci.web.service.WebBoServiceI;
+import com.vci.web.util.Func;
import com.vci.web.util.PlatformClientUtil;
import com.vci.web.util.WebUtil;
import org.apache.commons.lang3.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
+import java.io.File;
import java.util.*;
+import java.util.function.Function;
import java.util.stream.Collectors;
-import static com.vci.frameworkcore.constant.FrameWorkBusLangCodeConstant.DATA_OID_NOT_EXIST;
/**
* 瑙掕壊鐨勬煡璇㈡湇鍔★紝鍏煎鏉ュ钩鍙帮紝绱犳湁鐨勬帴鍙i兘杩斿洖鏂扮殑瑙掕壊鏄剧ず瀵硅薄
@@ -43,22 +61,45 @@
private WebBoServiceI boService;
/**
+ * 鐢ㄦ埛鏌ヨ鏈嶅姟
+ */
+ @Autowired
+ @Lazy
+ private SmUserQueryServiceI smUserQueryServiceI;
+
+ /**
+ * 骞冲彴璋冪敤瀹㈡埛绔�
+ */
+ @Autowired
+ private PlatformClientUtil platformClientUtil;
+
+ private final Integer QUERY_IN_LIMIT = 1000;
+
+ /**
+ * 鏃ュ織
+ */
+ private Logger logger = LoggerFactory.getLogger(getClass());
+
+ /**
* 鏍规嵁瑙掕壊涓婚敭鑾峰彇瑙掕壊鐨勪俊鎭�
- * @param roleOid 瑙掕壊涓婚敭
+ * @param conditionMap 瑙掕壊涓婚敭
* @return 瑙掕壊鐨勬樉绀哄璞★紝濡傛灉瑙掕壊涓嶅瓨鍦ㄥ垯杩斿洖null锛屼笉浼氭姏鍑哄紓甯�
* @throws VciBaseException 鍙傛暟涓虹┖鎴栬�呮暟鎹簱瀛樺湪闂鐨勬椂鍊欎細鎶涘嚭寮傚父
*/
@Override
- public SmRoleVO getRoleByRoleOid(String roleOid) throws VciBaseException {
- if(StringUtils.isBlank(roleOid)){
+ public SmRoleVO getRoleByConditionMap(Map<String,String> conditionMap) throws VciBaseException {
+ if(Func.isEmpty(conditionMap)){
return null;
}
- SmRoleForPlatform1 role = boService.selectByOid(roleOid, SmRoleForPlatform1.class);
- if(role == null || StringUtils.isBlank(role.getPluid())){
- throw new VciBaseException(DATA_OID_NOT_EXIST);
+ VciQueryWrapperForDO queryWrapper = new VciQueryWrapperForDO(conditionMap, SmRoleForPlatform1.class);
+ List<SmRoleForPlatform1> smRoleForPlatform1s = boService.selectByQueryWrapper(queryWrapper, SmRoleForPlatform1.class);
+ if(Func.isNotEmpty(smRoleForPlatform1s) && Func.isNotBlank(smRoleForPlatform1s.get(0).getPluid())){
+ //瑙掕壊鍚嶄笉鑳介噸澶嶆墍浠ョ洿鎺ュ彇绗竴涓厓绱�
+ return platformRole2SmRoleVO(smRoleForPlatform1s.get(0));
}
- return platformRole2SmRoleVO(role);
+ return null;
}
+
/**
* 鎵归噺鑾峰彇瑙掕壊鐨勪俊鎭� 锛堟牴鎹鑹蹭富閿級
* @param roleOidCollections 瑙掕壊涓婚敭鐨勯泦鍚堬紝鍙互瓒呰繃1000涓�
@@ -82,6 +123,7 @@
});
return platformRole2SmRoleVOs(roles);
}
+
/**
* 鑾峰彇瑙掕壊鐨勫垪琛紝榛樿浼氫互瑙掕壊鍚嶅崌搴忔帓鍒楋紝瑙掕壊鐨勭紪杈戦〉闈㈠垪琛ㄤ笉瑕佷娇鐢ㄨ繖涓帴鍙�
* @param queryMap 鏌ヨ鏉′欢
@@ -90,15 +132,12 @@
* @throws VciBaseException 鍙傛暟涓虹┖鐨勬椂鍊欎細鎶涘嚭寮傚父
*/
@Override
- public DataGrid<SmRoleVO> gridRoles(Map<String, String> queryMap,
- PageHelper pageHelper) throws VciBaseException {
+ public DataGrid<SmRoleVO> gridRoles(Map<String, String> queryMap, PageHelper pageHelper) throws VciBaseException {
if(pageHelper == null){
pageHelper = new PageHelper(-1);
}
pageHelper.addDefaultAsc("plname");
VciQueryWrapperForDO queryWrapper = new VciQueryWrapperForDO(queryMap,SmRoleForPlatform1.class,pageHelper);
- //鎴戜滑涓嶈兘鏄剧ず涓夊憳鍜岀鐞嗗憳鐨勮鑹�
- queryWrapper.eq("pltype","2");
List<SmRoleForPlatform1> roleForPlatform1s = boService.selectByQueryWrapper(queryWrapper, SmRoleForPlatform1.class);
DataGrid<SmRoleVO> dataGrid = new DataGrid<>();
if(!CollectionUtils.isEmpty(roleForPlatform1s)){
@@ -107,6 +146,7 @@
}
return dataGrid;
}
+
/**
* 鏍规嵁瑙掕壊涓婚敭鑾峰彇瑙掕壊鐨勫鍚�
* @param roleOid 瑙掕壊涓婚敭
@@ -115,9 +155,52 @@
@Override
public String getRoleNameByRoleOid(String roleOid) {
WebUtil.alertNotNull(roleOid,"瑙掕壊涓婚敭");
- return getRoleByRoleOid(roleOid).getName();
+ Map<String, String> conditionMap = new HashMap<>();
+ conditionMap.put("pluid",roleOid);
+ return getRoleByConditionMap(conditionMap).getName();
}
- /**
+
+ /**
+ * 鏍规嵁瑙掕壊鍚嶆煡璇㈣鑹蹭俊鎭�
+ * @param roleNameList
+ * @param queryMap
+ * @return
+ */
+ @Override
+ public List<SmRoleVO> listRoleByRoleName(Collection<String> roleNameList, Map<String, String> queryMap) {
+ if(Func.isEmpty(roleNameList)){
+ return new ArrayList<>();
+ }
+ if(queryMap == null){
+ queryMap = new HashMap<>();
+ }
+ List<SmRoleForPlatform1> roles = new ArrayList<>();
+ if(roleNameList.size() > QUERY_IN_LIMIT){
+ Map<String, String> finalQueryMap = queryMap;
+ WebUtil.switchCollectionForOracleIn(roleNameList).stream().forEach(roleNames->{
+ Map<String,String> conditionMap = new HashMap<>();
+ finalQueryMap.forEach((key,value)->{
+ conditionMap.put(key,value);
+ });
+ conditionMap.put("plname", QueryOptionConstant.IN + WebUtil.toInSql(roleNames.toArray(new String[0])));
+ VciQueryWrapperForDO queryWrapper = new VciQueryWrapperForDO(conditionMap,SmRoleForPlatform1.class);
+ List<SmRoleForPlatform1> roleForPlatform1s = boService.selectByQueryWrapper(queryWrapper, SmRoleForPlatform1.class);
+ if(!CollectionUtils.isEmpty(roleForPlatform1s)){
+ roles.addAll(roleForPlatform1s);
+ }
+ });
+ }else{
+ queryMap.put("plname", QueryOptionConstant.IN + WebUtil.toInSql(roleNameList.toArray(new String[0])));
+ }
+ VciQueryWrapperForDO queryWrapper = new VciQueryWrapperForDO(queryMap,SmRoleForPlatform1.class);
+ List<SmRoleForPlatform1> roleForPlatform1s = boService.selectByQueryWrapper(queryWrapper, SmRoleForPlatform1.class);
+ if(!CollectionUtils.isEmpty(roleForPlatform1s)){
+ roles.addAll(roleForPlatform1s);
+ }
+ return platformRole2SmRoleVOs(roles);
+ }
+
+ /**
* 鏍规嵁鐢ㄦ埛涓婚敭鑾峰彇鍏宠仈鐨勮鑹�
* @param userOid 鐢ㄦ埛涓婚敭
* @param queryMap 鏌ヨ鏉′欢锛屽鏋滈渶瑕佷娇鐢ㄧ敤鎴风殑灞炴�ф潵鏌ヨ鍙互浣跨敤pkUser.xxxx
@@ -168,6 +251,7 @@
}
return platformRole2SmRoleVOs(roles);
}
+
/**
* 鏍规嵁鐢ㄦ埛涓婚敭鑾峰彇鍏宠仈鐨勮鑹�
* @param userOid 鐢ㄦ埛涓婚敭
@@ -208,6 +292,7 @@
}
return gridRoles(queryMap,pageHelper);
}
+
/**
* 鑾峰彇鏈叧鑱旀煇涓敤鎴风殑瑙掕壊
* @param userOid 鐢ㄦ埛涓婚敭
@@ -217,20 +302,10 @@
@Override
public List<SmRoleVO> listRoleUnInUserOid(String userOid,
Map<String, String> queryMap) {
+
return listRoleByUserOid(userOid,queryMap,true);
}
- /**
- * 鑾峰彇鏈叧鑱旀煇涓敤鎴风殑瑙掕壊
- * @param userOid 鐢ㄦ埛涓婚敭
- * @param queryMap 鏌ヨ鏉′欢锛屽鏋滈渶瑕佷娇鐢ㄧ敤鎴风殑灞炴�ф潵鏌ヨ鍙互浣跨敤pkUser.xxxx
- * @param pageHelper 鍒嗛〉鍜屾帓搴忓璞★紝鑰佸钩鍙颁笉鏀寔浣跨敤瑙掕壊缂栧彿鏉ユ帓搴�
- * @return 瑙掕壊鐨勬樉绀哄璞�
- */
- @Override
- public DataGrid<SmRoleVO> gridRoleUninUserOid(String userOid,
- Map<String, String> queryMap, PageHelper pageHelper) {
- return gridRoleByUserOid(userOid,queryMap,pageHelper,true);
- }
+
/**
* 鎵归噺鏍规嵁鐢ㄦ埛鐨勪富閿潵鑾峰彇瑙掕壊
* @param userOidCollection 鐢ㄦ埛涓婚敭闆嗗悎
@@ -250,19 +325,22 @@
if(!CollectionUtils.isEmpty(roleVOS)){
roleVOList.addAll(roleVOS);
String sql = "select pluseruid,plroleuid from pluserrole where pluseruid in (" + WebUtil.toInSql(userOids.toArray(new String[0])) + ")";
- List<com.vci.client.bof.ClientBusinessObject> cbos = boService.queryBySql(sql, null);
+ List<BusinessObject> cbos = boService.queryBySql(sql, null);
if(!CollectionUtils.isEmpty(cbos)){
cbos.stream().forEach(cbo->{
- String userOid = cbo.getAttributeValue("pluseruid");
+ String userOid = ObjectTool.getNewBOAttributeValue(cbo,"pluseruid");
List<String> roleOids = userRoleOidMap.getOrDefault(userOid,new ArrayList<>());
- roleOids.add(cbo.getAttributeValue("plroleuid"));
+ roleOids.add(ObjectTool.getNewBOAttributeValue(cbo,"plroleuid"));
userRoleOidMap.put(userOid,roleOids);
});
}
}
});
if(!CollectionUtils.isEmpty(roleVOList)){
- Map<String, SmRoleVO> roleVOMap = roleVOList.stream().collect(Collectors.toMap(s -> s.getOid(), t -> t));
+ //杩欏効搴旇瀵箁oleVOList鍋氫竴娆″幓閲嶅鐞嗭紝鍥犱负鑲畾浼氭湁閲嶅鐨勮鑹茶鏌ュ嚭鏉�
+ Map<String, SmRoleVO> roleVOMap = roleVOList.stream()
+ .collect(Collectors.toMap(SmRoleVO::getOid, Function.identity(), (existing, replacement) -> existing));
+ //Map<String, SmRoleVO> roleVOMap = roleVOList.stream().collect(Collectors.toMap(s -> s.getOid(), t -> t));
Map<String, List<SmRoleVO>> userRoleVOMap = new HashMap<>();
userRoleOidMap.forEach((userOid,roleOids)->{
List<SmRoleVO> roleVOS = new ArrayList<>();
@@ -277,6 +355,7 @@
}
return new HashMap<>();
}
+
/**
* 鏍规嵁鏉冮檺涓婚敭鑾峰彇鍏宠仈鐨勮鑹�
* @param functionOid 鏉冮檺涓婚敭
@@ -415,12 +494,12 @@
if(!CollectionUtils.isEmpty(roleVOS)){
roleVOList.addAll(roleVOS);
String sql = "select plroleoid,plfuncoid from plroleright where plfuncoid in (" + WebUtil.toInSql(userOids.toArray(new String[0])) + ")";
- List<com.vci.client.bof.ClientBusinessObject> cbos = boService.queryBySql(sql, null);
+ List<BusinessObject> cbos = boService.queryBySql(sql, null);
if(!CollectionUtils.isEmpty(cbos)){
cbos.stream().forEach(cbo->{
- String funcOid = cbo.getAttributeValue("plfuncoid");
+ String funcOid = ObjectTool.getBOAttributeValue(cbo,"plfuncoid");
List<String> roleOids = funcRoleOidMap.getOrDefault(funcOid,new ArrayList<>());
- roleOids.add(cbo.getAttributeValue("plroleoid"));
+ roleOids.add(ObjectTool.getBOAttributeValue(cbo,"plroleoid"));
funcRoleOidMap.put(funcOid,roleOids);
});
}
@@ -442,8 +521,9 @@
}
return new HashMap<>();
}
+
/**
- * 鍙傜収瑙掕壊鐨勫垪琛紝涓夊憳绠$悊鐨勪笁涓鑹蹭笉浼氭樉绀�
+ * 鍙傜収瑙掕壊鐨勫垪琛紝瓒呯鏌ュ叏閮紝鍏朵粬鐨勯兘鏄煡鏅�氱殑锛堜笉鍖呭惈涓夊憳锛�
* @param queryMap 鏌ヨ鏉′欢
* @param pageHelper 鍒嗛〉鍜屾帓搴忕殑淇℃伅锛屽湪鍏煎鑰佸钩鍙扮殑鏃跺�欎細鑷姩鍏煎锛屽鏋滃睘鎬т笉瀛樺湪浼氳嚜鍔ㄥ拷鐣�
* @return 瑙掕壊鐨勬樉绀哄璞″垪琛�
@@ -453,8 +533,14 @@
public DataGrid<SmRoleVO> refGridRoles(Map<String, String> queryMap,
PageHelper pageHelper) throws VciBaseException {
//鑰佸钩鍙版病鏈夌敓鏁堢姸鎬�
+ //鏍规嵁褰撳墠鐢ㄦ埛鏉ュ喅瀹氳兘鏌ラ偅浜涜鑹诧細鏅�氱敤鎴峰彧鑳芥煡鏅�氳鑹诧紝绠$悊鍛樺拰鏅�氱敤鎴峰彧鑳芥煡鏅�氳鑹�
+ String usertype = WebThreadLocalUtil.getCurrentUserSessionInfoInThread().getUsertype();
+ if(!UserTypeEnum.SUPPER_ADMIN.getValue().equals(usertype)){
+ queryMap.put("pltype","2");
+ }
return gridRoles(queryMap, pageHelper);
}
+
/**
* 瑙掕壊鐨勬爲褰㈠睍绀猴紝甯哥敤浜庤鑹查�夋嫨鐢ㄦ埛鐨勯〉闈娇鐢�
* @param treeQueryObject 鏍戞煡璇㈠璞�
@@ -486,6 +572,253 @@
}
/**
+ * 鎴愬憳绠$悊鍒嗛厤瑙掕壊璋冪敤锛屼繚瀛樼敤鎴疯鑹插叧鑱斿叧绯�
+ * @param userOids
+ * @param roleIds
+ * @return
+ */
+ @Override
+ public boolean saveRights(String[] userOids, String[] roleIds) throws PLException {
+ VciBaseUtil.alertNotNull(userOids,"鐢ㄦ埛涓婚敭");
+ //roleIds鍏佽涓虹┖锛屼负绌烘椂娓呯┖褰撳墠鐢ㄦ埛鐨勬潈闄�
+ UserEntityInfo userEntityInfo = new UserEntityInfo(WebThreadLocalUtil.getCurrentUserSessionInfoInThread().getUserId(),null);
+ return platformClientUtil.getFrameworkService().saveRights(roleIds,userOids,userEntityInfo);
+ }
+
+ /**
+ * 瑙掕壊绠$悊鍒嗛厤鎴愬憳鎺ュ彛璋冪敤
+ * @param userOids
+ * @param roleId
+ * @return
+ * @throws PLException
+ */
+ @Override
+ public boolean saveRight(String[] userOids, String roleId) throws PLException {
+ VciBaseUtil.alertNotNull(roleId,"瑙掕壊涓婚敭");
+ //roleIds鍏佽涓虹┖锛屼负绌烘椂娓呯┖褰撳墠鐢ㄦ埛鐨勬潈闄�
+ UserEntityInfo userEntityInfo = new UserEntityInfo(WebThreadLocalUtil.getCurrentUserSessionInfoInThread().getUserId(),null);
+ return platformClientUtil.getFrameworkService().saveRight(roleId,userOids,userEntityInfo);
+ }
+
+ /**
+ * 鏂板瑙掕壊
+ * @param smRoleDTO
+ * @return true鎴愬姛锛宖alse澶辫触
+ */
+ @Override
+ public boolean addRole(SmRoleDTO smRoleDTO) throws PLException {
+ //鍒ょ┖
+ VciBaseUtil.alertNotNull(
+ smRoleDTO,"娣诲姞鐨勮鑹插璞�",
+ smRoleDTO.getName(),"瑙掕壊鍚�");
+ //瑙掕壊鍚嶅垽閲�
+ Map<String, String> conditionMap = new HashMap<>();
+ conditionMap.put("plname",smRoleDTO.getName());
+ SmRoleVO dbSmRoleVO = getRoleByConditionMap(conditionMap);
+ if(Func.isNotEmpty(dbSmRoleVO)){
+ throw new VciBaseException("璇ヨ鑹插悕绉板凡缁忓瓨鍦�,璇蜂慨鏀�!");
+ }
+ SessionInfo loginUser = WebThreadLocalUtil.getCurrentUserSessionInfoInThread();
+ String userId = loginUser.getUserId();
+ //瑙掕壊绫诲瀷锛岃繖閲岃缃簡浼氬湪changeRoleObjectToRoleInfo涓浆鎹�
+ if(UserTypeEnum.SUPPER_ADMIN.getValue().equals(loginUser.getUsertype())){
+ smRoleDTO.setRoleClassify(RoleClassifyEnum.MANAGE.getValue());
+ }else {
+ smRoleDTO.setRoleClassify(RoleClassifyEnum.BUSINESS.getValue());
+ }
+ //鐢熸垚瀛樺偍鐨刢orba瀵硅薄
+ Date date = new Date();
+ smRoleDTO.setCreateTime(date);
+ smRoleDTO.setCreator(userId);
+ smRoleDTO.setLastModifier(userId);
+ RoleInfo roleInfo = changeSmRoleDTOToRoleInfo(smRoleDTO);
+ UserEntityInfo userEntityInfo = new UserEntityInfo(userId, "");
+ String oid = platformClientUtil.getFrameworkService().saveRole(roleInfo, userEntityInfo,null);
+ if (Func.isEmpty(oid)) {
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * 淇敼瑙掕壊
+ * @param smRoleDTO
+ * @return
+ */
+ @Override
+ public boolean updateRole(SmRoleDTO smRoleDTO) throws PLException {
+ //鍒ょ┖
+ VciBaseUtil.alertNotNull(
+ smRoleDTO,"娣诲姞鐨勮鑹插璞�",
+ smRoleDTO.getName(),"瑙掕壊鍚�");
+ //鏍规嵁瑙掕壊涓婚敭鏌ヨ锛岀‘淇濅慨鏀圭殑瑙掕壊瀛樺湪
+ Map<String, String> conditionMap = new HashMap<>();
+ conditionMap.put("pluid",smRoleDTO.getOid());
+ SmRoleVO dbSmRoleVO = getRoleByConditionMap(conditionMap);
+ //鏍规嵁涓婚敭娌℃煡璇㈠埌浜嗙敤鎴�
+ if(Func.isEmpty(dbSmRoleVO) || Func.isBlank(dbSmRoleVO.getOid())){
+ throw new PLException("500", new String[] { "褰撳墠淇敼鐨勮鑹蹭笉瀛樺湪!"});
+ }
+ //鏌ヨ鏁版嵁搴撲腑鐨勶紝鏍规嵁瑙掕壊鍚嶆煡閲�
+ conditionMap.clear();
+ conditionMap.put("plname",smRoleDTO.getName());
+ //鎺掗櫎鎺夊綋鍓嶄慨鏀圭殑鐢ㄦ埛
+ conditionMap.put("pluid",QueryOptionConstant.NOTEQUAL + smRoleDTO.getName());
+ SmRoleVO reapeatSmRoleVO = getRoleByConditionMap(conditionMap);
+ //璇存槑淇敼涓虹殑瑙掕壊鍚嶅凡瀛樺湪锛屼笉鑳介噸澶�
+ if(Func.isNotEmpty(reapeatSmRoleVO) && smRoleDTO.getName().equals(reapeatSmRoleVO)){
+ throw new PLException("500", new String[] { "璇ヨ鑹插悕绉板凡缁忓瓨鍦�,璇蜂慨鏀�!"});
+ }
+ SmRoleDTO smRoleDTO1 = new SmRoleDTO();
+ BeanUtil.copy(dbSmRoleVO,smRoleDTO1);
+ smRoleDTO1.setName(smRoleDTO.getName());
+ smRoleDTO1.setDescription(smRoleDTO.getDescription());
+ String loginUserId = WebThreadLocalUtil.getCurrentUserSessionInfoInThread().getUserId();; //"developer"
+ smRoleDTO.setLastModifier(loginUserId);
+ RoleInfo roleInfo = changeSmRoleDTOToRoleInfo(smRoleDTO1);
+ boolean updateBoolean = platformClientUtil.getFrameworkService().updateRole(roleInfo, new UserEntityInfo(loginUserId, null));
+ return updateBoolean;
+ }
+
+ /**
+ * 鍒犻櫎瑙掕壊
+ * @param ids
+ * @return
+ * @throws PLException
+ */
+ @Override
+ public boolean deleteRole(String[] ids) throws PLException {
+ VciBaseUtil.alertNotNull(ids,"瑕佸垹闄ょ殑瑙掕壊涓婚敭");
+ //浣跨敤涓婚敭鍒ゆ柇瑙掕壊鏄惁琚敤鎴峰紩鐢�
+ for (int i = 0; i < ids.length; i++) {
+ String roleName = this.checkIsUsed(ids[i]);
+ if(Func.isNotBlank(roleName)){
+ throw new PLException("500",new String[]{"褰撳墠閫変腑瑕佸垹闄ょ殑瑙掕壊涓瓨鍦ㄣ��"+roleName+"銆戣寮曠敤!"});
+ }
+ }
+ //鍏峰杩炲甫鍒犻櫎鐨勫姛鑳斤紝濡傝鑹茶彍鍗曟巿鏉冭〃閲岄潰鐨勬巿鏉冧俊鎭�
+ return platformClientUtil.getFrameworkService().deleteRole(
+ ids,
+ new UserEntityInfo(WebThreadLocalUtil.getCurrentUserSessionInfoInThread().getUserId(), null)
+ );
+ }
+
+ /**
+ * 妫�鏌ヨ鑹叉槸鍚︽湁鍦ㄥ紩鐢�
+ * @param roleOid
+ * @return
+ */
+ private String checkIsUsed(String roleOid){
+ List<SmUserVO> smUserVOS = smUserQueryServiceI.listUserByRoleOid(roleOid, null);
+ if (Func.isNotEmpty(smUserVOS)) {
+ return this.getRoleNameByRoleOid(roleOid);
+ }
+ return null;
+ }
+
+ /**
+ * 瀵煎叆瑙掕壊
+ * @param file
+ * @return
+ * @throws VciBaseException
+ */
+ @Override
+ public BaseResult importRole(File file) throws Exception {
+ VciBaseUtil.alertNotNull(file,"excel鏂囦欢");
+ if(!file.exists()){
+ throw new VciBaseException("瀵煎叆鐨別xcel鏂囦欢涓嶅瓨鍦�,{0}",new String[]{file.getPath()});
+ }
+ try{
+ //1銆佽鍙杄xcel涓殑鏁版嵁锛岀粍鎴愬璞�
+ ReadExcelOption excelOption = new ReadExcelOption();
+ //璇诲彇excel杞崲涓簆o瀵硅薄
+ List<SmRolePO> poList = ExcelUtil.readDataObjectFromExcel(file, SmRolePO.class,excelOption,(value, po, fieldName)->{});
+ //鍘婚櫎閮芥槸绌虹殑鎯呭喌
+ if(CollectionUtils.isEmpty(poList)){
+ return BaseResult.fail(ExcelLangCodeConstant.IMPORT_CONTENT_NULL,new String[]{});
+ }
+ //鏁版嵁搴撴煡璇㈡槸鍚︽湁宸插瓨鍦ㄧ殑瑙掕壊鍚嶏紝鏂逛究鍚庣画鍋氬垽閲嶅鐞�
+ List<SmRoleVO> smRoleVOList = this.listRoleByRoleName(poList.stream().map(SmRolePO::getName).collect(Collectors.toSet()),null);
+ List<String> repeatRoleName = new ArrayList<>();
+ if(Func.isNotEmpty(smRoleVOList)){
+ repeatRoleName = smRoleVOList.stream().map(SmRoleVO::getName).collect(Collectors.toList());
+ }
+ //褰撳墠excel涓槸鍚﹂噸澶嶇敤鐨勫垽閲峂ap:锛坘ey锛氳处鍙凤紝value锛氳鍙凤級
+ Map<String, String> excelReapeat = new HashMap<>();
+ //鍒ゆ柇蹇呭~灞炴�ф槸鍚︿负绌猴紝瑙掕壊鏄惁宸插瓨鍦紝浠ュ強琛ㄦ牸鍐呮槸鍚﹂噸澶�
+ List<String> finalRepeatroleName = repeatRoleName;
+ poList.stream().forEach(smRolePO -> {
+ //鍏堝蹇呭~灞炴�у垽绌哄鐞�
+ if(Func.isBlank(smRolePO.getName())){
+ throw new VciBaseException("绗��"+smRolePO.getRowIndex()+"銆戣锛宺olenameerror");
+ }else if(finalRepeatroleName.contains(smRolePO.getName())){//鍒ゆ柇瑙掕壊鍚嶆槸鍚︿笌搴撲腑閲嶅
+ throw new VciBaseException("绗��"+smRolePO.getRowIndex()+"銆戣锛岃鑹插悕鍦ㄧ郴缁熶腑宸茬粡瀛樺湪,璇蜂慨鏀�!");
+ }else if(excelReapeat.containsKey(smRolePO.getName())){//琛ㄦ牸涓垽閲�
+ throw new VciBaseException("绗��"+excelReapeat.get(smRolePO.getName())+"銆戣鍜岀銆�"+smRolePO.getRowIndex()+"銆戣鏁版嵁锛岃鑹插悕閲嶅");
+ }
+ excelReapeat.put(smRolePO.getName(),smRolePO.getRowIndex());
+ });
+ //淇濆瓨閫昏緫
+ poList.stream().forEach(smRolePO->{
+ try {
+ SmRoleDTO smRoleDTO = new SmRoleDTO();
+ BeanUtil.copy(smRolePO,smRoleDTO);
+ SessionInfo loginUser = WebThreadLocalUtil.getCurrentUserSessionInfoInThread();
+ String userId = loginUser.getUserId();
+ //瑙掕壊绫诲瀷锛岃繖閲岃缃簡浼氬湪changeRoleObjectToRoleInfo涓浆鎹�
+ if(UserTypeEnum.SUPPER_ADMIN.getValue().equals("0")){
+ smRoleDTO.setRoleClassify(RoleClassifyEnum.MANAGE.getValue());
+ }else {
+ smRoleDTO.setRoleClassify(RoleClassifyEnum.BUSINESS.getValue());
+ }
+ //鐢熸垚瀛樺偍鐨刢orba瀵硅薄
+ Date date = new Date();
+ smRoleDTO.setCreateTime(date);
+ smRoleDTO.setCreator(userId);
+ smRoleDTO.setLastModifier(userId);
+ RoleInfo roleInfo = changeSmRoleDTOToRoleInfo(smRoleDTO);
+ UserEntityInfo userEntityInfo = new UserEntityInfo(userId, "");
+ //鎵ц淇濆瓨
+ platformClientUtil.getFrameworkService().saveRole(roleInfo, userEntityInfo);
+ } catch (PLException e) {
+ e.printStackTrace();
+ throw new VciBaseException("鎵ц鍒扮銆�"+smRolePO.getRowIndex()+"銆戣淇濆瓨閫昏緫鏃跺嚭鐜伴敊璇紝鍘熷洜锛�" + VciBaseUtil.getExceptionMessage(e));
+ }
+ });
+ }catch (Exception e){
+ if(logger.isErrorEnabled()){
+ logger.error("璇诲彇excel鍐呭鏃舵垨淇濆瓨瑙掕壊淇℃伅鏃跺嚭鐜颁簡閿欒锛屽叿浣撳師鍥狅細",e.getMessage());
+ }
+ e.printStackTrace();
+ return BaseResult.fail(LangBaseUtil.getErrorMsg(e),new String[]{},e);
+ }
+ return BaseResult.success("瑙掕壊瀵煎叆鎴愬姛锛�");
+ }
+
+ /**
+ * 瑙掕壊DTO瀵硅薄杞琧orba瀵硅薄
+ * @param role
+ * @return
+ */
+ public RoleInfo changeSmRoleDTOToRoleInfo(SmRoleDTO role) {
+ RoleInfo roleInfo = new RoleInfo();
+ roleInfo.id = role.getOid() == null ? "" : role.getOid();
+ roleInfo.name = role.getName();
+ roleInfo.description = role.getDescription() == null ? "" : role.getDescription();
+ //绠$悊鍛樿鑹查粯璁や负1锛屾櫘閫氳鑹查粯璁や负2锛屼絾鏄兘闇�瑕佽缃皬涓�涓紝鍥犱负鍚庡彴鍒ゆ柇褰搕ype<2鏃朵細鎷縯ype+1
+ if(RoleClassifyEnum.MANAGE.getValue().equals(role.getRoleClassify())){
+ roleInfo.type = 0;
+ }else{
+ roleInfo.type = 1;
+ }
+ roleInfo.createTime = role.getCreateTime().getTime();
+ roleInfo.createUser = role.getCreator() == null ? "" : role.getCreator();
+ roleInfo.updateTime = System.currentTimeMillis();
+ roleInfo.updateUser = role.getLastModifier() == null ? "" : role.getLastModifier();
+ return roleInfo;
+ }
+
+ /**
* 瑙掕壊鐨勮浆鎹紝榛樿鍏ㄩ儴鏄痓s鎺у埗鐨勮鑹�
* @param roleForPlatform1List 鍘熷钩鍙扮殑瑙掕壊
* @return 瑙掕壊鐨勬樉绀哄璞�
@@ -494,7 +827,7 @@
List<SmRoleVO> roleVOList = new ArrayList<>();
if(!CollectionUtils.isEmpty(roleForPlatform1List)){
roleForPlatform1List.stream().forEach(s -> {
- roleVOList.add( platformRole2SmRoleVO(s));
+ roleVOList.add(platformRole2SmRoleVO(s));
});
}
return roleVOList;
@@ -517,11 +850,12 @@
}
roleVO.setRoleClassifyText(RoleClassifyEnum.getTextByValue(roleVO.getRoleClassify()));
roleVO.setRoleControlArea(RoleControlAreaEnum.BS.getValue());
- roleVO.setRoleClassifyText(RoleControlAreaEnum.BS.getText());
- roleVO.setCreateTime(roleForPlatform1.getPlcreatetime());
+ roleVO.setRoleControlAreaText(RoleControlAreaEnum.BS.getText());
+ roleVO.setDescription(roleForPlatform1.getPldesc());
+ roleVO.setCreateTime(new Date(roleForPlatform1.getPlcreatetime()));
roleVO.setCreator(roleForPlatform1.getPlcreateuser());
roleVO.setLastModifier(roleForPlatform1.getPlupdateuser());
- roleVO.setLastModifyTime(roleForPlatform1.getPlupdatetime());
+ roleVO.setLastModifyTime(new Date(roleForPlatform1.getPlupdatetime()));
roleVO.setBtmname(FrameWorkBtmTypeConstant.SM_ROLE_BTM_TYPE);
roleVO.setOwner(roleVO.getCreator());
roleVO.setTs(roleVO.getLastModifyTime());
--
Gitblit v1.9.3