修复双Sheet资产单独导入任务ID
This commit is contained in:
@@ -7,7 +7,6 @@ import com.ruoyi.info.collection.domain.dto.CcdiBaseStaffQueryDTO;
|
|||||||
import com.ruoyi.info.collection.domain.excel.CcdiBaseStaffAssetInfoExcel;
|
import com.ruoyi.info.collection.domain.excel.CcdiBaseStaffAssetInfoExcel;
|
||||||
import com.ruoyi.info.collection.domain.excel.CcdiBaseStaffExcel;
|
import com.ruoyi.info.collection.domain.excel.CcdiBaseStaffExcel;
|
||||||
import com.ruoyi.info.collection.domain.vo.*;
|
import com.ruoyi.info.collection.domain.vo.*;
|
||||||
import com.ruoyi.info.collection.service.ICcdiBaseStaffAssetImportService;
|
|
||||||
import com.ruoyi.info.collection.service.ICcdiBaseStaffImportService;
|
import com.ruoyi.info.collection.service.ICcdiBaseStaffImportService;
|
||||||
import com.ruoyi.info.collection.service.ICcdiBaseStaffService;
|
import com.ruoyi.info.collection.service.ICcdiBaseStaffService;
|
||||||
import com.ruoyi.info.collection.utils.EasyExcelUtil;
|
import com.ruoyi.info.collection.utils.EasyExcelUtil;
|
||||||
@@ -47,9 +46,6 @@ public class CcdiBaseStaffController extends BaseController {
|
|||||||
@Resource
|
@Resource
|
||||||
private ICcdiBaseStaffImportService importAsyncService;
|
private ICcdiBaseStaffImportService importAsyncService;
|
||||||
|
|
||||||
@Resource
|
|
||||||
private ICcdiBaseStaffAssetImportService baseStaffAssetImportService;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询员工列表
|
* 查询员工列表
|
||||||
*/
|
*/
|
||||||
@@ -161,14 +157,7 @@ public class CcdiBaseStaffController extends BaseController {
|
|||||||
return error("至少需要一条数据");
|
return error("至少需要一条数据");
|
||||||
}
|
}
|
||||||
|
|
||||||
BaseStaffImportSubmitResultVO result = new BaseStaffImportSubmitResultVO();
|
BaseStaffImportSubmitResultVO result = baseStaffService.importBaseStaffWithAssets(staffList, assetList);
|
||||||
if (hasStaffRows) {
|
|
||||||
result.setStaffTaskId(baseStaffService.importBaseStaff(staffList));
|
|
||||||
}
|
|
||||||
if (hasAssetRows) {
|
|
||||||
result.setAssetTaskId(baseStaffAssetImportService.importAssetInfo(assetList));
|
|
||||||
}
|
|
||||||
result.setMessage(buildImportSubmitMessage(hasStaffRows, hasAssetRows));
|
|
||||||
|
|
||||||
return AjaxResult.success("导入任务已提交,正在后台处理", result);
|
return AjaxResult.success("导入任务已提交,正在后台处理", result);
|
||||||
}
|
}
|
||||||
@@ -215,13 +204,4 @@ public class CcdiBaseStaffController extends BaseController {
|
|||||||
return getDataTable(pageData, failures.size());
|
return getDataTable(pageData, failures.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
private String buildImportSubmitMessage(boolean hasStaffRows, boolean hasAssetRows) {
|
|
||||||
if (hasStaffRows && hasAssetRows) {
|
|
||||||
return "已提交员工信息和员工资产信息导入任务";
|
|
||||||
}
|
|
||||||
if (hasStaffRows) {
|
|
||||||
return "已提交员工信息导入任务";
|
|
||||||
}
|
|
||||||
return "已提交员工资产信息导入任务";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ import com.ruoyi.info.collection.domain.vo.CcdiStaffFmyRelationVO;
|
|||||||
import com.ruoyi.info.collection.domain.vo.ImportStatusVO;
|
import com.ruoyi.info.collection.domain.vo.ImportStatusVO;
|
||||||
import com.ruoyi.info.collection.domain.vo.StaffFmyRelationImportFailureVO;
|
import com.ruoyi.info.collection.domain.vo.StaffFmyRelationImportFailureVO;
|
||||||
import com.ruoyi.info.collection.domain.vo.StaffFmyRelationImportSubmitResultVO;
|
import com.ruoyi.info.collection.domain.vo.StaffFmyRelationImportSubmitResultVO;
|
||||||
import com.ruoyi.info.collection.service.ICcdiAssetInfoImportService;
|
|
||||||
import com.ruoyi.info.collection.service.ICcdiStaffFmyRelationImportService;
|
import com.ruoyi.info.collection.service.ICcdiStaffFmyRelationImportService;
|
||||||
import com.ruoyi.info.collection.service.ICcdiStaffFmyRelationService;
|
import com.ruoyi.info.collection.service.ICcdiStaffFmyRelationService;
|
||||||
import com.ruoyi.info.collection.utils.EasyExcelUtil;
|
import com.ruoyi.info.collection.utils.EasyExcelUtil;
|
||||||
@@ -51,9 +50,6 @@ public class CcdiStaffFmyRelationController extends BaseController {
|
|||||||
@Resource
|
@Resource
|
||||||
private ICcdiStaffFmyRelationImportService relationImportService;
|
private ICcdiStaffFmyRelationImportService relationImportService;
|
||||||
|
|
||||||
@Resource
|
|
||||||
private ICcdiAssetInfoImportService assetInfoImportService;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询员工亲属关系列表
|
* 查询员工亲属关系列表
|
||||||
*/
|
*/
|
||||||
@@ -157,15 +153,7 @@ public class CcdiStaffFmyRelationController extends BaseController {
|
|||||||
return error("至少需要一条数据");
|
return error("至少需要一条数据");
|
||||||
}
|
}
|
||||||
|
|
||||||
StaffFmyRelationImportSubmitResultVO result = new StaffFmyRelationImportSubmitResultVO();
|
StaffFmyRelationImportSubmitResultVO result = relationService.importRelationWithAssets(relationList, assetList);
|
||||||
if (hasRelationRows) {
|
|
||||||
result.setRelationTaskId(relationService.importRelation(relationList));
|
|
||||||
}
|
|
||||||
if (hasAssetRows) {
|
|
||||||
result.setAssetTaskId(assetInfoImportService.importAssetInfo(assetList));
|
|
||||||
}
|
|
||||||
result.setMessage(buildImportSubmitMessage(hasRelationRows, hasAssetRows));
|
|
||||||
|
|
||||||
return AjaxResult.success("导入任务已提交,正在后台处理", result);
|
return AjaxResult.success("导入任务已提交,正在后台处理", result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -211,13 +199,4 @@ public class CcdiStaffFmyRelationController extends BaseController {
|
|||||||
return getDataTable(pageData, failures.size());
|
return getDataTable(pageData, failures.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
private String buildImportSubmitMessage(boolean hasRelationRows, boolean hasAssetRows) {
|
|
||||||
if (hasRelationRows && hasAssetRows) {
|
|
||||||
return "已提交员工亲属关系和亲属资产信息导入任务";
|
|
||||||
}
|
|
||||||
if (hasRelationRows) {
|
|
||||||
return "已提交员工亲属关系导入任务";
|
|
||||||
}
|
|
||||||
return "已提交亲属资产信息导入任务";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,8 @@ import com.ruoyi.info.collection.domain.vo.AssetImportFailureVO;
|
|||||||
import com.ruoyi.info.collection.domain.vo.ImportStatusVO;
|
import com.ruoyi.info.collection.domain.vo.ImportStatusVO;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 亲属资产信息异步导入 服务层
|
* 亲属资产信息异步导入 服务层
|
||||||
@@ -31,6 +33,19 @@ public interface ICcdiAssetInfoImportService {
|
|||||||
*/
|
*/
|
||||||
void importAssetInfoAsync(List<CcdiAssetInfoExcel> excelList, String taskId, String userName);
|
void importAssetInfoAsync(List<CcdiAssetInfoExcel> excelList, String taskId, String userName);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 同步执行亲属资产导入,可附加同一文件亲属关系Sheet成功导入的归属映射
|
||||||
|
*
|
||||||
|
* @param excelList Excel实体列表
|
||||||
|
* @param taskId 任务ID
|
||||||
|
* @param userName 用户名
|
||||||
|
* @param extraOwnerMappings 附加归属映射,key为亲属证件号,value为归属员工证件号集合
|
||||||
|
*/
|
||||||
|
void importAssetInfoSync(List<CcdiAssetInfoExcel> excelList,
|
||||||
|
String taskId,
|
||||||
|
String userName,
|
||||||
|
Map<String, Set<String>> extraOwnerMappings);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询导入状态
|
* 查询导入状态
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -5,6 +5,8 @@ import com.ruoyi.info.collection.domain.vo.BaseStaffAssetImportFailureVO;
|
|||||||
import com.ruoyi.info.collection.domain.vo.ImportStatusVO;
|
import com.ruoyi.info.collection.domain.vo.ImportStatusVO;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 员工资产信息异步导入 服务层
|
* 员工资产信息异步导入 服务层
|
||||||
@@ -31,6 +33,19 @@ public interface ICcdiBaseStaffAssetImportService {
|
|||||||
*/
|
*/
|
||||||
void importAssetInfoAsync(List<CcdiBaseStaffAssetInfoExcel> excelList, String taskId, String userName);
|
void importAssetInfoAsync(List<CcdiBaseStaffAssetInfoExcel> excelList, String taskId, String userName);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 同步执行员工资产导入,可附加同一文件员工Sheet成功导入的归属映射
|
||||||
|
*
|
||||||
|
* @param excelList Excel实体列表
|
||||||
|
* @param taskId 任务ID
|
||||||
|
* @param userName 用户名
|
||||||
|
* @param extraOwnerMappings 附加归属映射,key为资产持有人证件号,value为归属员工证件号集合
|
||||||
|
*/
|
||||||
|
void importAssetInfoSync(List<CcdiBaseStaffAssetInfoExcel> excelList,
|
||||||
|
String taskId,
|
||||||
|
String userName,
|
||||||
|
Map<String, Set<String>> extraOwnerMappings);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询导入状态
|
* 查询导入状态
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import com.ruoyi.info.collection.domain.vo.ImportFailureVO;
|
|||||||
import com.ruoyi.info.collection.domain.vo.ImportStatusVO;
|
import com.ruoyi.info.collection.domain.vo.ImportStatusVO;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Author: wkc
|
* @Author: wkc
|
||||||
@@ -19,6 +20,15 @@ public interface ICcdiBaseStaffImportService {
|
|||||||
*/
|
*/
|
||||||
void importBaseStaffAsync(List<CcdiBaseStaffExcel> excelList, String taskId);
|
void importBaseStaffAsync(List<CcdiBaseStaffExcel> excelList, String taskId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 同步执行员工导入并返回本轮成功员工身份证号
|
||||||
|
*
|
||||||
|
* @param excelList Excel数据列表
|
||||||
|
* @param taskId 任务ID
|
||||||
|
* @return 成功导入的身份证号集合
|
||||||
|
*/
|
||||||
|
Set<String> importBaseStaffSync(List<CcdiBaseStaffExcel> excelList, String taskId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询导入状态
|
* 查询导入状态
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -4,7 +4,9 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|||||||
import com.ruoyi.info.collection.domain.dto.CcdiBaseStaffAddDTO;
|
import com.ruoyi.info.collection.domain.dto.CcdiBaseStaffAddDTO;
|
||||||
import com.ruoyi.info.collection.domain.dto.CcdiBaseStaffEditDTO;
|
import com.ruoyi.info.collection.domain.dto.CcdiBaseStaffEditDTO;
|
||||||
import com.ruoyi.info.collection.domain.dto.CcdiBaseStaffQueryDTO;
|
import com.ruoyi.info.collection.domain.dto.CcdiBaseStaffQueryDTO;
|
||||||
|
import com.ruoyi.info.collection.domain.excel.CcdiBaseStaffAssetInfoExcel;
|
||||||
import com.ruoyi.info.collection.domain.excel.CcdiBaseStaffExcel;
|
import com.ruoyi.info.collection.domain.excel.CcdiBaseStaffExcel;
|
||||||
|
import com.ruoyi.info.collection.domain.vo.BaseStaffImportSubmitResultVO;
|
||||||
import com.ruoyi.info.collection.domain.vo.CcdiBaseStaffOptionVO;
|
import com.ruoyi.info.collection.domain.vo.CcdiBaseStaffOptionVO;
|
||||||
import com.ruoyi.info.collection.domain.vo.CcdiBaseStaffVO;
|
import com.ruoyi.info.collection.domain.vo.CcdiBaseStaffVO;
|
||||||
|
|
||||||
@@ -83,6 +85,16 @@ public interface ICcdiBaseStaffService {
|
|||||||
*/
|
*/
|
||||||
String importBaseStaff(List<CcdiBaseStaffExcel> excelList);
|
String importBaseStaff(List<CcdiBaseStaffExcel> excelList);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导入员工信息和员工资产双Sheet数据
|
||||||
|
*
|
||||||
|
* @param staffList 员工信息Sheet
|
||||||
|
* @param assetList 员工资产Sheet
|
||||||
|
* @return 提交结果
|
||||||
|
*/
|
||||||
|
BaseStaffImportSubmitResultVO importBaseStaffWithAssets(List<CcdiBaseStaffExcel> staffList,
|
||||||
|
List<CcdiBaseStaffAssetInfoExcel> assetList);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询员工下拉列表
|
* 查询员工下拉列表
|
||||||
* 支持按员工ID或姓名模糊搜索,只返回在职员工
|
* 支持按员工ID或姓名模糊搜索,只返回在职员工
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import com.ruoyi.info.collection.domain.vo.ImportStatusVO;
|
|||||||
import com.ruoyi.info.collection.domain.vo.StaffFmyRelationImportFailureVO;
|
import com.ruoyi.info.collection.domain.vo.StaffFmyRelationImportFailureVO;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 员工亲属关系异步导入 服务层
|
* 员工亲属关系异步导入 服务层
|
||||||
@@ -23,6 +24,16 @@ public interface ICcdiStaffFmyRelationImportService {
|
|||||||
*/
|
*/
|
||||||
void importRelationAsync(List<CcdiStaffFmyRelationExcel> excelList, String taskId, String userName);
|
void importRelationAsync(List<CcdiStaffFmyRelationExcel> excelList, String taskId, String userName);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 同步执行员工亲属关系导入并返回本轮成功关系映射
|
||||||
|
*
|
||||||
|
* @param excelList Excel实体列表
|
||||||
|
* @param taskId 任务ID
|
||||||
|
* @param userName 用户名
|
||||||
|
* @return key为亲属证件号,value为归属员工证件号
|
||||||
|
*/
|
||||||
|
Map<String, String> importRelationSync(List<CcdiStaffFmyRelationExcel> excelList, String taskId, String userName);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询导入失败记录
|
* 查询导入失败记录
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -4,8 +4,10 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|||||||
import com.ruoyi.info.collection.domain.dto.CcdiStaffFmyRelationAddDTO;
|
import com.ruoyi.info.collection.domain.dto.CcdiStaffFmyRelationAddDTO;
|
||||||
import com.ruoyi.info.collection.domain.dto.CcdiStaffFmyRelationEditDTO;
|
import com.ruoyi.info.collection.domain.dto.CcdiStaffFmyRelationEditDTO;
|
||||||
import com.ruoyi.info.collection.domain.dto.CcdiStaffFmyRelationQueryDTO;
|
import com.ruoyi.info.collection.domain.dto.CcdiStaffFmyRelationQueryDTO;
|
||||||
|
import com.ruoyi.info.collection.domain.excel.CcdiAssetInfoExcel;
|
||||||
import com.ruoyi.info.collection.domain.excel.CcdiStaffFmyRelationExcel;
|
import com.ruoyi.info.collection.domain.excel.CcdiStaffFmyRelationExcel;
|
||||||
import com.ruoyi.info.collection.domain.vo.CcdiStaffFmyRelationVO;
|
import com.ruoyi.info.collection.domain.vo.CcdiStaffFmyRelationVO;
|
||||||
|
import com.ruoyi.info.collection.domain.vo.StaffFmyRelationImportSubmitResultVO;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -81,4 +83,14 @@ public interface ICcdiStaffFmyRelationService {
|
|||||||
* @return 任务ID
|
* @return 任务ID
|
||||||
*/
|
*/
|
||||||
String importRelation(List<CcdiStaffFmyRelationExcel> excelList);
|
String importRelation(List<CcdiStaffFmyRelationExcel> excelList);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导入员工亲属关系和亲属资产双Sheet数据
|
||||||
|
*
|
||||||
|
* @param relationList 员工亲属关系Sheet
|
||||||
|
* @param assetList 亲属资产Sheet
|
||||||
|
* @return 提交结果
|
||||||
|
*/
|
||||||
|
StaffFmyRelationImportSubmitResultVO importRelationWithAssets(List<CcdiStaffFmyRelationExcel> relationList,
|
||||||
|
List<CcdiAssetInfoExcel> assetList);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -82,6 +82,15 @@ public class CcdiAssetInfoImportServiceImpl implements ICcdiAssetInfoImportServi
|
|||||||
@Async
|
@Async
|
||||||
@Transactional
|
@Transactional
|
||||||
public void importAssetInfoAsync(List<CcdiAssetInfoExcel> excelList, String taskId, String userName) {
|
public void importAssetInfoAsync(List<CcdiAssetInfoExcel> excelList, String taskId, String userName) {
|
||||||
|
importAssetInfoSync(excelList, taskId, userName, Map.of());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
|
public void importAssetInfoSync(List<CcdiAssetInfoExcel> excelList,
|
||||||
|
String taskId,
|
||||||
|
String userName,
|
||||||
|
Map<String, Set<String>> extraOwnerMappings) {
|
||||||
List<CcdiAssetInfo> successList = new ArrayList<>();
|
List<CcdiAssetInfo> successList = new ArrayList<>();
|
||||||
List<AssetImportFailureVO> failures = new ArrayList<>();
|
List<AssetImportFailureVO> failures = new ArrayList<>();
|
||||||
|
|
||||||
@@ -92,6 +101,7 @@ public class CcdiAssetInfoImportServiceImpl implements ICcdiAssetInfoImportServi
|
|||||||
.toList();
|
.toList();
|
||||||
|
|
||||||
Map<String, Set<String>> ownerMap = buildOwnerMap(personIds);
|
Map<String, Set<String>> ownerMap = buildOwnerMap(personIds);
|
||||||
|
mergeOwnerMappings(ownerMap, extraOwnerMappings);
|
||||||
|
|
||||||
for (int i = 0; i < excelList.size(); i++) {
|
for (int i = 0; i < excelList.size(); i++) {
|
||||||
CcdiAssetInfoExcel excel = excelList.get(i);
|
CcdiAssetInfoExcel excel = excelList.get(i);
|
||||||
@@ -189,6 +199,18 @@ public class CcdiAssetInfoImportServiceImpl implements ICcdiAssetInfoImportServi
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void mergeOwnerMappings(Map<String, Set<String>> result, Map<String, Set<String>> mappings) {
|
||||||
|
if (mappings == null || mappings.isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
for (Map.Entry<String, Set<String>> entry : mappings.entrySet()) {
|
||||||
|
if (StringUtils.isEmpty(entry.getKey()) || entry.getValue() == null || entry.getValue().isEmpty()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
result.computeIfAbsent(entry.getKey(), key -> new java.util.LinkedHashSet<>()).addAll(entry.getValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void validateExcel(CcdiAssetInfoExcel excel) {
|
private void validateExcel(CcdiAssetInfoExcel excel) {
|
||||||
if (StringUtils.isEmpty(excel.getPersonId())) {
|
if (StringUtils.isEmpty(excel.getPersonId())) {
|
||||||
throw new RuntimeException("亲属证件号不能为空");
|
throw new RuntimeException("亲属证件号不能为空");
|
||||||
|
|||||||
@@ -81,6 +81,15 @@ public class CcdiBaseStaffAssetImportServiceImpl implements ICcdiBaseStaffAssetI
|
|||||||
@Async
|
@Async
|
||||||
@Transactional
|
@Transactional
|
||||||
public void importAssetInfoAsync(List<CcdiBaseStaffAssetInfoExcel> excelList, String taskId, String userName) {
|
public void importAssetInfoAsync(List<CcdiBaseStaffAssetInfoExcel> excelList, String taskId, String userName) {
|
||||||
|
importAssetInfoSync(excelList, taskId, userName, Map.of());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
|
public void importAssetInfoSync(List<CcdiBaseStaffAssetInfoExcel> excelList,
|
||||||
|
String taskId,
|
||||||
|
String userName,
|
||||||
|
Map<String, Set<String>> extraOwnerMappings) {
|
||||||
List<CcdiAssetInfo> successList = new ArrayList<>();
|
List<CcdiAssetInfo> successList = new ArrayList<>();
|
||||||
List<BaseStaffAssetImportFailureVO> failures = new ArrayList<>();
|
List<BaseStaffAssetImportFailureVO> failures = new ArrayList<>();
|
||||||
|
|
||||||
@@ -91,6 +100,7 @@ public class CcdiBaseStaffAssetImportServiceImpl implements ICcdiBaseStaffAssetI
|
|||||||
.toList();
|
.toList();
|
||||||
|
|
||||||
Map<String, Set<String>> ownerMap = buildOwnerMap(personIds);
|
Map<String, Set<String>> ownerMap = buildOwnerMap(personIds);
|
||||||
|
mergeOwnerMappings(ownerMap, extraOwnerMappings);
|
||||||
Set<String> existingAssetKeys = buildExistingAssetKeys(personIds);
|
Set<String> existingAssetKeys = buildExistingAssetKeys(personIds);
|
||||||
Set<String> importedAssetKeys = new java.util.LinkedHashSet<>();
|
Set<String> importedAssetKeys = new java.util.LinkedHashSet<>();
|
||||||
|
|
||||||
@@ -207,6 +217,18 @@ public class CcdiBaseStaffAssetImportServiceImpl implements ICcdiBaseStaffAssetI
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void mergeOwnerMappings(Map<String, Set<String>> result, Map<String, Set<String>> mappings) {
|
||||||
|
if (mappings == null || mappings.isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
for (Map.Entry<String, Set<String>> entry : mappings.entrySet()) {
|
||||||
|
if (StringUtils.isEmpty(entry.getKey()) || entry.getValue() == null || entry.getValue().isEmpty()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
result.computeIfAbsent(entry.getKey(), key -> new java.util.LinkedHashSet<>()).addAll(entry.getValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void validateExcel(CcdiBaseStaffAssetInfoExcel excel) {
|
private void validateExcel(CcdiBaseStaffAssetInfoExcel excel) {
|
||||||
if (StringUtils.isEmpty(excel.getPersonId())) {
|
if (StringUtils.isEmpty(excel.getPersonId())) {
|
||||||
throw new RuntimeException("员工身份证号不能为空");
|
throw new RuntimeException("员工身份证号不能为空");
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ import org.springframework.data.redis.core.RedisTemplate;
|
|||||||
import org.springframework.scheduling.annotation.Async;
|
import org.springframework.scheduling.annotation.Async;
|
||||||
import org.springframework.scheduling.annotation.EnableAsync;
|
import org.springframework.scheduling.annotation.EnableAsync;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
@@ -51,6 +52,12 @@ public class CcdiBaseStaffImportServiceImpl implements ICcdiBaseStaffImportServi
|
|||||||
@Override
|
@Override
|
||||||
@Async
|
@Async
|
||||||
public void importBaseStaffAsync(List<CcdiBaseStaffExcel> excelList, String taskId) {
|
public void importBaseStaffAsync(List<CcdiBaseStaffExcel> excelList, String taskId) {
|
||||||
|
importBaseStaffSync(excelList, taskId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
|
public Set<String> importBaseStaffSync(List<CcdiBaseStaffExcel> excelList, String taskId) {
|
||||||
long startTime = System.currentTimeMillis();
|
long startTime = System.currentTimeMillis();
|
||||||
|
|
||||||
// 记录导入开始
|
// 记录导入开始
|
||||||
@@ -153,6 +160,11 @@ public class CcdiBaseStaffImportServiceImpl implements ICcdiBaseStaffImportServi
|
|||||||
long duration = System.currentTimeMillis() - startTime;
|
long duration = System.currentTimeMillis() - startTime;
|
||||||
ImportLogUtils.logImportComplete(log, taskId, "员工基础信息",
|
ImportLogUtils.logImportComplete(log, taskId, "员工基础信息",
|
||||||
excelList.size(), result.getSuccessCount(), result.getFailureCount(), duration);
|
excelList.size(), result.getSuccessCount(), result.getFailureCount(), duration);
|
||||||
|
|
||||||
|
return newRecords.stream()
|
||||||
|
.map(CcdiBaseStaff::getIdCard)
|
||||||
|
.filter(StringUtils::isNotEmpty)
|
||||||
|
.collect(Collectors.toCollection(LinkedHashSet::new));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -6,15 +6,19 @@ import com.ruoyi.info.collection.domain.CcdiBaseStaff;
|
|||||||
import com.ruoyi.info.collection.domain.dto.CcdiBaseStaffAddDTO;
|
import com.ruoyi.info.collection.domain.dto.CcdiBaseStaffAddDTO;
|
||||||
import com.ruoyi.info.collection.domain.dto.CcdiBaseStaffEditDTO;
|
import com.ruoyi.info.collection.domain.dto.CcdiBaseStaffEditDTO;
|
||||||
import com.ruoyi.info.collection.domain.dto.CcdiBaseStaffQueryDTO;
|
import com.ruoyi.info.collection.domain.dto.CcdiBaseStaffQueryDTO;
|
||||||
|
import com.ruoyi.info.collection.domain.excel.CcdiBaseStaffAssetInfoExcel;
|
||||||
import com.ruoyi.info.collection.domain.excel.CcdiBaseStaffExcel;
|
import com.ruoyi.info.collection.domain.excel.CcdiBaseStaffExcel;
|
||||||
|
import com.ruoyi.info.collection.domain.vo.BaseStaffImportSubmitResultVO;
|
||||||
import com.ruoyi.info.collection.domain.vo.CcdiAssetInfoVO;
|
import com.ruoyi.info.collection.domain.vo.CcdiAssetInfoVO;
|
||||||
import com.ruoyi.info.collection.domain.vo.CcdiBaseStaffOptionVO;
|
import com.ruoyi.info.collection.domain.vo.CcdiBaseStaffOptionVO;
|
||||||
import com.ruoyi.info.collection.domain.vo.CcdiBaseStaffVO;
|
import com.ruoyi.info.collection.domain.vo.CcdiBaseStaffVO;
|
||||||
import com.ruoyi.info.collection.enums.EmployeeStatus;
|
import com.ruoyi.info.collection.enums.EmployeeStatus;
|
||||||
import com.ruoyi.info.collection.mapper.CcdiBaseStaffMapper;
|
import com.ruoyi.info.collection.mapper.CcdiBaseStaffMapper;
|
||||||
import com.ruoyi.info.collection.service.ICcdiAssetInfoService;
|
import com.ruoyi.info.collection.service.ICcdiAssetInfoService;
|
||||||
|
import com.ruoyi.info.collection.service.ICcdiBaseStaffAssetImportService;
|
||||||
import com.ruoyi.info.collection.service.ICcdiBaseStaffImportService;
|
import com.ruoyi.info.collection.service.ICcdiBaseStaffImportService;
|
||||||
import com.ruoyi.info.collection.service.ICcdiBaseStaffService;
|
import com.ruoyi.info.collection.service.ICcdiBaseStaffService;
|
||||||
|
import com.ruoyi.common.utils.SecurityUtils;
|
||||||
import com.ruoyi.common.utils.StringUtils;
|
import com.ruoyi.common.utils.StringUtils;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import org.springframework.beans.BeanUtils;
|
import org.springframework.beans.BeanUtils;
|
||||||
@@ -46,6 +50,12 @@ public class CcdiBaseStaffServiceImpl implements ICcdiBaseStaffService {
|
|||||||
@Resource
|
@Resource
|
||||||
private ICcdiAssetInfoService assetInfoService;
|
private ICcdiAssetInfoService assetInfoService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private ICcdiBaseStaffAssetImportService baseStaffAssetImportService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private CcdiDualSheetImportOrchestrationService dualSheetImportOrchestrationService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询员工列表
|
* 查询员工列表
|
||||||
*
|
*
|
||||||
@@ -218,28 +228,52 @@ public class CcdiBaseStaffServiceImpl implements ICcdiBaseStaffService {
|
|||||||
@Transactional
|
@Transactional
|
||||||
public String importBaseStaff(List<CcdiBaseStaffExcel> excelList) {
|
public String importBaseStaff(List<CcdiBaseStaffExcel> excelList) {
|
||||||
String taskId = UUID.randomUUID().toString();
|
String taskId = UUID.randomUUID().toString();
|
||||||
long startTime = System.currentTimeMillis();
|
initializeImportStatus("import:baseStaff:", taskId, excelList.size());
|
||||||
|
|
||||||
// 初始化Redis状态
|
|
||||||
String statusKey = "import:baseStaff:" + taskId;
|
|
||||||
Map<String, Object> statusData = new HashMap<>();
|
|
||||||
statusData.put("taskId", taskId);
|
|
||||||
statusData.put("status", "PROCESSING");
|
|
||||||
statusData.put("totalCount", excelList.size());
|
|
||||||
statusData.put("successCount", 0);
|
|
||||||
statusData.put("failureCount", 0);
|
|
||||||
statusData.put("progress", 0);
|
|
||||||
statusData.put("startTime", startTime);
|
|
||||||
statusData.put("message", "正在处理...");
|
|
||||||
|
|
||||||
redisTemplate.opsForHash().putAll(statusKey, statusData);
|
|
||||||
redisTemplate.expire(statusKey, 7, java.util.concurrent.TimeUnit.DAYS);
|
|
||||||
|
|
||||||
importAsyncService.importBaseStaffAsync(excelList, taskId);
|
importAsyncService.importBaseStaffAsync(excelList, taskId);
|
||||||
|
|
||||||
return taskId;
|
return taskId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
|
public BaseStaffImportSubmitResultVO importBaseStaffWithAssets(List<CcdiBaseStaffExcel> staffList,
|
||||||
|
List<CcdiBaseStaffAssetInfoExcel> assetList) {
|
||||||
|
boolean hasStaffRows = staffList != null && !staffList.isEmpty();
|
||||||
|
boolean hasAssetRows = assetList != null && !assetList.isEmpty();
|
||||||
|
if (!hasStaffRows && !hasAssetRows) {
|
||||||
|
throw new RuntimeException("至少需要一条数据");
|
||||||
|
}
|
||||||
|
|
||||||
|
BaseStaffImportSubmitResultVO result = new BaseStaffImportSubmitResultVO();
|
||||||
|
result.setMessage(buildImportSubmitMessage(hasStaffRows, hasAssetRows));
|
||||||
|
|
||||||
|
if (hasStaffRows && !hasAssetRows) {
|
||||||
|
result.setStaffTaskId(importBaseStaff(staffList));
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
if (!hasStaffRows) {
|
||||||
|
result.setAssetTaskId(baseStaffAssetImportService.importAssetInfo(assetList));
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
String staffTaskId = UUID.randomUUID().toString();
|
||||||
|
String assetTaskId = UUID.randomUUID().toString();
|
||||||
|
initializeImportStatus("import:baseStaff:", staffTaskId, staffList.size());
|
||||||
|
initializeImportStatus("import:baseStaffAsset:", assetTaskId, assetList.size());
|
||||||
|
|
||||||
|
result.setStaffTaskId(staffTaskId);
|
||||||
|
result.setAssetTaskId(assetTaskId);
|
||||||
|
dualSheetImportOrchestrationService.importBaseStaffWithAssetsAsync(
|
||||||
|
staffList,
|
||||||
|
staffTaskId,
|
||||||
|
assetList,
|
||||||
|
assetTaskId,
|
||||||
|
currentUserName()
|
||||||
|
);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询员工下拉列表
|
* 查询员工下拉列表
|
||||||
* 支持按员工ID或姓名模糊搜索,只返回在职员工
|
* 支持按员工ID或姓名模糊搜索,只返回在职员工
|
||||||
@@ -252,6 +286,40 @@ public class CcdiBaseStaffServiceImpl implements ICcdiBaseStaffService {
|
|||||||
return baseStaffMapper.selectStaffOptions(query);
|
return baseStaffMapper.selectStaffOptions(query);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void initializeImportStatus(String keyPrefix, String taskId, int totalCount) {
|
||||||
|
Map<String, Object> statusData = new HashMap<>();
|
||||||
|
statusData.put("taskId", taskId);
|
||||||
|
statusData.put("status", "PROCESSING");
|
||||||
|
statusData.put("totalCount", totalCount);
|
||||||
|
statusData.put("successCount", 0);
|
||||||
|
statusData.put("failureCount", 0);
|
||||||
|
statusData.put("progress", 0);
|
||||||
|
statusData.put("startTime", System.currentTimeMillis());
|
||||||
|
statusData.put("message", "正在处理...");
|
||||||
|
|
||||||
|
String statusKey = keyPrefix + taskId;
|
||||||
|
redisTemplate.opsForHash().putAll(statusKey, statusData);
|
||||||
|
redisTemplate.expire(statusKey, 7, java.util.concurrent.TimeUnit.DAYS);
|
||||||
|
}
|
||||||
|
|
||||||
|
private String buildImportSubmitMessage(boolean hasStaffRows, boolean hasAssetRows) {
|
||||||
|
if (hasStaffRows && hasAssetRows) {
|
||||||
|
return "已提交员工信息和员工资产信息导入任务";
|
||||||
|
}
|
||||||
|
if (hasStaffRows) {
|
||||||
|
return "已提交员工信息导入任务";
|
||||||
|
}
|
||||||
|
return "已提交员工资产信息导入任务";
|
||||||
|
}
|
||||||
|
|
||||||
|
private String currentUserName() {
|
||||||
|
try {
|
||||||
|
return SecurityUtils.getUsername();
|
||||||
|
} catch (Exception e) {
|
||||||
|
return "system";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 构建查询条件
|
* 构建查询条件
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -0,0 +1,90 @@
|
|||||||
|
package com.ruoyi.info.collection.service.impl;
|
||||||
|
|
||||||
|
import com.ruoyi.info.collection.domain.excel.CcdiAssetInfoExcel;
|
||||||
|
import com.ruoyi.info.collection.domain.excel.CcdiBaseStaffAssetInfoExcel;
|
||||||
|
import com.ruoyi.info.collection.domain.excel.CcdiBaseStaffExcel;
|
||||||
|
import com.ruoyi.info.collection.domain.excel.CcdiStaffFmyRelationExcel;
|
||||||
|
import com.ruoyi.info.collection.service.ICcdiAssetInfoImportService;
|
||||||
|
import com.ruoyi.info.collection.service.ICcdiBaseStaffAssetImportService;
|
||||||
|
import com.ruoyi.info.collection.service.ICcdiBaseStaffImportService;
|
||||||
|
import com.ruoyi.info.collection.service.ICcdiStaffFmyRelationImportService;
|
||||||
|
import jakarta.annotation.Resource;
|
||||||
|
import org.springframework.scheduling.annotation.Async;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.LinkedHashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 双Sheet导入后台顺序编排。
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class CcdiDualSheetImportOrchestrationService {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private ICcdiBaseStaffImportService baseStaffImportService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private ICcdiBaseStaffAssetImportService baseStaffAssetImportService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private ICcdiStaffFmyRelationImportService relationImportService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private ICcdiAssetInfoImportService assetInfoImportService;
|
||||||
|
|
||||||
|
@Async
|
||||||
|
public void importBaseStaffWithAssetsAsync(List<CcdiBaseStaffExcel> staffList,
|
||||||
|
String staffTaskId,
|
||||||
|
List<CcdiBaseStaffAssetInfoExcel> assetList,
|
||||||
|
String assetTaskId,
|
||||||
|
String userName) {
|
||||||
|
Set<String> successIdCards = baseStaffImportService.importBaseStaffSync(staffList, staffTaskId);
|
||||||
|
baseStaffAssetImportService.importAssetInfoSync(
|
||||||
|
assetList,
|
||||||
|
assetTaskId,
|
||||||
|
userName,
|
||||||
|
buildSelfOwnerMappings(successIdCards)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Async
|
||||||
|
public void importRelationWithAssetsAsync(List<CcdiStaffFmyRelationExcel> relationList,
|
||||||
|
String relationTaskId,
|
||||||
|
List<CcdiAssetInfoExcel> assetList,
|
||||||
|
String assetTaskId,
|
||||||
|
String userName) {
|
||||||
|
Map<String, String> successRelationMappings = relationImportService.importRelationSync(relationList, relationTaskId, userName);
|
||||||
|
assetInfoImportService.importAssetInfoSync(
|
||||||
|
assetList,
|
||||||
|
assetTaskId,
|
||||||
|
userName,
|
||||||
|
buildRelationOwnerMappings(successRelationMappings)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Map<String, Set<String>> buildSelfOwnerMappings(Set<String> idCards) {
|
||||||
|
Map<String, Set<String>> result = new LinkedHashMap<>();
|
||||||
|
if (idCards == null || idCards.isEmpty()) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
for (String idCard : idCards) {
|
||||||
|
result.computeIfAbsent(idCard, key -> new LinkedHashSet<>()).add(idCard);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Map<String, Set<String>> buildRelationOwnerMappings(Map<String, String> relationMappings) {
|
||||||
|
Map<String, Set<String>> result = new LinkedHashMap<>();
|
||||||
|
if (relationMappings == null || relationMappings.isEmpty()) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
for (Map.Entry<String, String> entry : relationMappings.entrySet()) {
|
||||||
|
result.computeIfAbsent(entry.getKey(), key -> new LinkedHashSet<>()).add(entry.getValue());
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -57,6 +57,12 @@ public class CcdiStaffFmyRelationImportServiceImpl implements ICcdiStaffFmyRelat
|
|||||||
@Async
|
@Async
|
||||||
@Transactional
|
@Transactional
|
||||||
public void importRelationAsync(List<CcdiStaffFmyRelationExcel> excelList, String taskId, String userName) {
|
public void importRelationAsync(List<CcdiStaffFmyRelationExcel> excelList, String taskId, String userName) {
|
||||||
|
importRelationSync(excelList, taskId, userName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
|
public Map<String, String> importRelationSync(List<CcdiStaffFmyRelationExcel> excelList, String taskId, String userName) {
|
||||||
long startTime = System.currentTimeMillis();
|
long startTime = System.currentTimeMillis();
|
||||||
|
|
||||||
// 记录导入开始
|
// 记录导入开始
|
||||||
@@ -213,6 +219,15 @@ public class CcdiStaffFmyRelationImportServiceImpl implements ICcdiStaffFmyRelat
|
|||||||
long duration = System.currentTimeMillis() - startTime;
|
long duration = System.currentTimeMillis() - startTime;
|
||||||
ImportLogUtils.logImportComplete(log, taskId, "员工亲属关系",
|
ImportLogUtils.logImportComplete(log, taskId, "员工亲属关系",
|
||||||
excelList.size(), result.getSuccessCount(), result.getFailureCount(), duration);
|
excelList.size(), result.getSuccessCount(), result.getFailureCount(), duration);
|
||||||
|
|
||||||
|
return newRecords.stream()
|
||||||
|
.filter(item -> StringUtils.isNotEmpty(item.getRelationCertNo()) && StringUtils.isNotEmpty(item.getPersonId()))
|
||||||
|
.collect(Collectors.toMap(
|
||||||
|
CcdiStaffFmyRelation::getRelationCertNo,
|
||||||
|
CcdiStaffFmyRelation::getPersonId,
|
||||||
|
(left, right) -> left,
|
||||||
|
LinkedHashMap::new
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -6,11 +6,14 @@ import com.ruoyi.info.collection.domain.CcdiStaffFmyRelation;
|
|||||||
import com.ruoyi.info.collection.domain.dto.CcdiStaffFmyRelationAddDTO;
|
import com.ruoyi.info.collection.domain.dto.CcdiStaffFmyRelationAddDTO;
|
||||||
import com.ruoyi.info.collection.domain.dto.CcdiStaffFmyRelationEditDTO;
|
import com.ruoyi.info.collection.domain.dto.CcdiStaffFmyRelationEditDTO;
|
||||||
import com.ruoyi.info.collection.domain.dto.CcdiStaffFmyRelationQueryDTO;
|
import com.ruoyi.info.collection.domain.dto.CcdiStaffFmyRelationQueryDTO;
|
||||||
|
import com.ruoyi.info.collection.domain.excel.CcdiAssetInfoExcel;
|
||||||
import com.ruoyi.info.collection.domain.excel.CcdiStaffFmyRelationExcel;
|
import com.ruoyi.info.collection.domain.excel.CcdiStaffFmyRelationExcel;
|
||||||
import com.ruoyi.info.collection.domain.vo.CcdiAssetInfoVO;
|
import com.ruoyi.info.collection.domain.vo.CcdiAssetInfoVO;
|
||||||
import com.ruoyi.info.collection.domain.vo.CcdiStaffFmyRelationVO;
|
import com.ruoyi.info.collection.domain.vo.CcdiStaffFmyRelationVO;
|
||||||
|
import com.ruoyi.info.collection.domain.vo.StaffFmyRelationImportSubmitResultVO;
|
||||||
import com.ruoyi.info.collection.mapper.CcdiStaffEnterpriseRelationMapper;
|
import com.ruoyi.info.collection.mapper.CcdiStaffEnterpriseRelationMapper;
|
||||||
import com.ruoyi.info.collection.mapper.CcdiStaffFmyRelationMapper;
|
import com.ruoyi.info.collection.mapper.CcdiStaffFmyRelationMapper;
|
||||||
|
import com.ruoyi.info.collection.service.ICcdiAssetInfoImportService;
|
||||||
import com.ruoyi.info.collection.service.ICcdiAssetInfoService;
|
import com.ruoyi.info.collection.service.ICcdiAssetInfoService;
|
||||||
import com.ruoyi.info.collection.service.ICcdiStaffFmyRelationImportService;
|
import com.ruoyi.info.collection.service.ICcdiStaffFmyRelationImportService;
|
||||||
import com.ruoyi.info.collection.service.ICcdiStaffFmyRelationService;
|
import com.ruoyi.info.collection.service.ICcdiStaffFmyRelationService;
|
||||||
@@ -51,9 +54,15 @@ public class CcdiStaffFmyRelationServiceImpl implements ICcdiStaffFmyRelationSer
|
|||||||
@Resource
|
@Resource
|
||||||
private ICcdiAssetInfoService assetInfoService;
|
private ICcdiAssetInfoService assetInfoService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private ICcdiAssetInfoImportService assetInfoImportService;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private CcdiStaffEnterpriseRelationMapper staffEnterpriseRelationMapper;
|
private CcdiStaffEnterpriseRelationMapper staffEnterpriseRelationMapper;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private CcdiDualSheetImportOrchestrationService dualSheetImportOrchestrationService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询员工亲属关系列表
|
* 查询员工亲属关系列表
|
||||||
*
|
*
|
||||||
@@ -207,25 +216,11 @@ public class CcdiStaffFmyRelationServiceImpl implements ICcdiStaffFmyRelationSer
|
|||||||
|
|
||||||
// 生成任务ID
|
// 生成任务ID
|
||||||
String taskId = UUID.randomUUID().toString();
|
String taskId = UUID.randomUUID().toString();
|
||||||
long startTime = System.currentTimeMillis();
|
|
||||||
|
|
||||||
// 获取当前用户名
|
// 获取当前用户名
|
||||||
String userName = SecurityUtils.getUsername();
|
String userName = SecurityUtils.getUsername();
|
||||||
|
|
||||||
// 初始化Redis状态
|
initializeImportStatus("import:staffFmyRelation:", taskId, excelList.size());
|
||||||
String statusKey = "import:staffFmyRelation:" + taskId;
|
|
||||||
Map<String, Object> statusData = new HashMap<>();
|
|
||||||
statusData.put("taskId", taskId);
|
|
||||||
statusData.put("status", "PROCESSING");
|
|
||||||
statusData.put("totalCount", excelList.size());
|
|
||||||
statusData.put("successCount", 0);
|
|
||||||
statusData.put("failureCount", 0);
|
|
||||||
statusData.put("progress", 0);
|
|
||||||
statusData.put("startTime", startTime);
|
|
||||||
statusData.put("message", "正在处理...");
|
|
||||||
|
|
||||||
redisTemplate.opsForHash().putAll(statusKey, statusData);
|
|
||||||
redisTemplate.expire(statusKey, 7, TimeUnit.DAYS);
|
|
||||||
|
|
||||||
// 调用异步导入服务
|
// 调用异步导入服务
|
||||||
relationImportService.importRelationAsync(excelList, taskId, userName);
|
relationImportService.importRelationAsync(excelList, taskId, userName);
|
||||||
@@ -233,6 +228,79 @@ public class CcdiStaffFmyRelationServiceImpl implements ICcdiStaffFmyRelationSer
|
|||||||
return taskId;
|
return taskId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
|
public StaffFmyRelationImportSubmitResultVO importRelationWithAssets(List<CcdiStaffFmyRelationExcel> relationList,
|
||||||
|
List<CcdiAssetInfoExcel> assetList) {
|
||||||
|
boolean hasRelationRows = relationList != null && !relationList.isEmpty();
|
||||||
|
boolean hasAssetRows = assetList != null && !assetList.isEmpty();
|
||||||
|
if (!hasRelationRows && !hasAssetRows) {
|
||||||
|
throw new RuntimeException("至少需要一条数据");
|
||||||
|
}
|
||||||
|
|
||||||
|
StaffFmyRelationImportSubmitResultVO result = new StaffFmyRelationImportSubmitResultVO();
|
||||||
|
result.setMessage(buildImportSubmitMessage(hasRelationRows, hasAssetRows));
|
||||||
|
|
||||||
|
if (hasRelationRows && !hasAssetRows) {
|
||||||
|
result.setRelationTaskId(importRelation(relationList));
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
if (!hasRelationRows) {
|
||||||
|
result.setAssetTaskId(assetInfoImportService.importAssetInfo(assetList));
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
String relationTaskId = UUID.randomUUID().toString();
|
||||||
|
String assetTaskId = UUID.randomUUID().toString();
|
||||||
|
initializeImportStatus("import:staffFmyRelation:", relationTaskId, relationList.size());
|
||||||
|
initializeImportStatus("import:assetInfo:", assetTaskId, assetList.size());
|
||||||
|
|
||||||
|
result.setRelationTaskId(relationTaskId);
|
||||||
|
result.setAssetTaskId(assetTaskId);
|
||||||
|
dualSheetImportOrchestrationService.importRelationWithAssetsAsync(
|
||||||
|
relationList,
|
||||||
|
relationTaskId,
|
||||||
|
assetList,
|
||||||
|
assetTaskId,
|
||||||
|
currentUserName()
|
||||||
|
);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initializeImportStatus(String keyPrefix, String taskId, int totalCount) {
|
||||||
|
Map<String, Object> statusData = new HashMap<>();
|
||||||
|
statusData.put("taskId", taskId);
|
||||||
|
statusData.put("status", "PROCESSING");
|
||||||
|
statusData.put("totalCount", totalCount);
|
||||||
|
statusData.put("successCount", 0);
|
||||||
|
statusData.put("failureCount", 0);
|
||||||
|
statusData.put("progress", 0);
|
||||||
|
statusData.put("startTime", System.currentTimeMillis());
|
||||||
|
statusData.put("message", "正在处理...");
|
||||||
|
|
||||||
|
String statusKey = keyPrefix + taskId;
|
||||||
|
redisTemplate.opsForHash().putAll(statusKey, statusData);
|
||||||
|
redisTemplate.expire(statusKey, 7, TimeUnit.DAYS);
|
||||||
|
}
|
||||||
|
|
||||||
|
private String buildImportSubmitMessage(boolean hasRelationRows, boolean hasAssetRows) {
|
||||||
|
if (hasRelationRows && hasAssetRows) {
|
||||||
|
return "已提交员工亲属关系和亲属资产信息导入任务";
|
||||||
|
}
|
||||||
|
if (hasRelationRows) {
|
||||||
|
return "已提交员工亲属关系导入任务";
|
||||||
|
}
|
||||||
|
return "已提交亲属资产信息导入任务";
|
||||||
|
}
|
||||||
|
|
||||||
|
private String currentUserName() {
|
||||||
|
try {
|
||||||
|
return SecurityUtils.getUsername();
|
||||||
|
} catch (Exception e) {
|
||||||
|
return "system";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private CcdiAssetInfoVO toAssetInfoVO(CcdiAssetInfo assetInfo) {
|
private CcdiAssetInfoVO toAssetInfoVO(CcdiAssetInfo assetInfo) {
|
||||||
CcdiAssetInfoVO assetInfoVO = new CcdiAssetInfoVO();
|
CcdiAssetInfoVO assetInfoVO = new CcdiAssetInfoVO();
|
||||||
BeanUtils.copyProperties(assetInfo, assetInfoVO);
|
BeanUtils.copyProperties(assetInfo, assetInfoVO);
|
||||||
|
|||||||
@@ -0,0 +1,43 @@
|
|||||||
|
# 员工资产导入与实体库自动补入后端实施记录
|
||||||
|
|
||||||
|
## 基本信息
|
||||||
|
|
||||||
|
- 实施日期:2026-05-06
|
||||||
|
- 实施范围:后端
|
||||||
|
- 关联计划:`docs/plans/backend/2026-05-06-staff-asset-import-and-enterprise-autofill-fix-backend-implementation-plan.md`
|
||||||
|
|
||||||
|
## 修改内容
|
||||||
|
|
||||||
|
### 双 Sheet 导入任务编排
|
||||||
|
|
||||||
|
- 员工信息维护导入入口改为由服务层统一编排员工主 Sheet 与员工资产 Sheet。
|
||||||
|
- 员工亲属关系维护导入入口改为由服务层统一编排亲属关系主 Sheet 与亲属资产 Sheet。
|
||||||
|
- 当两个 Sheet 都有数据时,仍返回两个任务 ID,并按主 Sheet 导入成功结果为资产 Sheet 提供同文件内的归属映射。
|
||||||
|
- 当只导入资产 Sheet 时,仅生成并返回资产导入任务 ID,不生成员工或亲属关系主任务 ID。
|
||||||
|
- 当两个 Sheet 都为空时,保持返回“至少需要一条数据”。
|
||||||
|
|
||||||
|
### 实体库自动补入
|
||||||
|
|
||||||
|
- 新增统一的实体库自动补入服务,按统一社会信用代码去重,只插入实体库不存在的记录。
|
||||||
|
- 员工企业关系、信贷客户企业关系新增和导入时自动补入实体库。
|
||||||
|
- 中介新增、编辑和导入时取消“实体库必须已存在”的阻断校验;实体库缺失时按中介来源自动补入,不要求提供机构名称。
|
||||||
|
- 招投标供应商新增、编辑和导入时,对合法统一社会信用代码的供应商自动补入实体库。
|
||||||
|
- 新增企业来源枚举 `SUPPLIER`,用于标识供应商来源。
|
||||||
|
|
||||||
|
## 影响范围
|
||||||
|
|
||||||
|
- `/ccdi/baseStaff/importData`
|
||||||
|
- `/ccdi/staffFmyRelation/importData`
|
||||||
|
- 员工企业关系、信贷客户企业关系、中介、招投标供应商的新增/编辑/导入实体库联动逻辑
|
||||||
|
- 实体库基础信息表 `ccdi_enterprise_base_info`
|
||||||
|
|
||||||
|
## 验证记录
|
||||||
|
|
||||||
|
- 执行 `mvn -pl ccdi-info-collection -am -DskipTests compile`,结果:BUILD SUCCESS。
|
||||||
|
- 执行 `mvn -DskipTests compile`,结果:BUILD SUCCESS。
|
||||||
|
- 代码路径核对:员工主 Sheet 为空时仅调用员工资产导入服务并返回 `assetTaskId`;亲属关系主 Sheet 为空时仅调用亲属资产导入服务并返回 `assetTaskId`。
|
||||||
|
|
||||||
|
## 备注
|
||||||
|
|
||||||
|
- 本次为后端逻辑调整,未修改前端页面代码。
|
||||||
|
- 现有前端已按 `staffTaskId` / `relationTaskId` / `assetTaskId` 是否存在分别启动轮询,可直接兼容只返回资产任务 ID 的结果。
|
||||||
Reference in New Issue
Block a user