feat: 企标部门权限导入
This commit is contained in:
@@ -33,11 +33,23 @@ public class ESAuthDept {
|
|||||||
@ApiModelProperty(value = "标准分类")
|
@ApiModelProperty(value = "标准分类")
|
||||||
private String standardType;
|
private String standardType;
|
||||||
|
|
||||||
|
@Excel(name = "旧上级组织")
|
||||||
|
@ApiModelProperty(value = "上级组织")
|
||||||
|
private String oldHigherDeptName;
|
||||||
|
|
||||||
|
@Excel(name = "旧组织部门")
|
||||||
|
@ApiModelProperty(value = "组织部门")
|
||||||
|
private String oldDeptName;
|
||||||
|
|
||||||
|
@Excel(name = "再上一级组织(部分存在)")
|
||||||
|
@ApiModelProperty(value = "再上一级组织(部分存在)")
|
||||||
|
private String higherHigherDeptName;
|
||||||
|
|
||||||
@Excel(name = "上级组织")
|
@Excel(name = "上级组织")
|
||||||
@ApiModelProperty(value = "上级组织")
|
@ApiModelProperty(value = "上级组织")
|
||||||
private String higherDeptName;
|
private String higherDeptName;
|
||||||
|
|
||||||
@Excel(name = "组织部门")
|
@Excel(name = "新部门")
|
||||||
@ApiModelProperty(value = "组织部门")
|
@ApiModelProperty(value = "组织部门")
|
||||||
private String deptName;
|
private String deptName;
|
||||||
|
|
||||||
@@ -51,6 +63,9 @@ public class ESAuthDept {
|
|||||||
standardNumber == null &&
|
standardNumber == null &&
|
||||||
standardName == null &&
|
standardName == null &&
|
||||||
standardType == null &&
|
standardType == null &&
|
||||||
|
oldHigherDeptName == null &&
|
||||||
|
oldDeptName == null &&
|
||||||
|
higherHigherDeptName == null &&
|
||||||
higherDeptName == null &&
|
higherDeptName == null &&
|
||||||
deptName == null;
|
deptName == null;
|
||||||
}
|
}
|
||||||
|
|||||||
+50
-14
@@ -246,7 +246,7 @@ public class LawsEnterpriseStandardServiceImpl extends ServiceImpl<LawsEnterpris
|
|||||||
fb.setStandardNumber(newBzh);
|
fb.setStandardNumber(newBzh);
|
||||||
String cybzh = dto.getCybzh();
|
String cybzh = dto.getCybzh();
|
||||||
// 采用标准号为空跳过拆分
|
// 采用标准号为空跳过拆分
|
||||||
if (StrUtil.isNotBlank(cybzh)){
|
if (StrUtil.isNotBlank(cybzh)) {
|
||||||
// 执行拆分
|
// 执行拆分
|
||||||
Map<String, String> map = StandardSplitUtils.simpleSplitStandardNumber(newBzh, cybzh);
|
Map<String, String> map = StandardSplitUtils.simpleSplitStandardNumber(newBzh, cybzh);
|
||||||
fb.setStandardClass(map.get(FieldCommon.STANDARD_CLASS));
|
fb.setStandardClass(map.get(FieldCommon.STANDARD_CLASS));
|
||||||
@@ -580,6 +580,7 @@ public class LawsEnterpriseStandardServiceImpl extends ServiceImpl<LawsEnterpris
|
|||||||
|
|
||||||
// 获取数据
|
// 获取数据
|
||||||
List<ESAuthDept> datalist;
|
List<ESAuthDept> datalist;
|
||||||
|
List<EnterpriseStandardAuthDept> correctDataList = new ArrayList<>();
|
||||||
try {
|
try {
|
||||||
// 获取当前时间戳(毫秒)
|
// 获取当前时间戳(毫秒)
|
||||||
long startTime = System.currentTimeMillis();
|
long startTime = System.currentTimeMillis();
|
||||||
@@ -594,6 +595,10 @@ public class LawsEnterpriseStandardServiceImpl extends ServiceImpl<LawsEnterpris
|
|||||||
datalist = datalist.stream().filter(data -> StrUtil.isNotBlank(data.getStandardType()))
|
datalist = datalist.stream().filter(data -> StrUtil.isNotBlank(data.getStandardType()))
|
||||||
.filter(data -> data.getStandardType().startsWith("企业标准")).collect(Collectors.toList());
|
.filter(data -> data.getStandardType().startsWith("企业标准")).collect(Collectors.toList());
|
||||||
log.info("企标相关数据条数:{}", datalist.size());
|
log.info("企标相关数据条数:{}", datalist.size());
|
||||||
|
// 过滤掉新部门为空的数据
|
||||||
|
datalist = datalist.stream().filter(dr -> dr.getDeptName() != null && !dr.getDeptName().isEmpty()).collect(Collectors.toList());
|
||||||
|
log.info("过滤掉新部门为空的数据后数据条数:{}", datalist.size());
|
||||||
|
|
||||||
// 获取当前时间戳(毫秒)
|
// 获取当前时间戳(毫秒)
|
||||||
long endTime = System.currentTimeMillis();
|
long endTime = System.currentTimeMillis();
|
||||||
// 计算执行时间(毫秒)
|
// 计算执行时间(毫秒)
|
||||||
@@ -607,13 +612,10 @@ public class LawsEnterpriseStandardServiceImpl extends ServiceImpl<LawsEnterpris
|
|||||||
|
|
||||||
// 获取所有有关联的新部门
|
// 获取所有有关联的新部门
|
||||||
LambdaQueryWrapper<SysDepart> sysDeptWrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<SysDepart> sysDeptWrapper = new LambdaQueryWrapper<>();
|
||||||
sysDeptWrapper.eq(SysDepart::getDelFlag, CommonConstant.DEL_FLAG_0.toString());
|
sysDeptWrapper.eq(SysDepart::getDelFlag, YesOrNoEnum.NO.getValue());
|
||||||
sysDeptWrapper.eq(SysDepart::getStatus, 1);
|
sysDeptWrapper.eq(SysDepart::getStatus, 1);
|
||||||
List<SysDepart> curDeptList = sysDepartService.list(sysDeptWrapper);
|
List<SysDepart> curDeptList = sysDepartService.list(sysDeptWrapper);
|
||||||
curDeptList.add(sysDepartService.getById("0"));
|
Map<String, List<SysDepart>> curDeptNameMap = curDeptList.stream().collect(Collectors.groupingBy(SysDepart::getDepartName));
|
||||||
|
|
||||||
List<OldSystemDepartRelation> drList = oldSystemDepartRelationService.list();
|
|
||||||
Map<String, OldSystemDepartRelation> drMap = drList.stream().collect(Collectors.toMap(o -> o.getOldOrgName() + "-" + o.getOldOrgSuperior(), o -> o));
|
|
||||||
|
|
||||||
for (ESAuthDept ad : datalist) {
|
for (ESAuthDept ad : datalist) {
|
||||||
try {
|
try {
|
||||||
@@ -621,17 +623,49 @@ public class LawsEnterpriseStandardServiceImpl extends ServiceImpl<LawsEnterpris
|
|||||||
if (es == null) {
|
if (es == null) {
|
||||||
throw new JeroBootException("系统中未找到标准编号:" + ad.getStandardNumber());
|
throw new JeroBootException("系统中未找到标准编号:" + ad.getStandardNumber());
|
||||||
}
|
}
|
||||||
String oldDeptName = ad.getDeptName();
|
|
||||||
String oldHigherDeptName = ad.getHigherDeptName();
|
|
||||||
// 根据老部门名称从关系表中找到新部门名称
|
// 根据老部门名称从关系表中找到新部门名称
|
||||||
OldSystemDepartRelation oldSystemDepartRelation = drMap.get(oldDeptName + "-" + oldHigherDeptName);
|
List<SysDepart> sysDeparts = curDeptNameMap.get(ad.getDeptName());
|
||||||
if (oldSystemDepartRelation == null) {
|
if (sysDeparts == null || sysDeparts.isEmpty()) {
|
||||||
throw new JeroBootException("未找到该部门的现部门名称:" + oldDeptName + ",上级部门名称:" + oldHigherDeptName + ",标准编号:" + ad.getStandardNumber());
|
throw new JeroBootException("系统中未找到同名的现部门");
|
||||||
|
} else {
|
||||||
|
if (sysDeparts.size() > 1) {
|
||||||
|
// 根据上级部门名称再次匹配
|
||||||
|
for (SysDepart sysDepart : sysDeparts) {
|
||||||
|
String parentDeptName = ad.getHigherDeptName();
|
||||||
|
List<SysDepart> sysParentDeparts = curDeptNameMap.get(parentDeptName);
|
||||||
|
if (sysParentDeparts == null || sysParentDeparts.isEmpty()) {
|
||||||
|
throw new JeroBootException("匹配到多个同名部门,但系统中未找到同名的上级部门");
|
||||||
|
}
|
||||||
|
if (sysParentDeparts.size() > 1) {
|
||||||
|
String parentParentDeptName = ad.getHigherHigherDeptName();
|
||||||
|
if (StrUtil.isBlank(parentParentDeptName)) {
|
||||||
|
throw new JeroBootException("匹配到多个同名部门,匹配到多个同名上级部门,但缺失上级部门的上级部门");
|
||||||
|
}
|
||||||
|
List<SysDepart> sysParentParentDeparts = curDeptNameMap.get(parentParentDeptName);
|
||||||
|
if (sysParentParentDeparts.size() == 1) {
|
||||||
|
EnterpriseStandardAuthDept authDept = new EnterpriseStandardAuthDept();
|
||||||
|
authDept.setStandardId(es.getId());
|
||||||
|
authDept.setAuthDept(sysDepart.getId());
|
||||||
|
correctDataList.add(authDept);
|
||||||
|
break;
|
||||||
|
} else {
|
||||||
|
throw new JeroBootException("匹配到多个同名部门,但无法通过上级部门的上级部门名称确定具体部门");
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
EnterpriseStandardAuthDept authDept = new EnterpriseStandardAuthDept();
|
EnterpriseStandardAuthDept authDept = new EnterpriseStandardAuthDept();
|
||||||
authDept.setStandardId(es.getId());
|
authDept.setStandardId(es.getId());
|
||||||
authDept.setAuthDept(oldSystemDepartRelation.getCurOrgId());
|
authDept.setAuthDept(sysDepart.getId());
|
||||||
esAuthDeptService.save(authDept);
|
correctDataList.add(authDept);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
EnterpriseStandardAuthDept authDept = new EnterpriseStandardAuthDept();
|
||||||
|
SysDepart sysDepart = sysDeparts.get(0);
|
||||||
|
authDept.setStandardId(es.getId());
|
||||||
|
authDept.setAuthDept(sysDepart.getId());
|
||||||
|
correctDataList.add(authDept);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("导入部门对应出现错误:{}", e.getMessage());
|
log.error("导入部门对应出现错误:{}", e.getMessage());
|
||||||
@@ -643,6 +677,8 @@ public class LawsEnterpriseStandardServiceImpl extends ServiceImpl<LawsEnterpris
|
|||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("导入失败;{}", e.getMessage());
|
log.error("导入失败;{}", e.getMessage());
|
||||||
}
|
}
|
||||||
|
esAuthDeptService.saveBatch(correctDataList, correctDataList.size());
|
||||||
|
log.info("企标部门权限导入成功,成功条数{}", correctDataList.size());
|
||||||
if (!errImportList.isEmpty()) {
|
if (!errImportList.isEmpty()) {
|
||||||
log.info("导入失败数据条数:{}", errImportList.size());
|
log.info("导入失败数据条数:{}", errImportList.size());
|
||||||
this.exportWithExcel(response, errImportList, "ESAuthDeptErrorData.xls");
|
this.exportWithExcel(response, errImportList, "ESAuthDeptErrorData.xls");
|
||||||
@@ -891,7 +927,7 @@ public class LawsEnterpriseStandardServiceImpl extends ServiceImpl<LawsEnterpris
|
|||||||
gb.setStandardNumber(newBzh);
|
gb.setStandardNumber(newBzh);
|
||||||
String cybzh = dto.getCybzh();
|
String cybzh = dto.getCybzh();
|
||||||
// 采用标准号为空跳过拆分
|
// 采用标准号为空跳过拆分
|
||||||
if (StrUtil.isNotBlank(cybzh)){
|
if (StrUtil.isNotBlank(cybzh)) {
|
||||||
// 执行拆分
|
// 执行拆分
|
||||||
Map<String, String> map = StandardSplitUtils.simpleSplitStandardNumber(newBzh, cybzh);
|
Map<String, String> map = StandardSplitUtils.simpleSplitStandardNumber(newBzh, cybzh);
|
||||||
gb.setStandardClass(map.get(FieldCommon.STANDARD_CLASS));
|
gb.setStandardClass(map.get(FieldCommon.STANDARD_CLASS));
|
||||||
|
|||||||
Reference in New Issue
Block a user