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