|
@@ -6,13 +6,16 @@ import com.rongwei.bscommon.system.service.StudyFilePersonService;
|
|
|
import com.rongwei.bscommon.system.service.StudyFileRecordService;
|
|
|
import com.rongwei.bscommon.system.service.StudyFileService;
|
|
|
import com.rongwei.bscommon.system.utils.QHSEUtils;
|
|
|
-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.bsentity.dto.StudyFileProduceHistoryDto;
|
|
|
import com.rongwei.rwadmincommon.system.vo.SysUserVo;
|
|
|
+import com.rongwei.rwcommon.base.R;
|
|
|
import com.rongwei.rwcommon.utils.SecurityUtil;
|
|
|
+import org.slf4j.Logger;
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
@@ -20,10 +23,14 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
+import java.util.Objects;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
@Service
|
|
|
public class StudyFileServiceImpl implements StudyFileService {
|
|
|
+
|
|
|
+ private static final Logger logger = LoggerFactory.getLogger(StudyFileServiceImpl.class);
|
|
|
+
|
|
|
@Autowired
|
|
|
private StudyFileDao studyFileDao;
|
|
|
@Autowired
|
|
@@ -95,6 +102,63 @@ public class StudyFileServiceImpl implements StudyFileService {
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 取消流程,恢复历史数据
|
|
|
+ *
|
|
|
+ * @param id 取消流程的文件 ID
|
|
|
+ * @return 结果
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public R cancelProcess(String id) {
|
|
|
+ // 获取最新的学习文件信息
|
|
|
+ StudyFileDo currentFile = studyFileDao.selectById(id);
|
|
|
+ // 获取最新历史文件
|
|
|
+ StudyFileRecordDo historyFile = studyFileRecordService.selectLatestRecordByMainId(id);
|
|
|
+ if (historyFile == null) {
|
|
|
+ logger.info("文件:{},没有找到对应的历史文件", id);
|
|
|
+ return R.ok("没有找到对应的历史文件");
|
|
|
+ }
|
|
|
+ // 恢复文件历史数据
|
|
|
+ BeanUtils.copyProperties(historyFile, currentFile);
|
|
|
+ currentFile.setId(historyFile.getMainId());
|
|
|
+ if (Objects.isNull(historyFile.getRemark())) {
|
|
|
+ currentFile.setRemark("");
|
|
|
+ }
|
|
|
+ studyFileDao.updateById(currentFile);
|
|
|
+
|
|
|
+ // 删除人员信息
|
|
|
+ studyFilePersonService.deleteByStudyFileId(id);
|
|
|
+ List<StudyFilePersonRecordDo> personRecords =
|
|
|
+ studyFilePersonRecordService.selectListByHistoryId(historyFile.getId());
|
|
|
+
|
|
|
+ if (personRecords == null || personRecords.isEmpty()) {
|
|
|
+ logger.info("文件:{},没有找到对应人员历史数据", id);
|
|
|
+ return R.ok();
|
|
|
+ }
|
|
|
+
|
|
|
+ // 恢复人员
|
|
|
+ List<StudyFilePersonDo> persons = personRecords.stream()
|
|
|
+ .map(record -> convertToPerson(record, currentFile))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ studyFilePersonService.saveBatch(persons);
|
|
|
+ return R.ok();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 转换人员信息
|
|
|
+ *
|
|
|
+ * @param record 历史记录
|
|
|
+ * @param currentFile 最新文件
|
|
|
+ * @return 人员信息
|
|
|
+ */
|
|
|
+ private StudyFilePersonDo convertToPerson(StudyFilePersonRecordDo record, StudyFileDo currentFile) {
|
|
|
+ StudyFilePersonDo studyFilePersonDo = new StudyFilePersonDo();
|
|
|
+ BeanUtils.copyProperties(record, studyFilePersonDo);
|
|
|
+ studyFilePersonDo.setId(SecurityUtil.getUUID());
|
|
|
+ studyFilePersonDo.setStudyFileId(currentFile.getId());
|
|
|
+ return studyFilePersonDo;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 创建历史学习文件记录
|
|
|
*
|