From e38f4d12d2b051c42202d8554f4c92020d8be294 Mon Sep 17 00:00:00 2001
From: 田源 <lastanimals@163.com>
Date: 星期一, 22 七月 2024 10:10:58 +0800
Subject: [PATCH] 枚举类型导入,部门管理取消唯一标识列
---
Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/frameworkcore/compatibility/impl/OrgDeptQueryServiceImpl.java | 86 +++++++++++++++++++++---------------------
1 files changed, 43 insertions(+), 43 deletions(-)
diff --git a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/frameworkcore/compatibility/impl/OrgDeptQueryServiceImpl.java b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/frameworkcore/compatibility/impl/OrgDeptQueryServiceImpl.java
index 35748de..edaa600 100644
--- a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/frameworkcore/compatibility/impl/OrgDeptQueryServiceImpl.java
+++ b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/frameworkcore/compatibility/impl/OrgDeptQueryServiceImpl.java
@@ -1,19 +1,15 @@
package com.vci.frameworkcore.compatibility.impl;
+import com.vci.dto.OrgDepartmentDTO;
import com.vci.corba.common.PLException;
import com.vci.corba.common.data.UserEntityInfo;
import com.vci.corba.framework.data.DeptInfo;
import com.vci.corba.omd.data.BusinessObject;
import com.vci.frameworkcore.compatibility.OrgDeptQueryServiceI;
-import com.vci.frameworkcore.model.dto.OrgDepartmentDTO;
import com.vci.frameworkcore.lcstatuspck.FrameworkDataLCStatus;
-import com.vci.frameworkcore.model.OrgDeptForPlatform1;
-import com.vci.frameworkcore.model.dto.SmUserDTO;
-import com.vci.frameworkcore.model.po.OrgDeptPO;
-import com.vci.frameworkcore.model.po.SmUserPO;
-import com.vci.frameworkcore.pagemodel.OrgDepartmentVO;
-import com.vci.frameworkcore.pagemodel.SmUserVO;
-import com.vci.frameworkcore.properties.ConfigReader;
+import com.vci.model.OrgDeptForPlatform1;
+import com.vci.po.OrgDeptPO;
+import com.vci.pagemodel.OrgDepartmentVO;
import com.vci.omd.utils.ObjectTool;
import com.vci.starter.poi.bo.ReadExcelOption;
import com.vci.starter.poi.bo.WriteExcelData;
@@ -23,7 +19,6 @@
import com.vci.starter.revision.bo.TreeWrapperOptions;
import com.vci.starter.revision.service.RevisionModelUtil;
import com.vci.starter.web.constant.QueryOptionConstant;
-import com.vci.starter.web.enumpck.UserSecretEnum;
import com.vci.starter.web.exception.VciBaseException;
import com.vci.starter.web.pagemodel.*;
import com.vci.starter.web.util.*;
@@ -40,12 +35,8 @@
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
-import org.springframework.web.util.WebUtils;
import java.io.File;
-import java.nio.charset.StandardCharsets;
-import java.security.MessageDigest;
-import java.security.NoSuchAlgorithmException;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
@@ -99,7 +90,7 @@
}
Map<String, String> conditionMap = new HashMap<>();
conditionMap.put("pluid",deptOid);
- VciQueryWrapperForDO queryWrapper = new VciQueryWrapperForDO(conditionMap,OrgDeptForPlatform1.class);
+ VciQueryWrapperForDO queryWrapper = new VciQueryWrapperForDO(conditionMap, OrgDeptForPlatform1.class);
List<OrgDeptForPlatform1> deptForPlatform1s = boService.selectByQueryWrapper(queryWrapper, OrgDeptForPlatform1.class);
if(Func.isEmpty(deptForPlatform1s)){
return null;
@@ -645,12 +636,12 @@
orgDepartmentDTO.getOid(),"鐢ㄦ埛涓婚敭",
orgDepartmentDTO.getId(),"鐢ㄦ埛鍚�"
);
- //鎸塷id鏌ヨ鏁版嵁搴撲腑宸插瓨鍦ㄧ殑
+ //鎸塷id鏌ヨ鏁版嵁搴撲腑宸插瓨鍦ㄧ殑锛岀‘淇濅慨鏀圭殑閮ㄩ棬瀛樺湪
OrgDepartmentVO dbDepartmentVO = getDeptByDeptOid(orgDepartmentDTO.getOid());
if(Func.isEmpty(dbDepartmentVO)){
throw new VciBaseException("淇敼鐨勯儴闂ㄤ笉瀛樺湪锛�");
}
- //閮ㄩ棬鍚嶅拰缂栧彿鍒ら噸
+ //閮ㄩ棬鍚嶅拰缂栧彿鍒ら噸锛岄伩鍏嶆柊瀹堕儴闂ㄩ噸澶�
Map<String, String> conditionMap = new HashMap<>();
conditionMap.put("plname",QueryOptionConstant.OR + orgDepartmentDTO.getName());
if(Func.isNotBlank(orgDepartmentDTO.getId())){
@@ -712,7 +703,7 @@
@Override
public boolean deleteDept(String[] ids) throws PLException {
VciBaseUtil.alertNotNull(ids,"瑕佸垹闄ょ殑閮ㄩ棬涓婚敭");
- //鍏峰杩炲甫鍒犻櫎鐨勫姛鑳斤紝濡傝鑹茶彍鍗曟巿鏉冭〃閲岄潰鐨勬巿鏉冧俊鎭�
+ //TODO: 搴旇鏄笉鍏峰杩炲甫鍒犻櫎鐨勫姛鑳斤紝绛栫暐鍒犻櫎鍚庣敤鎴峰叧鑱旂殑鏃犵敤閮ㄩ棬杩樺湪,鑰冭檻鍚庢湡鏄惁闇�瑕佸仛锛屾暟鎹噺涓嶅ぇ鍙互涓嶅仛杩炲甫鍒犻櫎
return platformClientUtil.getFrameworkService().deleteDepartment(
ids,
new UserEntityInfo("developer"/*WebThreadLocalUtil.getCurrentUserSessionInfoInThread().getUserId()*/, null)
@@ -743,7 +734,7 @@
List<String> columns = new ArrayList<>(Arrays.asList("ID", "鍚嶇О", "缂栧彿", "浠e彿", "涓撲笟", "鐖禝D锛堥儴闂ㄥ敮涓�鏍囪瘑ID锛�", "鎻忚堪"));
//璁剧疆蹇呭~鍒�
ColumnNameisRed.clear();
- ColumnNameisRed.add(0);
+ //ColumnNameisRed.add(0);
ColumnNameisRed.add(1);
//鍐檈xcel
String excelPath = LocalFileUtil.getDefaultTempFolder() + File.separator + downloadFileName + ".xls";
@@ -776,7 +767,7 @@
* @throws VciBaseException
*/
@Override
- public BaseResult importDept(File file) throws VciBaseException {
+ public BaseResult importDept(File file) throws Exception {
VciBaseUtil.alertNotNull(file,"excel鏂囦欢");
if(!file.exists()){
throw new VciBaseException("瀵煎叆鐨別xcel鏂囦欢涓嶅瓨鍦�,{0}",new String[]{file.getPath()});
@@ -813,22 +804,21 @@
Map<String, String> oidMap = new HashMap<>();
poList.stream().forEach(po->{
String parentId = Func.isBlank(po.getParentId()) ? "":po.getParentId();
- //琛ㄦ牸鍐呭垽閲�
- //閮ㄩ棬鍚嶇О鍒ょ┖
+ //閮ㄩ棬鍚嶇О鍒ょ┖锛岄�氬父閫氳繃po涓殑娉ㄨВ灏卞彲瀹炵幇
if(Func.isEmpty(po.getName())){
throw new VciBaseException("绗��"+po.getRowIndex()+"銆戣锛宒epterror,Reason:Name cannot be empty");
- }else if(repeatNameMap.getOrDefault(po.getName(), "").equals(parentId)/*excel涓悓涓�閮ㄩ棬涓婲ame鐩哥瓑*/){
+ }else if(parentId.equals(repeatNameMap.getOrDefault(po.getName(), null))/*excel涓悓涓�閮ㄩ棬涓婲ame鐩哥瓑*/){
//鍚屼竴閮ㄩ棬涓嬪悕绉板垽閲�
throw new VciBaseException("绗��"+po.getRowIndex()+"銆戣锛宒eptnameerror,Reason: Names under the same department cannot be duplicated");
}else if(Func.isNotEmpty(po.getId()) && repeatIdList.equals(po.getId())){
throw new VciBaseException("绗��"+po.getRowIndex()+"銆戣锛宒eptiderror,Reason: The primary key cannot be duplicated");
- }else if(Func.isNotEmpty(po.getNum()) && repeatNumMap.getOrDefault(po.getNum(),"").equals(parentId)/*excel涓悓涓�閮ㄩ棬涓嬬紪鍙峰瓨鍦� */){
+ }else if(Func.isNotEmpty(po.getNum()) && parentId.equals(repeatNumMap.getOrDefault(po.getNum(),null))/*excel涓悓涓�閮ㄩ棬涓嬬紪鍙峰瓨鍦� */){
throw new VciBaseException("绗��"+po.getRowIndex()+"銆戣锛宒eptnumerror,Reason: The number cannot be duplicated");
}else{
//2.2銆佹煡璇㈡暟鎹簱涓殑鏁版嵁锛堟煡閲岻D鍜孨UM锛夛紝姣旇緝楹荤儲闇�瑕佹牴鎹甈arentID鏌ヨ锛堟墍鏈夊彧鑳藉崟鏉℃煡璇㈣繘琛屽垽閲嶏級
//缁勮鏌ラ噸鏉′欢:鍚屼竴閮ㄩ棬涓�(parentId鐩哥瓑)锛宯ame鎴栬�卬um鐩哥瓑
HashMap<String, String> conditionMap = new HashMap<>();
- conditionMap.put("plname",po.getName());
+ conditionMap.put("plname",QueryOptionConstant.OR + po.getName());
conditionMap.put("plnum",QueryOptionConstant.OR + po.getNum());
String pId = Func.isBlank(po.getParentId()) ? null:po.getParentId();
List<OrgDepartmentVO> repeatOrgDept = this.getDeptByDeptPOidAndCondition(pId, conditionMap);
@@ -847,6 +837,8 @@
BeanUtil.convert(po,dto);
dto.setOid(po.getId());
dto.setId(po.getNum());
+ dto.setDescription(po.getDesc());
+ dto.setSpecialties(po.getSpecialties());
dto.setPkFatherDepartment(po.getParentId());
dto.setCreateTime(new Date());
dto.setCreator(loginUserId);
@@ -854,7 +846,7 @@
dto.setStatus((short) 0);
//2.2銆佽繃绋嬩腑澶勭悊涓婚敭杞崲闂鏈�濂芥槸涓�鏉′竴鏉$殑澶勭悊ID鏄惁瀛樺湪杩樻湁ParentID鏄惁瀛樺湪鐨勯棶棰�
//鍏堝垽鏂槸宸插瓨鍦ㄧ殑閮ㄩ棬ID锛岃繕鏄笉瀛樺湪鐨勯儴闂↖D锛屽凡瀛樺湪绯荤粺涓殑ID灏辨槸涓篋ept:寮�澶寸殑
- String pId = dto.getPkFatherDepartment();
+ String pId = Func.isBlank(dto.getPkFatherDepartment()) ? "":dto.getPkFatherDepartment();
//鏄凡瀛樺湪绯荤粺涓殑閮ㄩ棬id
if(pId.contains("Dept:")){
//瑙f瀽鍑虹湡瀹炵殑oid
@@ -863,33 +855,41 @@
if(Func.isBlank(deParentId) || Func.isEmpty(this.getDeptByDeptOid(deParentId))){
throw new VciBaseException("绗��"+ po.getRowIndex() +"銆戣锛宒eptparentiderror,Reason:Parent ID resolution error or does not exist in the system");
}
- //鏇挎崲鎺変复鏃朵娇鐢ㄧ殑閮ㄩ棬鍞竴鏍囪瘑
- dto.setPkOrganizationName(deParentId);
+ //鏇挎崲鎺変复鏃朵娇鐢ㄧ殑閮ㄩ棬鍞竴鏍囪瘑锛屼絾鏄负浜嗘柟渚垮悗缁垽鏂紝杩樻槸闇�瑕佸姞涓奃ept:鏍囪瘑
+ dto.setPkFatherDepartment("Dept:"+deParentId);
}
//鐢ㄦ埛鎵嬭緭浜嗛儴闂╫id锛屼絾鏄伩鍏峯id涓嶈鑼冮渶瑕侊紝鐢ㄨ鑼僶id杩涜鏇挎崲锛屽鏋滄病杈撳叆淇濆瓨鏃朵細鑷姩鐢熸垚oid
- if(Func.isNotBlank(dto.getOid())){
- String pkOid = VciBaseUtil.getPk();
+ String excelOid = dto.getOid();
+ if(Func.isNotBlank(excelOid)){
+ String pkOid = VciBaseUtil.getPk().toUpperCase(Locale.ROOT);
dto.setOid(pkOid);
//oid鏄犲皠鍏崇郴锛屽悗缁敤鏉ユ洿鏂皃arentId
- oidMap.put(dto.getOid(),pkOid);
+ oidMap.put(excelOid,pkOid);
}
DeptInfo deptInfo = this.changeOrgDeptDTOToDeptInfo(dto);
deptInfoList.add(deptInfo);
});
- //3銆佸鐞唅d鍜宲arentId鐨勬槧灏勫叧绯�:灏嗙敤鎴锋墜杈撶殑鐖禝D杞崲鎴愬疄闄呭瓨鍌ㄧ殑ID
- List<DeptInfo> lastDeptInfoList = deptInfoList.stream().map(info -> {
- //parentId涓嶄负绌哄苟涓旀病鏈塂ept:鐩稿叧鐨勫瓧绗︿覆,璇存槑鏄敤鎴锋墜杈撶殑ParentId(瀵煎叆鐨勬暟鎹氨鏄竴涓爲缁撴瀯)
- if (Func.isNotBlank(info.parentId) || info.parentId.contains("Dept:")) {
- //杞崲ParentId涓哄疄闄呰瀛樺偍鐨勯儴闂↖D
- info.parentId = oidMap.get(info.parentId);
+ //3銆佸鐞唅d鍜宲arentId鐨勬槧灏勫叧绯�:灏嗙敤鎴锋墜杈撶殑鐖禝D杞崲鎴愬疄闄呭瓨鍌ㄧ殑ID骞朵繚瀛樿繘搴�
+ deptInfoList.stream().forEach(info -> {
+ //3.1銆佸鏈�缁堝鐞嗗ソ鐨勯儴闂ㄦ暟鎹繚瀛�
+ try {
+ //parentId涓嶄负绌哄苟涓旀病鏈塂ept:鐩稿叧鐨勫瓧绗︿覆,璇存槑鏄敤鎴锋墜杈撶殑ParentId(瀵煎叆鐨勬暟鎹氨鏄竴涓爲缁撴瀯)
+ if (Func.isNotBlank(info.parentId) && !info.parentId.contains("Dept:")) {
+ //杞崲ParentId涓哄疄闄呰瀛樺偍鐨勯儴闂↖D
+ info.parentId = oidMap.get(info.parentId);
+ }else if(info.parentId.contains("Dept:")){
+ //绯荤粺涓凡瀛樺湪鐨勭埗閮ㄩ棬OID锛岄渶瑕佺Щ闄ゆ帀Dept:鏍囪瘑
+ info.parentId = info.parentId.replace("Dept:","");
+ }
+ platformClientUtil.getFrameworkService().saveDepartment(
+ info,
+ userEntityInfo
+ );
+ } catch (PLException e) {
+ e.printStackTrace();
+ throw new VciBaseException("淇濆瓨鏃跺嚭鐜伴敊璇紒锛屽師鍥狅細"+VciBaseUtil.getExceptionMessage(e));
}
- return info;
- }).collect(Collectors.toList());
- //4銆佸鏈�缁堝鐞嗗ソ鐨勯儴闂ㄦ暟鎹繚瀛橈紝瀹炵幇鏈�缁堢粺涓�淇濆瓨锛岄伩鍏嶄簡涓�閮ㄥ垎鏁版嵁杩涗簡涓�閮ㄥ垎鏁版嵁鍥犱负鏍¢獙娌¤繃娌¤繘搴撶殑闂
- platformClientUtil.getFrameworkService().batchSaveDepart(
- lastDeptInfoList.toArray(new DeptInfo[lastDeptInfoList.size()]),
- userEntityInfo
- );
+ });
}catch (Exception e){
if(logger.isErrorEnabled()){
logger.error("璇诲彇excel鍐呭鏃舵垨淇濆瓨鐢ㄦ埛淇℃伅鏃跺嚭鐜颁簡閿欒锛屽叿浣撳師鍥狅細",e.getMessage());
--
Gitblit v1.10.0