From d334ce7945bf6a1243927c3b778d14dd493e9918 Mon Sep 17 00:00:00 2001
From: yuxc <653031404@qq.com>
Date: 星期一, 04 十二月 2023 08:43:45 +0800
Subject: [PATCH] 1、增加批量修改excel导入功能。 2、增加批量修改excel下载功能。
---
Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/MdmIOService.java | 16 ++
Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/MdmIOServiceImpl.java | 362 +++++++++++++++++++++++++++++++++++++++++++++
Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/controller/MdmEngineController.java | 66 ++++++++
3 files changed, 444 insertions(+), 0 deletions(-)
diff --git a/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/controller/MdmEngineController.java b/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/controller/MdmEngineController.java
index e4e3328..e82445c 100644
--- a/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/controller/MdmEngineController.java
+++ b/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/controller/MdmEngineController.java
@@ -90,6 +90,72 @@
* @param response 鍝嶅簲瀵硅薄
* @throws IOException 鎶涘嚭寮傚父
*/
+ @GetMapping("/downloadExcelBatchEdit")
+ @VciBusinessLog(operateName = "涓嬭浇鎵归噺鐢宠缂栫爜鐨勫鍏ユā鏉�")
+ public void downloadImportExcelBatchEdit(String codeClassifyOid, HttpServletResponse response) throws IOException{
+ String excelName = mdmIOService.downloadImportExcelBatchEdit(codeClassifyOid);
+ try {
+ ControllerUtil.writeFileToResponse(response,excelName);
+ } catch (Throwable e) {
+ //濡傛灉鍑洪敊,鎶婇敊璇俊鎭啓鍒皌ext
+ String msg = LangBaseUtil.getErrorMsg(e);
+ if(StringUtils.isBlank(msg)){
+ msg = "鏈煡閿欒";
+ }
+ ControllerUtil.writeDataToResponse(response,msg.getBytes(StandardCharsets.UTF_8),null);
+ }
+ }
+
+
+ /**
+ * 瀵煎叆鎵归噺缂栬緫鏁版嵁
+ * @param codeClassifyOid 鍒嗙被鐨勪富閿�
+ * @param classifyAttr 鍒嗙被璺緞浣跨敤鐨勫睘鎬�
+ * @param file 鏂囦欢鐨勫唴瀹�
+ */
+ @VciBusinessLog(operateName = "瀵煎叆鎵归噺缂栬緫鏁版嵁")
+ @PostMapping("/batchImportEdit")
+ public R batchImportEdit(String codeClassifyOid, String classifyAttr,MultipartFile file,HttpServletResponse response) throws Throwable {
+ String excelFileName = LocalFileUtil.getDefaultTempFolder() + File.separator + file.getOriginalFilename();
+ File file1 = new File(excelFileName);
+ try {
+ file.transferTo(new File(excelFileName));
+ CodeImProtRusultVO codeImProtRusultVO =mdmIOService.batchImportEdit(codeClassifyOid, classifyAttr,file1);
+ if(StringUtils.isNotBlank(codeImProtRusultVO.getFilePath())||StringUtils.isNotBlank(codeImProtRusultVO.getRedisUuid())){
+ //鏀惧埌map閲�
+ R result = R.fail("瀵煎叆澶辫触");
+ if(StringUtils.isNotBlank(codeImProtRusultVO.getFilePath())) {
+ String filedUUid = ControllerUtil.putErrorFile(codeImProtRusultVO.getFilePath());
+ codeImProtRusultVO.setFileOid(filedUUid);
+ }
+ result.setData(codeImProtRusultVO);
+ return result;
+ }else {
+ return R.success("鎿嶄綔鎴愬姛锛�");
+ }
+ }catch (Throwable e) {
+ logger.error("瀵煎叆閿欒",e);
+ String errorFile = LocalFileUtil.getDefaultTempFolder() + File.separator + "閿欒.txt";
+ LocalFileUtil.writeContentToFile(LangBaseUtil.getErrorMsg(e),errorFile);
+ String uuid=ControllerUtil.putErrorFile(errorFile);
+ CodeImProtRusultVO codeImProtRusultVO =new CodeImProtRusultVO();
+ codeImProtRusultVO.setRedisUuid("");
+ codeImProtRusultVO.setFileOid(uuid);
+ codeImProtRusultVO.setFilePath(errorFile);
+ R r = R.fail("瀵煎叆澶辫触");
+ r.setData(codeImProtRusultVO);
+ return r;
+ }finally {
+ file1.delete();
+ }
+ }
+
+ /**
+ * 涓嬭浇鎵归噺鐢宠鐨勫鍏ユā鏉�
+ * @param codeClassifyOid 鍒嗙被鐨勪富閿�
+ * @param response 鍝嶅簲瀵硅薄
+ * @throws IOException 鎶涘嚭寮傚父
+ */
@GetMapping("/downloadTopImportExcel")
@VciBusinessLog(operateName = "涓嬭浇鎵归噺鐢宠缂栫爜鐨勫鍏ユā鏉�")
public void downloadTopImportExcel(String codeClassifyOid,HttpServletResponse response) throws IOException{
diff --git a/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/MdmIOService.java b/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/MdmIOService.java
index 4b2e394..659128b 100644
--- a/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/MdmIOService.java
+++ b/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/MdmIOService.java
@@ -29,6 +29,13 @@
String createImportExcel(String codeClassifyOid,boolean isHistory);
/**
+ * 鐢熸垚鎵归噺淇敼瀵煎叆鐨勬枃浠�
+ * @param codeClassifyOid 鍒嗙被鐨勪富閿�
+ * @return excel鐨勬枃浠跺湴鍧�
+ */
+ String downloadImportExcelBatchEdit(String codeClassifyOid);
+
+ /**
* 鐢熸垚瀵煎叆鐨勬枃浠�
* @param codeClassifyOid 鍒嗙被鐨勪富閿�
* @return excel鐨勬枃浠跺湴鍧�
@@ -61,6 +68,15 @@
*/
CodeImProtRusultVO batchImportHistoryData(String codeClassifyOid,String classifyAttr, File file) throws Throwable;
+ /**
+ * 瀵煎叆鎵归噺缂栬緫鏁版嵁
+ * @param codeClassifyOid 鍒嗙被鐨勪富閿�
+ * @param classifyAttr 鍒嗙被璺緞浣跨敤鐨勫睘鎬�
+ * @param file excel鏂囦欢鐨勪俊鎭�
+ * @return 鏈夐敊璇俊鎭殑excel
+ */
+ CodeImProtRusultVO batchImportEdit(String codeClassifyOid,String classifyAttr, File file) throws Throwable;
+
/***
* 浠巖edis缂撳瓨閲岃幏鍙栧埌瀵煎叆鐨勬暟鎹�
* @param codeClassifyOid
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 dfc6153..11a8da8 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.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.nacos.common.utils.StringUtils;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.google.protobuf.ServiceException;
import com.vci.ubcs.code.applyjtcodeservice.entity.DockingPreAttrMapping;
@@ -50,6 +51,7 @@
import com.vci.ubcs.starter.web.util.*;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
+import oracle.sql.TIMESTAMP;
import org.apache.commons.collections4.map.HashedMap;
import org.apache.poi.hssf.usermodel.HSSFRichTextString;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
@@ -58,6 +60,7 @@
import org.apache.poi.ss.usermodel.RichTextString;
import org.apache.poi.ss.usermodel.Workbook;
import org.springblade.core.redis.cache.BladeRedis;
+import org.springblade.core.secure.utils.AuthUtil;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.Func;
import org.springblade.core.tool.utils.StringUtil;
@@ -68,10 +71,18 @@
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import javax.annotation.Resource;
+import java.beans.BeanInfo;
+import java.beans.Introspector;
+import java.beans.PropertyDescriptor;
import java.io.File;
import java.io.IOException;
+import java.lang.reflect.Method;
+import java.math.BigDecimal;
import java.text.MessageFormat;
import java.text.SimpleDateFormat;
+import java.time.LocalDateTime;
+import java.time.ZoneId;
+import java.time.ZonedDateTime;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CopyOnWriteArrayList;
@@ -485,6 +496,122 @@
return excelName;
}
+ /**
+ * 鐢熸垚鎵归噺淇敼瀵煎叆鐨勬枃浠�
+ *
+ * @param codeClassifyOid 鍒嗙被鐨勪富閿�
+ * @return excel鐨勬枃浠跺湴鍧�
+ */
+ @Override
+ public String downloadImportExcelBatchEdit(String codeClassifyOid) {
+ List<CodeClassifyTemplateVO> templateVOList=new ArrayList<>();
+ VciBaseUtil.alertNotNull("瀵煎嚭妯℃澘","瀵煎嚭鐨勯厤缃�",codeClassifyOid,"涓婚搴撳垎绫荤殑涓婚敭");
+
+ CodeClassifyVO codeClassifyVO = classifyService.getObjectByOid(codeClassifyOid);
+
+ templateVOList= templateService.childTemplates(codeClassifyOid);
+
+ WriteExcelOption eo = new WriteExcelOption();
+ eo.setAppend(true);
+ //澧炲姞妯℃澘鐨勪俊鎭鍏�
+ LinkedList<WriteExcelData> tempEDList = new LinkedList<>();
+ tempEDList.add(new WriteExcelData(0,0,"缂栧彿"));
+ for(int j=0;j<templateVOList.size();j++){
+ CodeClassifyTemplateVO templateVO=templateVOList.get(j);
+ CodeClassifyTemplateVO codeClassifyTemplateVO = new CodeClassifyTemplateVO();
+ BeanUtils.copyProperties(templateVO,codeClassifyTemplateVO);
+ //缁勫悎鏍煎紡鐨勪笉瀵煎叆锛�
+ // 鏋氫妇鐨勬彁渚涘簭鍒楃殑閫夋嫨
+ //鏃堕棿鍏ㄩ儴缁熶竴涓簓yyy-MM-dd HH:mm:ss
+ //鍙傜収鐨勮嚜琛岃緭鍏ュ悕绉�
+ //鍒嗙被娉ㄥ叆鐨勪笉鐢紝閮芥槸瀵煎叆鍚庤嚜鍔ㄥ鐞嗙殑
+ //缂栫爜锛岀姸鎬佺瓑瀛楁涓嶅鍏�
+ List<CodeClassifyTemplateAttrVO> codeClassifyTemplateAttrVOList=codeClassifyTemplateVO.getAttributes();
+ if(!CollectionUtils.isEmpty(codeClassifyTemplateAttrVOList)) {
+ if (CollectionUtils.isEmpty(codeClassifyTemplateAttrVOList)) {
+ throw new VciBaseException("妯℃澘娌℃湁閰嶇疆灞炴��");
+ }
+ }
+ List<CodeClassifyTemplateAttrVO> templateAttrVOS = codeClassifyTemplateAttrVOList.stream().filter(s ->
+ !DEFAULT_ATTR_LIST.contains(s.getId())
+ && StringUtils.isBlank(s.getComponentRule())
+ && StringUtils.isBlank(s.getClassifyInvokeAttr())
+ && (VciBaseUtil.getBoolean(s.getFormDisplayFlag()))
+ ).collect(Collectors.toList());
+
+ if (CollectionUtils.isEmpty(templateAttrVOS)) {
+ throw new VciBaseException("妯℃澘娌℃湁閰嶇疆浠讳綍銆愯〃鍗曟樉绀恒�戜负銆愭槸銆戠殑灞炴��");
+ }
+
+// List<CodeClassifyTemplateAttrVO> idAttrVOList = codeClassifyTemplateVO.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,"缂栫爜(id)",""));
+// excelDataList.add(new WriteExcelData(0,1,"鐮佹瀹藉害",""));
+// excelDataList.add(new WriteExcelData(0,1,!CollectionUtils.isEmpty(idAttrVOList)?idAttrVOList.get(0).getName():"浼佷笟缂栫爜",idAttrVOList.get(0).getId()));
+// }
+ for (int i = 0; i < templateAttrVOS.size(); i++) {
+ CodeClassifyTemplateAttrVO attrVO = templateAttrVOS.get(i);
+
+ Object text = attrVO.getName();
+ text = exportKeyAndRequired(workbook,attrVO,text);
+ int colIndex = 1 + i;
+ 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())
+ ||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() + ("_灞炴�ф壒閲忎慨鏀规ā鏉�.xls");
+ eo.addSheetDataList(templateVOList.size()+"妯℃澘淇℃伅銆愯鍕垮垹闄ゆ垨绉诲姩銆�",tempEDList);
+ ExcelUtil.writeDataToFile(excelName,eo);
+ return excelName;
+ }
/**
* 鑾峰彇鐮佹瀹藉害
* @param codeClassifyOid
@@ -1147,7 +1274,142 @@
throw e;
}
}
+ /**
+ * 瀵煎叆鎵归噺缂栬緫鏁版嵁
+ *
+ * @param codeClassifyOid 鍒嗙被鐨勪富閿�
+ * @param classifyAttr 鍒嗙被璺緞浣跨敤鐨勫睘鎬�
+ * @param file excel鏂囦欢鐨勪俊鎭�
+ * @return 鏈夐敊璇俊鎭殑excel
+ */
+ @Override
+ public CodeImProtRusultVO batchImportEdit(String codeClassifyOid, String classifyAttr,File file) throws Throwable{
+ VciBaseUtil.alertNotNull(codeClassifyOid,"鍒嗙被鐨勪富閿�");
+ ReadExcelOption reo = new ReadExcelOption();
+ reo.setReadAllSheet(true);
+ List<SheetDataSet> sheetDataSetList = ExcelUtil.readDataObjectFromExcel(file,null,reo);
+ if (sheetDataSetList.size() > LIMIT + 1) {
+ throw new VciBaseException("涓轰簡淇濊瘉绯荤粺鐨勭ǔ瀹氭�э紝璇蜂竴娆′笉瑕佸鍏ヨ秴杩�1涓囨潯鐨勬暟鎹�");
+ }
+ boolean isExport=false;
+ Map<String,List<WriteExcelData>> shetNameMap=new HashMap<>();
+ //鐩镐技椤圭洰鏌ラ噸
+ 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+"鏉$殑鏁版嵁");
+ }
+ //鏌ヨ鍒嗙被鍜屾ā鏉�
+ CodeClassifyFullInfoBO classifyFullInfo = classifyService.getClassifyFullInfo(codeClassifyOid);
+ //鍏堟壘鍒版瘡涓�琛岀殑鏍囬锛岀劧鍚庢牴鎹爣棰樻潵鑾峰彇瀵瑰簲鐨勫睘鎬�
+ SheetDataSet dataSet = sheetDataSetList.get(i);
+ List<SheetRowData> rowDataList = dataSet.getRowData();
+
+ //鎵剧涓�琛岋紝涓轰簡鎵炬爣棰�
+ CodeClassifyTemplateVO templateVO ;
+ //閮借浆鎹㈠畬浜嗐�傞渶瑕佹壒閲忔鏌�
+ //鎵炬墍鏈夌殑鍒嗙被璺緞,闇�瑕佹牎楠岃矾寰勬槸鍚︽纭紝鏄惁閮藉湪褰撳墠鐨勫垎绫荤殑涓嬬骇
+ List<CodeClassifyVO> childClassifyVOs = classifyService.listChildrenClassify(codeClassifyOid, true, classifyAttr, true);
+ Map<String/**璺緞**/, CodeClassifyVO> pathMap = Optional.ofNullable(childClassifyVOs).orElseGet(() -> new ArrayList<>()).stream().collect(Collectors.toMap(s -> s.getPath().startsWith("#") ? s.getPath().substring(1) : s.getPath(), t -> t));
+ List<String> titleRowData = dataSet.getColName();
+ Map<String, String> errorMap = new ConcurrentHashMap<>();
+ pathMap.put("#current#",classifyFullInfo.getCurrentClassifyVO());
+
+ try {
+ titleRowData.add("鍒嗙被璺緞");
+ List<CodeClassifyTemplateVO> templateVOList= checkSamesTemplate(titleRowData,sheetDataSetList,i,pathMap,errorMap);
+ titleRowData.remove(titleRowData.size()-1);
+ templateVO= templateVOList.get(0);
+ }catch (Throwable e){
+ throw new VciBaseException(e.getMessage());
+ }
+
+ CodeClassifyTemplateVO finalTemplateVO = templateVO;
+
+ List<SheetRowData> needowDataList = rowDataList.stream().filter(cbo -> {
+ String rowIndex = cbo.getRowIndex();
+ return !errorMap.containsKey(rowIndex);
+ }).collect(Collectors.toList());
+ //杩欓噷涓嶉櫎鍘婚粯璁ょ殑灞炴��
+ List<CodeClassifyTemplateAttrVO> attrVOS = templateVO.getAttributes();
+ Map<Integer/**鍒楀彿**/, String/**瀛楁鐨勫悕绉�**/> fieldIndexMap = new HashMap<>();
+
+ Map<String/**涓枃鍚嶇О**/, String/**鑻辨枃鍚嶇О**/> attrNameIdMap = attrVOS.stream().collect(Collectors.toMap(s -> s.getName(), t -> t.getId()));
+ fieldIndexMap.put(0,"id");
+ getFieldIndexMap(titleRowData, attrNameIdMap, fieldIndexMap);
+ //鍏堜笉鐢ㄧ灞炴�ф槸鍚﹂兘瀛樺湪锛屽厛杞崲涓�涓嬫暟鎹�
+ CodeOrderDTO orderDTO = new CodeOrderDTO();
+ for (SheetRowData sheetRowData : needowDataList) {
+ //鏌ヨ鏁版嵁
+ Map<String, String> conditionMap = new HashMap<>();
+ conditionMap.put("t.id", sheetRowData.getData().get(0));
+ conditionMap.put("t.lastv", "1");
+ CodeTemplateAttrSqlBO sqlBO = mdmEngineService.getSqlByTemplateVO(classifyFullInfo.getTopClassifyVO().getBtmTypeId(), templateVO, conditionMap, new PageHelper(-1));
+ //鎴戜滑浣跨敤鍜屼笟鍔$被鍨嬬殑鏉ユ煡璇�
+ List<Map> cbosB = commonsMapper.selectBySql(sqlBO.getSqlUnPage());
+ if(cbosB.size() == 0){
+ throw new ServiceException("缂栫爜锛�"+ sheetRowData.getData().get(0) + ",鏈兘鏌ヨ鍒扮浉鍏虫暟鎹��");
+ }
+ excelToCboEdit(fieldIndexMap, sheetRowData, orderDTO, cbosB.get(0));
+ orderDTO.setCopyFromVersion(orderDTO.getOid());
+ orderDTO.setOid(null);
+ try {
+ mdmEngineService.upSaveCode(orderDTO);
+ List<Map> newCbos = commonsMapper.selectBySql(sqlBO.getSqlUnPage());
+ //瀵圭爜鍊艰〃杩涜澶勭悊鏇挎崲鍒涘缓鏁版嵁鐨刼id
+ QueryWrapper<CodeAllCode> wrapper = new QueryWrapper<>();
+ wrapper.eq("CREATECODEOID",orderDTO.getCopyFromVersion());
+ List<CodeAllCode> codeAllCodes = codeAllCodeService.selectByWrapper(wrapper);
+ codeAllCodes.get(0).setCreateCodeOid(newCbos.get(0).get("OID").toString());
+ codeAllCodes.get(0).setLastModifyTime(new Date());
+ codeAllCodes.get(0).setTs(new Date());
+ codeAllCodes.get(0).setLastModifier(AuthUtil.getUser().getUserName());
+ codeAllCodeService.updateBatchById(codeAllCodes);
+ } catch (Throwable e) {
+ log.error("鎵归噺浜х敓缂栫爜鐨勬椂鍊欏嚭閿欎簡", e);
+// thisCbos.stream().forEach(cbo -> {
+// String rowIndex = cbo.getAttributeValue(IMPORT_ROW_INDEX);
+ errorMap.put(sheetRowData.getRowIndex(), ";绯荤粺閿欒锛屽瓨鍌ㄦ暟鎹殑鏃跺�欏嚭閿欎簡:"+e.getMessage());
+// });
+ }
+ }
+
+ if (errorMap.size() > 0) {
+ isExport = true;
+ }
+ createWriteExcelData(rowDataList, errorMap, new ArrayList<>(), titleRowData, shetNameMap, finalTemplateVO);
+
+ }
+ String excelFileName="";
+ if(isExport&&!CollectionUtils.isEmpty(shetNameMap)) {
+ excelFileName = LocalFileUtil.getDefaultTempFolder() + File.separator + "閿欒淇℃伅.xls";
+ WriteExcelOption eo = new WriteExcelOption();
+ shetNameMap.forEach((shetName, errorDataList) -> {
+ eo.addSheetDataList(shetName, errorDataList);
+ });
+ try {
+ new File(excelFileName).createNewFile();
+ } catch (IOException e) {
+ throw new VciBaseException(LangBaseUtil.getErrorMsg(e));
+ }
+ ExcelUtil.writeDataToFile(excelFileName, eo);
+ }
+ CodeImProtRusultVO codeImProtRusultVO=new CodeImProtRusultVO();
+ if(StringUtils.isNotBlank(excelFileName)) {
+ codeImProtRusultVO.setFilePath(excelFileName);
+ codeImProtRusultVO.setFileOid("");
+ saveLogUtil.operateLog("鏁版嵁鎵归噺鏇存敼",true, StringUtil.format("閿欒淇℃伅锛歿}",JSON.toJSONString(shetNameMap)) );
+ }else{
+ saveLogUtil.operateLog("鏁版嵁鎵归噺鏇存敼",false, StringUtil.format("瀵煎叆鎴愬姛鎬绘暟涓猴細{}",
+ sheetDataSetList.size()-1));
+ }
+ return codeImProtRusultVO;
+ }
/*private void converBaseModels(List<ClientBusinessObject> clientBusinessObjects,List<BaseModel>dataCBOList){
clientBusinessObjects.stream().forEach(clientBusinessObject -> {
BaseModel baseModel=new BaseModel();
@@ -3290,6 +3552,106 @@
}
/**
+ * excel杞崲涓篶bo鐨勫璞�
+ * @param fieldIndexMap 瀛楁鐨勪綅缃�
+ * @param rowDataList excel閲岀殑琛屾暟鎹�
+ * @param orderDTO 鏁寸悊鐨勬暟鎹�
+ * @param map 鏁版嵁鐨勫垪琛�
+ */
+ private void excelToCboEdit(Map<Integer,String> fieldIndexMap,SheetRowData rowDataList,
+ CodeOrderDTO orderDTO,
+ Map map){
+ rowDataList.getData().forEach((index,value)->{
+ String field = fieldIndexMap.get(index);
+ if (StringUtils.isBlank(field)) {
+ throw new VciBaseException("绗�" + (index + 1) + "鍒楃殑鏍囬鍦ㄧ郴缁熶腑涓嶅瓨鍦�");
+ }
+ map.put(field,value);
+ });
+
+ try {
+// for (Map map : cbos) {
+// Object obj = CodeOrderDTO.class.newInstance();
+ BeanInfo beanInfo = Introspector.getBeanInfo(orderDTO.getClass());
+ PropertyDescriptor[] propertyDescriptors = beanInfo.getPropertyDescriptors();
+ for (PropertyDescriptor property : propertyDescriptors) {
+ Method setter = property.getWriteMethod();
+ if (setter != null) {
+ //oracle鐨勬椂闂翠负TIMESTAMP鐨勶紝闇�瑕佽繘琛岃浆鎹㈡垚data锛屽惁鍒欏皢鎶ラ敊
+ if (map.get(property.getName().toUpperCase()) instanceof TIMESTAMP) {
+ LocalDateTime localDateTime = ((TIMESTAMP) map.get(property.getName().toUpperCase())).toLocalDateTime();
+ ZoneId zoneId = ZoneId.systemDefault();
+ ZonedDateTime zdt = localDateTime.atZone(zoneId);
+ Date date = Date.from(zdt.toInstant());
+ setter.invoke(orderDTO, date);
+ map.remove(property.getName().toUpperCase());
+ } //oracle鐨勬暟瀛椾负BigDecimal鐨勶紝闇�瑕佽繘琛岃浆鎹㈡垚Integer锛屽惁鍒欏皢鎶ラ敊
+ else if (map.get(property.getName().toUpperCase()) instanceof BigDecimal
+ && ("Integer").equals(setter.getParameterTypes()[0].getSimpleName())) {
+ setter.invoke(orderDTO, ((BigDecimal) map.get(property.getName().toUpperCase())).intValue());
+ map.remove(property.getName().toUpperCase());
+ } else if (map.containsKey(property.getName().toUpperCase())) {
+ if(setter.getParameterTypes()[0].getSimpleName().equals("String")){
+ setter.invoke(orderDTO, map.get(property.getName().toUpperCase()) == null ? null:String.valueOf(map.get(property.getName().toUpperCase())));
+ }else{
+ setter.invoke(orderDTO, map.get(property.getName().toUpperCase()));
+ }
+ map.remove(property.getName().toUpperCase());
+ }
+ }
+ }
+ for (Object key : map.keySet()) {
+ map.put(key, map.get(key) == null ? null : String.valueOf(map.get(key)));
+ }
+ } catch (Exception e) {
+ throw new VciBaseException("鏌ヨ澶辫触锛�" + e.getMessage());
+ }
+
+
+
+// Iterator<Map.Entry<String, String>> iterator = cbos.entrySet().iterator();
+//
+// Map.Entry<String, String> entry;
+// while (iterator.hasNext()) {
+// entry = iterator.next();
+//// if (WebUtil.isDefaultField(entry.getKey())) {
+// Object obj = BaseModel.class.newInstance();
+// BeanInfo beanInfo = Introspector.getBeanInfo(obj.getClass());
+// PropertyDescriptor[] propertyDescriptors = beanInfo.getPropertyDescriptors();
+// for (PropertyDescriptor property : propertyDescriptors) {
+// Method setter = property.getWriteMethod();
+// if (setter != null) {
+// //oracle鐨勬椂闂翠负TIMESTAMP鐨勶紝闇�瑕佽繘琛岃浆鎹㈡垚data锛屽惁鍒欏皢鎶ラ敊
+// if (map.get(property.getName().toUpperCase()) instanceof TIMESTAMP) {
+// LocalDateTime localDateTime = ((TIMESTAMP) map.get(property.getName().toUpperCase())).toLocalDateTime();
+// ZoneId zoneId = ZoneId.systemDefault();
+// ZonedDateTime zdt = localDateTime.atZone(zoneId);
+// Date date = Date.from(zdt.toInstant());
+// setter.invoke(obj, date);
+// map.remove(property.getName().toUpperCase());
+// } //oracle鐨勬暟瀛椾负BigDecimal鐨勶紝闇�瑕佽繘琛岃浆鎹㈡垚Integer锛屽惁鍒欏皢鎶ラ敊
+// else if (map.get(property.getName().toUpperCase()) instanceof BigDecimal
+// && ("Integer").equals(setter.getParameterTypes()[0].getSimpleName())) {
+// setter.invoke(obj, ((BigDecimal) map.get(property.getName().toUpperCase())).intValue());
+// map.remove(property.getName().toUpperCase());
+// } else if (map.containsKey(property.getName().toUpperCase())) {
+// if(setter.getParameterTypes()[0].getSimpleName().equals("String")){
+// setter.invoke(obj, map.get(property.getName().toUpperCase()) == null ? null:String.valueOf(map.get(property.getName().toUpperCase())));
+// }else{
+// setter.invoke(obj, map.get(property.getName().toUpperCase()));
+// }
+// map.remove(property.getName().toUpperCase());
+// }
+// }
+// }
+// WebUtil.setValueToField(entry.getKey(), orderDTO, entry.getValue());
+// iterator.remove();
+//// }
+// }
+ orderDTO.setData(map);
+ }
+
+ /**
* 妫�鏌ユ牎楠岃鍒欐病鏈夐�氳繃鐨勫唴瀹�
* @param attrVOS 闇�瑕佹牎楠岀殑灞炴��
* @param dataList 鏁版嵁鐨勫垪琛�
--
Gitblit v1.9.3