标准excl导入
This commit is contained in:
+19
-4
@@ -4,6 +4,7 @@ import com.adc.da.base.web.BaseController;
|
||||
import com.adc.da.common.ReadExcel;
|
||||
import com.adc.da.http.ResponseMessage;
|
||||
import com.adc.da.slrs.ImportExcelDatas.comment.ExclErrorOut;
|
||||
import com.adc.da.slrs.ImportExcelDatas.comment.ExclExport;
|
||||
import com.adc.da.slrs.ImportExcelDatas.entity.ImportDto;
|
||||
import com.adc.da.slrs.ImportExcelDatas.service.ImportExcelService;
|
||||
import com.adc.da.slrs.ImportExcelDatas.service.impl.ImportExcelServiceImpl;
|
||||
@@ -34,7 +35,7 @@ import java.util.Map;
|
||||
|
||||
@RestController
|
||||
@Api(description = "|SarStandPutTime|")
|
||||
@RequestMapping("/ImportExcel")
|
||||
@RequestMapping("/api/ImportExcel")
|
||||
public class ImportExcelController extends BaseController<ImportDto> {
|
||||
|
||||
@Autowired
|
||||
@@ -43,14 +44,24 @@ public class ImportExcelController extends BaseController<ImportDto> {
|
||||
@Autowired
|
||||
private ExclErrorOut exclErrorOut;
|
||||
|
||||
@ApiOperation("批量删除用户收藏")
|
||||
|
||||
@ApiOperation("从excl中导入标准信息")
|
||||
@PostMapping("/import")
|
||||
public void deleteList(MultipartFile file, MultipartFile file2, HttpServletResponse response, HttpServletRequest request) throws IOException {
|
||||
Map<String, List<ImportDto>> mapMap=importExcelService.getExcelData(file,file2);
|
||||
/**
|
||||
* 导入系统
|
||||
*/
|
||||
List<ImportDto> errorList = importExcelService.storageExclData(mapMap);
|
||||
// mapMap.put("导入后的信息",errorList);
|
||||
// List<ImportDto> guonei= mapMap.get("GNBZ");
|
||||
// List<ImportDto> haiwai = mapMap.get("HWBZ");
|
||||
// List<ImportDto> qibiao = mapMap.get("QYBZ");
|
||||
|
||||
|
||||
/**
|
||||
* 生成错误表格
|
||||
*/
|
||||
OutputStream os = null;
|
||||
Workbook workbook = null;
|
||||
try {
|
||||
@@ -61,7 +72,11 @@ public class ImportExcelController extends BaseController<ImportDto> {
|
||||
response.setContentType("application/force-download");
|
||||
//导出数据
|
||||
String headStr="标准号,标准名称,英文名称,发布时间,实施时间,标准状态,代替标准号,附件路径,错误原因";
|
||||
workbook = exclErrorOut.exportDatas(errorList,headStr);
|
||||
// workbook = exclErrorOut.exportDatas(guonei,headStr);
|
||||
|
||||
ExclExport exclExport = new ExclExport();
|
||||
workbook = exclExport.exportData(mapMap, headStr);
|
||||
|
||||
os = response.getOutputStream();
|
||||
workbook.write(os);
|
||||
os.flush();
|
||||
@@ -75,8 +90,8 @@ public class ImportExcelController extends BaseController<ImportDto> {
|
||||
}
|
||||
|
||||
|
||||
|
||||
// return responseMessage;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+179
-107
@@ -2,7 +2,6 @@ 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.http.Result;
|
||||
import com.adc.da.slrs.ImportExcelDatas.dao.ImportExcelDao;
|
||||
import com.adc.da.slrs.ImportExcelDatas.entity.ImportDto;
|
||||
import com.adc.da.slrs.ImportExcelDatas.service.ImportExcelService;
|
||||
@@ -10,9 +9,7 @@ import com.adc.da.slrs.sarBussionessStand.entity.SarBussionessStand;
|
||||
import com.adc.da.slrs.sarBussionessStand.service.ISarBussionessStandService;
|
||||
import com.adc.da.slrs.sarStandardsInfo.entity.SarStandardsInfo;
|
||||
import com.adc.da.slrs.sarStandardsInfo.service.ISarStandardsInfoService;
|
||||
import com.adc.da.sys.dao.DicTypeEODao;
|
||||
import com.adc.da.sys.entity.DicTypeEO;
|
||||
import com.adc.da.sys.entity.DictionaryEO;
|
||||
import com.adc.da.sys.service.impl.DicTypeEOServiceImpl;
|
||||
import com.adc.da.util.UUIDUtils;
|
||||
import com.adc.da.utils.util.InitStandAttrUtil;
|
||||
@@ -26,13 +23,13 @@ import org.apache.poi.xssf.usermodel.XSSFRow;
|
||||
import org.apache.poi.xssf.usermodel.XSSFSheet;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.InputStream;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
@Service
|
||||
@@ -70,6 +67,7 @@ public class ImportExcelServiceImpl extends ServiceImpl<ImportExcelDao, ImportDt
|
||||
dates.add("—" + i);
|
||||
dates.add("- " + i);
|
||||
dates.add("— " + i);
|
||||
dates.add("-" + i);
|
||||
}
|
||||
|
||||
if (file == null || file.getSize() == 0) {
|
||||
@@ -118,12 +116,18 @@ public class ImportExcelServiceImpl extends ServiceImpl<ImportExcelDao, ImportDt
|
||||
//中间的Map 判断标准号属于哪种类型
|
||||
Map<String, String> middle = new HashMap<>();
|
||||
datas.forEach(items -> {
|
||||
System.out.print(".");
|
||||
//判断是否是正确的数据
|
||||
String[] as = items.split(",");
|
||||
if (!inDate(as[0], dates)) {
|
||||
if( as.length < 8){
|
||||
ImportDto importDto = new ImportDto();
|
||||
importDto.setErrorStr(items);
|
||||
error.add(importDto);
|
||||
|
||||
} else if (!inDate(as[0], dates) ) {
|
||||
ImportDto importDto = getImportDto(as);
|
||||
error.add(importDto);
|
||||
middle.put(as[0].trim(), "error-" + error.size());
|
||||
middle.put(as[7].trim(), "error-" + error.size());
|
||||
} else {
|
||||
//数据二次拆解 针对标准进行拆解
|
||||
String[] step2 = as[0].trim().split(" ");
|
||||
@@ -131,15 +135,15 @@ public class ImportExcelServiceImpl extends ServiceImpl<ImportExcelDao, ImportDt
|
||||
if (isCheck(GNS, step2[0].trim())) {
|
||||
ImportDto importDto = getImportDto(as);
|
||||
InCountry.add(importDto);
|
||||
middle.put(as[0].trim(), "GNBZ-" + InCountry.size());
|
||||
middle.put(as[7].trim(), "GNBZ-" + InCountry.size());
|
||||
} else if (isCheck(QBS, step2[0].trim())) {
|
||||
ImportDto importDto = getImportDto(as);
|
||||
QiBiao.add(importDto);
|
||||
middle.put(as[0].trim(), "QYBZ-" + QiBiao.size());
|
||||
middle.put(as[7].trim(), "QYBZ-" + QiBiao.size());
|
||||
} else {
|
||||
ImportDto importDto = getImportDto(as);
|
||||
OutCountry.add(importDto);
|
||||
middle.put(as[0].trim(), "HWBZ-" + OutCountry.size());
|
||||
middle.put(as[7].trim(), "HWBZ-" + OutCountry.size());
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -151,9 +155,11 @@ public class ImportExcelServiceImpl extends ServiceImpl<ImportExcelDao, ImportDt
|
||||
fujian.forEach(items2 -> {
|
||||
String[] fj = items2.split(",");
|
||||
if (fj.length > 2) {
|
||||
if (null != middle.get(null != fj[2] ? fj[2].trim() : "")) {
|
||||
if (null != middle.get(null != fj[1] ? fj[1].trim() : "")) {
|
||||
//对应数据位置
|
||||
String[] location = middle.get(fj[2].trim()).split("-");
|
||||
String[] location = middle.get(fj[1].trim()).split("-");
|
||||
// List<ImportDto> importDtos = res.get(location[0]);
|
||||
|
||||
res.get(location[0]).get(Integer.parseInt(location[1]) - 1).setPath(fj[3]);
|
||||
}
|
||||
}
|
||||
@@ -189,10 +195,15 @@ public class ImportExcelServiceImpl extends ServiceImpl<ImportExcelDao, ImportDt
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 数据数组转换为实体类
|
||||
* @param as
|
||||
* @return
|
||||
*/
|
||||
//赋值方法
|
||||
private ImportDto getImportDto(String[] as) {
|
||||
ImportDto importDto = new ImportDto();
|
||||
if (as.length == 7) {
|
||||
if (as.length == 8) {
|
||||
importDto.setStandId(null != as[0] ? as[0].trim() : "");
|
||||
importDto.setStandName(null != as[1] ? as[1].trim() : "");
|
||||
importDto.setStandNameEN(null != as[2] ? as[2].trim() : "");
|
||||
@@ -200,7 +211,7 @@ public class ImportExcelServiceImpl extends ServiceImpl<ImportExcelDao, ImportDt
|
||||
importDto.setImplementedTime(null != as[4] ? as[4].trim() : "");
|
||||
importDto.setStandStatus(null != as[5] ? as[5].trim() : "");
|
||||
importDto.setReplaceId(null != as[6] ? as[6].trim() : "");
|
||||
} else if (as.length == 6) {
|
||||
} else if (as.length == 7) {
|
||||
importDto.setStandId(null != as[0] ? as[0].trim() : "");
|
||||
importDto.setStandName(null != as[1] ? as[1].trim() : "");
|
||||
importDto.setStandNameEN(null != as[2] ? as[2].trim() : "");
|
||||
@@ -225,9 +236,10 @@ public class ImportExcelServiceImpl extends ServiceImpl<ImportExcelDao, ImportDt
|
||||
HSSFSheet sheet = workbook.getSheetAt(i);
|
||||
// 获取有多少行
|
||||
int lastNum = sheet.getLastRowNum();
|
||||
for (int j = 1; j <= lastNum; j++) {
|
||||
for (int j = 0; j <= lastNum; j++) {
|
||||
HSSFRow row = sheet.getRow(j);
|
||||
if (null != row) {
|
||||
System.out.println("正在读取第"+j+"行...");
|
||||
strings.add(row.getCell(0).getStringCellValue());
|
||||
}
|
||||
}
|
||||
@@ -248,11 +260,12 @@ public class ImportExcelServiceImpl extends ServiceImpl<ImportExcelDao, ImportDt
|
||||
// 遍历sheet页
|
||||
for (int i = 0; i <= sheetNum; i++) {
|
||||
XSSFSheet sheet = workbook.getSheetAt(i);
|
||||
// 获取有多少行
|
||||
// 获取有多少行 0行开始
|
||||
int lastNum = sheet.getLastRowNum();
|
||||
for (int j = 1; j <= lastNum; j++) {
|
||||
for (int j = 0; j <= lastNum; j++) {
|
||||
XSSFRow row = sheet.getRow(j);
|
||||
if (null != row) {
|
||||
System.out.println("正在读取第"+j+"行...");
|
||||
strings.add(row.getCell(0).getStringCellValue());
|
||||
}
|
||||
}
|
||||
@@ -266,9 +279,7 @@ public class ImportExcelServiceImpl extends ServiceImpl<ImportExcelDao, ImportDt
|
||||
|
||||
|
||||
|
||||
private List<ImportDto> error = new ArrayList<>();
|
||||
|
||||
private List<ImportDto> fileError = new ArrayList<>();
|
||||
|
||||
@Autowired
|
||||
private ISarStandardsInfoService sarStandardsInfoService;
|
||||
@@ -278,12 +289,38 @@ public class ImportExcelServiceImpl extends ServiceImpl<ImportExcelDao, ImportDt
|
||||
|
||||
@Autowired
|
||||
private ISarBussionessStandService sarBussionessStandService;
|
||||
|
||||
|
||||
private List<ImportDto> error = new ArrayList<>();
|
||||
|
||||
private List<ImportDto> fileError = new ArrayList<>();
|
||||
|
||||
private HashSet<String> sarSort = new HashSet<>();
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public List<ImportDto> storageExclData(Map<String, List<ImportDto>> importListMap) {
|
||||
|
||||
//TODO 利用stream把list变为set
|
||||
// List<DicTypeEO> list = dicTypeEOService.list();
|
||||
// list.stream().flatMap(dicTypeEO -> {
|
||||
// return dicTypeEO;
|
||||
// }.co)
|
||||
List<DicTypeEO> isExist = dicTypeEOService.getTypeIdByDicIdAndTypeName("JKSADFH564S", null, null, null);
|
||||
isExist.forEach(item->{
|
||||
sarSort.add(item.getDicTypeCode());
|
||||
});
|
||||
|
||||
|
||||
error = importListMap.get("error");
|
||||
|
||||
AtomicInteger QYBZcount= new AtomicInteger();
|
||||
AtomicInteger QYBZcountUpdate= new AtomicInteger();
|
||||
AtomicInteger HWBZcount= new AtomicInteger();
|
||||
AtomicInteger HWBZcountUpdate= new AtomicInteger();
|
||||
AtomicInteger GNBZcount= new AtomicInteger();
|
||||
AtomicInteger GNBZcountUpdate= new AtomicInteger();
|
||||
|
||||
/**
|
||||
* 初始化国内外标准属性字段
|
||||
*/
|
||||
@@ -296,24 +333,26 @@ public class ImportExcelServiceImpl extends ServiceImpl<ImportExcelDao, ImportDt
|
||||
/**
|
||||
* 海外标准
|
||||
*/
|
||||
|
||||
|
||||
importListMap.get("HWBZ").forEach(item -> {
|
||||
if (true ) {
|
||||
String standID = UUIDUtils.randomUUID20();
|
||||
|
||||
String standID = UUIDUtils.randomUUID20();
|
||||
//使用初始化的属性字段映射 获得key值,value为""
|
||||
Map<String, String> mapField = standAttrMap;
|
||||
SarStandardsInfo ForeignEO = parseImportDtoToStandardsInfo(item,mapField, standID);
|
||||
|
||||
//使用初始化的属性字段映射 获得key值,value为""
|
||||
Map<String, String> mapField = standAttrMap;
|
||||
SarStandardsInfo ForeignEO = parseImportDtoToStandardsInfo(item,mapField, standID);
|
||||
if (ForeignEO != null) {
|
||||
ForeignEO.setValidFlag("0");
|
||||
ForeignEO.setStandType("FOREIGN");
|
||||
QueryWrapper<SarStandardsInfo> standSaveWrapper = new QueryWrapper<>();
|
||||
standSaveWrapper
|
||||
.eq("STAND_SORT", ForeignEO.getStandSort())
|
||||
.eq("STAND_NUMBER", ForeignEO.getStandNumber())
|
||||
.eq("STAND_YEAR", ForeignEO.getStandYear());
|
||||
|
||||
if (ForeignEO != null) {
|
||||
ForeignEO.setValidFlag("0");
|
||||
ForeignEO.setStandType("FOREIGN");
|
||||
QueryWrapper<SarStandardsInfo> standSaveWrapper = new QueryWrapper<>();
|
||||
standSaveWrapper
|
||||
.eq("STAND_SORT", ForeignEO.getStandSort())
|
||||
.eq("STAND_NUMBER", ForeignEO.getStandNumber())
|
||||
.eq("STAND_YEAR", ForeignEO.getStandYear());
|
||||
|
||||
SarStandardsInfo one = sarStandardsInfoService.getOne(standSaveWrapper);
|
||||
SarStandardsInfo one = sarStandardsInfoService.getOne(standSaveWrapper);
|
||||
|
||||
|
||||
|
||||
@@ -322,6 +361,9 @@ public class ImportExcelServiceImpl extends ServiceImpl<ImportExcelDao, ImportDt
|
||||
|
||||
try {
|
||||
sarStandardsInfoService.updateSarStandardsInfo(ForeignEO);
|
||||
HWBZcountUpdate.getAndIncrement();
|
||||
HWBZcount.getAndIncrement();
|
||||
System.out.println("海外标准执行更新===第: "+HWBZcount+"行");
|
||||
} catch (Exception e) {
|
||||
item.setErrorStr("标准更新失败");
|
||||
error.add(item);
|
||||
@@ -331,6 +373,8 @@ public class ImportExcelServiceImpl extends ServiceImpl<ImportExcelDao, ImportDt
|
||||
} else {
|
||||
try {
|
||||
sarStandardsInfoService.createSarStandardsInfo(ForeignEO);
|
||||
HWBZcount.getAndIncrement();
|
||||
System.out.println("海外标准执行新增===第: "+HWBZcount+"行");
|
||||
} catch (Exception e) {
|
||||
item.setErrorStr("标准新增失败");
|
||||
error.add(item);
|
||||
@@ -340,12 +384,16 @@ public class ImportExcelServiceImpl extends ServiceImpl<ImportExcelDao, ImportDt
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
item.setErrorStr("标准号无法解析");
|
||||
error.add(item);
|
||||
} else {
|
||||
item.setErrorStr("标准号无法解析");
|
||||
error.add(item);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
||||
@@ -354,56 +402,60 @@ public class ImportExcelServiceImpl extends ServiceImpl<ImportExcelDao, ImportDt
|
||||
*/
|
||||
|
||||
importListMap.get("GNBZ").forEach(item -> {
|
||||
String standID = UUIDUtils.randomUUID20();
|
||||
//使用初始化的属性字段映射 获得key值,value为""
|
||||
Map<String, String> mapStandField = standAttrMap;
|
||||
SarStandardsInfo InlandEO = parseImportDtoToStandardsInfo(item, mapStandField,standID);
|
||||
|
||||
if (InlandEO != null) {
|
||||
|
||||
|
||||
InlandEO.setValidFlag("0");
|
||||
InlandEO.setStandType("INLAND");
|
||||
if (true) {
|
||||
String standID = UUIDUtils.randomUUID20();
|
||||
//使用初始化的属性字段映射 获得key值,value为""
|
||||
Map<String, String> mapStandField = standAttrMap;
|
||||
SarStandardsInfo InlandEO = parseImportDtoToStandardsInfo(item, mapStandField, standID);
|
||||
|
||||
if (InlandEO != null) {
|
||||
|
||||
|
||||
QueryWrapper<SarStandardsInfo> standSaveWrapper = new QueryWrapper<>();
|
||||
standSaveWrapper
|
||||
.eq("STAND_SORT", InlandEO.getStandSort())
|
||||
.eq("STAND_NUMBER", InlandEO.getStandNumber())
|
||||
.eq("STAND_YEAR", InlandEO.getStandYear());
|
||||
InlandEO.setValidFlag("0");
|
||||
InlandEO.setStandType("INLAND");
|
||||
|
||||
|
||||
SarStandardsInfo one = sarStandardsInfoService.getOne(standSaveWrapper);
|
||||
if (one != null) {
|
||||
QueryWrapper<SarStandardsInfo> standSaveWrapper = new QueryWrapper<>();
|
||||
standSaveWrapper
|
||||
.eq("STAND_SORT", InlandEO.getStandSort())
|
||||
.eq("STAND_NUMBER", InlandEO.getStandNumber())
|
||||
.eq("STAND_YEAR", InlandEO.getStandYear());
|
||||
|
||||
|
||||
InlandEO.setId(one.getId());
|
||||
try {
|
||||
sarStandardsInfoService.updateSarStandardsInfo(InlandEO);
|
||||
} catch (Exception e) {
|
||||
item.setErrorStr("国内标准更新失败");
|
||||
error.add(item);
|
||||
e.printStackTrace();
|
||||
SarStandardsInfo one = sarStandardsInfoService.getOne(standSaveWrapper);
|
||||
if (one != null) {
|
||||
|
||||
|
||||
InlandEO.setId(one.getId());
|
||||
try {
|
||||
sarStandardsInfoService.updateSarStandardsInfo(InlandEO);
|
||||
} catch (Exception e) {
|
||||
item.setErrorStr("国内标准更新失败");
|
||||
error.add(item);
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
|
||||
|
||||
try {
|
||||
sarStandardsInfoService.createSarStandardsInfo(InlandEO);
|
||||
} catch (Exception e) {
|
||||
item.setErrorStr("国内标准新增失败");
|
||||
error.add(item);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
|
||||
|
||||
try {
|
||||
sarStandardsInfoService.createSarStandardsInfo(InlandEO);
|
||||
} catch (Exception e) {
|
||||
item.setErrorStr("国内标准新增失败");
|
||||
error.add(item);
|
||||
e.printStackTrace();
|
||||
}
|
||||
item.setErrorStr("标准号无法解析");
|
||||
error.add(item);
|
||||
importListMap.replace("error", error);
|
||||
}
|
||||
} else {
|
||||
item.setErrorStr("标准号无法解析");
|
||||
error.add(item);
|
||||
importListMap.replace("error", error);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
@@ -420,38 +472,61 @@ public class ImportExcelServiceImpl extends ServiceImpl<ImportExcelDao, ImportDt
|
||||
listStandBussField.forEach(item->{
|
||||
bussAttrMap.put(item,"");
|
||||
});
|
||||
|
||||
importListMap.get("QYBZ").forEach(item -> {
|
||||
String standId = UUIDUtils.randomUUID20();
|
||||
SarBussionessStand BussEO = parseImportDtoToSarBussionessStand(item, bussAttrMap,standId);
|
||||
|
||||
if (BussEO != null) {
|
||||
|
||||
try {
|
||||
QueryWrapper<SarBussionessStand> saveWrapper = new QueryWrapper<>();
|
||||
saveWrapper.eq("STAND_CODE", item.getStandId());
|
||||
SarBussionessStand one = sarBussionessStandService.getOne(saveWrapper);
|
||||
if (one != null) {
|
||||
BussEO.setId(one.getId());
|
||||
sarBussionessStandService.updateSarBussionessStand(BussEO);
|
||||
} else {
|
||||
sarBussionessStandService.createSarBussionessStand(BussEO);
|
||||
if (true){
|
||||
// if (item.getStandId().contains("Q/FT T396—2021") ){
|
||||
|
||||
String standId = UUIDUtils.randomUUID20();
|
||||
SarBussionessStand BussEO = parseImportDtoToSarBussionessStand(item, bussAttrMap,standId);
|
||||
|
||||
if (BussEO != null) {
|
||||
|
||||
try {
|
||||
QueryWrapper<SarBussionessStand> saveWrapper = new QueryWrapper<>();
|
||||
saveWrapper.eq("STAND_CODE", item.getStandId());
|
||||
SarBussionessStand one = sarBussionessStandService.getOne(saveWrapper);
|
||||
if (one != null) {
|
||||
BussEO.setId(one.getId());
|
||||
sarBussionessStandService.updateSarBussionessStand(BussEO);
|
||||
QYBZcountUpdate.getAndIncrement();
|
||||
QYBZcount.getAndIncrement();
|
||||
System.out.println("企业标准执行更新====第: "+QYBZcount+"行");
|
||||
|
||||
} else {
|
||||
sarBussionessStandService.createSarBussionessStand(BussEO);
|
||||
QYBZcount.getAndIncrement();
|
||||
System.out.println("企业标准执行新增第: "+QYBZcount+"行");
|
||||
}
|
||||
|
||||
|
||||
} catch (Exception e) {
|
||||
item.setErrorStr("数据格式错误");
|
||||
error.add(item);
|
||||
|
||||
e.printStackTrace();
|
||||
|
||||
}
|
||||
|
||||
|
||||
} catch (Exception e) {
|
||||
item.setErrorStr("数据格式错误");
|
||||
error.add(item);
|
||||
|
||||
e.printStackTrace();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
||||
error.addAll(fileError);
|
||||
System.out.println("执行结束");
|
||||
System.out.println("执行国内标准"+GNBZcount+"条");
|
||||
System.out.println("国内标准执行更新"+GNBZcountUpdate+"条");
|
||||
System.out.println("执行国外标准"+HWBZcount+"条");
|
||||
System.out.println("海外标准执行更新"+HWBZcountUpdate+"条");
|
||||
System.out.println("执行企业标准"+QYBZcount+"条");
|
||||
System.out.println("企业标准执行更新"+QYBZcountUpdate+"条");
|
||||
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
@@ -464,13 +539,10 @@ public class ImportExcelServiceImpl extends ServiceImpl<ImportExcelDao, ImportDt
|
||||
* @return
|
||||
*/
|
||||
public SarStandardsInfo parseImportDtoToStandardsInfo(ImportDto importDto,Map<String,String> fieldMap, String standId) {
|
||||
|
||||
|
||||
HashMap<String, String> analysis = analysisStandId(importDto);
|
||||
if (analysis == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
SarStandardsInfo sarStandardsInfoEO = new SarStandardsInfo();
|
||||
sarStandardsInfoEO.setId(standId);
|
||||
|
||||
@@ -507,21 +579,21 @@ public class ImportExcelServiceImpl extends ServiceImpl<ImportExcelDao, ImportDt
|
||||
if (importDto.getPath() != null) {
|
||||
String path[] = importDto.getPath().split("/");
|
||||
String realPath = "";
|
||||
for (int i = 4; i < path.length; i++) {
|
||||
for (int i = 3; i < path.length; i++) {
|
||||
realPath = realPath + "/" + path[i];
|
||||
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
// File file = new File("C:\\Users\\22501\\Desktop\\foton\\2021\\" + realPath);
|
||||
// File file = new File("C:\\Users\\22501\\Desktop\\foton\\" + realPath);
|
||||
// File file = new File(importPath + realPath);
|
||||
File file = new File("/home/file/2021/" + realPath);
|
||||
File file = new File("/data/from12/Attach_swf_bak" + realPath);
|
||||
if (file.exists()) {
|
||||
AttFileVo fileInfo = attFileEOService.saveFileInfo(file);
|
||||
|
||||
if (importDto.getImplementedTime() != null) {
|
||||
fieldMap.put("FBGJBD", fileInfo.getAttId());
|
||||
fieldMap.put("FBGBJBD", fileInfo.getAttId());
|
||||
} else {
|
||||
fieldMap.put("GLWJ", fileInfo.getAttId());
|
||||
}
|
||||
@@ -585,16 +657,16 @@ public class ImportExcelServiceImpl extends ServiceImpl<ImportExcelDao, ImportDt
|
||||
if (importDto.getPath() != null) {
|
||||
String path[] = importDto.getPath().split("/");
|
||||
String realPath = "";
|
||||
for (int i = 4; i < path.length; i++) {
|
||||
for (int i = 3; i < path.length; i++) {
|
||||
realPath = realPath + "/" + path[i];
|
||||
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
// File file = new File("C:\\Users\\22501\\Desktop\\foton\\2021\\" + realPath);
|
||||
// File file = new File("C:\\Users\\22501\\Desktop\\foton\\" + realPath);
|
||||
// File file = new File(importPath + realPath);
|
||||
File file = new File("/home/file/2021/" + realPath);
|
||||
File file = new File("/data/from12/Attach_swf_bak" + realPath);
|
||||
|
||||
if (file.exists()) {
|
||||
AttFileVo fileInfo = attFileEOService.saveFileInfo(file);
|
||||
@@ -671,8 +743,8 @@ public class ImportExcelServiceImpl extends ServiceImpl<ImportExcelDao, ImportDt
|
||||
result.put("number", number);
|
||||
result.put("year", year);
|
||||
//标准类别不存在,新增标准类别
|
||||
List<DicTypeEO> isExist = dicTypeEOService.getTypeIdByDicIdAndTypeName("JKSADFH564S", null, sort, null);
|
||||
if (isExist == null || isExist.isEmpty() || isExist.size()==0){
|
||||
// List<DicTypeEO> isExist = dicTypeEOService.getTypeIdByDicIdAndTypeName("JKSADFH564S", null, sort, null);
|
||||
if (!sarSort.contains(sort)){
|
||||
|
||||
DicTypeEO dicTypeVO = new DicTypeEO();
|
||||
dicTypeVO.setId(null);
|
||||
@@ -682,6 +754,7 @@ public class ImportExcelServiceImpl extends ServiceImpl<ImportExcelDao, ImportDt
|
||||
dicTypeVO.setShowIndex(1);
|
||||
Integer dicTypeEO = dicTypeEOService.saveDictype(dicTypeVO);
|
||||
if (dicTypeEO>0){
|
||||
sarSort.add(sort);
|
||||
importDto.setErrorStr("标准类别不存在,已新增");
|
||||
}else {
|
||||
importDto.setErrorStr("标准类别不存在,新增失败");
|
||||
@@ -692,7 +765,6 @@ public class ImportExcelServiceImpl extends ServiceImpl<ImportExcelDao, ImportDt
|
||||
|
||||
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user