批量调薪action

This commit is contained in:
钱涛 2022-12-06 09:41:26 +08:00
parent 23dd15a568
commit 5b1615675d
2 changed files with 111 additions and 20 deletions

View File

@ -0,0 +1,72 @@
package com.engine.salary.action;
import com.engine.common.util.ServiceUtil;
import com.engine.salary.entity.salaryarchive.param.SalaryArchiveImportHandleParam;
import com.engine.salary.enums.salaryarchive.SalaryArchiveImportTypeEnum;
import com.engine.salary.enums.salaryarchive.SalaryArchiveListTypeEnum;
import com.engine.salary.service.SalaryArchiveExcelService;
import com.engine.salary.service.impl.SalaryArchiveExcelServiceImpl;
import lombok.extern.slf4j.Slf4j;
import weaver.conn.RecordSet;
import weaver.general.Util;
import weaver.hrm.User;
import weaver.interfaces.workflow.action.Action;
import weaver.soa.workflow.request.Property;
import weaver.soa.workflow.request.RequestInfo;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@Slf4j
public class CheckSalaryArchiveBatchAdjustmentByUpload implements Action {
private SalaryArchiveExcelService getSalaryArchiveExcelService(User user) {
return ServiceUtil.getService(SalaryArchiveExcelServiceImpl.class, user);
}
@Override
public String execute(RequestInfo requestInfo) {
try {
Property[] properties = requestInfo.getMainTableInfo().getProperty();
Map<String, String> fieldMap = Arrays.stream(properties).collect(Collectors.toMap(Property::getName,
property -> Util.null2String(property.getValue())));
String dxmd = fieldMap.get("dxmd");
RecordSet rs = new RecordSet();
String queryImageId = "select imagefileid from docimagefile where docid = ?";
rs.executeQuery(queryImageId, dxmd);
String imagefileid = null;
if (rs.next()) {
imagefileid = rs.getString("imagefileid");
}
SalaryArchiveImportHandleParam param = SalaryArchiveImportHandleParam.builder().imageId(imagefileid)
.listType(SalaryArchiveListTypeEnum.FIXED.getValue())
.importType(SalaryArchiveImportTypeEnum.SALARYITEMADJUST.getValue())
.onlyCheck(true)
.isProcess(true)
.build();
Map<String, Object> map = getSalaryArchiveExcelService(new User()).batchImportEbatch(param);
int errorCount = (int) map.get("errorCount");
if (errorCount > 0) {
log.error("批量调薪存在异常 requestId:{} map:{}",requestInfo.getRequestid(), map);
List<Map<String, String>> excelComments = (List<Map<String, String>>) map.get("errorNotice");
StringBuilder message = new StringBuilder("excel中");
for (Map<String, String> comments : excelComments) {
message.append(comments.get("message")).append("\n");
}
requestInfo.getRequestManager().setMessage(message.toString());
return FAILURE_AND_CONTINUE;
}
} catch (Exception e) {
log.error("批量调薪异常", e);
requestInfo.getRequestManager().setMessage(e.getMessage());
return FAILURE_AND_CONTINUE;
}
return SUCCESS;
}
}

View File

@ -6,6 +6,7 @@ import com.engine.salary.enums.salaryarchive.SalaryArchiveImportTypeEnum;
import com.engine.salary.enums.salaryarchive.SalaryArchiveListTypeEnum;
import com.engine.salary.service.SalaryArchiveExcelService;
import com.engine.salary.service.impl.SalaryArchiveExcelServiceImpl;
import lombok.extern.slf4j.Slf4j;
import weaver.conn.RecordSet;
import weaver.general.Util;
import weaver.hrm.User;
@ -17,6 +18,7 @@ import java.util.Arrays;
import java.util.Map;
import java.util.stream.Collectors;
@Slf4j
public class SalaryArchiveBatchAdjustmentByUpload implements Action {
private SalaryArchiveExcelService getSalaryArchiveExcelService(User user) {
@ -25,29 +27,46 @@ public class SalaryArchiveBatchAdjustmentByUpload implements Action {
@Override
public String execute(RequestInfo requestInfo) {
Property[] properties = requestInfo.getMainTableInfo().getProperty();
Map<String, String> fieldMap = Arrays.stream(properties).collect(Collectors.toMap(Property::getName,
property -> Util.null2String(property.getValue())));
try {
String dxmd = fieldMap.get("dxmd");
Property[] properties = requestInfo.getMainTableInfo().getProperty();
Map<String, String> fieldMap = Arrays.stream(properties).collect(Collectors.toMap(Property::getName,
property -> Util.null2String(property.getValue())));
RecordSet rs = new RecordSet();
String queryImageId = "select imagefileid from docimagefile where docid = ?";
rs.executeQuery(queryImageId, dxmd);
String imagefileid = null;
if (rs.next()) {
imagefileid = rs.getString("imagefileid");
String dxmd = fieldMap.get("dxmd");
RecordSet rs = new RecordSet();
String queryImageId = "select imagefileid from docimagefile where docid = ?";
rs.executeQuery(queryImageId, dxmd);
String imagefileid = null;
if (rs.next()) {
imagefileid = rs.getString("imagefileid");
}
SalaryArchiveImportHandleParam param = SalaryArchiveImportHandleParam.builder().imageId(imagefileid)
.listType(SalaryArchiveListTypeEnum.FIXED.getValue())
.importType(SalaryArchiveImportTypeEnum.SALARYITEMADJUST.getValue())
.onlyCheck(false)
.isProcess(true)
.build();
Map<String, Object> map = getSalaryArchiveExcelService(new User()).batchImportEbatch(param);
int errorCount = (int) map.get("errorCount");
if (errorCount > 0) {
log.error("批量调薪存在异常 requestId:{} map:{}",requestInfo.getRequestid(), map);
// List<Map<String, String>> excelComments = (List<Map<String, String>>) map.get("errorNotice");
// StringBuilder message = new StringBuilder();
// for (Map<String, String> comments : excelComments) {
// message.append(comments.get("message")).append("/n");
// }
// requestInfo.getRequestManager().setMessage(message.toString());
// return FAILURE_AND_CONTINUE;
}
} catch (Exception e) {
log.error("批量调薪异常", e);
requestInfo.getRequestManager().setMessage(e.getMessage());
return FAILURE_AND_CONTINUE;
}
SalaryArchiveImportHandleParam param = SalaryArchiveImportHandleParam.builder().imageId(imagefileid)
.listType(SalaryArchiveListTypeEnum.FIXED.getValue())
.importType(SalaryArchiveImportTypeEnum.SALARYITEMADJUST.getValue())
.onlyCheck(false)
.isProcess(true)
.build();
Map<String, Object> map = getSalaryArchiveExcelService(new User()).batchImportEbatch(param);
return SUCCESS;
}
}