commit
This commit is contained in:
+200
-166
@@ -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.service.impl.SarStandardsInfoServiceImpl;
|
||||
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;
|
||||
import org.apache.poi.hssf.usermodel.HSSFRow;
|
||||
import org.apache.poi.hssf.usermodel.HSSFSheet;
|
||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
||||
@@ -34,7 +36,6 @@ import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.InputStream;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
@@ -82,12 +83,12 @@ public class ImportExcelServiceImpl extends ServiceImpl<ImportExcelDao, ImportDt
|
||||
@Override
|
||||
public Map<String, List<ImportDto>> getExcelData(MultipartFile file, MultipartFile file2) {
|
||||
|
||||
List<String> dates=new ArrayList<>();
|
||||
for(int i=1669;i<2023;i++){
|
||||
dates.add("-"+i);
|
||||
dates.add("—"+i);
|
||||
dates.add("- "+i);
|
||||
dates.add("— "+i);
|
||||
List<String> dates = new ArrayList<>();
|
||||
for (int i = 1669; i < 2023; i++) {
|
||||
dates.add("-" + i);
|
||||
dates.add("—" + i);
|
||||
dates.add("- " + i);
|
||||
dates.add("— " + i);
|
||||
}
|
||||
|
||||
if (file == null || file.getSize() == 0) {
|
||||
@@ -138,10 +139,10 @@ public class ImportExcelServiceImpl extends ServiceImpl<ImportExcelDao, ImportDt
|
||||
datas.forEach(items -> {
|
||||
//判断是否是正确的数据
|
||||
String[] as = items.split(",");
|
||||
if (!inDate(as[0],dates)) {
|
||||
if (!inDate(as[0], dates)) {
|
||||
ImportDto importDto = getImportDto(as);
|
||||
error.add(importDto);
|
||||
middle.put(as[0].trim(), "error-"+error.size());
|
||||
middle.put(as[0].trim(), "error-" + error.size());
|
||||
} else {
|
||||
//数据二次拆解 针对标准进行拆解
|
||||
String[] step2 = as[0].trim().split(" ");
|
||||
@@ -149,15 +150,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[0].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[0].trim(), "QYBZ-" + QiBiao.size());
|
||||
} else {
|
||||
ImportDto importDto = getImportDto(as);
|
||||
OutCountry.add(importDto);
|
||||
middle.put(as[0].trim(), "HWBZ-"+OutCountry.size());
|
||||
middle.put(as[0].trim(), "HWBZ-" + OutCountry.size());
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -166,22 +167,22 @@ public class ImportExcelServiceImpl extends ServiceImpl<ImportExcelDao, ImportDt
|
||||
res.put("QYBZ", QiBiao);
|
||||
res.put("HWBZ", OutCountry);
|
||||
|
||||
fujian.forEach(items2 ->{
|
||||
String[] fj=items2.split(",");
|
||||
if (fj.length>2) {
|
||||
fujian.forEach(items2 -> {
|
||||
String[] fj = items2.split(",");
|
||||
if (fj.length > 2) {
|
||||
if (null != middle.get(null != fj[2] ? fj[2].trim() : "")) {
|
||||
//对应数据位置
|
||||
String[] location = middle.get(fj[2].trim()).split("-");
|
||||
res.get(location[0]).get(Integer.parseInt(location[1])-1).setPath(fj[3]);
|
||||
res.get(location[0]).get(Integer.parseInt(location[1]) - 1).setPath(fj[3]);
|
||||
}
|
||||
}
|
||||
} );
|
||||
});
|
||||
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
private boolean inDate(String as,List<String> dates) {
|
||||
private boolean inDate(String as, List<String> dates) {
|
||||
if (null != as && !"".equals(as)) {
|
||||
for (String s : dates) {
|
||||
if (s.equals(as.trim())) {
|
||||
@@ -282,13 +283,13 @@ public class ImportExcelServiceImpl extends ServiceImpl<ImportExcelDao, ImportDt
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Value("file.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
|
||||
public List<ImportDto> storageExclData(Map<String, List<ImportDto>> importListMap) {
|
||||
|
||||
@@ -297,75 +298,72 @@ public class ImportExcelServiceImpl extends ServiceImpl<ImportExcelDao, ImportDt
|
||||
/**
|
||||
* 海外标准
|
||||
*/
|
||||
importListMap.get("HWBZ").forEach(item->{
|
||||
importListMap.get("HWBZ").forEach(item -> {
|
||||
|
||||
String standID = UUIDUtils.randomUUID20();
|
||||
|
||||
SarStandardsInfo sarStandardsInfo = parseImportDtoToStandardsInfo(item, standID);
|
||||
//
|
||||
//
|
||||
if (sarStandardsInfo!=null)
|
||||
{
|
||||
if (sarStandardsInfo != null) {
|
||||
SarStandAttrInfo sarStandAttrInfo = parseImportDtoToStandAttrInfo(item, standID);
|
||||
|
||||
sarStandardsInfo.setValidFlag("0");
|
||||
sarStandardsInfo.setStandType("FOREIGN");
|
||||
QueryWrapper<SarStandardsInfo> standSaveWrapper = new QueryWrapper<>();
|
||||
standSaveWrapper
|
||||
.eq("STAND_SORT",sarStandardsInfo.getStandSort())
|
||||
.eq("STAND_NUMBER",sarStandardsInfo.getStandNumber())
|
||||
.eq("STAND_YEAR",sarStandardsInfo.getStandYear());
|
||||
sarStandardsInfo.setValidFlag("0");
|
||||
sarStandardsInfo.setStandType("FOREIGN");
|
||||
QueryWrapper<SarStandardsInfo> standSaveWrapper = new QueryWrapper<>();
|
||||
standSaveWrapper
|
||||
.eq("STAND_SORT", sarStandardsInfo.getStandSort())
|
||||
.eq("STAND_NUMBER", sarStandardsInfo.getStandNumber())
|
||||
.eq("STAND_YEAR", sarStandardsInfo.getStandYear());
|
||||
|
||||
SarStandardsInfo one = sarStandardsInfoService.getOne(standSaveWrapper);
|
||||
if (one!=null){
|
||||
sarStandardsInfo.setId(one.getId());
|
||||
SarStandardsInfo one = sarStandardsInfoService.getOne(standSaveWrapper);
|
||||
if (one != null) {
|
||||
sarStandardsInfo.setId(one.getId());
|
||||
|
||||
sarStandardsInfoService.update(sarStandardsInfo,standSaveWrapper);
|
||||
QueryWrapper<SarStandAttrInfo> standAttrWrapper = new QueryWrapper<>();
|
||||
standAttrWrapper.eq("STAND_ID",one.getId());
|
||||
sarStandardsInfoService.update(sarStandardsInfo, standSaveWrapper);
|
||||
QueryWrapper<SarStandAttrInfo> 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"+"\'";
|
||||
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 (sarStandAttrInfo.getSsrq() != null) {
|
||||
value += "," + "\'" + sarStandAttrInfo.getSsrq() + "\'";
|
||||
}
|
||||
sarStandAttrInfoDao.insertStandAttr(field, value);
|
||||
|
||||
|
||||
if (sarStandAttrInfo.getDtbjh()!=null){
|
||||
value+=","+"\'"+sarStandAttrInfo.getDtbjh()+"\'";
|
||||
}
|
||||
|
||||
if (sarStandAttrInfo.getSsrq()!=null){
|
||||
value+=","+"\'"+sarStandAttrInfo.getSsrq()+"\'";
|
||||
}
|
||||
sarStandAttrInfoDao.insertStandAttr(field,value);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}else{
|
||||
} else {
|
||||
item.setErrorStr("标准号无法解析");
|
||||
error.add(item);
|
||||
importListMap.replace("error",error);
|
||||
importListMap.replace("error", error);
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 国内标准
|
||||
*/
|
||||
importListMap.get("GNBZ").forEach(item->{
|
||||
importListMap.get("GNBZ").forEach(item -> {
|
||||
String standID = UUIDUtils.randomUUID20();
|
||||
|
||||
SarStandardsInfo sarStandardsInfo = parseImportDtoToStandardsInfo(item, standID);
|
||||
|
||||
if (sarStandardsInfo!=null){
|
||||
if (sarStandardsInfo != null) {
|
||||
SarStandAttrInfo sarStandAttrInfo = parseImportDtoToStandAttrInfo(item, standID);
|
||||
|
||||
sarStandardsInfo.setValidFlag("0");
|
||||
@@ -374,44 +372,44 @@ public class ImportExcelServiceImpl extends ServiceImpl<ImportExcelDao, ImportDt
|
||||
|
||||
QueryWrapper<SarStandardsInfo> standSaveWrapper = new QueryWrapper<>();
|
||||
standSaveWrapper
|
||||
.eq("STAND_SORT",sarStandardsInfo.getStandSort())
|
||||
.eq("STAND_NUMBER",sarStandardsInfo.getStandNumber())
|
||||
.eq("STAND_YEAR",sarStandardsInfo.getStandYear());
|
||||
.eq("STAND_SORT", sarStandardsInfo.getStandSort())
|
||||
.eq("STAND_NUMBER", sarStandardsInfo.getStandNumber())
|
||||
.eq("STAND_YEAR", sarStandardsInfo.getStandYear());
|
||||
|
||||
|
||||
SarStandardsInfo one = sarStandardsInfoService.getOne(standSaveWrapper);
|
||||
if (one!=null){
|
||||
if (one != null) {
|
||||
sarStandardsInfo.setId(one.getId());
|
||||
sarStandardsInfoService.update(sarStandardsInfo,standSaveWrapper);
|
||||
sarStandardsInfoService.update(sarStandardsInfo, standSaveWrapper);
|
||||
|
||||
QueryWrapper<SarStandAttrInfo> standAttrWrapper = new QueryWrapper<>();
|
||||
standAttrWrapper.eq("STAND_ID",one.getId());
|
||||
standAttrWrapper.eq("STAND_ID", one.getId());
|
||||
sarStandAttrInfo.setStandId(one.getId());
|
||||
sarStandAttrInfoService.update(sarStandAttrInfo,standAttrWrapper);
|
||||
}else {
|
||||
sarStandAttrInfoService.update(sarStandAttrInfo, standAttrWrapper);
|
||||
} else {
|
||||
|
||||
|
||||
sarStandardsInfoService.save(sarStandardsInfo);
|
||||
|
||||
|
||||
String field="ID,STAND_ID,VALID_FLAG,DTBJH,SSRQ";
|
||||
String value="\'"+sarStandAttrInfo.getId()+"\'"+","+"\'"+sarStandAttrInfo.getStandId()+"\'"+","+"\'"+"0"+"\'";
|
||||
String field = "ID,STAND_ID,VALID_FLAG,DTBJH,SSRQ";
|
||||
String value = "\'" + sarStandAttrInfo.getId() + "\'" + "," + "\'" + sarStandAttrInfo.getStandId() + "\'" + "," + "\'" + "0" + "\'";
|
||||
|
||||
|
||||
if (sarStandAttrInfo.getDtbjh()!=null){
|
||||
value+=","+"\'"+sarStandAttrInfo.getDtbjh()+"\'";
|
||||
if (sarStandAttrInfo.getDtbjh() != null) {
|
||||
value += "," + "\'" + sarStandAttrInfo.getDtbjh() + "\'";
|
||||
}
|
||||
|
||||
if (sarStandAttrInfo.getSsrq()!=null){
|
||||
value+=","+"\'"+sarStandAttrInfo.getSsrq()+"\'";
|
||||
if (sarStandAttrInfo.getSsrq() != null) {
|
||||
value += "," + "\'" + sarStandAttrInfo.getSsrq() + "\'";
|
||||
}
|
||||
sarStandAttrInfoDao.insertStandAttr(field,value);
|
||||
sarStandAttrInfoDao.insertStandAttr(field, value);
|
||||
|
||||
}
|
||||
}else {
|
||||
} else {
|
||||
item.setErrorStr("标准号无法解析");
|
||||
error.add(item);
|
||||
importListMap.replace("error",error);
|
||||
importListMap.replace("error", error);
|
||||
}
|
||||
|
||||
|
||||
@@ -421,12 +419,12 @@ public class ImportExcelServiceImpl extends ServiceImpl<ImportExcelDao, ImportDt
|
||||
/**
|
||||
* 企业标准
|
||||
*/
|
||||
importListMap.get("QYBZ").forEach(item->{
|
||||
String standId=UUIDUtils.randomUUID20();
|
||||
importListMap.get("QYBZ").forEach(item -> {
|
||||
String standId = UUIDUtils.randomUUID20();
|
||||
|
||||
SarBussionessStand sarBussionessStand = parseImportDtoToSarBussionessStand(item, standId);
|
||||
|
||||
if (sarBussionessStand!=null) {
|
||||
if (sarBussionessStand != null) {
|
||||
|
||||
SarBussStandAttrInfo sarBussStandAttrInfo = parseImportDtoToSarBussStandAttrInfo(item, standId);
|
||||
|
||||
@@ -475,46 +473,94 @@ 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);
|
||||
if (analysis==null){
|
||||
if (analysis == null) {
|
||||
return null;
|
||||
}else {
|
||||
}
|
||||
|
||||
SarStandardsInfo sarStandardsInfo = new SarStandardsInfo();
|
||||
sarStandardsInfo.setId(standId);
|
||||
SarStandardsInfo sarStandardsInfoEO = new SarStandardsInfo();
|
||||
sarStandardsInfoEO.setId(standId);
|
||||
|
||||
|
||||
sarStandardsInfo.setStandSort(analysis.get("sort"));
|
||||
sarStandardsInfo.setStandNumber(analysis.get("number"));
|
||||
sarStandardsInfo.setStandYear(analysis.get("year"));
|
||||
sarStandardsInfoEO.setStandSort(analysis.get("sort"));
|
||||
sarStandardsInfoEO.setStandNumber(analysis.get("number"));
|
||||
sarStandardsInfoEO.setStandYear(analysis.get("year"));
|
||||
|
||||
sarStandardsInfo.setStandName(importDto.getStandName());
|
||||
sarStandardsInfo.setStandEnName(importDto.getStandNameEN());
|
||||
sarStandardsInfoEO.setStandName(importDto.getStandName());
|
||||
sarStandardsInfoEO.setStandEnName(importDto.getStandNameEN());
|
||||
|
||||
String issueDate = importDto.getPublishTime().substring(0, 9);
|
||||
sarStandardsInfo.setIssueTime(issueDate);//标准发布日期
|
||||
/**
|
||||
* 截取发布日期 年月日
|
||||
*/
|
||||
String issueDate = importDto.getPublishTime().substring(0, 9);
|
||||
sarStandardsInfoEO.setIssueTime(issueDate);//标准发布日期
|
||||
|
||||
String standStatus = importDto.getStandStatus();
|
||||
if ("有效".equals(standStatus)) {
|
||||
sarStandardsInfoEO.setTextStatus("vsaga7nwub");//现行有效
|
||||
}
|
||||
|
||||
/**
|
||||
* 标准属性字段
|
||||
*/
|
||||
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];
|
||||
|
||||
String standStatus = importDto.getStandStatus();
|
||||
if ("有效".equals(standStatus)) {
|
||||
sarStandardsInfo.setTextStatus("vsaga7nwub");//现行有效
|
||||
}
|
||||
|
||||
return sarStandardsInfo;
|
||||
|
||||
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;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public SarStandAttrInfo parseImportDtoToStandAttrInfo(ImportDto importDto,String standId) {
|
||||
|
||||
public SarStandAttrInfo parseImportDtoToStandAttrInfo(ImportDto importDto, String standId) {
|
||||
|
||||
|
||||
SarStandAttrInfo sarStandAttrInfo = new SarStandAttrInfo();
|
||||
@@ -529,33 +575,30 @@ public class ImportExcelServiceImpl extends ServiceImpl<ImportExcelDao, ImportDt
|
||||
|
||||
// Arrays.stream(path).limit(2,path.length);
|
||||
|
||||
if (importDto.getPath()!=null)
|
||||
{
|
||||
if (importDto.getPath() != null) {
|
||||
String path[] = importDto.getPath().split("/");
|
||||
String realPath="";
|
||||
String realPath = "";
|
||||
for (int i = 4; i < path.length; i++) {
|
||||
realPath=realPath+"/"+path[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()){
|
||||
if (file.exists()) {
|
||||
AttFileVo fileInfo = attFileEOService.saveFileInfo(file);
|
||||
HashMap<String, String> fileMap = new HashMap<>();
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* * @Param: [standId, fileMap] fileMap<field,fileIds>
|
||||
*/
|
||||
fileMap.put("GLWJ",fileInfo.getAttId());
|
||||
fileMap.put("GLWJ", fileInfo.getAttId());
|
||||
try {
|
||||
sarStandardsInfoService.createStandFile(standId,fileMap);
|
||||
sarStandardsInfoService.createStandFile(standId, fileMap);
|
||||
} catch (Exception e) {
|
||||
importDto.setErrorStr("创建标准文件异常");
|
||||
fileError.add(importDto);
|
||||
@@ -564,19 +607,18 @@ public class ImportExcelServiceImpl extends ServiceImpl<ImportExcelDao, ImportDt
|
||||
}
|
||||
|
||||
sarStandAttrInfo.setGlwj(fileInfo.getAttId());
|
||||
}else {
|
||||
} else {
|
||||
importDto.setErrorStr("文件不存在");
|
||||
fileError.add(importDto);
|
||||
}
|
||||
|
||||
}catch (Exception e){
|
||||
} catch (Exception e) {
|
||||
importDto.setErrorStr("文件打开失败");
|
||||
fileError.add(importDto);
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -585,16 +627,13 @@ public class ImportExcelServiceImpl extends ServiceImpl<ImportExcelDao, ImportDt
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public SarBussionessStand parseImportDtoToSarBussionessStand(ImportDto importDto,String standId){
|
||||
public SarBussionessStand parseImportDtoToSarBussionessStand(ImportDto importDto, String standId) {
|
||||
|
||||
|
||||
HashMap<String, String> analysis = analysisStandId(importDto);
|
||||
if (analysis==null){
|
||||
if (analysis == null) {
|
||||
return null;
|
||||
}else {
|
||||
} else {
|
||||
SarBussionessStand sarBussionessStand = new SarBussionessStand();
|
||||
sarBussionessStand.setId(standId);
|
||||
sarBussionessStand.setStandSort(analysis.get("sort"));
|
||||
@@ -606,31 +645,28 @@ public class ImportExcelServiceImpl extends ServiceImpl<ImportExcelDao, ImportDt
|
||||
sarBussionessStand.setPutTime(importDto.getImplementedTime());
|
||||
sarBussionessStand.setReplacedStandNum(importDto.getReplaceId());
|
||||
sarBussionessStand.setValidFlag(0);
|
||||
if ("有效".equals(importDto.getStandStatus())){
|
||||
if ("有效".equals(importDto.getStandStatus())) {
|
||||
sarBussionessStand.setTextStatusBuss("vsaga7nwub");
|
||||
}
|
||||
return sarBussionessStand;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public SarBussStandAttrInfo parseImportDtoToSarBussStandAttrInfo(ImportDto importDto,String standId){
|
||||
public SarBussStandAttrInfo parseImportDtoToSarBussStandAttrInfo(ImportDto importDto, String standId) {
|
||||
SarBussStandAttrInfo sarBussStandAttrInfo = new SarBussStandAttrInfo();
|
||||
sarBussStandAttrInfo.setId(UUIDUtils.randomUUID20());
|
||||
sarBussStandAttrInfo.setStandId(standId);
|
||||
sarBussStandAttrInfo.setValidFlag("0");
|
||||
|
||||
|
||||
|
||||
if (importDto.getPath()!=null)
|
||||
{
|
||||
if (importDto.getPath() != null) {
|
||||
String path[] = importDto.getPath().split("/");
|
||||
String realPath="";
|
||||
String realPath = "";
|
||||
for (int i = 4; i < path.length; i++) {
|
||||
realPath=realPath+"/"+path[i];
|
||||
realPath = realPath + "/" + path[i];
|
||||
|
||||
}
|
||||
|
||||
@@ -640,77 +676,75 @@ public class ImportExcelServiceImpl extends ServiceImpl<ImportExcelDao, ImportDt
|
||||
// File file = new File(importPath + realPath);
|
||||
File file = new File("/home/file/2021/" + realPath);
|
||||
|
||||
if (file.exists()){
|
||||
AttFileVo fileInfo = attFileEOService.saveFileInfo(file);
|
||||
HashMap<String, String> fileMap = new HashMap<>();
|
||||
if (file.exists()) {
|
||||
AttFileVo fileInfo = attFileEOService.saveFileInfo(file);
|
||||
HashMap<String, String> fileMap = new HashMap<>();
|
||||
|
||||
|
||||
/**
|
||||
* * @Param: [standId, fileMap] fileMap<field,fileIds>
|
||||
*/
|
||||
fileMap.put("GLWJBUSS", fileInfo.getAttId());
|
||||
try {
|
||||
sarBussionessStandService.createStandFile(standId, fileMap);
|
||||
} catch (Exception e) {
|
||||
importDto.setErrorStr("创建标准文件异常");
|
||||
fileError.add(importDto);
|
||||
e.printStackTrace();
|
||||
System.out.println("创建标准文件异常");
|
||||
}
|
||||
|
||||
/**
|
||||
* * @Param: [standId, fileMap] fileMap<field,fileIds>
|
||||
*/
|
||||
fileMap.put("GLWJBUSS",fileInfo.getAttId());
|
||||
try {
|
||||
sarBussionessStandService.createStandFile(standId,fileMap);
|
||||
} catch (Exception e) {
|
||||
importDto.setErrorStr("创建标准文件异常");
|
||||
sarBussStandAttrInfo.setGlwj(fileInfo.getAttId());
|
||||
|
||||
} else {
|
||||
importDto.setErrorStr("文件不存在");
|
||||
fileError.add(importDto);
|
||||
e.printStackTrace();
|
||||
System.out.println("创建标准文件异常");
|
||||
}
|
||||
|
||||
sarBussStandAttrInfo.setGlwj(fileInfo.getAttId());
|
||||
|
||||
}else {
|
||||
importDto.setErrorStr("文件不存在");
|
||||
} catch (Exception e) {
|
||||
importDto.setErrorStr("路径错误!");
|
||||
fileError.add(importDto);
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}catch (Exception e){
|
||||
importDto.setErrorStr("路径错误!");
|
||||
fileError.add(importDto);
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
return sarBussStandAttrInfo;
|
||||
}
|
||||
|
||||
|
||||
public HashMap<String,String> analysisStandId(ImportDto importDto){
|
||||
public HashMap<String, String> analysisStandId(ImportDto importDto) {
|
||||
HashMap<String, String> result = new HashMap<>();
|
||||
if(importDto.getStandId()==null){
|
||||
if (importDto.getStandId() == null) {
|
||||
importDto.setErrorStr("标准号为空");
|
||||
error.add(importDto);
|
||||
return null;
|
||||
}else {
|
||||
} else {
|
||||
String standId = importDto.getStandId();
|
||||
//格式 非空格字符+空格+非空格字符+‘-’或‘—’或空格+年份 如Q/FT F003—2001
|
||||
Pattern pattern = Pattern.compile("^\\S*\\s\\S*[\\u2014\\u002d\\s]\\d{4}$");
|
||||
if (!pattern.matcher(standId).matches()){
|
||||
if (!pattern.matcher(standId).matches()) {
|
||||
importDto.setErrorStr("标准号无法解析");
|
||||
error.add(importDto);
|
||||
return null;
|
||||
}
|
||||
|
||||
String sort="";
|
||||
String number="";
|
||||
String year="";
|
||||
String sort = "";
|
||||
String number = "";
|
||||
String year = "";
|
||||
String[] split = importDto.getStandId().split("[\\u2014\\u002d\\s]");//以空格或'-'或'—'分割
|
||||
|
||||
// 多种格式(╯‵□′)╯︵┻━┻ Q-FL T015-2021 Q/ FL T015-2021 Q/FL T015-2021
|
||||
int length = split.length;
|
||||
number=split[length-2];
|
||||
year=split[length-1];
|
||||
for (int i = 0; i < length-2; i++) {
|
||||
sort+=split[i];
|
||||
number = split[length - 2];
|
||||
year = split[length - 1];
|
||||
for (int i = 0; i < length - 2; i++) {
|
||||
sort += split[i];
|
||||
}
|
||||
|
||||
result.put("sort",sort);
|
||||
result.put("number",number);
|
||||
result.put("year",year);
|
||||
result.put("sort", sort);
|
||||
result.put("number", number);
|
||||
result.put("year", year);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user