From ea9e2b31cc9ccd9e406a514ad3c38cf949a80571 Mon Sep 17 00:00:00 2001 From: "zhaokaiyao@91isoft.com" <6922339zky> Date: Thu, 9 Sep 2021 23:06:19 +0800 Subject: [PATCH] =?UTF-8?q?excl=E6=89=B9=E9=87=8F=E5=AF=BC=E5=85=A5?= =?UTF-8?q?=E6=A0=87=E5=87=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/ImportExcelServiceImpl.java | 383 +++++++----------- 1 file changed, 136 insertions(+), 247 deletions(-) diff --git a/adc-da-slrs/src/main/java/com/adc/da/slrs/ImportExcelDatas/service/impl/ImportExcelServiceImpl.java b/adc-da-slrs/src/main/java/com/adc/da/slrs/ImportExcelDatas/service/impl/ImportExcelServiceImpl.java index 3169c12a..79489ba1 100644 --- a/adc-da-slrs/src/main/java/com/adc/da/slrs/ImportExcelDatas/service/impl/ImportExcelServiceImpl.java +++ b/adc-da-slrs/src/main/java/com/adc/da/slrs/ImportExcelDatas/service/impl/ImportExcelServiceImpl.java @@ -2,24 +2,14 @@ package com.adc.da.slrs.ImportExcelDatas.service.impl; import com.adc.da.att.service.IAttFileEOService; import com.adc.da.att.vo.AttFileVo; -import com.adc.da.mq.CreateStandMQService; import com.adc.da.slrs.ImportExcelDatas.dao.ImportExcelDao; import com.adc.da.slrs.ImportExcelDatas.entity.ImportDto; import com.adc.da.slrs.ImportExcelDatas.service.ImportExcelService; -import com.adc.da.slrs.sarBussStandAttrInfo.dao.SarBussStandAttrInfoDao; -import com.adc.da.slrs.sarBussStandAttrInfo.entity.SarBussStandAttrInfo; -import com.adc.da.slrs.sarBussStandAttrInfo.service.impl.SarBussStandAttrInfoServiceImpl; -import com.adc.da.slrs.sarBussionessStand.dao.SarBussionessStandDao; import com.adc.da.slrs.sarBussionessStand.entity.SarBussionessStand; -import com.adc.da.slrs.sarBussionessStand.service.impl.SarBussionessStandServiceImpl; -import com.adc.da.slrs.sarStandAttrInfo.dao.SarStandAttrInfoDao; -import com.adc.da.slrs.sarStandAttrInfo.entity.SarStandAttrInfo; -import com.adc.da.slrs.sarStandAttrInfo.service.impl.SarStandAttrInfoServiceImpl; -import com.adc.da.slrs.sarStandardsInfo.dao.SarStandardsInfoDao; +import com.adc.da.slrs.sarBussionessStand.service.ISarBussionessStandService; import com.adc.da.slrs.sarStandardsInfo.entity.SarStandardsInfo; -import com.adc.da.slrs.sarStandardsInfo.service.impl.SarStandardsInfoServiceImpl; +import com.adc.da.slrs.sarStandardsInfo.service.ISarStandardsInfoService; import com.adc.da.util.UUIDUtils; -import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.google.gson.Gson; @@ -46,32 +36,17 @@ public class ImportExcelServiceImpl extends ServiceImpl fileError = new ArrayList<>(); + @Autowired + private ISarStandardsInfoService sarStandardsInfoService; + + private ISarBussionessStandService sarBussionessStandService; @Override public List storageExclData(Map> importListMap) { @@ -302,53 +281,50 @@ public class ImportExcelServiceImpl extends ServiceImpl standSaveWrapper = new QueryWrapper<>(); standSaveWrapper - .eq("STAND_SORT", sarStandardsInfo.getStandSort()) - .eq("STAND_NUMBER", sarStandardsInfo.getStandNumber()) - .eq("STAND_YEAR", sarStandardsInfo.getStandYear()); + .eq("STAND_SORT", ForeignEO.getStandSort()) + .eq("STAND_NUMBER", ForeignEO.getStandNumber()) + .eq("STAND_YEAR", ForeignEO.getStandYear()); SarStandardsInfo one = sarStandardsInfoService.getOne(standSaveWrapper); - if (one != null) { - sarStandardsInfo.setId(one.getId()); - - sarStandardsInfoService.update(sarStandardsInfo, standSaveWrapper); - QueryWrapper standAttrWrapper = new QueryWrapper<>(); - standAttrWrapper.eq("STAND_ID", one.getId()); - - sarStandAttrInfo.setStandId(one.getId()); - sarStandAttrInfoService.update(sarStandAttrInfo, standAttrWrapper); - } else { - sarStandardsInfoService.save(sarStandardsInfo); - String field = "ID,STAND_ID,VALID_FLAG,DTBJH,SSRQ"; - String value = "\'" + sarStandAttrInfo.getId() + "\'" + "," + "\'" + sarStandAttrInfo.getStandId() + "\'" + "," + "\'" + "0" + "\'"; - if (sarStandAttrInfo.getDtbjh() != null) { - value += "," + "\'" + sarStandAttrInfo.getDtbjh() + "\'"; + + if (one != null) { + ForeignEO.setId(one.getId()); + + try { + sarStandardsInfoService.updateSarStandardsInfo(ForeignEO); + } catch (Exception e) { + item.setErrorStr("标准更新失败"); + error.add(item); + e.printStackTrace(); + } + + } else { + try { + sarStandardsInfoService.createSarStandardsInfo(ForeignEO); + } catch (Exception e) { + item.setErrorStr("标准新增失败"); + error.add(item); + e.printStackTrace(); + } + } - if (sarStandAttrInfo.getSsrq() != null) { - value += "," + "\'" + sarStandAttrInfo.getSsrq() + "\'"; - } - sarStandAttrInfoDao.insertStandAttr(field, value); - - - } - } else { item.setErrorStr("标准号无法解析"); error.add(item); - importListMap.replace("error", error); } @@ -361,50 +337,46 @@ public class ImportExcelServiceImpl extends ServiceImpl { String standID = UUIDUtils.randomUUID20(); - SarStandardsInfo sarStandardsInfo = parseImportDtoToStandardsInfo(item, standID); + SarStandardsInfo InlandEO = parseImportDtoToStandardsInfo(item, standID); - if (sarStandardsInfo != null) { - SarStandAttrInfo sarStandAttrInfo = parseImportDtoToStandAttrInfo(item, standID); + if (InlandEO != null) { - sarStandardsInfo.setValidFlag("0"); - sarStandardsInfo.setStandType("INLAND"); + + InlandEO.setValidFlag("0"); + InlandEO.setStandType("INLAND"); QueryWrapper standSaveWrapper = new QueryWrapper<>(); standSaveWrapper - .eq("STAND_SORT", sarStandardsInfo.getStandSort()) - .eq("STAND_NUMBER", sarStandardsInfo.getStandNumber()) - .eq("STAND_YEAR", sarStandardsInfo.getStandYear()); + .eq("STAND_SORT", InlandEO.getStandSort()) + .eq("STAND_NUMBER", InlandEO.getStandNumber()) + .eq("STAND_YEAR", InlandEO.getStandYear()); SarStandardsInfo one = sarStandardsInfoService.getOne(standSaveWrapper); if (one != null) { - sarStandardsInfo.setId(one.getId()); - sarStandardsInfoService.update(sarStandardsInfo, standSaveWrapper); - QueryWrapper standAttrWrapper = new QueryWrapper<>(); - standAttrWrapper.eq("STAND_ID", one.getId()); - sarStandAttrInfo.setStandId(one.getId()); - sarStandAttrInfoService.update(sarStandAttrInfo, standAttrWrapper); + + InlandEO.setId(one.getId()); + try { + sarStandardsInfoService.updateSarStandardsInfo(InlandEO); + } catch (Exception e) { + item.setErrorStr("国内标准更新失败"); + error.add(item); + e.printStackTrace(); + } + + } else { - sarStandardsInfoService.save(sarStandardsInfo); - - - String field = "ID,STAND_ID,VALID_FLAG,DTBJH,SSRQ"; - String value = "\'" + sarStandAttrInfo.getId() + "\'" + "," + "\'" + sarStandAttrInfo.getStandId() + "\'" + "," + "\'" + "0" + "\'"; - - - if (sarStandAttrInfo.getDtbjh() != null) { - value += "," + "\'" + sarStandAttrInfo.getDtbjh() + "\'"; + try { + sarStandardsInfoService.createSarStandardsInfo(InlandEO); + } catch (Exception e) { + item.setErrorStr("国内标准新增失败"); + error.add(item); + e.printStackTrace(); } - - if (sarStandAttrInfo.getSsrq() != null) { - value += "," + "\'" + sarStandAttrInfo.getSsrq() + "\'"; - } - sarStandAttrInfoDao.insertStandAttr(field, value); - } } else { item.setErrorStr("标准号无法解析"); @@ -422,32 +394,19 @@ public class ImportExcelServiceImpl extends ServiceImpl { String standId = UUIDUtils.randomUUID20(); - SarBussionessStand sarBussionessStand = parseImportDtoToSarBussionessStand(item, standId); - - if (sarBussionessStand != null) { - - SarBussStandAttrInfo sarBussStandAttrInfo = parseImportDtoToSarBussStandAttrInfo(item, standId); + SarBussionessStand BussEO = parseImportDtoToSarBussionessStand(item, standId); + if (BussEO != null) { try { QueryWrapper saveWrapper = new QueryWrapper<>(); saveWrapper.eq("STAND_CODE", item.getStandId()); SarBussionessStand one = sarBussionessStandService.getOne(saveWrapper); if (one != null) { - sarBussionessStand.setId(one.getId()); - sarBussionessStandService.update(sarBussionessStand, saveWrapper); - - QueryWrapper bussAttrWrapper = new QueryWrapper<>(); - bussAttrWrapper.eq("STAND_ID", one.getId()); - sarBussStandAttrInfo.setStandId(one.getId()); - sarBussStandAttrInfoService.update(sarBussStandAttrInfo, bussAttrWrapper); - sarBussStandAttrInfoDao.updateStandInfo(one.getId(), "GLWJBUSS", sarBussStandAttrInfo.getGlwj()); - + BussEO.setId(one.getId()); + sarBussionessStandService.updateSarBussionessStand(BussEO); } else { - sarBussionessStandService.save(sarBussionessStand); - sarBussStandAttrInfoService.save(sarBussStandAttrInfo); - - sarBussStandAttrInfoDao.updateStandInfo(sarBussStandAttrInfo.getStandId(), "GLWJBUSS", sarBussStandAttrInfo.getGlwj()); + sarBussionessStandService.createSarBussionessStand(BussEO); } @@ -464,15 +423,17 @@ public class ImportExcelServiceImpl extends ServiceImpl fileMap = new HashMap<>(); - - - /** - * * @Param: [standId, fileMap] fileMap - */ - fileMap.put("GLWJ", fileInfo.getAttId()); - try { - sarStandardsInfoService.createStandFile(standId, fileMap); - } catch (Exception e) { - importDto.setErrorStr("创建标准文件异常"); - fileError.add(importDto); - e.printStackTrace(); - System.out.println("创建标准文件异常"); - } - - sarStandAttrInfo.setGlwj(fileInfo.getAttId()); - } else { - importDto.setErrorStr("文件不存在"); - fileError.add(importDto); - } - - } catch (Exception e) { - importDto.setErrorStr("文件打开失败"); - fileError.add(importDto); - e.printStackTrace(); - } - - - } - - - return sarStandAttrInfo; - - } - - + /** + * 整理为企业标准实体 + * @param importDto + * @param standId + * @return + */ public SarBussionessStand parseImportDtoToSarBussionessStand(ImportDto importDto, String standId) { @@ -648,6 +546,54 @@ public class ImportExcelServiceImpl extends ServiceImpl attrInfoMap = new HashMap<>(); + if (importDto.getPath() != null) { + String path[] = importDto.getPath().split("/"); + String realPath = ""; + for (int i = 4; i < path.length; i++) { + realPath = realPath + "/" + path[i]; + + } + + + try { +// File file = new File("C:\\Users\\22501\\Desktop\\foton\\2021\\" + realPath); +// File file = new File(importPath + realPath); + File file = new File("/home/file/2021/" + realPath); + + if (file.exists()) { + AttFileVo fileInfo = attFileEOService.saveFileInfo(file); + + + if (importDto.getImplementedTime()!=null && importDto.getImplementedTime()!=""){ + attrInfoMap.put("FBGBUSS",fileInfo.getAttId()); + + }else { + attrInfoMap.put("GLWJBUSS",fileInfo.getAttId()); + } + + + + } else { + importDto.setErrorStr("文件不存在"); + fileError.add(importDto); + } + + } catch (Exception e) { + importDto.setErrorStr("路径错误!"); + fileError.add(importDto); + e.printStackTrace(); + } + + + } + + return sarBussionessStand; } @@ -655,63 +601,6 @@ public class ImportExcelServiceImpl extends ServiceImpl fileMap = new HashMap<>(); - - - /** - * * @Param: [standId, fileMap] fileMap - */ - fileMap.put("GLWJBUSS", fileInfo.getAttId()); - try { - sarBussionessStandService.createStandFile(standId, fileMap); - } catch (Exception e) { - importDto.setErrorStr("创建标准文件异常"); - fileError.add(importDto); - e.printStackTrace(); - System.out.println("创建标准文件异常"); - } - - sarBussStandAttrInfo.setGlwj(fileInfo.getAttId()); - - } else { - importDto.setErrorStr("文件不存在"); - fileError.add(importDto); - } - - } catch (Exception e) { - importDto.setErrorStr("路径错误!"); - fileError.add(importDto); - e.printStackTrace(); - } - - - } - return sarBussStandAttrInfo; - } - public HashMap analysisStandId(ImportDto importDto) { HashMap result = new HashMap<>();