From 38179daee9602cfcf61dd8a687df38c9ba4be999 Mon Sep 17 00:00:00 2001 From: MustangDeng <670124965@qq.com> Date: Thu, 21 Apr 2022 14:46:45 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E6=88=91=E7=9A=84=E5=B7=A5=E8=B5=84?= =?UTF-8?q?=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../salary/service/TaxAgentService.java | 9 + .../service/impl/SalarySendServiceImpl.java | 193 +++++++++--------- .../service/impl/TaxAgentServiceImpl.java | 12 ++ 3 files changed, 120 insertions(+), 94 deletions(-) diff --git a/src/com/engine/salary/service/TaxAgentService.java b/src/com/engine/salary/service/TaxAgentService.java index f32c49a52..a80fb2cb1 100644 --- a/src/com/engine/salary/service/TaxAgentService.java +++ b/src/com/engine/salary/service/TaxAgentService.java @@ -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 findAll(); + /** + * 根据id获取单个个税扣缴义务人 + * + * @param id + * @return + */ + TaxAgent getById(Long id); + } diff --git a/src/com/engine/salary/service/impl/SalarySendServiceImpl.java b/src/com/engine/salary/service/impl/SalarySendServiceImpl.java index 556484e73..bd9b185b2 100644 --- a/src/com/engine/salary/service/impl/SalarySendServiceImpl.java +++ b/src/com/engine/salary/service/impl/SalarySendServiceImpl.java @@ -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; // /** @@ -350,51 +355,52 @@ public class SalarySendServiceImpl extends Service implements SalarySendService // salaryTemplate.setBackground(encode); // } - // 获取薪资项目数据 -// List> 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 map = new LinkedHashMap<>(); -// map.put("salaryItemId", m.getSalaryItemId()); -// map.put("resultValue", m.getResultValue()); -// return map; -// }).collect(Collectors.toList()); -// -// Map map = new LinkedHashMap<>(); -// map.put("tenantName", TenantContext.getCurrentTenant().getTenantName()); -// map.put("sendTime", SalaryDateUtil.getFormatLocalDateTime(salarySendInfo.getSendTime())); -// List listDTOS = JSONArray.parseArray(salaryTemplate.getSalaryItemSetting(), SalaryTemplateSalaryItemSetListDTO.class); -// Optional optionalEmployeeInformation = listDTOS.stream().filter(e -> SalaryTemplateSalaryItemSetGroupConstant.EMPLOYEE_INFO_GROUP_ID.equals(e.getGroupId())).findFirst(); -// SalaryTemplateSalaryItemSetListDTO employeeInformation = optionalEmployeeInformation.orElse(null); -// List 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> salaryAcctResultS = getSalaryAcctResultMapper().listSome(acctPo).stream().map(m -> { + Map map = new LinkedHashMap<>(); + map.put("salaryItemId", m.getSalaryItemId()); + map.put("resultValue", m.getResultValue()); + return map; + }).collect(Collectors.toList()); + + Map map = new LinkedHashMap<>(); + map.put("tenantName", ""); + map.put("sendTime", SalaryDateUtil.getFormatLocalDateTime(salarySendInfo.getSendTime())); + List listDTOS = JSONArray.parseArray(salaryTemplate.getSalaryItemSetting(), SalaryTemplateSalaryItemSetListDTO.class); + Optional optionalEmployeeInformation = listDTOS.stream().filter(e -> SalaryTemplateSalaryItemSetGroupConstant.EMPLOYEE_INFO_GROUP_ID.equals(e.getGroupId())).findFirst(); + SalaryTemplateSalaryItemSetListDTO employeeInformation = optionalEmployeeInformation.orElse(null); + List 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 +428,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 +474,46 @@ public class SalarySendServiceImpl extends Service implements SalarySendService * @param taxAgentName * @param employeeField */ -// private void buildEmployeeInfo(SalaryTemplateSalaryItemSetListDTO employeeInformation, SimpleEmployee simpleEmployee, String taxAgentName, Map 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 items = employeeInformation.getItems(); -// Set> entries = employeeField.entrySet(); -// for (SalaryTemplateSalaryItemListDTO e : items) { -// Optional> 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 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 items = employeeInformation.getItems(); + Set> entries = employeeField.entrySet(); + for (SalaryTemplateSalaryItemListDTO e : items) { + Optional> 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); + } + } + } + } + } + } /** * 组装详情数据 diff --git a/src/com/engine/salary/service/impl/TaxAgentServiceImpl.java b/src/com/engine/salary/service/impl/TaxAgentServiceImpl.java index 7ac809592..9ae70b9cd 100644 --- a/src/com/engine/salary/service/impl/TaxAgentServiceImpl.java +++ b/src/com/engine/salary/service/impl/TaxAgentServiceImpl.java @@ -3,14 +3,21 @@ package com.engine.salary.service.impl; import com.engine.core.impl.Service; import com.engine.salary.biz.TaxAgentBiz; import com.engine.salary.cmd.TaxAgent.*; +import com.engine.salary.entity.salaryarchive.po.TaxAgentPO; import com.engine.salary.entity.taxrate.TaxAgent; +import com.engine.salary.mapper.TaxAgentMapper; +import com.engine.salary.mapper.salaryacct.SalaryAcctResultMapper; import com.engine.salary.service.TaxAgentService; +import com.engine.salary.util.db.MapperProxyFactory; import java.util.Collection; import java.util.Map; public class TaxAgentServiceImpl extends Service implements TaxAgentService { + private TaxAgentMapper getTaxAgentMapper(){ + return MapperProxyFactory.getProxy(TaxAgentMapper.class); + } @Override public Map list(Map params) { return commandExecutor.execute(new TaxAgentListCmd(params,user)); @@ -45,4 +52,9 @@ public class TaxAgentServiceImpl extends Service implements TaxAgentService { public Collection findAll() { return new TaxAgentBiz().listAll(); } + + @Override + public TaxAgent getById(Long id) { + return getTaxAgentMapper().getById(id); + } } From 3003d0fadbc87e7a5886c485a2e84e08caee4963 Mon Sep 17 00:00:00 2001 From: MustangDeng <670124965@qq.com> Date: Thu, 21 Apr 2022 16:45:03 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E7=94=9F=E6=88=90=E5=B7=A5=E8=B5=84?= =?UTF-8?q?=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/com/engine/salary/biz/SalarySendBiz.java | 10 ++ .../engine/salary/biz/SalarySendInfoBiz.java | 11 ++ .../salarybill/SalarySendInfoMapper.java | 3 +- .../mapper/salarybill/SalarySendMapper.java | 2 + .../mapper/salarybill/SalarySendMapper.xml | 94 +++++++++++- .../salary/service/SalarySendService.java | 3 +- .../impl/SalaryAcctRecordServiceImpl.java | 13 +- .../service/impl/SalarySendServiceImpl.java | 142 +++++++++--------- 8 files changed, 193 insertions(+), 85 deletions(-) diff --git a/src/com/engine/salary/biz/SalarySendBiz.java b/src/com/engine/salary/biz/SalarySendBiz.java index 312b8b1df..0b6219985 100644 --- a/src/com/engine/salary/biz/SalarySendBiz.java +++ b/src/com/engine/salary/biz/SalarySendBiz.java @@ -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(); + } + } } diff --git a/src/com/engine/salary/biz/SalarySendInfoBiz.java b/src/com/engine/salary/biz/SalarySendInfoBiz.java index 43b342efa..2b036c1db 100644 --- a/src/com/engine/salary/biz/SalarySendInfoBiz.java +++ b/src/com/engine/salary/biz/SalarySendInfoBiz.java @@ -104,4 +104,15 @@ public class SalarySendInfoBiz { sqlSession.close(); } } + + public void batchInsert(List salarySendInfos) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + SalarySendInfoMapper mapper = sqlSession.getMapper(SalarySendInfoMapper.class); + mapper.batchInsert(salarySendInfos); + sqlSession.commit(); + } finally { + sqlSession.close(); + } + } } diff --git a/src/com/engine/salary/mapper/salarybill/SalarySendInfoMapper.java b/src/com/engine/salary/mapper/salarybill/SalarySendInfoMapper.java index 2bea5e956..7712cc391 100644 --- a/src/com/engine/salary/mapper/salarybill/SalarySendInfoMapper.java +++ b/src/com/engine/salary/mapper/salarybill/SalarySendInfoMapper.java @@ -64,9 +64,8 @@ public interface SalarySendInfoMapper { /** * 批量插入工资单信息记录 * @param pos - * @param currentTenantKey */ - void batchInsert(@Param("collection") List pos, String currentTenantKey); + void batchInsert(@Param("collection") List pos); /** * 发放、撤回工资单 diff --git a/src/com/engine/salary/mapper/salarybill/SalarySendMapper.java b/src/com/engine/salary/mapper/salarybill/SalarySendMapper.java index 6c02fd968..4abfaa448 100644 --- a/src/com/engine/salary/mapper/salarybill/SalarySendMapper.java +++ b/src/com/engine/salary/mapper/salarybill/SalarySendMapper.java @@ -55,4 +55,6 @@ public interface SalarySendMapper { * @return */ List listSome(SalarySendPO params); + + void insertIgnoreNull(SalarySendPO salarySend); } \ No newline at end of file diff --git a/src/com/engine/salary/mapper/salarybill/SalarySendMapper.xml b/src/com/engine/salary/mapper/salarybill/SalarySendMapper.xml index 55b2fa99e..2ae345cea 100644 --- a/src/com/engine/salary/mapper/salarybill/SalarySendMapper.xml +++ b/src/com/engine/salary/mapper/salarybill/SalarySendMapper.xml @@ -164,9 +164,9 @@ AND salary_accounting_id = #{salaryAccountingId} - - AND salary_acct_record_id = #{salaryAcctRecordId} - + + + AND salary_sob_id = #{salarySobId} @@ -198,5 +198,93 @@ + + + INSERT INTO hrsa_salary_send + + + id, + + + salary_month, + + + salary_accounting_id, + + + salary_sob_id, + + + send_num, + + + send_total, + + + last_send_time, + + + creator, + + + create_time, + + + update_time, + + + delete_type, + + + tenant_key, + + + + + + #{id}, + + + #{salaryMonth}, + + + #{salaryAccountingId}, + + + #{salarySobId}, + + + #{sendNum}, + + + #{sendTotal}, + + + #{lastSendTime}, + + + #{creator}, + + + #{createTime}, + + + #{updateTime}, + + + #{deleteType}, + + + #{tenantKey}, + + + + + + + + \ No newline at end of file diff --git a/src/com/engine/salary/service/SalarySendService.java b/src/com/engine/salary/service/SalarySendService.java index a91e65e1f..a2529c00e 100644 --- a/src/com/engine/salary/service/SalarySendService.java +++ b/src/com/engine/salary/service/SalarySendService.java @@ -28,10 +28,9 @@ public interface SalarySendService { /** * 薪资核算-归档生成工资单 * @param salaryAccountingId - * @param currentTenantKey * @return */ -// Map generateSalaryBill(Long salaryAccountingId, Long currentEmployeeId, String currentTenantKey); + String generateSalaryBill(Long salaryAccountingId); /** * 薪资核算-归档撤销工资单 diff --git a/src/com/engine/salary/service/impl/SalaryAcctRecordServiceImpl.java b/src/com/engine/salary/service/impl/SalaryAcctRecordServiceImpl.java index 884d2adff..7f3bd99f9 100644 --- a/src/com/engine/salary/service/impl/SalaryAcctRecordServiceImpl.java +++ b/src/com/engine/salary/service/impl/SalaryAcctRecordServiceImpl.java @@ -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 loggerContext = new LoggerContext<>(); diff --git a/src/com/engine/salary/service/impl/SalarySendServiceImpl.java b/src/com/engine/salary/service/impl/SalarySendServiceImpl.java index bd9b185b2..f420efab6 100644 --- a/src/com/engine/salary/service/impl/SalarySendServiceImpl.java +++ b/src/com/engine/salary/service/impl/SalarySendServiceImpl.java @@ -155,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 generateSalaryBill(Long salaryAccountingId, Long currentEmployeeId, String currentTenantKey) { -// // 校验salaryAccountingId -// if (salaryAccountingId == null) { -// return WeaResult.fail(SalaryI18nUtil.getI18nLabel(currentTenantKey, currentEmployeeId, 100497, "核算id必传")); -// } -// -// List 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 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 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 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 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 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 salaryAcctEmployees = getSalaryAcctEmployeeMapper().listSome(employeePO); + + Long salarySendId = IdGenerator.generate(); + + SalaryAcctRecordPO salaryAcctRecord = acctRecords.get(0); + + List 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)