From fa8f28cf848d2c3aeaa548a7ac65f93b690392c3 Mon Sep 17 00:00:00 2001
From: yuxc <yuxc@vci-tech.com>
Date: 星期五, 23 八月 2024 10:19:35 +0800
Subject: [PATCH] 1、配置文件上传
---
Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/frameworkcore/compatibility/impl/SmRoleQueryServiceImpl.java | 399 ++++++++++++++++++++++++++++++++++++++++++++++++--------
1 files changed, 337 insertions(+), 62 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 c71204f..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,39 +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.OrgDepartmentVO;
-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兘杩斿洖鏂扮殑瑙掕壊鏄剧ず瀵硅薄
@@ -50,27 +61,43 @@
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;
}
/**
@@ -105,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)){
@@ -131,10 +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
@@ -236,20 +302,8 @@
@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);
+ return listRoleByUserOid(userOid,queryMap,true);
}
/**
@@ -469,7 +523,7 @@
}
/**
- * 鍙傜収瑙掕壊鐨勫垪琛紝涓夊憳绠$悊鐨勪笁涓鑹蹭笉浼氭樉绀�
+ * 鍙傜収瑙掕壊鐨勫垪琛紝瓒呯鏌ュ叏閮紝鍏朵粬鐨勯兘鏄煡鏅�氱殑锛堜笉鍖呭惈涓夊憳锛�
* @param queryMap 鏌ヨ鏉′欢
* @param pageHelper 鍒嗛〉鍜屾帓搴忕殑淇℃伅锛屽湪鍏煎鑰佸钩鍙扮殑鏃跺�欎細鑷姩鍏煎锛屽鏋滃睘鎬т笉瀛樺湪浼氳嚜鍔ㄥ拷鐣�
* @return 瑙掕壊鐨勬樉绀哄璞″垪琛�
@@ -479,6 +533,11 @@
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);
}
@@ -513,35 +572,250 @@
}
/**
- * 璇ユ柟娉曞彧鏀寔涓�娆″彧鍏佽鍗曚釜鐢ㄦ埛鍒嗛厤澶氫釜瑙掕壊锛屼竴瀵瑰
- * @param userOid
+ * 鎴愬憳绠$悊鍒嗛厤瑙掕壊璋冪敤锛屼繚瀛樼敤鎴疯鑹插叧鑱斿叧绯�
+ * @param userOids
* @param roleIds
* @return
*/
@Override
- public boolean saveRights(String userOid, String[] roleIds) throws PLException {
- VciBaseUtil.alertNotNull(userOid,"鐢ㄦ埛涓婚敭");
+ public boolean saveRights(String[] userOids, String[] roleIds) throws PLException {
+ VciBaseUtil.alertNotNull(userOids,"鐢ㄦ埛涓婚敭");
//roleIds鍏佽涓虹┖锛屼负绌烘椂娓呯┖褰撳墠鐢ㄦ埛鐨勬潈闄�
- //鍏堟煡閲�
- if(Func.isNotEmpty(roleIds)){
- List<String> repeatRoleOidList = new ArrayList<>();
- //寰幆杩涜鏌ラ噸锛岄伩鍏峣n澶т簬1000
- WebUtil.switchCollectionForOracleIn(Arrays.asList(roleIds)).stream().forEach(deptoids->{
- String sql = "select pluseruid,plroleuid from pluserrole where pluseruid = '" + userOid
- + "' and " + "plroleuid in ("+WebUtil.toInSql(deptoids.toArray(new String[0]))+")";
- List<BusinessObject> cbos = boService.queryBySql(sql, null);
- if(!CollectionUtils.isEmpty(cbos)){
- cbos.stream().forEach(cbo->{
- repeatRoleOidList.add(ObjectTool.getNewBOAttributeValue(cbo,"plroleuid"));
- });
+ 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));
}
});
- //绉婚櫎閲嶅鐨�
- List<String> tempList = new ArrayList<>(Arrays.asList(roleIds));
- tempList.removeAll(repeatRoleOidList);
- roleIds = tempList.toArray(new String[tempList.size()]);
+ }catch (Exception e){
+ if(logger.isErrorEnabled()){
+ logger.error("璇诲彇excel鍐呭鏃舵垨淇濆瓨瑙掕壊淇℃伅鏃跺嚭鐜颁簡閿欒锛屽叿浣撳師鍥狅細",e.getMessage());
+ }
+ e.printStackTrace();
+ return BaseResult.fail(LangBaseUtil.getErrorMsg(e),new String[]{},e);
}
- return platformClientUtil.getFrameworkService().saveRights(roleIds,new String[]{userOid},new UserEntityInfo());
+ 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;
}
/**
@@ -553,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;
@@ -576,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