From 566c542d3f1eb0ad9e918bd1fa9586ab1ed7ec86 Mon Sep 17 00:00:00 2001
From: xiejun <xj@2023>
Date: 星期五, 17 十一月 2023 01:28:50 +0800
Subject: [PATCH] 自定义流水相关开发

---
 Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/MdmIOServiceImpl.java |   61 ++++++++++++++++++++----------
 1 files changed, 41 insertions(+), 20 deletions(-)

diff --git a/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/MdmIOServiceImpl.java b/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/MdmIOServiceImpl.java
index 4696e02..57d9c79 100644
--- a/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/MdmIOServiceImpl.java
+++ b/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/MdmIOServiceImpl.java
@@ -3,6 +3,7 @@
 import com.alibaba.fastjson.JSONObject;
 import com.alibaba.nacos.common.utils.StringUtils;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.google.protobuf.ServiceException;
 import com.vci.ubcs.code.applyjtcodeservice.feign.IMdmInterJtClient;
 import com.vci.ubcs.code.bo.AttributeValue;
 import com.vci.ubcs.code.bo.CodeClassifyFullInfoBO;
@@ -65,6 +66,7 @@
 import java.io.File;
 import java.io.IOException;
 import java.text.MessageFormat;
+import java.text.SimpleDateFormat;
 import java.util.*;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.CopyOnWriteArrayList;
@@ -97,6 +99,10 @@
 
 	@Value("${batchadd.redis.time:6000000}")
 	public int BATCHADD_REDIS_TIME;
+
+	@Value("${batchadd.import_data_limit:5001}")
+	private Integer IMPORT_DATA_LIMIT;
+
 	/**
 	 * 涓婚搴撳垎绫荤殑鏈嶅姟
 	 */
