|
@@ -1,25 +1,42 @@
|
|
package com.qmth.sop.business.templete.execute;
|
|
package com.qmth.sop.business.templete.execute;
|
|
|
|
|
|
|
|
+import cn.hutool.core.date.DateUtil;
|
|
|
|
+import com.qmth.boot.api.exception.ApiException;
|
|
|
|
+import com.qmth.sop.business.bean.dto.UserArchivesImportDto;
|
|
|
|
+import com.qmth.sop.business.entity.BasicAttachment;
|
|
|
|
+import com.qmth.sop.business.entity.TBTask;
|
|
import com.qmth.sop.business.service.TBTaskService;
|
|
import com.qmth.sop.business.service.TBTaskService;
|
|
import com.qmth.sop.business.templete.export.AsyncExportTaskTemplete;
|
|
import com.qmth.sop.business.templete.export.AsyncExportTaskTemplete;
|
|
import com.qmth.sop.business.templete.service.TaskLogicService;
|
|
import com.qmth.sop.business.templete.service.TaskLogicService;
|
|
|
|
+import com.qmth.sop.common.contant.SystemConstant;
|
|
|
|
+import com.qmth.sop.common.enums.TaskResultEnum;
|
|
|
|
+import com.qmth.sop.common.enums.TaskStatusEnum;
|
|
|
|
+import com.qmth.sop.common.enums.TaskTypeEnum;
|
|
import com.qmth.sop.common.util.Result;
|
|
import com.qmth.sop.common.util.Result;
|
|
|
|
+import com.qmth.sop.common.util.ResultUtil;
|
|
|
|
+import org.apache.commons.collections4.CollectionUtils;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
|
|
+import java.text.MessageFormat;
|
|
|
|
+import java.util.Date;
|
|
|
|
+import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
|
|
+import java.util.StringJoiner;
|
|
|
|
|
|
/**
|
|
/**
|
|
- * @Description: 用户档案批量导出
|
|
|
|
- * @Author: CaoZixuan
|
|
|
|
- * @Date: 2021-08-12
|
|
|
|
|
|
+ * @Description: 人员档案导出
|
|
|
|
+ * @Param:
|
|
|
|
+ * @return:
|
|
|
|
+ * @Author: wangliang
|
|
|
|
+ * @Date: 2023/8/1
|
|
*/
|
|
*/
|
|
@Service
|
|
@Service
|
|
public class AsyncUserArchivesExportService extends AsyncExportTaskTemplete {
|
|
public class AsyncUserArchivesExportService extends AsyncExportTaskTemplete {
|
|
private final static Logger log = LoggerFactory.getLogger(AsyncUserArchivesExportService.class);
|
|
private final static Logger log = LoggerFactory.getLogger(AsyncUserArchivesExportService.class);
|
|
- public static final String OBJ_TITLE = "用户基本信息";
|
|
|
|
|
|
+ public static final String OBJ_TITLE = "人员档案信息";
|
|
|
|
|
|
@Resource
|
|
@Resource
|
|
TaskLogicService taskLogicService;
|
|
TaskLogicService taskLogicService;
|
|
@@ -29,6 +46,34 @@ public class AsyncUserArchivesExportService extends AsyncExportTaskTemplete {
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public Result exportTask(Map<String, Object> map) throws Exception {
|
|
public Result exportTask(Map<String, Object> map) throws Exception {
|
|
- return null;
|
|
|
|
|
|
+ TBTask tbTask = (TBTask) map.get(SystemConstant.TASK);
|
|
|
|
+ StringJoiner stringJoinerSummary = new StringJoiner("\n")
|
|
|
|
+ .add(MessageFormat.format("{0}{1}{2}", DateUtil.format(new Date(), SystemConstant.DEFAULT_DATE_PATTERN), BEGIN_TITLE, OBJ_TITLE));
|
|
|
|
+ tbTask.setStatus(TaskStatusEnum.RUNNING);
|
|
|
|
+ tbTask.setSummary(stringJoinerSummary.toString());
|
|
|
|
+ tbTaskService.updateById(tbTask);
|
|
|
|
+ try {
|
|
|
|
+ Map<String, Object> result = taskLogicService.executeExportUserArchivesLogic(map);
|
|
|
|
+ List<UserArchivesImportDto> archivesImportDtoList = (List<UserArchivesImportDto>) result.get(SystemConstant.EXCEL_DATA);
|
|
|
|
+ BasicAttachment basicAttachment = (BasicAttachment) result.get(SystemConstant.EXCEL_ATTACHMENT);
|
|
|
|
+ stringJoinerSummary.add(MessageFormat.format("{0}{1}{2}{3}", DateUtil.format(new Date(), SystemConstant.DEFAULT_DATE_PATTERN), FINISH_TITLE, !CollectionUtils.isEmpty(archivesImportDtoList) ? archivesImportDtoList.size() : 0, FINISH_SIZE));
|
|
|
|
+
|
|
|
|
+ tbTask.setImportFileName(TaskTypeEnum.USER_ARCHIVES_EXPORT.getTitle());
|
|
|
|
+ tbTask.setResultFilePath(basicAttachment.getPath());
|
|
|
|
+ tbTask.setResult(TaskResultEnum.SUCCESS);
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ log.error(SystemConstant.LOG_ERROR, e);
|
|
|
|
+ stringJoinerSummary.add(MessageFormat.format("{0}{1}{2}{3}", DateUtil.format(new Date(), SystemConstant.DEFAULT_DATE_PATTERN), EXCEPTION_TITLE, EXCEPTION_DATA, e.getMessage()));
|
|
|
|
+ tbTask.setResult(TaskResultEnum.ERROR);
|
|
|
|
+ if (e instanceof ApiException) {
|
|
|
|
+ ResultUtil.error((ApiException) e, e.getMessage());
|
|
|
|
+ } else {
|
|
|
|
+ ResultUtil.error(e.getMessage());
|
|
|
|
+ }
|
|
|
|
+ } finally {//生成txt文件
|
|
|
|
+ tbTask.setSummary(stringJoinerSummary.toString());
|
|
|
|
+ super.createTxt(tbTask);
|
|
|
|
+ }
|
|
|
|
+ return ResultUtil.ok();
|
|
}
|
|
}
|
|
}
|
|
}
|