Merge remote-tracking branch 'origin/develop' into develop

This commit is contained in:
钱涛 2022-04-21 20:29:25 +08:00
commit a20198fc4f
10 changed files with 306 additions and 179 deletions

View File

@ -86,4 +86,14 @@ public class SalarySendBiz {
}
}
public void insert(SalarySendPO salarySend) {
SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession();
try {
SalarySendMapper mapper = sqlSession.getMapper(SalarySendMapper.class);
mapper.insertIgnoreNull(salarySend);
sqlSession.commit();
} finally {
sqlSession.close();
}
}
}

View File

@ -104,4 +104,15 @@ public class SalarySendInfoBiz {
sqlSession.close();
}
}
public void batchInsert(List<SalarySendInfoPO> salarySendInfos) {
SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession();
try {
SalarySendInfoMapper mapper = sqlSession.getMapper(SalarySendInfoMapper.class);
mapper.batchInsert(salarySendInfos);
sqlSession.commit();
} finally {
sqlSession.close();
}
}
}

View File

@ -64,9 +64,8 @@ public interface SalarySendInfoMapper {
/**
* 批量插入工资单信息记录
* @param pos
* @param currentTenantKey
*/
void batchInsert(@Param("collection") List<SalarySendInfoPO> pos, String currentTenantKey);
void batchInsert(@Param("collection") List<SalarySendInfoPO> pos);
/**
* 发放撤回工资单

View File

@ -55,4 +55,6 @@ public interface SalarySendMapper {
* @return
*/
List<SalarySendPO> listSome(SalarySendPO params);
void insertIgnoreNull(SalarySendPO salarySend);
}

View File

@ -164,9 +164,9 @@
<if test="salaryAccountingId != null and salaryAccountingId != ''">
AND salary_accounting_id = #{salaryAccountingId}
</if>
<if test="salaryAcctRecordId != null and salaryAcctRecordId != ''">
AND salary_acct_record_id = #{salaryAcctRecordId}
</if>
<!-- <if test="salaryAcctRecordId != null and salaryAcctRecordId != ''">-->
<!-- AND salary_acct_record_id = #{salaryAcctRecordId}-->
<!-- </if>-->
<if test="salarySobId != null and salarySobId != ''">
AND salary_sob_id = #{salarySobId}
</if>
@ -198,5 +198,93 @@
</select>
<!-- 插入不为NULL的字段 -->
<insert id="insertIgnoreNull" parameterType="com.engine.salary.entity.salaryBill.po.SalarySendPO"
keyProperty="id" keyColumn="id" useGeneratedKeys="true"
>
INSERT INTO hrsa_salary_send
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
id,
</if>
<if test="salaryMonth != null">
salary_month,
</if>
<if test="salaryAccountingId != null">
salary_accounting_id,
</if>
<if test="salarySobId != null">
salary_sob_id,
</if>
<if test="sendNum != null">
send_num,
</if>
<if test="sendTotal != null">
send_total,
</if>
<if test="lastSendTime != null">
last_send_time,
</if>
<if test="creator != null">
creator,
</if>
<if test="createTime != null">
create_time,
</if>
<if test="updateTime != null">
update_time,
</if>
<if test="deleteType != null">
delete_type,
</if>
<if test="tenantKey != null">
tenant_key,
</if>
</trim>
<trim prefix="VALUES (" suffix=")" suffixOverrides=",">
<if test="id != null">
#{id},
</if>
<if test="salaryMonth != null">
#{salaryMonth},
</if>
<if test="salaryAccountingId != null">
#{salaryAccountingId},
</if>
<if test="salarySobId != null">
#{salarySobId},
</if>
<if test="sendNum != null">
#{sendNum},
</if>
<if test="sendTotal != null">
#{sendTotal},
</if>
<if test="lastSendTime != null">
#{lastSendTime},
</if>
<if test="creator != null">
#{creator},
</if>
<if test="createTime != null">
#{createTime},
</if>
<if test="updateTime != null">
#{updateTime},
</if>
<if test="deleteType != null">
#{deleteType},
</if>
<if test="tenantKey != null">
#{tenantKey},
</if>
</trim>
</insert>
</mapper>

