Commit bd54c0d1 authored by huyuchen's avatar huyuchen

huych-电子档案批量导入第三次提交

parent 4338a7a0
......@@ -53,6 +53,11 @@ public interface ArchiveConstants {
*/
String ATTA_RELATION_TYPE_FEEDBACK = "3";
/**
* 附件关系类型-人员附件
*/
String ATTA_RELATION_TYPE_PER = "4";
/**
* 附件状态-可用
*/
......@@ -83,26 +88,6 @@ public interface ArchiveConstants {
*/
String MATERIAL_TYPE_LEAVE = "离职";
/**
* 资料类型编码-存量
*/
String MATERIAL_TYPE_CODE_STOCK = "0";
/**
* 资料类型编码-新签
*/
String MATERIAL_TYPE_CODE_NEW = "1";
/**
* 资料类型编码-续签
*/
String MATERIAL_TYPE_CODE_RENEW = "2";
/**
* 资料类型编码-离职
*/
String MATERIAL_TYPE_CODE_LEAVE = "3";
/**
* 处理结果-成功
*/
......
package com.yifu.cloud.plus.v1.batch.controller;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.yifu.cloud.plus.v1.batch.entity.TAttaInfo;
import com.yifu.cloud.plus.v1.batch.service.FileUploadService;
import com.yifu.cloud.plus.v1.batch.service.TAttaInfoService;
import com.yifu.cloud.plus.v1.batch.entity.TAttaInfo;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.util.Common;
import com.yifu.cloud.plus.v1.yifu.common.core.util.OSSUtil;
......@@ -18,7 +18,9 @@ import org.springframework.web.multipart.MultipartFile;
import java.io.IOException;
import java.net.URL;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @author fang
......@@ -187,8 +189,9 @@ public class FileUploadController {
}
// 构建OSS文件路径,如果文件名重复则添加后缀
String key = buildUniqueFilePath(filePath, fileName);
Map<String, String> keyMap = buildUniqueFilePath(filePath, fileName);
String key = keyMap.get("key");
fileName = keyMap.get("name");
// 校验文件类型
if (!Common.checkFile(key)) {
return R.failed("非法上传类型:" + fileName);
......@@ -245,11 +248,14 @@ public class FileUploadController {
* @param fileName 文件名
* @return 唯一的文件路径
*/
private String buildUniqueFilePath(String filePath, String fileName) {
private Map<String, String> buildUniqueFilePath(String filePath, String fileName) {
Map<String, String> fileMap = new HashMap<>();
// 检查文件是否存在
if (!fileUploadService.checkFileExists(filePath+ "/" + fileName)) {
return filePath+ "/" + fileName;
fileMap.put("key",filePath+ "/" + fileName);
fileMap.put("name",fileName);
return fileMap;
}
// 文件存在,添加后缀
......@@ -264,6 +270,8 @@ public class FileUploadController {
nameWithoutExt = fileName;
extension = "";
}
return filePath + "/" + nameWithoutExt + "_" + System.currentTimeMillis() + extension;
fileMap.put("key",filePath + "/" + nameWithoutExt + "_" + System.currentTimeMillis() + extension);
fileMap.put("name",nameWithoutExt + "_" + System.currentTimeMillis() + extension);
return fileMap;
}
}
......@@ -8,6 +8,8 @@ import com.yifu.cloud.plus.v1.batch.vo.TElectronicArchiveDetailSearchVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 电子档案明细表
*
......@@ -22,4 +24,6 @@ public interface TElectronicArchiveDetailMapper extends BaseMapper<TElectronicAr
* @return
*/
IPage<TElectronicArchiveDetail> getTElectronicArchiveDetailPage(Page<TElectronicArchiveDetail> page, @Param("tElectronicArchiveDetail") TElectronicArchiveDetailSearchVo tElectronicArchiveDetail);
List<TElectronicArchiveDetail> getTElectronicArchiveDetailList(@Param("tElectronicArchiveDetail") TElectronicArchiveDetailSearchVo tElectronicArchiveDetail);
}
......@@ -24,6 +24,7 @@ import com.yifu.cloud.plus.v1.yifu.archives.vo.IdNameNoVo;
import com.yifu.cloud.plus.v1.yifu.archives.vo.TSettleDomainListVo;
import com.yifu.cloud.plus.v1.yifu.archives.vo.TSettleDomainSelectVo;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.CacheConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.ClientNameConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.util.*;
import com.yifu.cloud.plus.v1.yifu.common.core.vo.YifuUser;
......@@ -38,7 +39,6 @@ import org.springframework.cache.support.SimpleValueWrapper;
import org.springframework.mock.web.MockMultipartFile;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
import java.io.File;
......@@ -189,14 +189,24 @@ public class ElectronicArchiveImportServiceImpl implements ElectronicArchiveImpo
Map<String,String> map = new HashMap<>();
List<String> deptNoList = new ArrayList<>();
if (Common.isNotNull(user) && !CommonConstants.ZERO_STRING.equals(user.getSystemFlag())) {
boolean isCheck = true;
List<Long> roleList = user.getClientRoleMap().get(ClientNameConstants.CLIENT_MVP);
if (CommonConstants.ZERO_STRING.equals(user.getSystemFlag()) ||
(Common.isNotNull(roleList) && roleList.stream().anyMatch(role -> role == 1569585030423158786L))) {
isCheck = false;
}
if (Common.isNotNull(user) && isCheck) {
deptNoList = getDeptNoList(user.getId());
}
for (ArchiveImportVO data : dataList) {
try {
//超管和档案管理员无需校验项目权限
if (Common.isNotNull(user) && !CommonConstants.ZERO_STRING.equals(user.getSystemFlag())) {
if (Common.isEmpty(deptNoList)) {
if (Common.isNotNull(user) && isCheck) {
if (Common.isEmpty(deptNoList) || !deptNoList.contains(data.getDeptNo())) {
ErrorMessage<ArchiveImportVO> errorMessage = new ErrorMessage<>(data.getRowIndex()
,InsurancesConstants.DEPT_NO_NOT_IN_USER_DEPT_LIST,data);
errorMessageList.add(errorMessage);
......@@ -374,7 +384,6 @@ public class ElectronicArchiveImportServiceImpl implements ElectronicArchiveImpo
* 第二步:导入ZIP文件
*/
@Override
@Transactional(rollbackFor = Exception.class)
public R<?> importZipFile(MultipartFile file, String taskId) {
YifuUser user = SecurityUtils.getUser();
if (null == user) {
......@@ -566,7 +575,7 @@ public class ElectronicArchiveImportServiceImpl implements ElectronicArchiveImpo
taskService.updateById(task);
// 生成反馈表
generateFeedbackExcel(taskId, feedbackList);
generateFeedbackExcel(task, feedbackList);
return R.ok("处理完成");
} catch (Exception e) {
......@@ -761,15 +770,6 @@ public class ElectronicArchiveImportServiceImpl implements ElectronicArchiveImpo
private void processFile(File file, TElectronicArchiveDetail detail, String materialType,
List<ArchiveFeedbackVO> feedbackList, Set<String> materialTypes) {
String fileName = file.getName();
long fileSize = file.length();
// 1. 校验文件大小
// if (fileSize > ArchiveConstants.SINGLE_FILE_MAX_SIZE) {
// ArchiveFeedbackVO feedback = createFeedbackVO(detail, materialType,
// ArchiveConstants.PROCESS_RESULT_FAILED, "单个文件大小超过15M:" + fileName);
// feedbackList.add(feedback);
// return;
// }
// 2. 校验文件格式
if (!checkFileFormat(fileName)) {
......@@ -916,7 +916,7 @@ public class ElectronicArchiveImportServiceImpl implements ElectronicArchiveImpo
/**
* 生成反馈表Excel
*/
private void generateFeedbackExcel(String taskId, List<ArchiveFeedbackVO> feedbackList) {
private void generateFeedbackExcel(TElectronicArchiveTask task, List<ArchiveFeedbackVO> feedbackList) {
if (CollUtil.isEmpty(feedbackList)) {
return;
}
......@@ -924,7 +924,7 @@ public class ElectronicArchiveImportServiceImpl implements ElectronicArchiveImpo
try {
// 创建临时文件
String tempFilePath = System.getProperty("java.io.tmpdir") + File.separator +
"feedback_" + System.currentTimeMillis() + ".xlsx";
task.getTaskCode() + "结果反馈表" + ".xlsx";
File feedbackFile = new File(tempFilePath);
// 使用EasyExcel生成反馈表
......@@ -939,13 +939,13 @@ public class ElectronicArchiveImportServiceImpl implements ElectronicArchiveImpo
fileToMultipartFile(feedbackFile),
"archive/feedback",
ArchiveConstants.ATTA_RELATION_TYPE_FEEDBACK,
taskId
task.getId()
);
if (R.isSuccess(uploadResult)) {
log.info("反馈表生成成功,任务ID:{}", taskId);
log.info("反馈表生成成功");
} else {
log.error("反馈表上传失败,任务ID:{}", taskId);
log.error("反馈表上传失败");
}
}
......@@ -953,7 +953,7 @@ public class ElectronicArchiveImportServiceImpl implements ElectronicArchiveImpo
FileUtil.del(feedbackFile);
} catch (Exception e) {
log.error("生成反馈表失败,任务ID:{}", taskId, e);
log.error("生成反馈表失败:", e);
}
}
......@@ -1021,7 +1021,6 @@ public class ElectronicArchiveImportServiceImpl implements ElectronicArchiveImpo
* 单个新增人员附件
*/
@Override
@Transactional(rollbackFor = Exception.class)
public R<?> uploadSinglePersonArchive(String empIdcard, String empName, String deptNo,
String deptName, String materialType, MultipartFile[] files) {
YifuUser user = SecurityUtils.getUser();
......@@ -1173,7 +1172,6 @@ public class ElectronicArchiveImportServiceImpl implements ElectronicArchiveImpo
* 前端先调用文件上传接口获取附件ID列表,再调用此方法更新附件的domainId
*/
@Override
@Transactional(rollbackFor = Exception.class)
public R<?> uploadSinglePersonArchiveByAttaIds(String empIdcard, String empName, String deptNo,
String deptName, String materialType, List<String> attaIdList) {
YifuUser user = SecurityUtils.getUser();
......@@ -1245,6 +1243,21 @@ public class ElectronicArchiveImportServiceImpl implements ElectronicArchiveImpo
detail.setFileCity(empInfo.getFileCity());
detail.setFileTown(empInfo.getFileTown());
detailService.save(detail);
// 创建任务,假删除任务
TElectronicArchiveTask task = new TElectronicArchiveTask();
task.setTaskCode("DZDAPL_SINGLE");
task.setUploadFileName("单个上传");
task.setStatus(ArchiveConstants.TASK_STATUS_GENERATED);
task.setDeleteFlag(CommonConstants.ONE_STRING);
taskService.save(task);
// 建立任务和档案详情的关联关系
TTaskArchiveRelation relation = new TTaskArchiveRelation();
relation.setTaskId(task.getId());
relation.setArchiveDetailId(detail.getId());
relationService.save(relation);
} else {
// 存在则更新资料类型(追加)
Set<String> existTypes = new HashSet<>();
......
......@@ -36,9 +36,9 @@ public class FileUploadServiceImpl implements FileUploadService {
private final TAttaInfoService tAttaInfoService;
private AtomicInteger atomicInteger = new AtomicInteger(0);
private AtomicInteger atomicInteger = new AtomicInteger(0);
//初始化附件上传队列上限值
private int maxLimit = 1;
private int maxLimit = 1;
private final SysConfigLimitMapper configLimitMapper;
......@@ -80,6 +80,7 @@ public class FileUploadServiceImpl implements FileUploadService {
extension = "";
}
key = filePath + "/" + nameWithoutExt + "_" + System.currentTimeMillis() + extension;
fileName = nameWithoutExt + "_" + System.currentTimeMillis() + extension;
}
boolean flag = ossUtil.uploadFileByStream(file.getInputStream(), key, "yf-hr-efile-source");
......
......@@ -105,4 +105,16 @@
</where>
ORDER BY a.CREATE_TIME DESC
</select>
<!--tElectronicArchiveDetail简单分页查询-->
<select id="getTElectronicArchiveDetailList" resultMap="tElectronicArchiveDetailMap">
SELECT
<include refid="Base_Column_List"/>
FROM t_electronic_archive_detail a
<where>
a.DELETE_FLAG = '0'
<include refid="tElectronicArchiveDetail_where"/>
</where>
ORDER BY a.CREATE_TIME DESC
</select>
</mapper>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment