From 9cacfb217b2dbf58c7efd1d96e818798a97d9382 Mon Sep 17 00:00:00 2001
From: ludc <pUXmgxCf6A>
Date: 星期四, 18 五月 2023 20:13:08 +0800
Subject: [PATCH] 以及发布webservice接口功能搭建,将通通用接口移植过来

---
 Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/MdmIOServiceImpl.java |  475 +++++++++++++----------------------------------------------
 1 files changed, 107 insertions(+), 368 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 f313a07..92eca05 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
@@ -1,419 +1,158 @@
 package com.vci.ubcs.code.service.impl;
 
-import com.alibaba.nacos.common.utils.StringUtils;
+import com.alibaba.cloud.commons.lang.StringUtils;
 import com.vci.ubcs.code.bo.CodeClassifyFullInfoBO;
 import com.vci.ubcs.code.dto.CodeOrderDTO;
 import com.vci.ubcs.code.service.ICodeClassifyService;
 import com.vci.ubcs.code.service.MdmEngineService;
 import com.vci.ubcs.code.service.MdmIOService;
-import com.vci.ubcs.code.vo.CodeClstemplateVO;
 import com.vci.ubcs.code.vo.pagemodel.CodeClassifyTemplateAttrVO;
+import com.vci.ubcs.code.vo.pagemodel.CodeClassifyTemplateVO;
 import com.vci.ubcs.code.vo.pagemodel.CodeClassifyVO;
-import com.vci.ubcs.code.vo.pagemodel.CodeImProtRusultVO;
-import com.vci.ubcs.starter.bo.WriteExcelData;
+import com.vci.ubcs.code.vo.pagemodel.CodeRuleVO;
+import com.vci.ubcs.code.vo.webserviceModel.attrmap.DataObjectVO;
+import com.vci.ubcs.code.vo.webserviceModel.attrmap.RowDatas;
+import com.vci.ubcs.code.vo.webserviceModel.result.xml.XMLResultDataObjectDetailDO;
 import com.vci.ubcs.starter.exception.VciBaseException;
-import com.vci.ubcs.starter.poi.bo.ReadExcelOption;
-import com.vci.ubcs.starter.poi.bo.SheetDataSet;
-import com.vci.ubcs.starter.poi.bo.SheetRowData;
-import com.vci.ubcs.starter.poi.bo.WriteExcelOption;
-import com.vci.ubcs.starter.poi.util.ExcelUtil;
-import com.vci.ubcs.starter.util.LocalFileUtil;
-import com.vci.ubcs.starter.web.enumpck.VciFieldTypeEnum;
-import com.vci.ubcs.starter.web.pagemodel.KeyValue;
 import com.vci.ubcs.starter.web.util.VciBaseUtil;
-import com.vci.ubcs.starter.web.util.VciDateUtil;
-import org.apache.poi.hssf.usermodel.HSSFRichTextString;
-import org.apache.poi.hssf.usermodel.HSSFWorkbook;
-import org.apache.poi.hssf.util.HSSFColor;
-import org.apache.poi.ss.usermodel.Font;
-import org.apache.poi.ss.usermodel.RichTextString;
-import org.apache.poi.ss.usermodel.Workbook;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.context.annotation.Lazy;
 import org.springframework.stereotype.Service;
 import org.springframework.util.CollectionUtils;
 
 import javax.annotation.Resource;
-import java.io.File;
 import java.util.*;
 import java.util.stream.Collectors;
 
-import static com.alibaba.druid.util.FnvHash.Constants.LIMIT;
-import static com.vci.ubcs.code.constant.MdmEngineConstant.CODE_FIELD;
-import static com.vci.ubcs.code.constant.MdmEngineConstant.DEFAULT_ATTR_LIST;
+import static com.vci.ubcs.code.constant.MdmEngineConstant.*;
 import static com.vci.ubcs.starter.poi.util.ExcelUtil.KEY_ATTR_CHAR;
 import static com.vci.ubcs.starter.poi.util.ExcelUtil.REQUIRED_CHAR;
 
 @Service
