邮件暂存

This commit is contained in:
钱涛 2023-06-02 14:38:56 +08:00
parent 4be4acc5d8
commit 0da2bfa55a
2 changed files with 61 additions and 54 deletions

View File

@ -20,6 +20,8 @@ import org.slf4j.LoggerFactory;
import weaver.common.MessageUtil;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.time.LocalDateTime;
import java.util.*;
@ -89,67 +91,68 @@ public class SalaryBillBO {
return employeeFieldNameMap;
}
// /**
// * 构建工资单中的人员信息
// *
// * @param employeeInformation
// * @param simpleEmployee
// * @param employeeField
// */
// public static void buildEmployeeInfo(SalaryTemplateSalaryItemSetListDTO employeeInformation, SimpleEmployee simpleEmployee, Map<String, String> employeeField) {
// if (employeeInformation == null || simpleEmployee == null) {
// return;
// }
// if (org.apache.commons.collections.CollectionUtils.isNotEmpty(employeeInformation.getItems())) {
// //获取员工信息的字段名和中文描述的map关系
// SalaryFormulaEmployeeDTO salaryFormulaEmployeeDTO = SalaryFormulaEmployeeDTO.builder().employeeId(simpleEmployee.getEmployeeId())
// .departmentName(simpleEmployee.getDepartment() == null ? "" : simpleEmployee.getDepartment().getName())
// .email(org.apache.commons.lang3.StringUtils.isEmpty(simpleEmployee.getEmail()) ? "" : simpleEmployee.getEmail())
/**
* 构建工资单中的人员信息
*
* @param employeeInformation
* @param simpleEmployee
* @param employeeField
*/
public static void buildEmployeeInfo(SalaryTemplateSalaryItemSetListDTO employeeInformation, DataCollectionEmployee simpleEmployee, Map<String, String> employeeField) {
if (employeeInformation == null || simpleEmployee == null) {
return;
}
if (org.apache.commons.collections.CollectionUtils.isNotEmpty(employeeInformation.getItems())) {
//获取员工信息的字段名和中文描述的map关系
SalaryFormulaEmployeeDTO salaryFormulaEmployeeDTO = SalaryFormulaEmployeeDTO.builder().employeeId(simpleEmployee.getEmployeeId())
.taxAgentName("axx")
.departmentName(simpleEmployee.getDepartmentName())
.email(org.apache.commons.lang3.StringUtils.isEmpty(simpleEmployee.getEmail()) ? "" : simpleEmployee.getEmail())
// .gradeName(simpleEmployee.getGrade() == null ? "" : simpleEmployee.getGrade().getName())
// .hireDate(SalaryDateUtil.getFormatLocalDate(simpleEmployee.getHiredate()))
// .sex(simpleEmployee.getSex() == null ? "" : simpleEmployee.getSex().getDescription())
// .mobile(org.apache.commons.lang3.StringUtils.isEmpty(simpleEmployee.getMobile()) ? "" : simpleEmployee.getMobile())
// .positionName(simpleEmployee.getPosition() == null ? "" : simpleEmployee.getPosition().getName())
.mobile(org.apache.commons.lang3.StringUtils.isEmpty(simpleEmployee.getMobile()) ? "" : simpleEmployee.getMobile())
.jobtitleName(simpleEmployee.getJobtitleName())
// .status(StringUtils.isEmpty(simpleEmployee.getPersonnelStatus()) ? "" : simpleEmployee.getPersonnelStatus())
// .telephone(org.apache.commons.lang3.StringUtils.isEmpty(simpleEmployee.getTelephone()) ? "" : simpleEmployee.getTelephone())
// .username(org.apache.commons.lang3.StringUtils.isEmpty(simpleEmployee.getUsername()) ? "" : simpleEmployee.getUsername())
// .jobNum(simpleEmployee.getJobNum() == null ? "" : simpleEmployee.getJobNum())
// .build();
// List<SalaryTemplateSalaryItemListDTO> items = employeeInformation.getItems();
// // 1.SalaryAcctResultBO.buildEmployeeFieldName()的取法
//// Set<Map.Entry<String, String>> entries = employeeField.entrySet();
//// for (SalaryTemplateSalaryItemListDTO e : items) {
//// Optional<Map.Entry<String, String>> entry = entries.stream().filter(f -> Objects.equals(e.getName(), f.getValue())).findFirst();
//// if (entry.isPresent()) {
//// String key = entry.get().getKey();
//// if (org.apache.commons.lang3.StringUtils.isNotBlank(key)) {
//// String getter = "get" + key.substring(0, 1).toUpperCase() + key.substring(1);
//// try {
//// Method method = salaryFormulaEmployeeDTO.getClass().getMethod(getter);
//// Object invoke = method.invoke(salaryFormulaEmployeeDTO);
//// e.setSalaryItemValue((String) invoke);
//// } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException ex) {
//// log.error("no such method", e);
//// }
//// }
//// }
//// }
// // 2.SalaryBillBO.buildEmployeeFieldName()
.telephone(org.apache.commons.lang3.StringUtils.isEmpty(simpleEmployee.getTelephone()) ? "" : simpleEmployee.getTelephone())
.username(org.apache.commons.lang3.StringUtils.isEmpty(simpleEmployee.getUsername()) ? "" : simpleEmployee.getUsername())
.workcode(simpleEmployee.getWorkcode())
.build();
List<SalaryTemplateSalaryItemListDTO> items = employeeInformation.getItems();
// 1.SalaryAcctResultBO.buildEmployeeFieldName()的取法
// Set<Map.Entry<String, String>> entries = employeeField.entrySet();
// for (SalaryTemplateSalaryItemListDTO e : items) {
// String employeeFieldName = employeeField.get(e.getName());
// if (!StringUtils.isEmpty(employeeFieldName)) {
// String getter = "get" + employeeFieldName.substring(0, 1).toUpperCase() + employeeFieldName.substring(1);
// try {
// Method method = salaryFormulaEmployeeDTO.getClass().getMethod(getter);
// Object invoke = method.invoke(salaryFormulaEmployeeDTO);
// e.setSalaryItemValue((String) invoke);
// } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException ex) {
// log.error("no such method", e);
// Optional<Map.Entry<String, String>> entry = entries.stream().filter(f -> Objects.equals(e.getName(), f.getValue())).findFirst();
// if (entry.isPresent()) {
// String key = entry.get().getKey();
// if (org.apache.commons.lang3.StringUtils.isNotBlank(key)) {
// String getter = "get" + key.substring(0, 1).toUpperCase() + key.substring(1);
// try {
// Method method = salaryFormulaEmployeeDTO.getClass().getMethod(getter);
// Object invoke = method.invoke(salaryFormulaEmployeeDTO);
// e.setSalaryItemValue((String) invoke);
// } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException ex) {
// log.error("no such method", e);
// }
// }
// }
// }
// }
// }
// 2.SalaryBillBO.buildEmployeeFieldName()
for (SalaryTemplateSalaryItemListDTO e : items) {
String employeeFieldName = employeeField.get(e.getName());
if (!StringUtils.isEmpty(employeeFieldName)) {
String getter = "get" + employeeFieldName.substring(0, 1).toUpperCase() + employeeFieldName.substring(1);
try {
Method method = salaryFormulaEmployeeDTO.getClass().getMethod(getter);
Object invoke = method.invoke(salaryFormulaEmployeeDTO);
e.setSalaryItemValue((String) invoke);
} catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException ex) {
log.error("no such method", e);
}
}
}
}
}
/**
* 获取工资单标题

View File

@ -411,6 +411,7 @@ public class SalaryBillServiceImpl extends Service implements SalaryBillService
enableSendList.forEach(e -> {
// 构建发送消息
// SendMessageEntity message = SalaryBillBO.buildSendMessage(e, allEmployeeMap, salaryBillSendParam);
SalaryBillBO.buildEmployeeInfo(salaryBillSendParam.getEmployeeInformation(), allEmployeeMap.get(e.get("employeeId").toString()), salaryBillSendParam.getEmployeeField());
SalaryBillBO.sendEmail(e, allEmployeeMap, salaryBillSendParam);
/** 发送工资单 **********************************************************/
// WeaResult<Long> sendResult = asyncSystemMessageRest.sendMsg(message);
@ -445,8 +446,11 @@ public class SalaryBillServiceImpl extends Service implements SalaryBillService
* @return
*/
private Map<String, DataCollectionEmployee> getEmployeeWholeInfo(List<Map<String, Object>> enableSendList) {
List<Long> ids = enableSendList.stream().map(e -> Long.valueOf(e.get("employeeId").toString())).collect(Collectors.toList());
// 获取所有人员信息
List<DataCollectionEmployee> simpleEmployees = getSalaryEmployeeService(user).listAll();
List<DataCollectionEmployee> simpleEmployees = getSalaryEmployeeService(user).getEmployeeByIdsAll(ids);
return SalaryEntityUtil.convert2Map(simpleEmployees, e -> e.getEmployeeId() + "");
}
// /** 工资单发放 end **********************************************************************/