@@ -397,9 +403,9 @@
 			LinkedList<WriteExcelData> excelDataList = new LinkedList<>();
 			Workbook workbook = new HSSFWorkbook();
 			if(isHistory){
-				excelDataList.add(new WriteExcelData(0,0,"鍒嗙被璺緞"));
-				excelDataList.add(new WriteExcelData(0,1,"鐮佹瀹藉害"));
-				excelDataList.add(new WriteExcelData(0,2,!CollectionUtils.isEmpty(idAttrVOList)?idAttrVOList.get(0).getName():"浼佷笟缂栫爜"));
+				excelDataList.add(new WriteExcelData(0,0,"鍒嗙被璺緞",""));
+				excelDataList.add(new WriteExcelData(0,1,"鐮佹瀹藉害",""));
+				excelDataList.add(new WriteExcelData(0,2,!CollectionUtils.isEmpty(idAttrVOList)?idAttrVOList.get(0).getName():"浼佷笟缂栫爜",idAttrVOList.get(0).getId()));
 			}
 			for (int i = 0; i < templateAttrVOS.size(); i++) {
 				CodeClassifyTemplateAttrVO attrVO = templateAttrVOS.get(i);
@@ -407,7 +413,7 @@
 				Object text = attrVO.getName();
 				text = exportKeyAndRequired(workbook,attrVO,text);
 				int colIndex = (isHistory?3:0) + i;
-				WriteExcelData excelData = new WriteExcelData(0, colIndex, text);
+				WriteExcelData excelData = new WriteExcelData(0, colIndex, text,attrVO.getId());
 				if(StringUtils.isNotBlank(attrVO.getCodeDateFormat())
 					|| VciFieldTypeEnum.VTDateTime.name().equalsIgnoreCase(attrVO.getAttributeDataType())
 					|| VciFieldTypeEnum.VTDate.name().equalsIgnoreCase(attrVO.getAttributeDataType())
@@ -787,11 +793,15 @@
 		String uuid=VciBaseUtil.getPk();
 		boolean isCreateUUid=false;
 		boolean isExport=false;
-		long start = System.currentTimeMillis();
+		//long start = System.currentTimeMillis();
 		for(int i=0;i<sheetDataSetList.size()-1;i++) {
 			if (CollectionUtils.isEmpty(sheetDataSetList) || CollectionUtils.isEmpty(sheetDataSetList.get(i).getRowData())
 				|| sheetDataSetList.get(i).getRowData().size() < 1) {
 				continue;
+			}
+			// 鍗曟瀵煎叆鏁伴噺闄愬埗
+			if(sheetDataSetList.get(i).getRowData().size() > IMPORT_DATA_LIMIT){
+				throw new ServiceException("涓轰簡淇濊瘉绯荤粺鐨勭ǔ瀹氭�э紝璇蜂竴娆′笉瑕佸鍏ヨ秴杩�"+IMPORT_DATA_LIMIT+"鏉$殑鏁版嵁");
 			}
 			//鍘嗗彶瀵煎叆鐨勬椂鍊欎笉澶勭悊缂栫爜
 			//----閫昏緫鍐呭----
@@ -815,7 +825,7 @@
 			//鎵剧涓�琛岋紝涓轰簡鎵炬爣棰�
 			CodeClassifyTemplateVO templateVO = new CodeClassifyTemplateVO();
 			/**  if (!templateService.checkChildHasSameTemplate(classifyFullInfo.getCurrentClassifyVO().getOid())) {
-			 throw new VciBaseException("褰撳墠鐨勫垎绫讳互鍙婁笅绾у垎绫荤殑妯℃澘涓嶇浉鍚�");
+			 	throw new VciBaseException("褰撳墠鐨勫垎绫讳互鍙婁笅绾у垎绫荤殑妯℃澘涓嶇浉鍚�");
 			 }***/
 			//閮借浆鎹㈠畬浜嗐�傞渶瑕佹壒閲忔鏌�
 			//鎵炬墍鏈夌殑鍒嗙被璺緞,闇�瑕佹牎楠岃矾寰勬槸鍚︽纭紝鏄惁閮藉湪褰撳墠鐨勫垎绫荤殑涓嬬骇
@@ -932,7 +942,8 @@
 			if (CollectionUtils.isEmpty(ruleOidMap.values())) {
 				throw new VciBaseException("瀵煎叆鐨勬暟鎹墍閫夋嫨鐨勫垎绫婚兘娌℃湁璁剧疆缂栫爜瑙勫垯");
 			}
-			Map<String, CodeRuleVO> ruleVOMap = ruleService.listCodeRuleByIds(ruleOidMap.values(), true).stream().collect(Collectors.toMap(s -> s.getOid(), t -> t));
+			// TODO: 鏀圭敤oid鏌ヨ瑙勫垯鐨勶紝鍒敤id
+			Map<String, CodeRuleVO> ruleVOMap = ruleService.listCodeRuleByOids(ruleOidMap.values()).stream().collect(Collectors.toMap(s -> s.getOid(), t -> t));
 			//鏍¢獙缂栫爜瑙勫垯鍜岀爜娈垫槸鍚︽纭�
 			Map<String, List<String>> ruleRowIndexMap = new ConcurrentHashMap<>();
 			checkSecLengthInHistory(cboList, classifyVOMap, ruleVOMap, ruleOidMap, errorMap, ruleRowIndexMap);
@@ -1027,7 +1038,7 @@
 					//VciBaseUtil.setCurrentUserSessionInfo(sessionInfo);
 					List<String> rowIndexList = ruleRowIndexMap.get(ruleOid);
 					List<ClientBusinessObject> thisCbos = finalNeedSaveCboList.stream().filter(cbo -> rowIndexList.contains(cbo.getAttributeValue(IMPORT_ROW_INDEX)) && !errorMap.containsKey(cbo.getAttributeValue(IMPORT_ROW_INDEX))).collect(Collectors.toList());
-					List<BaseModel> dataCBOList=new ArrayList<>();
+					List<BaseModel> dataCBOList=new CopyOnWriteArrayList<>();
 					thisCbos.stream().forEach(clientBusinessObject -> {
 						BaseModel baseModel=new BaseModel();
 						BeanUtil.convert(clientBusinessObject,baseModel);
@@ -1044,7 +1055,7 @@
 							log.error("鎵归噺浜х敓缂栫爜鐨勬椂鍊欏嚭閿欎簡", e);
 							thisCbos.stream().forEach(cbo -> {
 								String rowIndex = cbo.getAttributeValue(IMPORT_ROW_INDEX);
-								errorMap.put(rowIndex, errorMap.getOrDefault(rowIndex, "") + ";绯荤粺閿欒锛屽瓨鍌ㄦ暟鎹殑鏃跺�欏嚭閿欎簡");
+								errorMap.put(rowIndex, errorMap.getOrDefault(rowIndex, "") + ";绯荤粺閿欒锛屽瓨鍌ㄦ暟鎹殑鏃跺�欏嚭閿欎簡:"+e.getMessage());
 							});
 
 						}
@@ -1057,7 +1068,7 @@
 				engineService.batchSaveSelectChar(templateVO, dataCBOIdList);
 			}
 		}
-		long end = System.currentTimeMillis();
+		//long end = System.currentTimeMillis();
 		//log.info("=============for鎵ц鏃堕棿================="+String.valueOf((end-start)/1000));
 		String excelFileName="";
 		if(isExport&&!CollectionUtils.isEmpty(shetNameMap)) {
@@ -1138,7 +1149,6 @@
 	 * @param currentTemplateVO
 	 * @param templateColumnVOMap
 	 */
-
 	private void createTemplate(CodeClassifyTemplateVO currentTemplateVO,Map<String,List<ColumnVO>>templateColumnVOMap){
 
 		List<CodeClassifyTemplateAttrVO> templateAttrVOS = currentTemplateVO.getAttributes().stream().filter(s ->
@@ -1749,7 +1759,8 @@
 				Map<String/**鍒嗙被涓婚敭**/, String/**瑙勫垯涓婚敭**/> ruleOidMap = new ConcurrentHashMap<String, String>();
 				List<String> unExistRuleClassifyOidList = new CopyOnWriteArrayList<>();
 				checkRuleOidInHistory(classifyVOMap, ruleOidMap, unExistRuleClassifyOidList);
-				ruleVOMap = ruleService.listCodeRuleByIds(ruleOidMap.values(), true).stream().collect(Collectors.toMap(s -> s.getOid(), t -> t));
+				// TODO	鏀圭敤oid鏌ヨ鐨勶紝杩欏効涓嶈鐢╥d
+				ruleVOMap = ruleService.listCodeRuleByOids(ruleOidMap.values()).stream().collect(Collectors.toMap(s -> s.getOid(), t -> t));
 
 				checkSecLengthInHistory(cboList, classifyVOMap, ruleVOMap, ruleOidMap, errorMap, ruleRowIndexMap);
 			}
@@ -2364,6 +2375,7 @@
 			String dataStatus=cbo.getLcStatus();
 			RowDatas rowData=codeDataMap.get(code);
 			String status=rowData.getStatus();
+			String lastModifier= rowData.getEditor();
 			String operation=rowData.getOperation();
 			if (cbo.getTs().compareTo(orderDTO.getTs())==0?false:true) {
 				// throw new VciBaseException("鏁版嵁涓嶆槸鏈�鏂扮殑锛屽彲鑳戒粬浜哄凡缁忎慨鏀癸紝璇峰埛鏂板悗鍐嶈瘯");
@@ -2394,12 +2406,20 @@
 				cbo.setName(orderDTO.getName());
 				try {
 					cbo.setAttributeValueWithNoCheck("description", orderDTO.getDescription());
-					cbo.setAttributeValue("name", orderDTO.getName());
+				//	cbo.setAttributeValue("name", orderDTO.getName());
 					//  if(finalIsProcess){//鍦ㄦ祦绋嬩腑涓嶅厑璁告洿鏀�
 					//     errorMap.put(code,errorMap.getOrDefault(code, errorMap.getOrDefault(code,"")+";鏁版嵁"+code+"鍦ㄦ祦绋嬩腑锛屼笉鍏佽鏇存敼!"));
 					//  }else{
+					Date date=new Date();
 					cbo.setLcStatus(status);
 					cbo.setAttributeValue("lcstatus",status);
+					cbo.setLastModifyTime(date);
+					cbo.setLastModifier(lastModifier);
+					cbo.setLastModifyTime(date);
+					cbo.setAttributeValue("lastmodifier",lastModifier);
+					cbo.setAttributeValue("lastmodifytime",new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS").format(date));
+					cbo.setTs(date);
+					cbo.setAttributeValue("ts",new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS").format(date));
 					//  }
 				} catch (VciBaseException e) {
 					e.printStackTrace();
@@ -2745,10 +2765,10 @@
 //					if (lifeCycleVO != null) {
 //						cbo.setLcStatus(lifeCycleVO.getStartStatus());
 //					} else {
-					cbo.setLcStatus(CodeDefaultLC.EDITING.getValue());
+					cbo.setLcStatus(CodeDefaultLC.RELEASED.getValue());
 //					}
 				} else {
-					cbo.setLcStatus(CodeDefaultLC.EDITING.getValue());
+					cbo.setLcStatus(CodeDefaultLC.RELEASED.getValue());
 				}
 
 			}
@@ -2936,7 +2956,7 @@
 						for (int j = 0; j < ruleVO.getSecVOList().size(); j++) {
 							CodeBasicSecVO secVO = ruleVO.getSecVOList().get(j);
 							String length= secValues[j];
-							if(StringUtils.isNotBlank(secVO.getCodeSecLength())&&VciBaseUtil.getInt(length)>VciBaseUtil.getInt(secVO.getCodeSecLength())){
+							if(StringUtils.isNotBlank(secVO.getCodeSecLength())&&VciBaseUtil.getInt(length)>(VciBaseUtil.getInt(secVO.getCodeSecLength())+((secVO.getPrefixCode()+secVO.getSuffixCode()).length()))){
 								errorMap.put(rowIndex,errorMap.getOrDefault(rowIndex,"") + ";鐮佹瀹藉害涓庣郴缁熶腑鐨勭紪鐮佽鍒欎笉鍚�" );
 								fined = true;
 								break;
@@ -3114,7 +3134,7 @@
 						Integer userSecret = VciBaseUtil.getCurrentUserSecret();
 						cbo.setAttributeValue(SECRET_FIELD,String.valueOf((userSecret==null || userSecret ==0)? UserSecretEnum.NONE.getValue():userSecret));
 					}
-					cbo.setLcStatus(CodeDefaultLC.EDITING.getValue());
+					cbo.setLcStatus(CodeDefaultLC.RELEASED.getValue());
 				}else{
 					//姝ゆ椂杩樻病鏈夎浆鎹㈣矾寰�
 					//cbo.setAttributeValue(CODE_FULL_PATH_FILED, childOidPathMap.getOrDefault(rowData.getData().getOrDefault(CODE_CLASSIFY_OID_FIELD,""),fullPath));
@@ -3171,7 +3191,7 @@
 						Integer userSecret = VciBaseUtil.getCurrentUserSecret();
 						cbo.setAttributeValue(SECRET_FIELD,String.valueOf((userSecret==null || userSecret ==0)? UserSecretEnum.NONE.getValue():userSecret));
 					}
-					cbo.setLcStatus(CodeDefaultLC.EDITING.getValue());
+					cbo.setLcStatus(CodeDefaultLC.RELEASED.getValue());
 				}else{
 					//姝ゆ椂杩樻病鏈夎浆鎹㈣矾寰�
 					//cbo.setAttributeValue(CODE_FULL_PATH_FILED, childOidPathMap.getOrDefault(rowData.getData().getOrDefault(CODE_CLASSIFY_OID_FIELD,""),fullPath));
@@ -3737,7 +3757,8 @@
 							}
 						}
 						CodeClassifyFullInfoBO newClassifyFullInfo= classifyFullInfoMap.get(cbo.getAttributeValue(CODE_CLASSIFY_OID_FIELD));
-						List<CodeClassifyVO> classifyVOS = newClassifyFullInfo.getParentClassifyVOs().stream().sorted(((o1, o2) -> o2.getDataLevel().compareTo(o1.getDataLevel()))).collect(Collectors.toList());
+						List<CodeClassifyVO> classifyVOS = newClassifyFullInfo.getParentClassifyVOs().stream().sorted(((o1, o2) -> -o2.getDataLevel().compareTo(o1.getDataLevel()))).collect(Collectors.toList());
+
 						int level = VciBaseUtil.getInt(attrVO.getClassifyInvokeLevel());
 						if (classifyVOS.size()>=level && level > 0 ) {
 							classifyVO = classifyVOS.get(level-1);
@@ -3796,7 +3817,7 @@
 		//2.鍒ゆ柇鍏抽敭灞炴�у湪绯荤粺閲屾槸鍚﹂噸澶�
 		//鍥犱负鏁版嵁閲忓緢澶э紝鎵�浠ュ緱鎯冲姙娉曞苟琛�
 		//SessionInfo sessionInfo = VciBaseUtil.getCurrentUserSessionInfo();
-		Map<String,List<BaseModel>> indexTODataMap=new HashMap<>();
+		Map<String,List<BaseModel>> indexTODataMap=new ConcurrentHashMap<>();
 		List<ClientBusinessObject> repeatDataMap = cboList.parallelStream().filter(cbo -> {
 			//姣忚閮藉緱鏌ヨ.濡傛灉鍏朵腑鍑虹幇浜嗛敊璇紝鎴戜滑灏辩洿鎺ユ姏鍑哄紓甯革紝鍏朵綑鐨勬樉绀�
 			//VciBaseUtil.setCurrentUserSessionInfo(sessionInfo);

--
Gitblit v1.9.3