+@Slf4j
 public class MdmIOServiceImpl implements MdmIOService {
-
-
 	/**
-	 * 涓婚搴撳垎绫荤殑鏈嶅姟
+	 * 鍒嗙被鏈嶅姟灞�
 	 */
 	@Resource
+	@Lazy
 	private ICodeClassifyService classifyService;
 
 	/**
-	 * 妯℃澘鐨勬湇鍔�
+	 * 鍒嗙被鏈嶅姟灞�
 	 */
 	@Resource
-	private CodeClstemplateServiceImpl templateService;
-
-	/**
-	 * 涓绘暟鎹紩鎿庣殑鏈嶅姟
-	 */
-	@Resource
+	@Lazy
 	private MdmEngineService engineService;
 
 	/**
-	 * 鐢熸垚瀵煎叆鐨勬枃浠�
-	 *
-	 * @param codeClassifyOid 鍒嗙被鐨勪富閿�
-	 * @param isHistory 鏄惁鍘嗗彶鏁版嵁瀵煎叆
-	 * @return excel鐨勬枃浠跺湴鍧�
+	 * 闆嗘垚鎵归噺鐢宠鏁版嵁
+	 * @param orderDTO 鍒嗙被鐨勪富閿�
+	 * @param dataObjectVO 鏁版嵁淇℃伅
+	 * @param resultDataObjectDetailDOs 閿欒淇℃伅
+	 * @return 鏈夐敊璇俊鎭殑excel
 	 */
 	@Override
-	public String createImportExcel(String codeClassifyOid, boolean isHistory) {
-		List<CodeClstemplateVO> templateVOList=new ArrayList<>();
-
-		VciBaseUtil.alertNotNull("瀵煎嚭妯℃澘","瀵煎嚭鐨勯厤缃�",codeClassifyOid,"涓婚搴撳垎绫荤殑涓婚敭");
-
-		CodeClassifyVO codeClassifyVO = classifyService.getObjectByOid(codeClassifyOid);
-
-		if(isHistory){
-			templateVOList= templateService.childTemplates(codeClassifyOid);
-		}else{
-			//鎵炬ā鏉�
-			CodeClstemplateVO templateVO = engineService.getUsedTemplateByClassifyOid(codeClassifyOid);
-			templateVOList.add(templateVO);
-		}
-
-		WriteExcelOption eo = new WriteExcelOption();
-		eo.setAppend(true);
-		//澧炲姞妯℃澘鐨勪俊鎭鍏�
-		LinkedList<WriteExcelData> tempEDList = new LinkedList<>();
-		tempEDList.add(new WriteExcelData(0,0,"妯℃澘涓婚敭"));
-		tempEDList.add(new WriteExcelData(0,1,"妯℃澘浠e彿"));
-		tempEDList.add(new WriteExcelData(0,2,"妯℃澘鍚嶇О"));
-		for(int j=0;j<templateVOList.size();j++){
-			CodeClstemplateVO  templateVO=templateVOList.get(j);
-
-			//缁勫悎鏍煎紡鐨勪笉瀵煎叆锛�
-			// 鏋氫妇鐨勬彁渚涘簭鍒楃殑閫夋嫨
-			//鏃堕棿鍏ㄩ儴缁熶竴涓簓yyy-MM-dd HH:mm:ss
-			//鍙傜収鐨勮嚜琛岃緭鍏ュ悕绉�
-			//鍒嗙被娉ㄥ叆鐨勪笉鐢紝閮芥槸瀵煎叆鍚庤嚜鍔ㄥ鐞嗙殑
-			//缂栫爜锛岀姸鎬佺瓑瀛楁涓嶅鍏�
-			List<CodeClassifyTemplateAttrVO> templateAttrVOS = templateVO.getAttributes().stream().filter(s ->
-				!DEFAULT_ATTR_LIST.contains(s.getId())
-					&& StringUtils.isBlank(s.getComponentRule())
-					&& StringUtils.isBlank(s.getClassifyInvokeAttr())
-					&& (isHistory || VciBaseUtil.getBoolean(s.getFormDisplayFlag()))
-			).collect(Collectors.toList());
-
-			if(CollectionUtils.isEmpty(templateAttrVOS)){
-				throw new VciBaseException("妯℃澘娌℃湁閰嶇疆浠讳綍銆愯〃鍗曟樉绀恒�戜负銆愭槸銆戠殑灞炴��");
-			}
-			List<CodeClassifyTemplateAttrVO> idAttrVOList = templateVO.getAttributes().stream().filter(s -> s.getId().equalsIgnoreCase(CODE_FIELD)).collect(Collectors.toList());
-			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():"浼佷笟缂栫爜"));
-			}
-			for (int i = 0; i < templateAttrVOS.size(); i++) {
-				CodeClassifyTemplateAttrVO attrVO = templateAttrVOS.get(i);
-
-				Object text = attrVO.getName();
-				text = exportKeyAndRequired(workbook,attrVO,text);
-				int colIndex = (isHistory?3:0) + i;
-				WriteExcelData excelData = new WriteExcelData(0, colIndex, text);
-				if(StringUtils.isNotBlank(attrVO.getCodeDateFormat())
-					|| VciFieldTypeEnum.VTDateTime.name().equalsIgnoreCase(attrVO.getAttributeDataType())
-					|| VciFieldTypeEnum.VTDate.name().equalsIgnoreCase(attrVO.getAttributeDataType())
-					||VciFieldTypeEnum.VTTime.name().equalsIgnoreCase(attrVO.getAttributeDataType())){
-					excelData.setDateFormat(VciDateUtil.DateTimeFormat);
-				}
-				if(text instanceof RichTextString){
-					excelData.setFontColor(String.valueOf(HSSFColor.HSSFColorPredefined.RED.getIndex()));
-				}
-				excelDataList.add(excelData);
-				if(StringUtils.isNotBlank(attrVO.getEnumString()) || StringUtils.isNotBlank(attrVO.getEnumId())){
-					//娣诲姞鏁版嵁鏈夋晥鎬�
-					List<String> enumValueList = new ArrayList<>();
-					enumValueList.add("");
-					List<KeyValue> valueList = engineService.listComboboxItems(attrVO);
-					if(!CollectionUtils.isEmpty(valueList)){
-						valueList.stream().forEach(kv->{
-							enumValueList.add(kv.getValue());
-						});
-					}
-					//榛樿鍔�1涓囨潯
-					WriteExcelData ed = new WriteExcelData(1,colIndex,"");
-					ed.setRowTo(100);
-					ed.setColTo(colIndex);
-					ed.setValidation(true);
-					ed.setValidationDataList(enumValueList);
-					ed.setValidationErrorMsg("璇峰湪搴忓垪涓�夋嫨姝g‘鐨勫��");
-					excelDataList.add(ed);
-				}
-				if(VciFieldTypeEnum.VTBoolean.name().equalsIgnoreCase(attrVO.getAttributeDataType())){
-					List<String> booleanList = new ArrayList<>();
-
-					booleanList.add("鏄�");
-					booleanList.add("鍚�");
-					//榛樿鍔�1涓囨潯
-					WriteExcelData ed = new WriteExcelData(1,colIndex,"");
-					ed.setRowTo(100);
-					ed.setColTo(colIndex);
-					ed.setValidation(true);
-					ed.setValidationDataList(booleanList);
-					ed.setValidationErrorMsg("璇峰湪搴忓垪涓�夋嫨姝g‘鐨勫��");
-					excelDataList.add(ed);
-				}
-			}
-			eo.addSheetDataList(j+templateVO.getName(),excelDataList);
-			tempEDList.add(new WriteExcelData(j+1,0,templateVO.getOid()));
-			tempEDList.add(new WriteExcelData(j+1,1,templateVO.getId()));
-			tempEDList.add(new WriteExcelData(j+1,2,templateVO.getName()));
-		}
-		String excelName = LocalFileUtil.getDefaultTempFolder() + File.separator + codeClassifyVO.getName() + (isHistory?"_鍘嗗彶鏁版嵁瀵煎叆妯℃澘.xls": "_瀵煎叆妯℃澘.xls");
-		eo.addSheetDataList(templateVOList.size()+"妯℃澘淇℃伅銆愯鍕垮垹闄ゆ垨绉诲姩銆�",tempEDList);
-		ExcelUtil.writeDataToFile(excelName,eo);
-		return excelName;
-	}
-
-	/**
-	 * 瀵煎嚭鐨勬椂鍊欏皝瑁呭繀杈撳拰鍏抽敭灞炴��
-	 * @param attrVO 灞炴�х殑鏄剧ず瀵硅薄
-	 * @param text 鍗曞厓鏍肩殑鍊�
-	 */
-	private Object exportKeyAndRequired(Workbook workbook,CodeClassifyTemplateAttrVO attrVO,Object text){
-		//蹇呰緭鍔�*锛屽叧閿睘鎬т负钃濊壊
-		if (VciBaseUtil.getBoolean(attrVO.getRequireFlag()) || VciBaseUtil.getBoolean(attrVO.getKeyAttrFlag())) {
-			String value = text.toString();
-			if(VciBaseUtil.getBoolean(attrVO.getRequireFlag())) {
-				value += REQUIRED_CHAR;
-			}
-			if(VciBaseUtil.getBoolean(attrVO.getKeyAttrFlag())){
-				value += KEY_ATTR_CHAR;
-			}
-			RichTextString ts = new HSSFRichTextString(value);
-			if(VciBaseUtil.getBoolean(attrVO.getRequireFlag())){
-				Font font =  workbook.createFont();
-				font.setColor(HSSFColor.HSSFColorPredefined.RED.getIndex());
-				ts.applyFont(font);
-			}
-
-			if(VciBaseUtil.getBoolean(attrVO.getKeyAttrFlag())){
-				Font font =  workbook.createFont();
-				font.setColor(HSSFColor.HSSFColorPredefined.BLUE.getIndex());
-				ts.applyFont(font);
-			}
-			return ts;
-		}
-		return text;
-	}
-
-
-	/**
-	 * 鎵归噺鐢宠缂栫爜鏁版嵁
-	 *
-	 * @param orderDTO 缂栫爜鐢宠淇℃伅锛屽繀椤诲寘鍚垎绫讳富閿拰鐮佹鐨勪俊鎭�
-	 * @param file     excel鏂囦欢鐨勪俊鎭�
-	 * @return  鏈夐敊璇俊鎭殑excel鐨勬枃浠�
-	 */
-	@Override
-	public CodeImProtRusultVO batchImportCode(CodeOrderDTO orderDTO, File file) {
+	public void batchSyncApplyCode(CodeOrderDTO orderDTO, DataObjectVO dataObjectVO, LinkedList<XMLResultDataObjectDetailDO> resultDataObjectDetailDOs) {
+		Map<String,String> errorMap=new HashMap<>();
 		VciBaseUtil.alertNotNull(orderDTO,"缂栫爜鐢宠鐩稿叧鐨勬暟鎹�",orderDTO.getCodeClassifyOid(),"涓婚搴撳垎绫讳富閿�");
-		ReadExcelOption reo = new ReadExcelOption();
-		reo.setReadAllSheet(true);
-		List<SheetDataSet> sheetDataSetList = ExcelUtil.readDataObjectFromExcel(file,null,reo);
-		if(CollectionUtils.isEmpty(sheetDataSetList) || CollectionUtils.isEmpty(sheetDataSetList.get(0).getRowData())
-			||sheetDataSetList.get(0).getRowData().size()<1){
-			throw new VciBaseException("娌℃湁璇诲彇鍒颁换浣曠殑鏁版嵁");
-		}
-		if(sheetDataSetList.size()>LIMIT+1){
-			throw new VciBaseException("涓轰簡淇濊瘉绯荤粺鐨勭ǔ瀹氭�э紝璇蜂竴娆′笉瑕佸鍏ヨ秴杩�1涓囨潯鐨勬暟鎹�");
-		}
+		CodeClassifyFullInfoBO classifyFullInfo = classifyService.getClassifyFullInfo(orderDTO.getCodeClassifyOid());
+		//瑙勫垯鐨勪富閿渶瑕佸幓鑾峰彇
+		CodeRuleVO ruleVO = engineService.getCodeRuleByClassifyFullInfo(classifyFullInfo);
+		//1.鍒ゆ柇瑙勫垯涓櫎浜嗘祦姘寸爜娈碉紝鏄惁鏈夊叾浠栫爜娈�
+		//engineService.checkSecValueOnOrder(ruleVO,orderDTO);
+		//鏌ヨ鍒嗙被鍜屾ā鏉�
 		//鍏堟壘鍒版瘡涓�琛岀殑鏍囬锛岀劧鍚庢牴鎹爣棰樻潵鑾峰彇瀵瑰簲鐨勫睘鎬�
-		SheetDataSet dataSet = sheetDataSetList.get(0);
+		List<RowDatas> rowDataList = dataObjectVO.getRowData();
+		Map<String , RowDatas>rowDataMap=new LinkedHashMap<>();
+		rowDataList.stream().forEach(rowData->{
+			rowDataMap.put(rowData.getRowIndex(),rowData);
+		});
 		//鎵剧涓�琛岋紝涓轰簡鎵炬爣棰�
-		CodeClstemplateVO templateVO = engineService.getUsedTemplateByClassifyOid(orderDTO.getCodeClassifyOid());
+		CodeClassifyTemplateVO templateVO = engineService.getUsedTemplateByClassifyOid(orderDTO.getCodeClassifyOid());
 
 		//鏍¢獙妯℃澘鏄笉鏄渶鏂扮殑
-		checkTemplateSync(sheetDataSetList,templateVO,0);
-		//鍏堜笉鐢ㄧ灞炴�ф槸鍚﹂兘瀛樺湪锛屽厛杞崲涓�涓嬫暟鎹�
-		Map<String,String> errorMap = new HashMap<>();
-		String redisUUid=batchImportCodes(orderDTO,templateVO,dataSet,errorMap,true);
-		CodeImProtRusultVO codeImProtRusultVO = new CodeImProtRusultVO();
-		List<String> needRowIndexList = new ArrayList<>();
-//		String filePath = returnErrorToExcel(dataSet.getRowData(), errorMap, needRowIndexList, dataSet.getColName());
-//		if(StringUtils.isNotBlank(filePath)) {
-//			codeImProtRusultVO.setFilePath(filePath);
-//		}
-//		if(StringUtils.isNotBlank(redisUUid)){
-//			codeImProtRusultVO.setRedisUuid(redisUUid);
-//		}
-		return null;
-//		return codeImProtRusultVO;
+		//checkTemplateSync(sheetDataSetList,templateVO);
+		//闄ゅ幓榛樿鐨勫睘鎬�.杩樻湁鍙湁琛ㄥ崟鏄剧ず鐨勫瓧娈垫墠瀵煎叆
+		List<CodeClassifyTemplateAttrVO> attrVOS = templateVO.getAttributes().stream().filter(s ->!DEFAULT_SYNC_ATTR_LIST.contains(s.getId()) && VciBaseUtil.getBoolean(s.getFormDisplayFlag())
+		).collect(Collectors.toList());
+		Map<Integer/**鍒楀彿**/,String/**瀛楁鐨勫悕绉�**/> fieldIndexMap = new HashMap<>();
+		List<String> titleRowData = dataObjectVO.getColName();
+		Map<String/**涓枃鍚嶇О**/, String/**鑻辨枃鍚嶇О**/> attrNameIdMap = attrVOS.stream().collect(Collectors.toMap(s -> s.getName(), t -> t.getId().toLowerCase(Locale.ROOT),(o1, o2)->o2));
+		getFieldIndexMap(titleRowData,attrNameIdMap,fieldIndexMap);
+
+		//闇�瑕佸垽鏂槸鍚︽墍鏈夌殑灞炴�ч兘鍦ㄦā鏉夸笂浜�
+		List<CodeClassifyTemplateAttrVO> unExistAttrVOs = attrVOS.stream().filter(s -> !fieldIndexMap.containsValue(s.getId().toLowerCase(Locale.ROOT))
+			&& StringUtils.isBlank(s.getComponentRule()) && StringUtils.isBlank(s.getClassifyInvokeAttr())//缁勫悎瑙勫垯鍜屽垎绫绘敞鍏ョ‘瀹炴病缁欑敤鎴峰鍑哄幓
+		).collect(Collectors.toList());
+		if(!CollectionUtils.isEmpty(unExistAttrVOs)){
+			throw new VciBaseException("銆�" + unExistAttrVOs.stream().map(CodeClassifyTemplateAttrVO::getName) + "銆戣繖浜涘睘鎬у湪excel涓病鏈夋壘鍒�");
+		}
+
+		String fullPath = getFullPath(classifyFullInfo);
+
+		// List<CodeClassifyProcessTempVO> codeClassifyProcessTempVOS=codeClassifyProcessTempService.listProcessTemplate(templateVO.getOid(),"code_cls_flow_use_order");
+		boolean isProcess=false;
+		//娉ㄩ噴鎺夋澶勪笅闈㈡墍鏈夐兘鎸夌収涓嶅垽鏂祦绋嬪瓨鍌ㄧ姸鎬佷簡
+		/** if(!CollectionUtils.isEmpty(codeClassifyProcessTempVOS)){
+		 isProcess=true;
+		 }***/
+		//List<ClientBusinessObject> cboList = new ArrayList<>();
+		//Map<String,String> codeOidToSystemOidMap=new HashMap<>();//瀛樺偍缂栫爜鏁版嵁鍜岄泦鎴愮郴缁熸暟鎹畂id瀵圭収鏄犲皠
+		//excelToCbo(classifyFullInfo,titleRowData,fieldIndexMap,rowDataList,templateVO,cboList,fullPath,isProcess,"create",errorMap,codeOidToSystemOidMap);
+
+		//閮借浆鎹㈠畬浜嗐�傞渶瑕佹壒閲忔鏌�
+		//濡傛灉鍑洪敊浜嗭紝鎴戜滑渚濈劧鎵ц鏈夋晥鐨勬暟鎹紝鏃犳晥鐨勬暟鎹啓鍥炲埌excel涓�
+		//2.鍒ゆ柇蹇呰緭椤广�傘�傞渶瑕佸叏閮ㄧ殑灞炴�э紝濡傛灉鏄繀杈擄紝浣嗘槸琛ㄥ崟閲岄潰涓嶆樉绀虹殑锛屽彧鑳芥槸鍒嗙被娉ㄥ叆鎴栬�呯粍鍚堣鍒�
+
+	}
+
+	@Override
+	public void batchSyncEditDatas(CodeClassifyVO codeClassifyVO, DataObjectVO dataObjectVO, LinkedList<XMLResultDataObjectDetailDO> resultDataObjectDetailDOs) {
+
 	}
 
 	/**
-	 * 鏍¢獙妯℃澘鏄惁涓哄悓姝ョ殑
-	 * @param sheetDataSetList excel閲岀殑鍐呭
-	 * @param templateVO 妯℃澘鐨勪俊鎭�
+	 * 鑾峰彇鍒嗙被鐨勫叏璺緞
+	 * @param classifyFullInfo 鍒嗙被鐨勫叏閮ㄤ俊鎭�
+	 * @return 鍏ㄨ矾寰�
 	 */
-	private void checkTemplateSync(List<SheetDataSet> sheetDataSetList,CodeClstemplateVO templateVO,int i){
-		String templateOidInExcel = "";
-		String templateName="";
-		if(!CollectionUtils.isEmpty(sheetDataSetList)
-			&& sheetDataSetList.size()>1 && !CollectionUtils.isEmpty(sheetDataSetList.get(sheetDataSetList.size()-1).getColName())){
-			List<SheetRowData>  rowData=  sheetDataSetList.get(sheetDataSetList.size()-1).getRowData();
-			templateName=rowData.get(i).getData().get(2);
-			templateOidInExcel=rowData.get(i).getData().get(0);
-			//templateOidInExcel = sheetDataSetList.get(sheetDataSetList.size()-1).getColName().get(sheetDataSetList.size()-i);
+	private String getFullPath(CodeClassifyFullInfoBO classifyFullInfo){
+		String fullPath = "";
+		if(!CollectionUtils.isEmpty(classifyFullInfo.getParentClassifyVOs())){
+			fullPath = classifyFullInfo.getParentClassifyVOs().stream().sorted(((o1, o2) -> o1.getDataLevel().compareTo(o2.getDataLevel())))
+				.map(CodeClassifyVO::getOid).collect(Collectors.joining("##"));
+		}else{
+			fullPath = classifyFullInfo.getCurrentClassifyVO().getOid();
 		}
-       /* if(!CollectionUtils.isEmpty(sheetDataSetList)
-                && sheetDataSetList.size()>1 && !CollectionUtils.isEmpty(sheetDataSetList.get(sheetDataSetList.size()-1).getColName())){
-            List<SheetRowData>  rowData=  sheetDataSetList.get(sheetDataSetList.size()-1).getRowData();
-            templateOidInExcel=rowData.get(i).getData().get(0);
-           //templateOidInExcel = sheetDataSetList.get(sheetDataSetList.size()-1).getColName().get(sheetDataSetList.size()-i);
-        }*/
-		if(StringUtils.isBlank(templateOidInExcel) || !templateOidInExcel.equalsIgnoreCase(templateVO.getOid())){
-			throw new VciBaseException("妯℃澘銆�"+templateName+"銆戜腑鐨勬暟鎹幏鍙栫殑妯$増淇℃伅涓庡綋鍓嶆ā鏉夸笉鍖归厤锛岃纭繚excel鏂囦欢閲屾湁銆愭ā鏉夸俊鎭�-璇峰嬁绉诲姩鎴栧垹闄ゃ�戠殑宸ヤ綔琛紝涓旂‘淇濇瘡娆″鍏ラ兘鏄厛涓嬭浇鐨勫鍏ユā鏉垮悗娣诲姞鐨勬暟鎹�");
-		}
+		return fullPath;
+	}
 
+	/**
+	 * excel鐨勬爣棰樹笂鑾峰彇瀛楁鎵�鍦ㄧ殑浣嶇疆
+	 * @param titleRowData 鏍囬鐨勫唴瀹�
+	 * @param attrNameIdMap 妯℃澘涓睘鎬у悕绉板拰鑻辨枃鐨勬槧灏�
+	 * @param fieldIndexMap 浣嶇疆鍜岃嫳鏂囧瓧娈电殑鏄犲皠
+	 */
+	private void getFieldIndexMap(List<String> titleRowData,Map<String/**鍚嶇О**/,String/**瀛楁鍚�**/> attrNameIdMap,Map<Integer/**浣嶇疆**/,String/**鑻辨枃鍚嶅瓧**/> fieldIndexMap){
+		for (int i = 0; i < titleRowData.size(); i++) {
+			String title = titleRowData.get(i);
+			String id = attrNameIdMap.getOrDefault(title.replace(KEY_ATTR_CHAR,"").replace(REQUIRED_CHAR
+				,""),"");
+			if(StringUtils.isBlank(id) && "鍒嗙被璺緞".equalsIgnoreCase(title)){
+				id = CODE_CLASSIFY_OID_FIELD;
+			}
+			if(StringUtils.isBlank(id) && "鐮佹瀹藉害".equalsIgnoreCase(title)){
+				id = CODE_SEC_LENGTH_FIELD;
+			}
+			if(StringUtils.isBlank(id) && "浼佷笟缂栫爜".equalsIgnoreCase(title)){
+				id = CODE_FIELD;
+			}
+			if(StringUtils.isNotBlank(id)){
+				fieldIndexMap.put(i,id);
+			}
+		}
 	}
 
 
-	/***
-	 * 鎵归噺澶勭悊鐢宠鏁版嵁
-	 * @param orderDTO
-	 * @param templateVO
-	 * @param dataSet
-	 * @return
-	 */
-	private String batchImportCodes(CodeOrderDTO orderDTO,CodeClstemplateVO templateVO,SheetDataSet dataSet,Map<String,String> errorMap,boolean isEnumType){
-		List<String> codeList=new ArrayList<>();
-//		CodeClassifyFullInfoBO classifyFullInfo = classifyService.getClassifyFullInfo(orderDTO.getCodeClassifyOid());
-		//瑙勫垯鐨勪富閿渶瑕佸幓鑾峰彇
-//		CodeRuleVO ruleVO = engineService.getCodeRuleByClassifyFullInfo(classifyFullInfo);
-//		//1.鍒ゆ柇瑙勫垯涓櫎浜嗘祦姘寸爜娈碉紝鏄惁鏈夊叾浠栫爜娈�
-//		engineService.checkSecValueOnOrder(ruleVO,orderDTO);
-//		List<SheetRowData> rowDataList = dataSet.getRowData();
-//
-//		//闄ゅ幓榛樿鐨勫睘鎬�.杩樻湁鍙湁琛ㄥ崟鏄剧ず鐨勫瓧娈垫墠瀵煎叆
-//		List<CodeClassifyTemplateAttrVO> attrVOS = templateVO.getAttributes().stream().filter(s ->
-//			!DEFAULT_ATTR_LIST.contains(s.getId()) && VciBaseUtil.getBoolean(s.getFormdisplayflag())
-//		).collect(Collectors.toList());
-//		Map<Integer/**鍒楀彿**/,String/**瀛楁鐨勫悕绉�**/> fieldIndexMap = new HashMap<>();
-//		List<String> titleRowData = dataSet.getColName();
-//		Map<String/**涓枃鍚嶇О**/, String/**鑻辨枃鍚嶇О**/> attrNameIdMap = attrVOS.stream().collect(Collectors.toMap(s -> s.getName(), t -> t.getId().toLowerCase(Locale.ROOT),(o1, o2)->o2));
-//		getFieldIndexMap(titleRowData,attrNameIdMap,fieldIndexMap);
-//
-//		//闇�瑕佸垽鏂槸鍚︽墍鏈夌殑灞炴�ч兘鍦ㄦā鏉夸笂浜�
-//		List<CodeClassifyTemplateAttrVO> unExistAttrVOs = attrVOS.stream().filter(s -> !fieldIndexMap.containsValue(s.getId().toLowerCase(Locale.ROOT))
-//			&& StringUtils.isBlank(s.getComponentrule()) && StringUtils.isBlank(s.getClassifyinvokeattr())//缁勫悎瑙勫垯鍜屽垎绫绘敞鍏ョ‘瀹炴病缁欑敤鎴峰鍑哄幓
-//		).collect(Collectors.toList());
-//		if(!CollectionUtils.isEmpty(unExistAttrVOs)){
-//			throw new VciBaseException("銆�" + unExistAttrVOs.stream().map(CodeClassifyTemplateAttrVO::getName) + "銆戣繖浜涘睘鎬у湪鍒楄〃涓病鏈夋壘鍒�");
-//		}
-//		List<ClientBusinessObject> cboList = new ArrayList<>();
-//		String fullPath = getFullPath(classifyFullInfo);
-//		excelToCbo(classifyFullInfo,fieldIndexMap,rowDataList,templateVO,cboList,fullPath,true);
-//
-//		//閮借浆鎹㈠畬浜嗐�傞渶瑕佹壒閲忔鏌�
-//		//濡傛灉鍑洪敊浜嗭紝鎴戜滑渚濈劧鎵ц鏈夋晥鐨勬暟鎹紝鏃犳晥鐨勬暟鎹啓鍥炲埌excel涓�
-//		//2.鍒ゆ柇蹇呰緭椤广�傘�傞渶瑕佸叏閮ㄧ殑灞炴�э紝濡傛灉鏄繀杈擄紝浣嗘槸琛ㄥ崟閲岄潰涓嶆樉绀虹殑锛屽彧鑳芥槸鍒嗙被娉ㄥ叆鎴栬�呯粍鍚堣鍒�
-//		batchCheckRequiredAttrOnOrder(templateVO,cboList,errorMap);
-//		//3.鍒ゆ柇鍏抽敭灞炴��
-//		CodeImportResultVO keyResultVO = batchCheckKeyAttrOnOrder(classifyFullInfo, templateVO, cboList);
-//		Set<String> selfRepeatRowIndexList = keyResultVO.getSelfRepeatRowIndexList();
-//		Set<String> keyAttrRepeatRowIndexList = keyResultVO.getKeyAttrRepeatRowIndexList();
-//		if(!CollectionUtils.isEmpty(selfRepeatRowIndexList)){
-//			selfRepeatRowIndexList.stream().forEach(rowIndex->{
-//				errorMap.put(rowIndex,errorMap.getOrDefault(rowIndex,"") + ";鍦ㄥ綋鍓嶅鐞嗙殑鏁版嵁鏂囦欢涓叧閿睘鎬ч噸澶�" );
-//			});
-//		}
-//		if(!CollectionUtils.isEmpty(keyAttrRepeatRowIndexList)){
-//			keyAttrRepeatRowIndexList.stream().forEach(rowIndex->{
-//				errorMap.put(rowIndex,errorMap.getOrDefault(rowIndex,"") + ";鍏抽敭灞炴�т笌绯荤粺涓殑閲嶅" );
-//			});
-//		}
-//		//鍒嗙被娉ㄥ叆
-//		batchSwitchClassifyAttrOnOrder(attrVOS,cboList,classifyFullInfo,false);
-//		//boolean
-//		reSwitchBooleanAttrOnOrder(attrVOS,cboList);
-//		//4.鏍¢獙瑙勫垯
-//		batchCheckVerifyOnOrder(attrVOS, cboList,errorMap);
-//		if(isEnumType) {//鏄惁闇�瑕佹牎楠屾灇涓�/鍙傜収
-//			//5.鏍¢獙鏋氫妇鏄惁姝g‘
-//			batchSwitchEnumAttrOnOrder(attrVOS, cboList, errorMap);
-//			//7.澶勭悊鍙傜収鐨勬儏鍐�
-//			batchSwitchReferAttrOnOrder(attrVOS,cboList,errorMap);
-//		}
-//		//6.鏃堕棿鏍煎紡鐨勯獙璇�
-//		//6.鏃堕棿鐨勶紝蹇呴』缁熶竴涓簓yyy-MM-dd HH:mm:ss
-//		batchSwitchDateAttrOnOrder(attrVOS,cboList,errorMap);
-//		//鏈�鍚庡紕缁勫悎瑙勫垯
-//		batchSwitchComponentAttrOnOrder(attrVOS,cboList);
-//		String uuid=redisService.getUUIDEveryDay();
-//		Map<String, ClientBusinessObject> rowIndexCboMap = cboList.stream().filter(cbo -> cbo != null).collect(Collectors.toList()).stream().collect(Collectors.toMap(s -> s.getAttributeValue((IMPORT_ROW_INDEX)), t -> t));
-//
-//		if(errorMap.size()>0) {
-//			createRedisDatas(uuid + "-error",templateVO, rowIndexCboMap, dataSet, fieldIndexMap, errorMap,false);
-//		}
-//		boolean isCreateUUid=false;
-//		List<ClientBusinessObject> needSaveCboList = cboList.stream().filter(cbo -> {
-//			String rowIndex = cbo.getAttributeValue(IMPORT_ROW_INDEX);
-//			return !errorMap.containsKey(rowIndex);
-//		}).collect(Collectors.toList());
-//		//鐩镐技鏍¢獙
-//		Map<String,String>resembleMap=new HashMap<>();
-//		List<DataResembleVO> dataResembleVOS=new ArrayList<>();
-//		String btmtypeid= classifyFullInfo.getTopClassifyVO().getBtmtypeid();
-//		bathcResembleQuery(orderDTO.getCodeClassifyOid(),templateVO,needSaveCboList,resembleMap,btmtypeid,dataResembleVOS);
-//		if(resembleMap.size()>0) {
-//			isCreateUUid=true;
-//			if(!CollectionUtils.isEmpty(dataResembleVOS)) {
-//				redisService.setCacheList(uuid + "-resemble-data", dataResembleVOS);
-//				createRedisDatas(uuid + "-resemble",templateVO, rowIndexCboMap, dataSet, fieldIndexMap, resembleMap, false);
-//			}
-//		}
-//		//鎺掗櫎閿欒鐨勶紝鍓╀笅姝g‘鐨�
-//		Map<String,String> newErrorMap=new HashMap<>();
-//		newErrorMap.putAll(resembleMap);
-//		newErrorMap.putAll(errorMap);
-//		needSaveCboList = cboList.stream().filter(cbo -> {
-//			String rowIndex = cbo.getAttributeValue(IMPORT_ROW_INDEX);
-//			return !newErrorMap.containsKey(rowIndex);
-//		}).collect(Collectors.toList());
-//		if((errorMap.size()>0&&needSaveCboList.size()>0)||resembleMap.size()>0){
-//			isCreateUUid=true;
-//		}
-//		createRedisByCodeClassify(uuid + "-class",templateVO,dataSet,fieldIndexMap,false);
-//		if(newErrorMap.size()>0) {
-//			createRedisDatas(uuid + "-ok",templateVO, rowIndexCboMap, dataSet, fieldIndexMap, newErrorMap,true);
-//		}else {
-//			uuid="";
-//			//瑕佹妸浠ヤ笂鐨勯敊璇殑閮芥姏鍑哄悗锛屽啀缁х画澶勭悊鏃堕棿鍜岀粍鍚堣鍒�
-//			needSaveCboList = cboList.stream().filter(cbo -> {
-//				String rowIndex = cbo.getAttributeValue(IMPORT_ROW_INDEX);
-//				return !newErrorMap.containsKey(rowIndex);
-//			}).collect(Collectors.toList());
-//			if (!CollectionUtils.isEmpty(needSaveCboList)) {
-//				//9.鎴戜滑澶勭悊涓氬姟鏁版嵁
-//				//鐢熸垚缂栫爜鐨勫唴瀹�
-//				codeList = productCodeService.productCodeAndSaveData(classifyFullInfo, templateVO, ruleVO, orderDTO.getSecDTOList(), needSaveCboList);
-//				//濡傛灉鏄紪鐮佺敓鎴愬け璐ワ紝鍒欑洿鎺ュ氨澶辫触浜嗭紝鍏朵粬鐨勫垽鏂嚭鏉ユ湁閿欒鐨勬垜浠兘缁熶竴杩斿洖鍒癳xcel閲岄潰
-//				engineService.batchSaveSelectChar(templateVO, needSaveCboList);
-//			}
-//		}
-//		if(!isCreateUUid){
-//			return uuid="";
-//		}
-//		return uuid;
-		return null;
-	}
 }

--
Gitblit v1.9.3