feat: 老法规企标授权部门对应关系导入
This commit is contained in:
@@ -40,6 +40,10 @@ public class ESAuthDept {
|
|||||||
@ApiModelProperty(value = "组织部门")
|
@ApiModelProperty(value = "组织部门")
|
||||||
private String deptName;
|
private String deptName;
|
||||||
|
|
||||||
|
@Excel(name = "错误信息", width = 35)
|
||||||
|
@ApiModelProperty(value = "错误信息")
|
||||||
|
private String errorInfo;
|
||||||
|
|
||||||
public boolean isEmptyRow() {
|
public boolean isEmptyRow() {
|
||||||
return standardId == null &&
|
return standardId == null &&
|
||||||
standardNumber == null &&
|
standardNumber == null &&
|
||||||
|
|||||||
+14
-21
@@ -222,7 +222,9 @@ public class LawsEnterpriseStandardServiceImpl extends ServiceImpl<LawsEnterpris
|
|||||||
this.oldSysGBImport(gbDatalist, errImportList);
|
this.oldSysGBImport(gbDatalist, errImportList);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.exportWithExcel(response, errImportList, "OldSystemStandardErrorData.xls");
|
if (!errImportList.isEmpty()) {
|
||||||
|
this.exportWithExcel(response, errImportList, "OldSystemStandardErrorData.xls");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -397,7 +399,7 @@ public class LawsEnterpriseStandardServiceImpl extends ServiceImpl<LawsEnterpris
|
|||||||
@Override
|
@Override
|
||||||
public void importOldESAuthDeptExcel(MultipartFile file, HttpServletResponse response) {
|
public void importOldESAuthDeptExcel(MultipartFile file, HttpServletResponse response) {
|
||||||
List<ESAuthDept> errImportList = new ArrayList<>();
|
List<ESAuthDept> errImportList = new ArrayList<>();
|
||||||
// 验证文件是否为压缩格式file.getContentType()).contains("xls")
|
// 验证文件是否为压缩格式
|
||||||
if (!Objects.requireNonNull(file.getOriginalFilename()).contains("xls")) {
|
if (!Objects.requireNonNull(file.getOriginalFilename()).contains("xls")) {
|
||||||
throw new JeroBootException("文件格式不正确,请上传Excel。");
|
throw new JeroBootException("文件格式不正确,请上传Excel。");
|
||||||
}
|
}
|
||||||
@@ -443,8 +445,6 @@ public class LawsEnterpriseStandardServiceImpl extends ServiceImpl<LawsEnterpris
|
|||||||
sysDeptWrapper.eq(SysDepart::getDelFlag, CommonConstant.DEL_FLAG_0.toString());
|
sysDeptWrapper.eq(SysDepart::getDelFlag, CommonConstant.DEL_FLAG_0.toString());
|
||||||
sysDeptWrapper.eq(SysDepart::getStatus, 1);
|
sysDeptWrapper.eq(SysDepart::getStatus, 1);
|
||||||
List<SysDepart> curDeptList = sysDepartService.list(sysDeptWrapper);
|
List<SysDepart> curDeptList = sysDepartService.list(sysDeptWrapper);
|
||||||
Map<String, List<SysDepart>> curDeptNameMap = curDeptList.stream().collect(Collectors.groupingBy(SysDepart::getDepartName));
|
|
||||||
Map<String, SysDepart> curDeptIdMap = curDeptList.stream().collect(Collectors.toMap(SysDepart::getId, o -> o));
|
|
||||||
curDeptList.add(sysDepartService.getById("0"));
|
curDeptList.add(sysDepartService.getById("0"));
|
||||||
|
|
||||||
List<OldSystemDepartRelation> drList = oldSystemDepartRelationService.list();
|
List<OldSystemDepartRelation> drList = oldSystemDepartRelationService.list();
|
||||||
@@ -452,6 +452,10 @@ public class LawsEnterpriseStandardServiceImpl extends ServiceImpl<LawsEnterpris
|
|||||||
|
|
||||||
for (ESAuthDept ad : datalist) {
|
for (ESAuthDept ad : datalist) {
|
||||||
try {
|
try {
|
||||||
|
LawsEnterpriseStandard es = esMap.get(ad.getStandardId());
|
||||||
|
if (es == null) {
|
||||||
|
throw new JeroBootException("系统中未找到标准编号:" + ad.getStandardNumber());
|
||||||
|
}
|
||||||
String oldDeptName = ad.getDeptName();
|
String oldDeptName = ad.getDeptName();
|
||||||
String oldHigherDeptName = ad.getHigherDeptName();
|
String oldHigherDeptName = ad.getHigherDeptName();
|
||||||
// 根据老部门名称从关系表中找到新部门名称
|
// 根据老部门名称从关系表中找到新部门名称
|
||||||
@@ -459,27 +463,16 @@ public class LawsEnterpriseStandardServiceImpl extends ServiceImpl<LawsEnterpris
|
|||||||
if (oldSystemDepartRelation == null) {
|
if (oldSystemDepartRelation == null) {
|
||||||
throw new JeroBootException("未找到该部门的现部门名称:" + oldDeptName + ",上级部门名称:" + oldHigherDeptName + ",标准编号:" + ad.getStandardNumber());
|
throw new JeroBootException("未找到该部门的现部门名称:" + oldDeptName + ",上级部门名称:" + oldHigherDeptName + ",标准编号:" + ad.getStandardNumber());
|
||||||
} else {
|
} else {
|
||||||
// 通过现部门名称找到对应的新部门
|
EnterpriseStandardAuthDept authDept = new EnterpriseStandardAuthDept();
|
||||||
List<SysDepart> curDepts = curDeptNameMap.get(oldSystemDepartRelation.getCurOrgName());
|
authDept.setStandardId(es.getId());
|
||||||
if (curDepts == null || curDepts.isEmpty()) {
|
authDept.setAuthDept(oldSystemDepartRelation.getCurOrgId());
|
||||||
throw new JeroBootException("未找到该部门,部门名称:" + oldDeptName + ",上级部门名称:" + oldHigherDeptName + ",标准编号:" + ad.getStandardNumber());
|
esAuthDeptService.save(authDept);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// 如果只有一个则找到
|
|
||||||
// List<String> deptNameList = "";
|
|
||||||
// String curDeptId = curDeptNameMap.get(ad.getDeptName() + "-" + ad.getHigherDeptName()).getId();
|
|
||||||
// if (StrUtil.isBlank(curDeptId)) {
|
|
||||||
// log.error("导入部门对应出现错误:{}", "找不到对应的新部门");
|
|
||||||
// log.error("错误数据:{}", ad.toString());
|
|
||||||
// continue;
|
|
||||||
// }
|
|
||||||
// EnterpriseStandardAuthDept authDept = new EnterpriseStandardAuthDept();
|
|
||||||
// authDept.setStandardId(esMap.get(ad.getStandardId()).getId());
|
|
||||||
// authDept.setAuthDept(curDeptId);
|
|
||||||
// esAuthDeptService.save(authDept);
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("导入部门对应出现错误:{}", e.getMessage());
|
log.error("导入部门对应出现错误:{}", e.getMessage());
|
||||||
log.error("错误数据:{}", ad.toString());
|
log.error("错误数据:{}", ad.toString());
|
||||||
|
ad.setErrorInfo(e.getMessage());
|
||||||
|
errImportList.add(ad);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|||||||
Reference in New Issue
Block a user