|
@@ -6,7 +6,11 @@ import com.rongwei.bscommon.sys.service.StudyFilePersonService;
|
|
|
import com.rongwei.bscommon.sys.service.StudyFileRecordService;
|
|
|
import com.rongwei.bscommon.sys.service.StudyFileService;
|
|
|
import com.rongwei.bscommon.sys.utils.QHSEUtils;
|
|
|
-import com.rongwei.bsentity.domain.*;
|
|
|
+import com.rongwei.bsentity.Dto.StudyFileProduceHistoryDto;
|
|
|
+import com.rongwei.bsentity.domain.StudyFileDo;
|
|
|
+import com.rongwei.bsentity.domain.StudyFilePersonDo;
|
|
|
+import com.rongwei.bsentity.domain.StudyFilePersonRecordDo;
|
|
|
+import com.rongwei.bsentity.domain.StudyFileRecordDo;
|
|
|
import com.rongwei.rwadmincommon.system.vo.SysUserVo;
|
|
|
import com.rongwei.rwcommon.utils.SecurityUtil;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
@@ -39,6 +43,8 @@ public class StudyFileServiceImpl implements StudyFileService {
|
|
|
@Override
|
|
|
@Transactional
|
|
|
public boolean produceHistory(StudyFileDo studyFileDo, String processType) {
|
|
|
+ // 获取当前用户信息
|
|
|
+ SysUserVo currentUser = QHSEUtils.getCurrentUser();
|
|
|
|
|
|
// 获取最新的学习文件信息
|
|
|
StudyFileDo currentFile = studyFileDao.selectById(studyFileDo.getId());
|
|
@@ -53,11 +59,38 @@ public class StudyFileServiceImpl implements StudyFileService {
|
|
|
}
|
|
|
|
|
|
// 保存历史学习文件信息
|
|
|
- StudyFileRecordDo historyFile = createHistoryFileRecord(currentFile);
|
|
|
+ StudyFileRecordDo historyFile = createHistoryFileRecord(currentFile, currentUser);
|
|
|
studyFileRecordService.save(historyFile);
|
|
|
|
|
|
// 处理相关人员历史记录
|
|
|
- processPersonHistoryRecords(currentFile.getId(), historyFile.getId(), processType);
|
|
|
+ processPersonHistoryRecords(currentFile.getId(), historyFile.getId(), processType, currentUser);
|
|
|
+
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 同步人员信息
|
|
|
+ *
|
|
|
+ * @param dto 同步数据
|
|
|
+ * @return 同步结果
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ @Transactional
|
|
|
+ public boolean syncPerson(StudyFileProduceHistoryDto dto) {
|
|
|
+ SysUserVo currentUser = QHSEUtils.getCurrentUser();
|
|
|
+ // 查询当前文件的所有人员信息
|
|
|
+ List<StudyFilePersonDo> currentPersons = studyFilePersonService.selectListByStudyFileId(dto.getId());
|
|
|
+ // 获取最新历史文件
|
|
|
+ StudyFileRecordDo historyFile = studyFileRecordService.selectLatestRecordByMainId(dto.getId());
|
|
|
+ // 删除人员历史记录
|
|
|
+ studyFilePersonRecordService.deleteByHistoryId(historyFile.getId());
|
|
|
+ // 转换为历史记录并收集需要删除的ID
|
|
|
+ List<StudyFilePersonRecordDo> historyPersons = currentPersons.stream()
|
|
|
+ .map(person -> convertToHistoryPersonRecord(person, historyFile.getId(), currentUser))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+
|
|
|
+ // 批量保存历史记录
|
|
|
+ studyFilePersonRecordService.saveBatch(historyPersons);
|
|
|
|
|
|
return true;
|
|
|
}
|
|
@@ -65,13 +98,20 @@ public class StudyFileServiceImpl implements StudyFileService {
|
|
|
/**
|
|
|
* 创建历史学习文件记录
|
|
|
*
|
|
|
- * @param source 源数据
|
|
|
+ * @param source 源数据
|
|
|
+ * @param currentUser
|
|
|
*/
|
|
|
- private StudyFileRecordDo createHistoryFileRecord(StudyFileDo source) {
|
|
|
+ private StudyFileRecordDo createHistoryFileRecord(StudyFileDo source, SysUserVo currentUser) {
|
|
|
StudyFileRecordDo target = new StudyFileRecordDo();
|
|
|
BeanUtils.copyProperties(source, target);
|
|
|
target.setId(SecurityUtil.getUUID());
|
|
|
target.setMainId(source.getId());
|
|
|
+ target.setCreatedate(new Date());
|
|
|
+ target.setCreateuserid(currentUser.getId());
|
|
|
+ target.setCreateusername(currentUser.getName());
|
|
|
+ target.setModifydate(new Date());
|
|
|
+ target.setModifyuserid(currentUser.getId());
|
|
|
+ target.setModifyusername(currentUser.getName());
|
|
|
return target;
|
|
|
}
|
|
|
|
|
@@ -81,15 +121,14 @@ public class StudyFileServiceImpl implements StudyFileService {
|
|
|
* @param fileId 文件ID
|
|
|
* @param historyFileId 历史文件ID
|
|
|
* @param processType 流程类型
|
|
|
+ * @param currentUser 当前用户
|
|
|
*/
|
|
|
- private void processPersonHistoryRecords(String fileId, String historyFileId, String processType) {
|
|
|
- // 获取当前用户信息
|
|
|
- SysUserVo currentUser = QHSEUtils.getCurrentUser();
|
|
|
-
|
|
|
+ private void processPersonHistoryRecords(String fileId,
|
|
|
+ String historyFileId, String processType, SysUserVo currentUser) {
|
|
|
// 查询当前文件的所有人员信息
|
|
|
List<StudyFilePersonDo> currentPersons = studyFilePersonService.selectListByStudyFileId(fileId);
|
|
|
|
|
|
- // 转换为历史记录并收集需要删除的ID
|
|
|
+ // 转换为历史记录
|
|
|
List<StudyFilePersonRecordDo> historyPersons = currentPersons.stream()
|
|
|
.map(person -> convertToHistoryPersonRecord(person, historyFileId, currentUser))
|
|
|
.collect(Collectors.toList());
|
|
@@ -115,15 +154,19 @@ public class StudyFileServiceImpl implements StudyFileService {
|
|
|
* @param historyFileId 历史文件ID
|
|
|
* @param currentUser
|
|
|
*/
|
|
|
- private StudyFilePersonRecordDo convertToHistoryPersonRecord(StudyFilePersonDo source, String historyFileId, SysUserVo currentUser) {
|
|
|
+ private StudyFilePersonRecordDo convertToHistoryPersonRecord(StudyFilePersonDo source,
|
|
|
+ String historyFileId, SysUserVo currentUser) {
|
|
|
StudyFilePersonRecordDo target = new StudyFilePersonRecordDo();
|
|
|
BeanUtils.copyProperties(source, target);
|
|
|
target.setId(SecurityUtil.getUUID());
|
|
|
target.setMainId(source.getId());
|
|
|
- target.setStudyFileId(historyFileId);
|
|
|
+ target.setHistoryId(historyFileId);
|
|
|
target.setCreatedate(new Date());
|
|
|
target.setCreateuserid(currentUser.getId());
|
|
|
target.setCreateusername(currentUser.getName());
|
|
|
+ target.setModifydate(new Date());
|
|
|
+ target.setModifyuserid(currentUser.getId());
|
|
|
+ target.setModifyusername(currentUser.getName());
|
|
|
return target;
|
|
|
}
|
|
|
}
|