导入数据时,标准类别不存在时新增
This commit is contained in:
+57
-16
@@ -2,6 +2,7 @@ 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;
|
||||
@@ -9,6 +10,10 @@ 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;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
@@ -269,11 +274,16 @@ public class ImportExcelServiceImpl extends ServiceImpl<ImportExcelDao, ImportDt
|
||||
@Autowired
|
||||
private ISarStandardsInfoService sarStandardsInfoService;
|
||||
|
||||
@Autowired
|
||||
private DicTypeEOServiceImpl dicTypeEOService;
|
||||
|
||||
@Autowired
|
||||
private ISarBussionessStandService sarBussionessStandService;
|
||||
@Override
|
||||
public List<ImportDto> storageExclData(Map<String, List<ImportDto>> importListMap) {
|
||||
|
||||
|
||||
|
||||
error = importListMap.get("error");
|
||||
/**
|
||||
* 初始化国内外标准属性字段
|
||||
@@ -292,8 +302,8 @@ public class ImportExcelServiceImpl extends ServiceImpl<ImportExcelDao, ImportDt
|
||||
String standID = UUIDUtils.randomUUID20();
|
||||
|
||||
//使用初始化的属性字段映射 获得key值,value为""
|
||||
Map<String, String> mapFilter = standAttrMap;
|
||||
SarStandardsInfo ForeignEO = parseImportDtoToStandardsInfo(item,mapFilter, standID);
|
||||
Map<String, String> mapField = standAttrMap;
|
||||
SarStandardsInfo ForeignEO = parseImportDtoToStandardsInfo(item,mapField, standID);
|
||||
|
||||
if (ForeignEO != null) {
|
||||
ForeignEO.setValidFlag("0");
|
||||
@@ -347,8 +357,8 @@ public class ImportExcelServiceImpl extends ServiceImpl<ImportExcelDao, ImportDt
|
||||
importListMap.get("GNBZ").forEach(item -> {
|
||||
String standID = UUIDUtils.randomUUID20();
|
||||
//使用初始化的属性字段映射 获得key值,value为""
|
||||
Map<String, String> mapStandFiled = standAttrMap;
|
||||
SarStandardsInfo InlandEO = parseImportDtoToStandardsInfo(item, mapStandFiled,standID);
|
||||
Map<String, String> mapStandField = standAttrMap;
|
||||
SarStandardsInfo InlandEO = parseImportDtoToStandardsInfo(item, mapStandField,standID);
|
||||
|
||||
if (InlandEO != null) {
|
||||
|
||||
@@ -450,11 +460,11 @@ public class ImportExcelServiceImpl extends ServiceImpl<ImportExcelDao, ImportDt
|
||||
/**
|
||||
* 整理为标准信息实体
|
||||
* @param importDto
|
||||
* @param filedMap 属性字段
|
||||
* @param fieldMap 属性字段
|
||||
* @param standId
|
||||
* @return
|
||||
*/
|
||||
public SarStandardsInfo parseImportDtoToStandardsInfo(ImportDto importDto,Map<String,String> filedMap, String standId) {
|
||||
public SarStandardsInfo parseImportDtoToStandardsInfo(ImportDto importDto,Map<String,String> fieldMap, String standId) {
|
||||
|
||||
|
||||
HashMap<String, String> analysis = analysisStandId(importDto);
|
||||
@@ -488,8 +498,8 @@ public class ImportExcelServiceImpl extends ServiceImpl<ImportExcelDao, ImportDt
|
||||
* 标准属性字段
|
||||
*/
|
||||
|
||||
filedMap.put("DTBJH", importDto.getReplaceId());
|
||||
filedMap.put("SSRQ", importDto.getImplementedTime().substring(0, 19));
|
||||
fieldMap.put("DTBJH", importDto.getReplaceId());
|
||||
fieldMap.put("SSRQ", importDto.getImplementedTime().substring(0, 19));
|
||||
|
||||
|
||||
/**
|
||||
@@ -512,9 +522,9 @@ public class ImportExcelServiceImpl extends ServiceImpl<ImportExcelDao, ImportDt
|
||||
AttFileVo fileInfo = attFileEOService.saveFileInfo(file);
|
||||
|
||||
if (importDto.getImplementedTime() != null) {
|
||||
filedMap.put("FBGJBD", fileInfo.getAttId());
|
||||
fieldMap.put("FBGJBD", fileInfo.getAttId());
|
||||
} else {
|
||||
filedMap.put("GLWJ", fileInfo.getAttId());
|
||||
fieldMap.put("GLWJ", fileInfo.getAttId());
|
||||
}
|
||||
|
||||
} else {
|
||||
@@ -531,7 +541,7 @@ public class ImportExcelServiceImpl extends ServiceImpl<ImportExcelDao, ImportDt
|
||||
}
|
||||
// attrInfoMap.put("")
|
||||
Gson gson = new Gson();
|
||||
String attrInfoJson = gson.toJson(filedMap);
|
||||
String attrInfoJson = gson.toJson(fieldMap);
|
||||
sarStandardsInfoEO.setSarStandAttrEOStr(attrInfoJson);//新增修改时属性表信息
|
||||
|
||||
|
||||
@@ -546,7 +556,7 @@ public class ImportExcelServiceImpl extends ServiceImpl<ImportExcelDao, ImportDt
|
||||
* @param standId
|
||||
* @return
|
||||
*/
|
||||
public SarBussionessStand parseImportDtoToSarBussionessStand(ImportDto importDto,Map<String,String> mapFiled, String standId) {
|
||||
public SarBussionessStand parseImportDtoToSarBussionessStand(ImportDto importDto,Map<String,String> fieldMap, String standId) {
|
||||
|
||||
|
||||
HashMap<String, String> analysis = analysisStandId(importDto);
|
||||
@@ -592,10 +602,10 @@ public class ImportExcelServiceImpl extends ServiceImpl<ImportExcelDao, ImportDt
|
||||
|
||||
|
||||
if (importDto.getImplementedTime()!=null && importDto.getImplementedTime()!=""){
|
||||
mapFiled.put("FBGBUSS",fileInfo.getAttId());
|
||||
fieldMap.put("FBGBUSS",fileInfo.getAttId());
|
||||
|
||||
}else {
|
||||
mapFiled.put("GLWJBUSS",fileInfo.getAttId());
|
||||
fieldMap.put("GLWJBUSS",fileInfo.getAttId());
|
||||
}
|
||||
|
||||
|
||||
@@ -614,7 +624,7 @@ public class ImportExcelServiceImpl extends ServiceImpl<ImportExcelDao, ImportDt
|
||||
|
||||
}
|
||||
|
||||
String attrInfoJson = new Gson().toJson(mapFiled);
|
||||
String attrInfoJson = new Gson().toJson(fieldMap);
|
||||
sarBussionessStand.setSarStandAttrEOStr(attrInfoJson);//新增修改时属性表信息
|
||||
return sarBussionessStand;
|
||||
}
|
||||
@@ -623,7 +633,11 @@ public class ImportExcelServiceImpl extends ServiceImpl<ImportExcelDao, ImportDt
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 解析标准号,标准类别不存在则新增
|
||||
* @param importDto
|
||||
* @return
|
||||
*/
|
||||
public HashMap<String, String> analysisStandId(ImportDto importDto) {
|
||||
HashMap<String, String> result = new HashMap<>();
|
||||
if (importDto.getStandId() == null) {
|
||||
@@ -645,6 +659,7 @@ public class ImportExcelServiceImpl extends ServiceImpl<ImportExcelDao, ImportDt
|
||||
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];
|
||||
@@ -656,10 +671,36 @@ public class ImportExcelServiceImpl extends ServiceImpl<ImportExcelDao, ImportDt
|
||||
result.put("sort", sort);
|
||||
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){
|
||||
|
||||
DicTypeEO dicTypeVO = new DicTypeEO();
|
||||
dicTypeVO.setId(null);
|
||||
dicTypeVO.setDicId("JKSADFH564S");
|
||||
dicTypeVO.setDicTypeCode(sort);
|
||||
dicTypeVO.setDicTypeName(sort);
|
||||
dicTypeVO.setShowIndex(1);
|
||||
Integer dicTypeEO = dicTypeEOService.saveDictype(dicTypeVO);
|
||||
if (dicTypeEO>0){
|
||||
importDto.setErrorStr("标准类别不存在,已新增");
|
||||
}else {
|
||||
importDto.setErrorStr("标准类别不存在,新增失败");
|
||||
}
|
||||
error.add(importDto);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user