feat: 老部门新部门对应关系导入
This commit is contained in:
+3
@@ -34,6 +34,9 @@ public class OldSystemImportDTO {
|
|||||||
@Excel(name = "BZFL", width = 15, orderNum = "6")
|
@Excel(name = "BZFL", width = 15, orderNum = "6")
|
||||||
private String bzfl;
|
private String bzfl;
|
||||||
|
|
||||||
|
@Excel(name = "国家/地区", width = 15, orderNum = "6", dicCode = "country_or_region")
|
||||||
|
private String country;
|
||||||
|
|
||||||
@Excel(name = "BZYYTYPE", width = 15, orderNum = "7")
|
@Excel(name = "BZYYTYPE", width = 15, orderNum = "7")
|
||||||
private String bzyytype;
|
private String bzyytype;
|
||||||
|
|
||||||
|
|||||||
+13
-21
@@ -28,33 +28,19 @@ public class OldSystemDepartRelation implements Serializable {
|
|||||||
@ApiModelProperty(value = "主键ID")
|
@ApiModelProperty(value = "主键ID")
|
||||||
private String id;
|
private String id;
|
||||||
|
|
||||||
/**
|
|
||||||
* 组织部门
|
|
||||||
*/
|
|
||||||
@Excel(name = "组织部门", width = 15)
|
|
||||||
@ApiModelProperty(value = "组织部门")
|
|
||||||
private String oldOrgName;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 上级组织
|
* 上级组织
|
||||||
*/
|
*/
|
||||||
@Excel(name = "上级组织", width = 15)
|
@Excel(name = "旧上级组织", width = 15)
|
||||||
@ApiModelProperty(value = "上级组织")
|
@ApiModelProperty(value = "旧上级组织")
|
||||||
private String oldOrgSuperior;
|
private String oldOrgSuperior;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 组织级别
|
* 组织部门
|
||||||
*/
|
*/
|
||||||
@Excel(name = "组织级别", width = 15)
|
@Excel(name = "旧组织部门", width = 15)
|
||||||
@ApiModelProperty(value = "组织级别")
|
@ApiModelProperty(value = "旧组织部门")
|
||||||
private String orgLevel;
|
private String oldOrgName;
|
||||||
|
|
||||||
/**
|
|
||||||
* 现组织部门
|
|
||||||
*/
|
|
||||||
@Excel(name = "现组织部门", width = 15)
|
|
||||||
@ApiModelProperty(value = "现组织部门")
|
|
||||||
private String curOrgName;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 现上级组织
|
* 现上级组织
|
||||||
@@ -63,6 +49,13 @@ public class OldSystemDepartRelation implements Serializable {
|
|||||||
@ApiModelProperty(value = "现上级组织")
|
@ApiModelProperty(value = "现上级组织")
|
||||||
private String curOrgSuperior;
|
private String curOrgSuperior;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 现组织部门
|
||||||
|
*/
|
||||||
|
@Excel(name = "现组织部门", width = 15)
|
||||||
|
@ApiModelProperty(value = "现组织部门")
|
||||||
|
private String curOrgName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 现组织部门Id
|
* 现组织部门Id
|
||||||
*/
|
*/
|
||||||
@@ -89,7 +82,6 @@ public class OldSystemDepartRelation implements Serializable {
|
|||||||
public boolean isEmptyRow() {
|
public boolean isEmptyRow() {
|
||||||
return oldOrgName == null &&
|
return oldOrgName == null &&
|
||||||
oldOrgSuperior == null &&
|
oldOrgSuperior == null &&
|
||||||
orgLevel == null &&
|
|
||||||
curOrgName == null &&
|
curOrgName == null &&
|
||||||
curOrgSuperior == null &&
|
curOrgSuperior == null &&
|
||||||
curOrgId == null &&
|
curOrgId == null &&
|
||||||
|
|||||||
+4
@@ -75,6 +75,10 @@ public class OldSystemDepartRelationServiceImpl extends ServiceImpl<OldSystemDep
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
log.info("导入数据条数:{}", list.size());
|
||||||
|
// 过滤掉新部门为空的数据
|
||||||
|
list = list.stream().filter(dr -> dr.getCurOrgName() != null && !dr.getCurOrgName().isEmpty()).collect(Collectors.toList());
|
||||||
|
log.info("过滤掉新部门为空的数据后数据条数:{}", list.size());
|
||||||
// 获取所有有关联的新部门
|
// 获取所有有关联的新部门
|
||||||
LambdaQueryWrapper<SysDepart> sysDeptWrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<SysDepart> sysDeptWrapper = new LambdaQueryWrapper<>();
|
||||||
sysDeptWrapper.eq(SysDepart::getDelFlag, CommonConstant.DEL_FLAG_0.toString());
|
sysDeptWrapper.eq(SysDepart::getDelFlag, CommonConstant.DEL_FLAG_0.toString());
|
||||||
|
|||||||
+81
-53
@@ -228,6 +228,13 @@ public class LawsEnterpriseStandardServiceImpl extends ServiceImpl<LawsEnterpris
|
|||||||
// 文件关联
|
// 文件关联
|
||||||
List<OSSFile> ossFileList = new ArrayList<>();
|
List<OSSFile> ossFileList = new ArrayList<>();
|
||||||
long startTime = System.currentTimeMillis();
|
long startTime = System.currentTimeMillis();
|
||||||
|
LambdaQueryWrapper<SysUser> userWrapper = new LambdaQueryWrapper<>();
|
||||||
|
userWrapper.eq(SysUser::getRealname, "杨永鹏");
|
||||||
|
userWrapper.eq(SysUser::getUsername, "077652");
|
||||||
|
SysUser defaultUser = sysUserService.getOne(userWrapper);
|
||||||
|
if (defaultUser == null) {
|
||||||
|
throw new JeroBootException("未找到默认用户");
|
||||||
|
}
|
||||||
// 转换数据
|
// 转换数据
|
||||||
List<LawsOverseasStandard> fbList = new ArrayList<>();
|
List<LawsOverseasStandard> fbList = new ArrayList<>();
|
||||||
for (OldSystemImportDTO dto : fbDatalist) {
|
for (OldSystemImportDTO dto : fbDatalist) {
|
||||||
@@ -277,6 +284,11 @@ public class LawsEnterpriseStandardServiceImpl extends ServiceImpl<LawsEnterpris
|
|||||||
fb.setSubstituteStandardNumber(dto.getTdbzh());
|
fb.setSubstituteStandardNumber(dto.getTdbzh());
|
||||||
fb.setReplacedByStandardNumber(dto.getBtdbzh());
|
fb.setReplacedByStandardNumber(dto.getBtdbzh());
|
||||||
|
|
||||||
|
String excelCountry = dto.getCountry();
|
||||||
|
if (StrUtil.isNotBlank(excelCountry)) {
|
||||||
|
fb.setCountryOrRegion(dto.getCountry());
|
||||||
|
}
|
||||||
|
|
||||||
// 责任部门暂不导入
|
// 责任部门暂不导入
|
||||||
// String zrbm = dto.getZrbm();
|
// String zrbm = dto.getZrbm();
|
||||||
// if (oldDeptMap.get(zrbm) != null && oldDeptMap.get(zrbm).get(0) != null) {
|
// if (oldDeptMap.get(zrbm) != null && oldDeptMap.get(zrbm).get(0) != null) {
|
||||||
@@ -295,24 +307,24 @@ public class LawsEnterpriseStandardServiceImpl extends ServiceImpl<LawsEnterpris
|
|||||||
if (sysUser != null) {
|
if (sysUser != null) {
|
||||||
fb.setResponsibleDepartmentUser(sysUser.getId());
|
fb.setResponsibleDepartmentUser(sysUser.getId());
|
||||||
} else {
|
} else {
|
||||||
throw new JeroBootException("未找到责任人,姓名:" + zrr + ",工号:" + zrrid + ",标准编号:" + dto.getBzh());
|
fb.setResponsibleDepartmentUser(defaultUser.getId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 根据文件路径获取文件Id
|
// 根据文件路径获取文件Id
|
||||||
// String originPath = dto.getSclj();
|
String originPath = dto.getSclj();
|
||||||
// if (StrUtil.isNotBlank(originPath)) {
|
if (StrUtil.isNotBlank(originPath)) {
|
||||||
// String filePath = this.getFilePath(originPath);
|
String filePath = this.getFilePath(originPath);
|
||||||
// if (MinioUtil.doesObjectExist(filePath)) {
|
if (MinioUtil.doesObjectExist(filePath)) {
|
||||||
// // 存入关系表
|
// 存入关系表
|
||||||
// OSSFile ossFile = new OSSFile();
|
OSSFile ossFile = new OSSFile();
|
||||||
// ossFile.setUrl(filePath);
|
ossFile.setUrl(filePath);
|
||||||
// ossFile.setStandardNo(dto.getBzh());
|
ossFile.setStandardNo(dto.getBzh());
|
||||||
// ossFile.setFileName(FileUtil.getName(filePath));
|
ossFile.setFileName(FileUtil.getName(filePath));
|
||||||
// ossFile.setStandardFileType("publish_of_original");
|
ossFile.setStandardFileType("publish_of_original");
|
||||||
// ossFileList.add(ossFile);
|
ossFileList.add(ossFile);
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
fbList.add(fb);
|
fbList.add(fb);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("导入转换外标数据时发生错误:{}", e.getMessage());
|
log.error("导入转换外标数据时发生错误:{}", e.getMessage());
|
||||||
@@ -669,13 +681,15 @@ public class LawsEnterpriseStandardServiceImpl extends ServiceImpl<LawsEnterpris
|
|||||||
datalist = datalist.stream().filter(data -> !this.containsChinese(data.getBzh())).collect(Collectors.toList());
|
datalist = datalist.stream().filter(data -> !this.containsChinese(data.getBzh())).collect(Collectors.toList());
|
||||||
// 剔除不导入的数据 国家标准/GJB国家军用标准
|
// 剔除不导入的数据 国家标准/GJB国家军用标准
|
||||||
// datalist = datalist.stream().filter(data -> !data.getBzfl().equals("国家标准/GJB国家军用标准")).collect(Collectors.toList());
|
// datalist = datalist.stream().filter(data -> !data.getBzfl().equals("国家标准/GJB国家军用标准")).collect(Collectors.toList());
|
||||||
// // 删除政策 文件 之后的数据
|
// 删除政策 文件 之后的数据
|
||||||
// datalist = datalist.stream().filter(data -> !this.containsChinese(data.getBzh())).collect(Collectors.toList());
|
datalist = datalist.stream().filter(data -> !this.containsChinese(data.getBzh())).collect(Collectors.toList());
|
||||||
//// // 只取用国标数据
|
//// // 只取用国标数据
|
||||||
//// datalist = datalist.stream().filter(data -> data.getBzfl().startsWith("国家标准")).collect(Collectors.toList());
|
//// datalist = datalist.stream().filter(data -> data.getBzfl().startsWith("国家标准")).collect(Collectors.toList());
|
||||||
//// // 只取用外标数据
|
// // 只取用外标数据
|
||||||
// datalist = datalist.stream().filter(data -> data.getBzfl().contains("国外") || data.getBzfl().contains("ISO"))
|
datalist = datalist.stream().filter(data -> data.getBzfl().contains("国外") ||
|
||||||
// .collect(Collectors.toList());
|
data.getBzfl().contains("ISO") ||
|
||||||
|
data.getBzfl().contains("引进"))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
|
|
||||||
// 区分数据
|
// 区分数据
|
||||||
@@ -858,6 +872,14 @@ public class LawsEnterpriseStandardServiceImpl extends ServiceImpl<LawsEnterpris
|
|||||||
// 文件关联
|
// 文件关联
|
||||||
List<OSSFile> ossFileList = new ArrayList<>();
|
List<OSSFile> ossFileList = new ArrayList<>();
|
||||||
long startTime = System.currentTimeMillis();
|
long startTime = System.currentTimeMillis();
|
||||||
|
// 获取默认用户
|
||||||
|
LambdaQueryWrapper<SysUser> userWrapper = new LambdaQueryWrapper<>();
|
||||||
|
userWrapper.eq(SysUser::getRealname, "杨永鹏");
|
||||||
|
userWrapper.eq(SysUser::getUsername, "077652");
|
||||||
|
SysUser defaultUser = sysUserService.getOne(userWrapper);
|
||||||
|
if (defaultUser == null) {
|
||||||
|
throw new JeroBootException("未找到默认用户");
|
||||||
|
}
|
||||||
// 转换数据
|
// 转换数据
|
||||||
List<LawsDomesticStandard> gbList = new ArrayList<>();
|
List<LawsDomesticStandard> gbList = new ArrayList<>();
|
||||||
for (OldSystemImportDTO dto : gbDatalist) {
|
for (OldSystemImportDTO dto : gbDatalist) {
|
||||||
@@ -885,6 +907,9 @@ public class LawsEnterpriseStandardServiceImpl extends ServiceImpl<LawsEnterpris
|
|||||||
String ssrq = dto.getSsrq();
|
String ssrq = dto.getSsrq();
|
||||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
|
||||||
if (StrUtil.isNotBlank(fbrq)) {
|
if (StrUtil.isNotBlank(fbrq)) {
|
||||||
|
if (fbrq.length() == 6) {
|
||||||
|
fbrq = fbrq + "01";
|
||||||
|
}
|
||||||
Date newDate = sdf.parse(fbrq.trim());
|
Date newDate = sdf.parse(fbrq.trim());
|
||||||
if (newDate != null) {
|
if (newDate != null) {
|
||||||
gb.setReleaseDate(newDate);
|
gb.setReleaseDate(newDate);
|
||||||
@@ -893,6 +918,9 @@ public class LawsEnterpriseStandardServiceImpl extends ServiceImpl<LawsEnterpris
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (StrUtil.isNotBlank(ssrq)) {
|
if (StrUtil.isNotBlank(ssrq)) {
|
||||||
|
if (ssrq.length() == 6) {
|
||||||
|
ssrq = ssrq + "01";
|
||||||
|
}
|
||||||
Date newDate = sdf.parse(ssrq.trim());
|
Date newDate = sdf.parse(ssrq.trim());
|
||||||
if (newDate != null) {
|
if (newDate != null) {
|
||||||
gb.setImplementationDate(newDate);
|
gb.setImplementationDate(newDate);
|
||||||
@@ -925,24 +953,24 @@ public class LawsEnterpriseStandardServiceImpl extends ServiceImpl<LawsEnterpris
|
|||||||
if (sysUser != null) {
|
if (sysUser != null) {
|
||||||
gb.setResponsibleDepartmentUser(sysUser.getId());
|
gb.setResponsibleDepartmentUser(sysUser.getId());
|
||||||
} else {
|
} else {
|
||||||
throw new JeroBootException("未找到责任人,姓名:" + zrr + ",工号:" + zrrid + ",标准编号:" + dto.getBzh());
|
gb.setResponsibleDepartmentUser(defaultUser.getId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 根据文件路径获取文件Id
|
// 根据文件路径获取文件Id
|
||||||
// String originPath = dto.getSclj();
|
String originPath = dto.getSclj();
|
||||||
// if (StrUtil.isNotBlank(originPath)) {
|
if (StrUtil.isNotBlank(originPath)) {
|
||||||
// String filePath = this.getFilePath(originPath);
|
String filePath = this.getFilePath(originPath);
|
||||||
// if (MinioUtil.doesObjectExist(filePath)) {
|
if (MinioUtil.doesObjectExist(filePath)) {
|
||||||
// // 存入关系表
|
// 存入关系表
|
||||||
// OSSFile ossFile = new OSSFile();
|
OSSFile ossFile = new OSSFile();
|
||||||
// ossFile.setUrl(filePath);
|
ossFile.setUrl(filePath);
|
||||||
// ossFile.setStandardNo(dto.getBzh());
|
ossFile.setStandardNo(dto.getBzh());
|
||||||
// ossFile.setFileName(FileUtil.getName(filePath));
|
ossFile.setFileName(FileUtil.getName(filePath));
|
||||||
// ossFile.setStandardFileType("publish_of_original");
|
ossFile.setStandardFileType("publish_of_original");
|
||||||
// ossFileList.add(ossFile);
|
ossFileList.add(ossFile);
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
gb.setIsAsmsImport("0");
|
gb.setIsAsmsImport("0");
|
||||||
gbList.add(gb);
|
gbList.add(gb);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@@ -1157,19 +1185,19 @@ public class LawsEnterpriseStandardServiceImpl extends ServiceImpl<LawsEnterpris
|
|||||||
es.setCategoryCode(excelUtils.translateDictValue("standard_category_code", categoryCode, listDict));
|
es.setCategoryCode(excelUtils.translateDictValue("standard_category_code", categoryCode, listDict));
|
||||||
}
|
}
|
||||||
// 根据文件路径获取文件Id
|
// 根据文件路径获取文件Id
|
||||||
// String originPath = dto.getSclj();
|
String originPath = dto.getSclj();
|
||||||
// if (StrUtil.isNotBlank(originPath)) {
|
if (StrUtil.isNotBlank(originPath)) {
|
||||||
// String filePath = this.getFilePath(originPath);
|
String filePath = this.getFilePath(originPath);
|
||||||
// if (MinioUtil.doesObjectExist(filePath)) {
|
if (MinioUtil.doesObjectExist(filePath)) {
|
||||||
// // 存入关系表
|
// 存入关系表
|
||||||
// OSSFile ossFile = new OSSFile();
|
OSSFile ossFile = new OSSFile();
|
||||||
// ossFile.setUrl(filePath);
|
ossFile.setUrl(filePath);
|
||||||
// ossFile.setStandardNo(dto.getBzh());
|
ossFile.setStandardNo(dto.getBzh());
|
||||||
// ossFile.setFileName(FileUtil.getName(filePath));
|
ossFile.setFileName(FileUtil.getName(filePath));
|
||||||
// ossFile.setStandardFileType("publish_of_original");
|
ossFile.setStandardFileType("publish_of_original");
|
||||||
// ossFileList.add(ossFile);
|
ossFileList.add(ossFile);
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
esList.add(es);
|
esList.add(es);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("导入转换企标数据时发生错误:{}", e.getMessage());
|
log.error("导入转换企标数据时发生错误:{}", e.getMessage());
|
||||||
@@ -1188,7 +1216,7 @@ public class LawsEnterpriseStandardServiceImpl extends ServiceImpl<LawsEnterpris
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 3. 将文件关系列表转为Map,用于快速查找
|
// 3. 将文件关系列表转为Map,用于快速查找
|
||||||
// Map<String, List<OSSFile>> standardNumberToFileMap = ossFileList.stream().collect(Collectors.groupingBy(OSSFile::getStandardNo));
|
Map<String, List<OSSFile>> standardNumberToFileMap = ossFileList.stream().collect(Collectors.groupingBy(OSSFile::getStandardNo));
|
||||||
|
|
||||||
// 4. 遍历待保存或更新的列表,设置ID
|
// 4. 遍历待保存或更新的列表,设置ID
|
||||||
StringBuilder oldIds = new StringBuilder();
|
StringBuilder oldIds = new StringBuilder();
|
||||||
@@ -1229,12 +1257,12 @@ public class LawsEnterpriseStandardServiceImpl extends ServiceImpl<LawsEnterpris
|
|||||||
// 保存文件关联
|
// 保存文件关联
|
||||||
String standardId = entity.getId();
|
String standardId = entity.getId();
|
||||||
// 保存文件关联
|
// 保存文件关联
|
||||||
// List<OSSFile> ossFiles = standardNumberToFileMap.get(entity.getStandardNumber());
|
List<OSSFile> ossFiles = standardNumberToFileMap.get(entity.getStandardNumber());
|
||||||
// if (ossFiles != null && !ossFiles.isEmpty()) {
|
if (ossFiles != null && !ossFiles.isEmpty()) {
|
||||||
// OSSFile ossFile = ossFiles.get(0);
|
OSSFile ossFile = ossFiles.get(0);
|
||||||
// ossFile.setStandardId(standardId);
|
ossFile.setStandardId(standardId);
|
||||||
// ossFileService.save(ossFile);
|
ossFileService.save(ossFile);
|
||||||
// }
|
}
|
||||||
entity.setId(standardId);
|
entity.setId(standardId);
|
||||||
// 拼接新id
|
// 拼接新id
|
||||||
newIds.append(standardId).append(",");
|
newIds.append(standardId).append(",");
|
||||||
|
|||||||
Reference in New Issue
Block a user