fix: 后端丢失class

This commit is contained in:
2023-11-30 09:04:48 +08:00
parent e6d3b0155c
commit c7d4419378
8 changed files with 297 additions and 37 deletions
@@ -26,4 +26,31 @@ public interface ILawsEnterpriseStandardService extends IService<LawsEnterpriseS
* @return
*/
void importExcelOldSystem(MultipartFile file, String type, HttpServletResponse response);
/**
* 老法规企标所有人权限数据导入
*
* @param file
* @param response
* @return
*/
void importOldESAuthAllExcel(MultipartFile file, HttpServletResponse response);
/**
* 老法规企标个人权限数据导入
*
* @param file
* @param response
* @return
*/
void importOldESAuthUserExcel(MultipartFile file, HttpServletResponse response);
/**
* 老法规企标部门权限数据导入
*
* @param file
* @param response
* @return
*/
void importOldESAuthDeptExcel(MultipartFile file, HttpServletResponse response);
}
@@ -115,6 +115,9 @@ public class LawsEnterpriseStandardServiceImpl extends ServiceImpl<LawsEnterpris
@Resource
private ILawsHomeSearchService lawsHomeSearchService;
@Resource
private ISysDepartService sysDepartService;
@Override
public LawsEnterpriseStandard queryByStandardNumber(String standardNumber) {
if (StringUtils.isBlank(standardNumber)) {
@@ -210,7 +213,7 @@ public class LawsEnterpriseStandardServiceImpl extends ServiceImpl<LawsEnterpris
}
// 导入国标
// 判断是否需要跳过
if (gbDatalist.isEmpty()) {
if (gbDatalist.isEmpty()) {
log.info("国标数据为空,跳过导入");
} else {
this.oldSysGBImport(gbDatalist, errImportList);
@@ -391,29 +394,56 @@ public class LawsEnterpriseStandardServiceImpl extends ServiceImpl<LawsEnterpris
List<LawsEnterpriseStandard> esList = this.list(esWrapper.isNotNull(LawsEnterpriseStandard::getOldSystemId));
Map<String, LawsEnterpriseStandard> esMap = esList.stream().collect(Collectors.toMap(LawsEnterpriseStandard::getOldSystemId, o -> o));
Map<String, List<ESAuthDept>> auMap = datalist.stream().collect(Collectors.groupingBy(ESAuthDept::getStandardId));
List<SysDepart> deptlist = departService.list();
// Map<String, SysDepart> deptMap = deptlist.stream().collect(Collectors.toMap(SysDepart::getUsername, o -> o));
//
// List<EnterpriseStandardAuthUser> authUserList = new ArrayList<>();
// // 遍历esMap
// for (Map.Entry<String, LawsEnterpriseStandard> entry : esMap.entrySet()) {
// LawsEnterpriseStandard es = entry.getValue();
// String standardId = es.getId();
// List<ESAuthUser> auList = auMap.get(standardId);
// if (auList != null) {
// for (ESAuthUser au : auList) {
// EnterpriseStandardAuthUser authUser = new EnterpriseStandardAuthUser();
// authUser.setStandardId(es.getId());
// String userId = userMap.get(au.getWorkNumber()).getId();
// authUser.setAuthUser(userId);
// authUser.setAuthExpireDate(date);
// authUserList.add(authUser);
// }
// }
// }
// esAuthUserService.saveBatch(authUserList, authUserList.size());
log.info("企标所有人权限导入成功");
// 将Excel中涉及到的老部门名称和老上级部门名称找出来
Set<String> oldDeptNameList = new HashSet<>();
for (ESAuthDept ad : datalist) {
oldDeptNameList.add(ad.getDeptName());
oldDeptNameList.add(ad.getHigherDeptName());
}
// 根据老部门名称获取新部门Id
LambdaQueryWrapper<OldSystemDepartRelation> oldDeptWrapper = new LambdaQueryWrapper<>();
oldDeptWrapper.in(OldSystemDepartRelation::getOldOrgName, oldDeptNameList);
List<OldSystemDepartRelation> oldDeptList = oldDeptService.list(oldDeptWrapper);
// 获取所有有关联的新部门
LambdaQueryWrapper<SysDepart> sysDeptWrapper = new LambdaQueryWrapper<>();
sysDeptWrapper.eq(SysDepart::getDelFlag, CommonConstant.DEL_FLAG_0.toString());
sysDeptWrapper.eq(SysDepart::getStatus, 1);
List<SysDepart> curDeptList = sysDepartService.list(sysDeptWrapper);
curDeptList.add(sysDepartService.getById("0"));
Map<String, SysDepart> allCurDeptMap = curDeptList.stream().collect(Collectors.toMap(SysDepart::getId, o -> o));
Map<String, SysDepart> curDeptNameMap = new HashMap<>();
for (SysDepart d : curDeptList) {
if (StrUtil.isNotBlank(d.getParentId())) {
String departName = d.getDepartName();
SysDepart sysDepart = allCurDeptMap.get(d.getParentId());
if (sysDepart != null) {
departName = departName + "-" + sysDepart.getDepartName();
}
curDeptNameMap.put(departName, d);
}
}
for (ESAuthDept ad : datalist) {
try {
EnterpriseStandardAuthDept authDept = new EnterpriseStandardAuthDept();
authDept.setStandardId(esMap.get(ad.getStandardId()).getId());
String curDeptId = curDeptNameMap.get(ad.getDeptName() + "-" + ad.getHigherDeptName()).getId();
if (StrUtil.isBlank(curDeptId)) {
log.error("导入部门对应出现错误:{}", "找不到对应的新部门");
log.error("错误数据:{}", ad.toString());
continue;
}
authDept.setAuthDept(curDeptId);
esAuthDeptService.save(authDept);
} catch (Exception e) {
log.error("导入部门对应出现错误:{}", e.getMessage());
log.error("错误数据:{}", ad.toString());
}
}
} catch (Exception e) {
log.error("导入失败;{}", e.getMessage());
}
@@ -501,7 +531,7 @@ public class LawsEnterpriseStandardServiceImpl extends ServiceImpl<LawsEnterpris
String zrr = dto.getZrr();
String zrrid = dto.getZrrid();
if (StrUtil.isNotBlank(zrr) && StrUtil.isNotBlank(zrrid)) {
gb.setResponsibleDepartment(allUserMap.get(zrr + zrrid).getId());
gb.setResponsibleDepartmentUser(allUserMap.get(zrr + zrrid).getId());
}
// 根据文件路径获取文件Id