View File

@ -28,10 +28,9 @@ public interface SalarySendService {
/**
* 薪资核算-归档生成工资单
* @param salaryAccountingId
* @param currentTenantKey
* @return
*/
// Map<String, Object> generateSalaryBill(Long salaryAccountingId, Long currentEmployeeId, String currentTenantKey);
String generateSalaryBill(Long salaryAccountingId);
/**
* 薪资核算-归档撤销工资单

View File

@ -1,5 +1,6 @@
package com.engine.salary.service;
import com.engine.salary.entity.salaryarchive.po.TaxAgentPO;
import com.engine.salary.entity.taxrate.TaxAgent;
import java.util.Collection;
@ -21,4 +22,12 @@ public interface TaxAgentService {
Collection<TaxAgent> findAll();
/**
* 根据id获取单个个税扣缴义务人
*
* @param id
* @return
*/
TaxAgent getById(Long id);
}

View File

@ -15,10 +15,7 @@ import com.engine.salary.enums.salaryaccounting.SalaryAcctRecordStatusEnum;
import com.engine.salary.enums.salarysob.IncomeCategoryEnum;
import com.engine.salary.exception.SalaryRunTimeException;
import com.engine.salary.mapper.salaryacct.SalaryAcctRecordMapper;
import com.engine.salary.service.SalaryAcctEmployeeService;
import com.engine.salary.service.SalaryAcctRecordService;
import com.engine.salary.service.SalaryAcctResultService;
import com.engine.salary.service.SalarySobService;
import com.engine.salary.service.*;
import com.engine.salary.util.SalaryDateUtil;
import com.engine.salary.util.SalaryEntityUtil;
import com.engine.salary.util.SalaryI18nUtil;
@ -64,6 +61,10 @@ public class SalaryAcctRecordServiceImpl extends Service implements SalaryAcctRe
return (SalaryAcctResultService) ServiceUtil.getService(SalaryAcctResultServiceImpl.class, user);
}
private SalarySendService getSalarySendService(User user) {
return ServiceUtil.getService(SalarySendServiceImpl.class, user);
}
// private SalaryCheckResultService salaryCheckResultService;
//
// private SalaryCheckResultDetailService salaryCheckResultDetailService;
@ -361,8 +362,8 @@ public class SalaryAcctRecordServiceImpl extends Service implements SalaryAcctRe
salaryAcctRecordPO.setStatus(SalaryAcctRecordStatusEnum.ARCHIVED.getValue());
salaryAcctRecordPO.setUpdateTime(new Date());
getSalaryAcctRecordMapper().updateIgnoreNull(salaryAcctRecordPO);
//todo 生成工资单
// salarySendService.generateSalaryBill(salaryAcctRecordId, employeeId, tenantKey);
// 生成工资单
getSalarySendService(user).generateSalaryBill(salaryAcctRecordId);
// 记录日志
// String targetName = getLogTargetNameById(salaryAcctRecordId);
// LoggerContext<SalaryAcctRecordPO> loggerContext = new LoggerContext<>();

View File

