commit
This commit is contained in:
+71
-37
@@ -19,8 +19,10 @@ import com.adc.da.slrs.sarStandardsInfo.dao.SarStandardsInfoDao;
|
|||||||
import com.adc.da.slrs.sarStandardsInfo.entity.SarStandardsInfo;
|
import com.adc.da.slrs.sarStandardsInfo.entity.SarStandardsInfo;
|
||||||
import com.adc.da.slrs.sarStandardsInfo.service.impl.SarStandardsInfoServiceImpl;
|
import com.adc.da.slrs.sarStandardsInfo.service.impl.SarStandardsInfoServiceImpl;
|
||||||
import com.adc.da.util.UUIDUtils;
|
import com.adc.da.util.UUIDUtils;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.google.gson.Gson;
|
||||||
import org.apache.poi.hssf.usermodel.HSSFRow;
|
import org.apache.poi.hssf.usermodel.HSSFRow;
|
||||||
import org.apache.poi.hssf.usermodel.HSSFSheet;
|
import org.apache.poi.hssf.usermodel.HSSFSheet;
|
||||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
||||||
@@ -34,7 +36,6 @@ import org.springframework.web.multipart.MultipartFile;
|
|||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.text.SimpleDateFormat;
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
@@ -282,13 +283,13 @@ public class ImportExcelServiceImpl extends ServiceImpl<ImportExcelDao, ImportDt
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Value("file.importPath")
|
@Value("file.importPath")
|
||||||
private String importPath;
|
private String importPath;
|
||||||
|
|
||||||
private List<ImportDto> error = new ArrayList<>();
|
private List<ImportDto> error = new ArrayList<>();
|
||||||
|
|
||||||
private List<ImportDto> fileError = new ArrayList<>();
|
private List<ImportDto> fileError = new ArrayList<>();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<ImportDto> storageExclData(Map<String, List<ImportDto>> importListMap) {
|
public List<ImportDto> storageExclData(Map<String, List<ImportDto>> importListMap) {
|
||||||
|
|
||||||
@@ -304,8 +305,7 @@ public class ImportExcelServiceImpl extends ServiceImpl<ImportExcelDao, ImportDt
|
|||||||
SarStandardsInfo sarStandardsInfo = parseImportDtoToStandardsInfo(item, standID);
|
SarStandardsInfo sarStandardsInfo = parseImportDtoToStandardsInfo(item, standID);
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
if (sarStandardsInfo!=null)
|
if (sarStandardsInfo != null) {
|
||||||
{
|
|
||||||
SarStandAttrInfo sarStandAttrInfo = parseImportDtoToStandAttrInfo(item, standID);
|
SarStandAttrInfo sarStandAttrInfo = parseImportDtoToStandAttrInfo(item, standID);
|
||||||
|
|
||||||
sarStandardsInfo.setValidFlag("0");
|
sarStandardsInfo.setValidFlag("0");
|
||||||
@@ -342,7 +342,6 @@ public class ImportExcelServiceImpl extends ServiceImpl<ImportExcelDao, ImportDt
|
|||||||
sarStandAttrInfoDao.insertStandAttr(field, value);
|
sarStandAttrInfoDao.insertStandAttr(field, value);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -356,7 +355,6 @@ public class ImportExcelServiceImpl extends ServiceImpl<ImportExcelDao, ImportDt
|
|||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 国内标准
|
* 国内标准
|
||||||
*/
|
*/
|
||||||
@@ -475,40 +473,89 @@ public class ImportExcelServiceImpl extends ServiceImpl<ImportExcelDao, ImportDt
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public SarStandardsInfo parseImportDtoToStandardsInfo(ImportDto importDto, String standId) {
|
public SarStandardsInfo parseImportDtoToStandardsInfo(ImportDto importDto, String standId) {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
HashMap<String, String> analysis = analysisStandId(importDto);
|
HashMap<String, String> analysis = analysisStandId(importDto);
|
||||||
if (analysis == null) {
|
if (analysis == null) {
|
||||||
return null;
|
return null;
|
||||||
}else {
|
}
|
||||||
|
|
||||||
SarStandardsInfo sarStandardsInfo = new SarStandardsInfo();
|
SarStandardsInfo sarStandardsInfoEO = new SarStandardsInfo();
|
||||||
sarStandardsInfo.setId(standId);
|
sarStandardsInfoEO.setId(standId);
|
||||||
|
|
||||||
|
|
||||||
sarStandardsInfo.setStandSort(analysis.get("sort"));
|
sarStandardsInfoEO.setStandSort(analysis.get("sort"));
|
||||||
sarStandardsInfo.setStandNumber(analysis.get("number"));
|
sarStandardsInfoEO.setStandNumber(analysis.get("number"));
|
||||||
sarStandardsInfo.setStandYear(analysis.get("year"));
|
sarStandardsInfoEO.setStandYear(analysis.get("year"));
|
||||||
|
|
||||||
sarStandardsInfo.setStandName(importDto.getStandName());
|
sarStandardsInfoEO.setStandName(importDto.getStandName());
|
||||||
sarStandardsInfo.setStandEnName(importDto.getStandNameEN());
|
sarStandardsInfoEO.setStandEnName(importDto.getStandNameEN());
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 截取发布日期 年月日
|
||||||
|
*/
|
||||||
String issueDate = importDto.getPublishTime().substring(0, 9);
|
String issueDate = importDto.getPublishTime().substring(0, 9);
|
||||||
sarStandardsInfo.setIssueTime(issueDate);//标准发布日期
|
sarStandardsInfoEO.setIssueTime(issueDate);//标准发布日期
|
||||||
|
|
||||||
String standStatus = importDto.getStandStatus();
|
String standStatus = importDto.getStandStatus();
|
||||||
if ("有效".equals(standStatus)) {
|
if ("有效".equals(standStatus)) {
|
||||||
sarStandardsInfo.setTextStatus("vsaga7nwub");//现行有效
|
sarStandardsInfoEO.setTextStatus("vsaga7nwub");//现行有效
|
||||||
}
|
}
|
||||||
|
|
||||||
return sarStandardsInfo;
|
/**
|
||||||
|
* 标准属性字段
|
||||||
|
*/
|
||||||
|
HashMap<String, String> attrInfoMap = new HashMap<>();
|
||||||
|
attrInfoMap.put("DTBJH", importDto.getReplaceId());
|
||||||
|
attrInfoMap.put("SSRQ", importDto.getImplementedTime().substring(0, 9));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 文件
|
||||||
|
*/
|
||||||
|
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) {
|
||||||
|
attrInfoMap.put("FBGJBD", fileInfo.getAttId());
|
||||||
|
} else {
|
||||||
|
attrInfoMap.put("GLWJ", fileInfo.getAttId());
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
importDto.setErrorStr("文件不存在");
|
||||||
|
fileError.add(importDto);
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
importDto.setErrorStr("文件打开失败");
|
||||||
|
fileError.add(importDto);
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
// attrInfoMap.put("")
|
||||||
|
Gson gson = new Gson();
|
||||||
|
|
||||||
|
String attrInfoJson = gson.toJson(attrInfoMap);
|
||||||
|
sarStandardsInfoEO.setSarStandAttrEOStr(attrInfoJson);
|
||||||
|
|
||||||
|
|
||||||
|
return sarStandardsInfoEO;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -516,7 +563,6 @@ public class ImportExcelServiceImpl extends ServiceImpl<ImportExcelDao, ImportDt
|
|||||||
public SarStandAttrInfo parseImportDtoToStandAttrInfo(ImportDto importDto, String standId) {
|
public SarStandAttrInfo parseImportDtoToStandAttrInfo(ImportDto importDto, String standId) {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
SarStandAttrInfo sarStandAttrInfo = new SarStandAttrInfo();
|
SarStandAttrInfo sarStandAttrInfo = new SarStandAttrInfo();
|
||||||
sarStandAttrInfo.setId(UUIDUtils.randomUUID20());
|
sarStandAttrInfo.setId(UUIDUtils.randomUUID20());
|
||||||
sarStandAttrInfo.setStandId(standId);
|
sarStandAttrInfo.setStandId(standId);
|
||||||
@@ -529,8 +575,7 @@ public class ImportExcelServiceImpl extends ServiceImpl<ImportExcelDao, ImportDt
|
|||||||
|
|
||||||
// Arrays.stream(path).limit(2,path.length);
|
// Arrays.stream(path).limit(2,path.length);
|
||||||
|
|
||||||
if (importDto.getPath()!=null)
|
if (importDto.getPath() != null) {
|
||||||
{
|
|
||||||
String path[] = importDto.getPath().split("/");
|
String path[] = importDto.getPath().split("/");
|
||||||
String realPath = "";
|
String realPath = "";
|
||||||
for (int i = 4; i < path.length; i++) {
|
for (int i = 4; i < path.length; i++) {
|
||||||
@@ -539,7 +584,6 @@ public class ImportExcelServiceImpl extends ServiceImpl<ImportExcelDao, ImportDt
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// File file = new File("C:\\Users\\22501\\Desktop\\foton\\2021\\" + realPath);
|
// File file = new File("C:\\Users\\22501\\Desktop\\foton\\2021\\" + realPath);
|
||||||
// File file = new File(importPath + realPath);
|
// File file = new File(importPath + realPath);
|
||||||
@@ -549,7 +593,6 @@ public class ImportExcelServiceImpl extends ServiceImpl<ImportExcelDao, ImportDt
|
|||||||
HashMap<String, String> fileMap = new HashMap<>();
|
HashMap<String, String> fileMap = new HashMap<>();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* * @Param: [standId, fileMap] fileMap<field,fileIds>
|
* * @Param: [standId, fileMap] fileMap<field,fileIds>
|
||||||
*/
|
*/
|
||||||
@@ -576,7 +619,6 @@ public class ImportExcelServiceImpl extends ServiceImpl<ImportExcelDao, ImportDt
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -585,9 +627,6 @@ public class ImportExcelServiceImpl extends ServiceImpl<ImportExcelDao, ImportDt
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public SarBussionessStand parseImportDtoToSarBussionessStand(ImportDto importDto, String standId) {
|
public SarBussionessStand parseImportDtoToSarBussionessStand(ImportDto importDto, String standId) {
|
||||||
|
|
||||||
|
|
||||||
@@ -613,7 +652,6 @@ public class ImportExcelServiceImpl extends ServiceImpl<ImportExcelDao, ImportDt
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -624,9 +662,7 @@ public class ImportExcelServiceImpl extends ServiceImpl<ImportExcelDao, ImportDt
|
|||||||
sarBussStandAttrInfo.setValidFlag("0");
|
sarBussStandAttrInfo.setValidFlag("0");
|
||||||
|
|
||||||
|
|
||||||
|
if (importDto.getPath() != null) {
|
||||||
if (importDto.getPath()!=null)
|
|
||||||
{
|
|
||||||
String path[] = importDto.getPath().split("/");
|
String path[] = importDto.getPath().split("/");
|
||||||
String realPath = "";
|
String realPath = "";
|
||||||
for (int i = 4; i < path.length; i++) {
|
for (int i = 4; i < path.length; i++) {
|
||||||
@@ -645,7 +681,6 @@ public class ImportExcelServiceImpl extends ServiceImpl<ImportExcelDao, ImportDt
|
|||||||
HashMap<String, String> fileMap = new HashMap<>();
|
HashMap<String, String> fileMap = new HashMap<>();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* * @Param: [standId, fileMap] fileMap<field,fileIds>
|
* * @Param: [standId, fileMap] fileMap<field,fileIds>
|
||||||
*/
|
*/
|
||||||
@@ -673,7 +708,6 @@ public class ImportExcelServiceImpl extends ServiceImpl<ImportExcelDao, ImportDt
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
return sarBussStandAttrInfo;
|
return sarBussStandAttrInfo;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user