@ -11,6 +11,7 @@ import com.engine.salary.biz.SalarySendInfoBiz;
import com.engine.salary.biz.SalarySobBiz;
import com.engine.salary.constant.SalaryItemConstant;
import com.engine.salary.constant.SalaryTemplateSalaryItemSetGroupConstant;
import com.engine.salary.entity.datacollection.DataCollectionEmployee;
import com.engine.salary.entity.salaryBill.dto.*;
import com.engine.salary.entity.salaryBill.param.*;
import com.engine.salary.entity.salaryBill.po.SalarySendInfoPO;
@ -24,6 +25,7 @@ import com.engine.salary.entity.salaryarchive.po.TaxAgentPO;
import com.engine.salary.entity.salaryformula.dto.SalaryFormulaEmployeeDTO;
import com.engine.salary.entity.salarysob.dto.SalarySobCycleDTO;
import com.engine.salary.entity.salarysob.po.SalarySobPO;
import com.engine.salary.entity.taxrate.TaxAgent;
import com.engine.salary.enums.salaryaccounting.SalaryAcctRecordStatusEnum;
import com.engine.salary.enums.salarybill.SalarySendStatusEnum;
import com.engine.salary.exception.SalaryRunTimeException;
@ -31,13 +33,11 @@ import com.engine.salary.mapper.salaryacct.SalaryAcctEmployeeMapper;
import com.engine.salary.mapper.salaryacct.SalaryAcctRecordMapper;
import com.engine.salary.mapper.salaryacct.SalaryAcctResultMapper;
import com.engine.salary.mapper.salarybill.SalarySendMapper;
import com.engine.salary.service.SalaryAcctRecordService;
import com.engine.salary.service.SalarySendService;
import com.engine.salary.service.SalaryTemplateService;
import com.engine.salary.service.TaxAgentService;
import com.engine.salary.service.*;
import com.engine.salary.util.JsonUtil;
import com.engine.salary.util.SalaryDateUtil;
import com.engine.salary.util.SalaryI18nUtil;
import com.engine.salary.util.db.MapperProxyFactory;
import com.engine.salary.util.excel.ExcelUtil;
import com.engine.salary.util.page.PageInfo;
import dm.jdbc.util.IdGenerator;
@ -53,6 +53,7 @@ import weaver.hrm.User;
import javax.annotation.Resource;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.*;
@ -100,6 +101,10 @@ public class SalarySendServiceImpl extends Service implements SalarySendService
return ServiceUtil.getService(TaxAgentServiceImpl.class, user);
}
private SalaryEmployeeService getSalaryEmployeeService(User user) {
return ServiceUtil.getService(SalaryEmployeeServiceImpl.class, user);
}
// @RpcReference
// private FileDownloadClient fileDownloadClient;
// /**
@ -150,78 +155,76 @@ public class SalarySendServiceImpl extends Service implements SalarySendService
return salarySends.stream().map(SalarySendPO::getSalaryAccountingId).collect(Collectors.toList());
}
// @Override
// @Transactional(rollbackFor = Exception.class)
// public WeaResult<Boolean> generateSalaryBill(Long salaryAccountingId, Long currentEmployeeId, String currentTenantKey) {
// // 校验salaryAccountingId
// if (salaryAccountingId == null) {
// return WeaResult.fail(SalaryI18nUtil.getI18nLabel(currentTenantKey, currentEmployeeId, 100497, "核算id必传"));
// }
//
// List<SalaryAcctRecordPO> acctRecords = new LambdaQueryChainWrapper<>(salaryAcctRecordMapper)
// .eq(SalaryAcctRecordPO::getDeleteType, 0)
// .eq(SalaryAcctRecordPO::getTenantKey, currentTenantKey)
// .eq(SalaryAcctRecordPO::getId, salaryAccountingId)
// .eq(SalaryAcctRecordPO::getStatus, SalaryAcctRecordStatusEnum.ARCHIVED.getValue()).list();
// // 检查核算的归档记录
// if (CollectionUtils.isEmpty(acctRecords)) {
// return WeaResult.fail(SalaryI18nUtil.getI18nLabel(currentTenantKey, currentEmployeeId, 100498, "核算记录不存在"));
// }
//
// List<SalarySendPO> salarySends = new LambdaQueryChainWrapper<>(mapper)
// .eq(SalarySendPO::getDeleteType, 0)
// .eq(SalarySendPO::getTenantKey, currentTenantKey)
// .eq(SalarySendPO::getSalaryAccountingId, salaryAccountingId).list();
// if (CollectionUtils.isNotEmpty(salarySends)) {
// return WeaResult.fail(SalaryI18nUtil.getI18nLabel(currentTenantKey, currentEmployeeId, 100499, "工资单已生成过,不可再重复生成"));
// }
//
// List<SalaryAcctEmployeePO> salaryAcctEmployees = new LambdaQueryChainWrapper<>(salaryAcctEmployeeMapper)
// .eq(SalaryAcctEmployeePO::getDeleteType, 0)
// .eq(SalaryAcctEmployeePO::getTenantKey, currentTenantKey)
// .eq(SalaryAcctEmployeePO::getSalaryAcctRecordId, salaryAccountingId).list();
//
// Long salarySendId = IdGenerator.generate();
//
// SalaryAcctRecordPO salaryAcctRecord = acctRecords.get(0);
//
// List<SalarySendInfoPO> salarySendInfos = org.apache.commons.collections4.CollectionUtils.emptyIfNull(salaryAcctEmployees).stream().map(m ->
// SalarySendInfoPO.builder()
// .id(IdGenerator.generate())
// .salarySendId(salarySendId)
// .employeeId(m.getEmployeeId())
// .salaryMonth(m.getSalaryMonth())
// .taxAgentId(m.getTaxAgentId())
// .salaryAcctRecordId(m.getSalaryAcctRecordId())
// .sendStatus(SalarySendStatusEnum.UNSEND.getValue())
// .salaryTemplate("")
// .creator(currentEmployeeId)
// .createTime(LocalDateTime.now())
// .updateTime(LocalDateTime.now())
// .tenantKey(currentTenantKey)
// .build()
// ).collect(Collectors.toList());
//
// SalarySendPO salarySend = SalarySendPO.builder()
// .id(salarySendId)
// .salaryMonth(salaryAcctRecord.getSalaryMonth())
// .salaryAccountingId(salaryAccountingId)
// .salarySobId(salaryAcctRecord.getSalarySobId())
// .sendNum(0)
// .sendTotal(salarySendInfos.size())
// .lastSendTime(LocalDateTime.now())
// .creator(currentEmployeeId)
// .createTime(LocalDateTime.now())
// .updateTime(LocalDateTime.now())
// .tenantKey(currentTenantKey)
// .build();
// // 插入工资单发放记录
// mapper.insert(salarySend);
// // 插入工资单人员记录
// salarySendInfoMapper.batchInsert(salarySendInfos, currentTenantKey);
//
// return WeaResult.success(Boolean.TRUE);
// }
@Override
public String generateSalaryBill(Long salaryAccountingId) {
// 校验salaryAccountingId
if (salaryAccountingId == null) {
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100497, "核算id必传"));
}
SalaryAcctRecordPO recordPo = new SalaryAcctRecordPO();
recordPo.setDeleteType(0);
recordPo.setId(salaryAccountingId);
recordPo.setStatus(SalaryAcctRecordStatusEnum.ARCHIVED.getValue());
List<SalaryAcctRecordPO> acctRecords = getSalaryAcctRecordMapper().listSome(recordPo);
// 检查核算的归档记录
if (CollectionUtils.isEmpty(acctRecords)) {
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100498, "核算记录不存在"));
}
SalarySendPO sendPO = new SalarySendPO();
sendPO.setDeleteType(0);
sendPO.setSalaryAccountingId(salaryAccountingId);
List<SalarySendPO> salarySends = mapper.listSome(sendPO);
if (CollectionUtils.isNotEmpty(salarySends)) {
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100499, "工资单已生成过,不可再重复生成"));
}
SalaryAcctEmployeePO employeePO = new SalaryAcctEmployeePO();
employeePO.setDeleteType(0);
employeePO.setSalaryAcctRecordId(salaryAccountingId);
List<SalaryAcctEmployeePO> salaryAcctEmployees = getSalaryAcctEmployeeMapper().listSome(employeePO);
Long salarySendId = IdGenerator.generate();
SalaryAcctRecordPO salaryAcctRecord = acctRecords.get(0);
List<SalarySendInfoPO> salarySendInfos = salaryAcctEmployees.stream().map(m ->
SalarySendInfoPO.builder()
.id(IdGenerator.generate())
.salarySendId(salarySendId)
.employeeId(m.getEmployeeId())
.salaryMonth(m.getSalaryMonth())
.taxAgentId(m.getTaxAgentId())
.salaryAcctRecordId(m.getSalaryAcctRecordId())
.sendStatus(SalarySendStatusEnum.UNSEND.getValue())
.salaryTemplate("")
.creator((long) user.getUID())
.createTime(new Date())
.updateTime(new Date())
.build()
).collect(Collectors.toList());
SalarySendPO salarySend = SalarySendPO.builder()
.id(salarySendId)
.salaryMonth(salaryAcctRecord.getSalaryMonth())
.salaryAccountingId(salaryAccountingId)
.salarySobId(salaryAcctRecord.getSalarySobId())
.sendNum(0)
.sendTotal(salarySendInfos.size())
.lastSendTime(new Date())
.creator((long) user.getUID())
.createTime(new Date())
.updateTime(new Date())
.build();
// 插入工资单发放记录
mapper.insert(salarySend);
// 插入工资单人员记录
salarySendInfoMapper.batchInsert(salarySendInfos);
return "";
}
// @Override
// @Transactional(rollbackFor = Exception.class)
@ -350,51 +353,52 @@ public class SalarySendServiceImpl extends Service implements SalarySendService
// salaryTemplate.setBackground(encode);
// }
// 获取薪资项目数据
// List<Map<String, Object>> salaryAcctResultS = new LambdaQueryChainWrapper<>(salaryAcctResultMapper)
// .eq(SalaryAcctResultPO::getDeleteType, 0)
// .eq(SalaryAcctResultPO::getTenantKey, currentTenantKey)
// .eq(SalaryAcctResultPO::getSalaryAcctRecordId, salarySendInfo.getSalaryAcctRecordId())
// .eq(SalaryAcctResultPO::getEmployeeId, currentEmployeeId).list().stream().map(m -> {
// Map<String, Object> map = new LinkedHashMap<>();
// map.put("salaryItemId", m.getSalaryItemId());
// map.put("resultValue", m.getResultValue());
// return map;
// }).collect(Collectors.toList());
//
// Map<String, Object> map = new LinkedHashMap<>();
// map.put("tenantName", TenantContext.getCurrentTenant().getTenantName());
// map.put("sendTime", SalaryDateUtil.getFormatLocalDateTime(salarySendInfo.getSendTime()));
// List<SalaryTemplateSalaryItemSetListDTO> listDTOS = JSONArray.parseArray(salaryTemplate.getSalaryItemSetting(), SalaryTemplateSalaryItemSetListDTO.class);
// Optional<SalaryTemplateSalaryItemSetListDTO> optionalEmployeeInformation = listDTOS.stream().filter(e -> SalaryTemplateSalaryItemSetGroupConstant.EMPLOYEE_INFO_GROUP_ID.equals(e.getGroupId())).findFirst();
// SalaryTemplateSalaryItemSetListDTO employeeInformation = optionalEmployeeInformation.orElse(null);
// List<SalaryTemplateSalaryItemSetListDTO> itemSetListDTOS = listDTOS.stream().filter(e -> !SalaryTemplateSalaryItemSetGroupConstant.EMPLOYEE_INFO_GROUP_ID.equals(e.getGroupId())).collect(Collectors.toList());
// itemSetListDTOS.stream().forEach(item -> {
// item.getItems().stream()
// .forEach(e -> {
// if (CollectionUtils.isEmpty(salaryAcctResultS)) {
// e.setSalaryItemValue("");
// } else {
// Object o = salaryAcctResultS.stream()
// .filter(f -> f.get("salaryItemId") != null && String.valueOf(f.get("salaryItemId")).equals(e.getSalaryItemId())).findFirst()
// .orElse(new HashMap<>())
// .get("resultValue");
// e.setSalaryItemValue(o == null ? "" : (String) o);
// }
// });
// });
// TaxAgentPO byId = taxAgentService.getById(salarySendInfo.getTaxAgentId(), currentTenantKey);
// SimpleEmployee simpleEmployee = hrmCommonEmployeeService.getEmployeeById(salarySendInfo.getEmployeeId(), currentTenantKey);
// buildEmployeeInfo(employeeInformation, simpleEmployee, byId.getName(), SalaryAcctResultBO.buildEmployeeFieldName());
// map.put("employeeInformation", employeeInformation);
// map.put("salaryGroups", itemSetListDTOS);
//
// salaryTemplate.setTheme(getBillTitle(salaryTemplate.getTheme(), salaryMonth, TenantContext.getCurrentTenant().getTenantName(), currentEmployeeId, currentTenantKey));
// map.put("salaryTemplate", salaryTemplate);
// map.put("salaryAcctResult", salaryAcctResultS);
//
// return map;
return null;
// 获取薪资项目数据
SalaryAcctResultPO acctPo = new SalaryAcctResultPO();
acctPo.setDeleteType(0);
acctPo.setSalaryAcctRecordId(salarySendInfo.getSalaryAcctRecordId());
acctPo.setEmployeeId(currentEmployeeId);
List<Map<String, Object>> salaryAcctResultS = getSalaryAcctResultMapper().listSome(acctPo).stream().map(m -> {
Map<String, Object> map = new LinkedHashMap<>();
map.put("salaryItemId", m.getSalaryItemId());
map.put("resultValue", m.getResultValue());
return map;
}).collect(Collectors.toList());
Map<String, Object> map = new LinkedHashMap<>();
map.put("tenantName", "");
map.put("sendTime", SalaryDateUtil.getFormatLocalDateTime(salarySendInfo.getSendTime()));
List<SalaryTemplateSalaryItemSetListDTO> listDTOS = JSONArray.parseArray(salaryTemplate.getSalaryItemSetting(), SalaryTemplateSalaryItemSetListDTO.class);
Optional<SalaryTemplateSalaryItemSetListDTO> optionalEmployeeInformation = listDTOS.stream().filter(e -> SalaryTemplateSalaryItemSetGroupConstant.EMPLOYEE_INFO_GROUP_ID.equals(e.getGroupId())).findFirst();
SalaryTemplateSalaryItemSetListDTO employeeInformation = optionalEmployeeInformation.orElse(null);
List<SalaryTemplateSalaryItemSetListDTO> itemSetListDTOS = listDTOS.stream().filter(e -> !SalaryTemplateSalaryItemSetGroupConstant.EMPLOYEE_INFO_GROUP_ID.equals(e.getGroupId())).collect(Collectors.toList());
itemSetListDTOS.stream().forEach(item -> {
item.getItems().stream()
.forEach(e -> {
if (CollectionUtils.isEmpty(salaryAcctResultS)) {
e.setSalaryItemValue("");
} else {
Object o = salaryAcctResultS.stream()
.filter(f -> f.get("salaryItemId") != null && String.valueOf(f.get("salaryItemId")).equals(e.getSalaryItemId())).findFirst()
.orElse(new HashMap<>())
.get("resultValue");
e.setSalaryItemValue(o == null ? "" : (String) o);
}
});
});
TaxAgent byId = getTaxAgentService(user).getById(salarySendInfo.getTaxAgentId());
DataCollectionEmployee simpleEmployee = getSalaryEmployeeService(user).getEmployeeById(salarySendInfo.getEmployeeId());
buildEmployeeInfo(employeeInformation, simpleEmployee, byId.getName(), SalaryAcctResultBO.buildEmployeeFieldName());
map.put("employeeInformation", employeeInformation);
map.put("salaryGroups", itemSetListDTOS);
salaryTemplate.setTheme(getBillTitle(salaryTemplate.getTheme(), salaryMonth, currentEmployeeId));
map.put("salaryTemplate", salaryTemplate);
map.put("salaryAcctResult", salaryAcctResultS);
return map;
}
@Override
@ -422,17 +426,16 @@ public class SalarySendServiceImpl extends Service implements SalarySendService
* 获取工资单标题
* @param theme
* @param salaryMonth
* @param tenantName
* @param currentEmployeeId
* @param currentTenantKey
* @return
*/
private String getBillTitle(String theme, LocalDate salaryMonth, String tenantName, Long currentEmployeeId, String currentTenantKey) {
private String getBillTitle(String theme, Date salaryMonth, Long currentEmployeeId) {
String yearI18n = SalaryI18nUtil.getI18nLabel(100325, "");
String monthI18n = SalaryI18nUtil.getI18nLabel(100326, "");
return theme
.replace("${companyName}", tenantName)
.replace("${salaryMonth}", salaryMonth.getYear() + yearI18n + salaryMonth.getMonth().getValue() + monthI18n);
// TODO 设置租户名称
.replace("${companyName}", "")
.replace("${salaryMonth}", new SimpleDateFormat("yyyy年MM月").format(salaryMonth));
}
/**
@ -469,46 +472,46 @@ public class SalarySendServiceImpl extends Service implements SalarySendService
* @param taxAgentName
* @param employeeField
*/
// private void buildEmployeeInfo(SalaryTemplateSalaryItemSetListDTO employeeInformation, SimpleEmployee simpleEmployee, String taxAgentName, Map<String, String> employeeField) {
// if (employeeInformation == null) {
// return;
// }
// if (CollectionUtils.isNotEmpty(employeeInformation.getItems())) {
// //获取员工信息的字段名和中文描述的map关系
// SalaryFormulaEmployeeDTO salaryFormulaEmployeeDTO = SalaryFormulaEmployeeDTO.builder().employeeId(simpleEmployee.getEmployeeId())
// .birthday(SalaryDateUtil.getFormatLocalDate(simpleEmployee.getBirthdayDate()))
// .departmentName(simpleEmployee.getDepartment() == null ? "" : simpleEmployee.getDepartment().getName())
// .email(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(StringUtils.isEmpty(simpleEmployee.getMobile()) ? "" : simpleEmployee.getMobile())
// .positionName(simpleEmployee.getPosition() == null ? "" : simpleEmployee.getPosition().getName())
// .status(simpleEmployee.getStatus() == null ? "" : simpleEmployee.getStatus().getDescription())
// .telephone(StringUtils.isEmpty(simpleEmployee.getTelephone()) ? "" : simpleEmployee.getTelephone())
// .username(StringUtils.isEmpty(simpleEmployee.getUsername()) ? "" : simpleEmployee.getUsername())
// .taxAgentName(taxAgentName)
// .build();
// List<SalaryTemplateSalaryItemListDTO> items = employeeInformation.getItems();
// Set<Entry<String, String>> entries = employeeField.entrySet();
// for (SalaryTemplateSalaryItemListDTO e : items) {
// Optional<Entry<String, String>> entry = entries.stream().filter(f -> Objects.equals(e.getName(), f.getValue())).findFirst();
// if (entry.isPresent()) {
// String key = entry.get().getKey();
// if (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);
// }
// }
// }
// }
// }
// }
private void buildEmployeeInfo(SalaryTemplateSalaryItemSetListDTO employeeInformation, DataCollectionEmployee simpleEmployee, String taxAgentName, Map<String, String> employeeField) {
if (employeeInformation == null) {
return;
}
if (CollectionUtils.isNotEmpty(employeeInformation.getItems())) {
//获取员工信息的字段名和中文描述的map关系
SalaryFormulaEmployeeDTO salaryFormulaEmployeeDTO = SalaryFormulaEmployeeDTO.builder().employeeId(simpleEmployee.getEmployeeId())
.birthday(simpleEmployee.getBirthday())
.departmentName(simpleEmployee.getDepartmentName() )
.email(StringUtils.isEmpty(simpleEmployee.getEmail()) ? "" : simpleEmployee.getEmail())
.gradeName(simpleEmployee.getJobcall())
.hireDate(SalaryDateUtil.getFormatLocalDate(simpleEmployee.getCompanystartdate()))
.sex(simpleEmployee.getSex() == "0" ? "" : "")
.mobile(StringUtils.isEmpty(simpleEmployee.getMobile()) ? "" : simpleEmployee.getMobile())
.positionName(simpleEmployee.getJobtitleName())
.status(simpleEmployee.getStatus() == null ? "" : simpleEmployee.getStatus())
.telephone(StringUtils.isEmpty(simpleEmployee.getTelephone()) ? "" : simpleEmployee.getTelephone())
.username(StringUtils.isEmpty(simpleEmployee.getUsername()) ? "" : simpleEmployee.getUsername())
.taxAgentName(taxAgentName)
.build();
List<SalaryTemplateSalaryItemListDTO> items = employeeInformation.getItems();
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 (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);
}
}
}
}
}
}
/**
* 组装详情数据

View File

@ -134,4 +134,9 @@ public class TaxAgentServiceImpl extends Service implements TaxAgentService {
public Collection<TaxAgent> findAll() {
return new TaxAgentBiz().listAll();
}
@Override
public TaxAgent getById(Long id) {
return getTaxAgentMapper().getById(id);
}
}