diff --git a/src/com/customization/salary/CustomSalaryAcctRecordWrapper.java b/src/com/customization/salary/CustomSalaryAcctRecordWrapper.java new file mode 100644 index 000000000..1def59641 --- /dev/null +++ b/src/com/customization/salary/CustomSalaryAcctRecordWrapper.java @@ -0,0 +1,58 @@ +package com.customization.salary; + + +import com.engine.core.cfg.annotation.ServiceDynamicProxy; +import com.engine.core.cfg.annotation.ServiceMethodDynamicProxy; +import com.engine.core.impl.aop.AbstractServiceProxy; +import com.engine.salary.entity.salaryacct.dto.SalaryAcctRecordListDTO; +import com.engine.salary.entity.salaryacct.param.SalaryAcctRecordQueryParam; +import com.engine.salary.entity.salaryacct.param.SalaryAcctRecordSaveParam; +import com.engine.salary.util.page.PageInfo; +import com.engine.salary.wrapper.SalaryAcctRecordWrapper; +import com.engine.salary.wrapper.proxy.SalaryAcctRecordWrapperProxy; +import weaver.general.BaseBean; + +import java.util.Collection; +import java.util.Map; + + +@ServiceDynamicProxy(target = SalaryAcctRecordWrapper.class, desc = "薪资核算") +public class CustomSalaryAcctRecordWrapper extends AbstractServiceProxy implements SalaryAcctRecordWrapperProxy { + + @Override + public PageInfo listPage(SalaryAcctRecordQueryParam queryParam) { + return null; + } + + @Override + public Map getForm(Long id) { + return null; + } + + @Override + public Long save(SalaryAcctRecordSaveParam saveParam) { + return null; + } + + @Override + public void delete(Collection ids) { + } + + @Override + public void file(Long id) { + } + + @Override + @ServiceMethodDynamicProxy(desc = "重新核算前,验证....") + public void reCalculate(Long id) { + + BaseBean baseBean = new BaseBean(); + baseBean.writeLog("拦截薪酬重新核算方法..."); + + //todo do some thing + + executeMethod(id); + + //todo do some thing + } +} \ No newline at end of file diff --git a/src/com/customization/salary/CustomSalarySend.java b/src/com/customization/salary/CustomSalarySend.java deleted file mode 100644 index d9ec73ad7..000000000 --- a/src/com/customization/salary/CustomSalarySend.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.customization.salary; - -import com.engine.core.cfg.annotation.ServiceDynamicProxy; -import com.engine.core.impl.aop.AbstractServiceProxy; -import com.engine.salary.entity.salaryBill.param.SalarySendGrantParam; -import com.engine.salary.entity.salaryBill.param.SalarySendWithdrawParam; -import com.engine.salary.wrapper.SalarySendWrapper; -import com.engine.salary.wrapper.proxy.SalarySendWrapperProxy; -import weaver.general.BaseBean; - -import java.util.Map; - -@ServiceDynamicProxy(target = SalarySendWrapper.class, desc = "薪资核算") -public class CustomSalarySend extends AbstractServiceProxy implements SalarySendWrapperProxy { - @Override - public void grant(SalarySendGrantParam queryParam) { - BaseBean baseBean = new BaseBean(); - baseBean.writeLog("拦截工资单发送方法..."); - - //todo do some thing - - Object o = executeMethod(queryParam); - - //todo do some thing - } - - @Override - public Map withdraw(SalarySendWithdrawParam queryParam) { - return null; - } -} diff --git a/src/com/customization/salary/CustomSalarySendWrapper.java b/src/com/customization/salary/CustomSalarySendWrapper.java new file mode 100644 index 000000000..0f35ad8e1 --- /dev/null +++ b/src/com/customization/salary/CustomSalarySendWrapper.java @@ -0,0 +1,45 @@ +package com.customization.salary; + +import com.engine.common.util.ServiceUtil; +import com.engine.core.cfg.annotation.ServiceDynamicProxy; +import com.engine.core.cfg.annotation.ServiceMethodDynamicProxy; +import com.engine.core.impl.aop.AbstractServiceProxy; +import com.engine.salary.entity.salaryBill.param.SalarySendGrantParam; +import com.engine.salary.entity.salaryBill.param.SalarySendWithdrawParam; +import com.engine.salary.service.SalaryBillService; +import com.engine.salary.service.impl.SalaryBillServiceImpl; +import com.engine.salary.wrapper.SalarySendWrapper; +import com.engine.salary.wrapper.proxy.SalarySendWrapperProxy; +import weaver.hrm.User; + +import java.util.List; +import java.util.Map; + +@ServiceDynamicProxy(target = SalarySendWrapper.class, desc = "工资单发送") +public class CustomSalarySendWrapper extends AbstractServiceProxy implements SalarySendWrapperProxy { + + private SalaryBillService getSalaryBillService(User user) { + return ServiceUtil.getService(SalaryBillServiceImpl.class, user); + } + + @Override + @ServiceMethodDynamicProxy(desc = "拦截工资单发送方法") + public void grant(SalarySendGrantParam queryParam) { + Long salarySendId = queryParam.getSalarySendId(); + List ids = queryParam.getIds(); + List> sendInfoList = getSalaryBillService(new User()).getSendInfoList(salarySendId, ids); + //解析sendInfoList,拼接短信内容 + System.out.println("发送短信"); + + //todo do some thing + + executeMethod(queryParam); + + //todo do some thing + } + + @Override + public Map withdraw(SalarySendWithdrawParam queryParam) { + return null; + } +} diff --git a/src/com/engine/salary/service/SalaryBillService.java b/src/com/engine/salary/service/SalaryBillService.java index 00caeb1ee..a39bbd53d 100644 --- a/src/com/engine/salary/service/SalaryBillService.java +++ b/src/com/engine/salary/service/SalaryBillService.java @@ -2,11 +2,17 @@ package com.engine.salary.service; import com.engine.salary.entity.salaryBill.param.SalarySendGrantParam; +import java.util.List; +import java.util.Map; + /** - * @Description: 工资单 - * @Author: wangxiangzhong - * @Date: 2021-12-11 11:28 - */ + * 工资单 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ public interface SalaryBillService { /** @@ -16,6 +22,14 @@ public interface SalaryBillService { */ void grant(SalarySendGrantParam queryParam); + /** + * 获取内容 + * @param sendId + * @param ids + * @return + */ + List> getSendInfoList(Long sendId, List ids); + /** * 工资单撤回 * diff --git a/src/com/engine/salary/service/impl/SalaryBillServiceImpl.java b/src/com/engine/salary/service/impl/SalaryBillServiceImpl.java index a21cfad46..9d5ceaef2 100644 --- a/src/com/engine/salary/service/impl/SalaryBillServiceImpl.java +++ b/src/com/engine/salary/service/impl/SalaryBillServiceImpl.java @@ -402,6 +402,54 @@ public class SalaryBillServiceImpl extends Service implements SalaryBillService .buildDetailList(list, salaryAcctEmployees, salaryAcctResultValues); } + public List> getSendInfoList(Long sendId, List ids) { + + SalarySendPO salarySend = getSalarySendMapper().getById(sendId); + SalarySendInfoQueryParam queryParam = new SalarySendInfoQueryParam(); + queryParam.setSalarySendId(salarySend.getId()); +// // 空就是所有 +// queryParam.setIds(ids); + queryParam.setSendStatuss(Arrays.asList(SalarySendStatusEnum.UNSEND.getValue(), SalarySendStatusEnum.WITHDRAW.getValue())); + // 2.获取基本数据 + List list = Lists.newArrayList(); + if (CollectionUtils.isEmpty(ids)) { + list = getSalarySendInfoMapper().list(queryParam); + } else { + List> partition = Lists.partition(ids, 500); + for (List idsPart : partition) { + queryParam.setIds(idsPart); + list.addAll(getSalarySendInfoMapper().list(queryParam)); + } + } + List salaryAcctEmployeeList = this.getSalaryAcctEmployeeService(user).listBySalaryAcctRecordId(salarySend.getSalaryAccountingId()); + List acctEmployeeIds = salaryAcctEmployeeList.stream().map(SalaryAcctEmployeePO::getEmployeeId).distinct().collect(Collectors.toList()); + list = list.stream().filter(f -> acctEmployeeIds.contains(f.getEmployeeId())).collect(Collectors.toList()); + + List employeeIds = list.stream().map(SalarySendInfoListDTO::getEmployeeId).collect(Collectors.toList()); + + // 3.组装详情数据 + // 获取薪资项目数据 + List salaryAcctEmployees = Lists.newArrayList(); + List salaryAcctResultValues = Lists.newArrayList(); + + //是否需要发送邮件 + if (CollectionUtils.isNotEmpty(ids)) { + int partSize = 100;// 分片大小,越小进度条跑得越短平快,但是总体速度更慢 + List> partition = Lists.partition(employeeIds, partSize); + for (List part : partition) { + // 更新进度 + List acctEmployees = getSalaryAcctEmployeeService(user).listBySalaryAcctRecordIdsAndEmployeeIds(Collections.singletonList(salarySend.getSalaryAccountingId()), part); + salaryAcctEmployees.addAll(acctEmployees); + salaryAcctResultValues.addAll(getSalaryAcctResultService(user).listBySalaryAcctEmployeeIds(SalaryEntityUtil.properties(acctEmployees, SalaryAcctEmployeePO::getId, Collectors.toList()))); + } + } else { + salaryAcctEmployees = getSalaryAcctEmployeeService(user).listBySalaryAcctRecordId(salarySend.getSalaryAccountingId()); + salaryAcctResultValues = getSalaryAcctResultService(user).listBySalaryAcctRecordIds(Collections.singletonList(salarySend.getSalaryAccountingId())); + } + return getSalarySendService(user) + .buildDetailList(list, salaryAcctEmployees, salaryAcctResultValues); + } + /** * 发送消息 * diff --git a/src/com/engine/salary/service/impl/SalarySendServiceImpl.java b/src/com/engine/salary/service/impl/SalarySendServiceImpl.java index a4e6d24fe..46c7cdd0b 100644 --- a/src/com/engine/salary/service/impl/SalarySendServiceImpl.java +++ b/src/com/engine/salary/service/impl/SalarySendServiceImpl.java @@ -800,9 +800,9 @@ public class SalarySendServiceImpl extends Service implements SalarySendService return listMaps; } // 所有个税扣缴义务人 - Map taxAgentMap = SalaryEntityUtil.convert2Map(getTaxAgentService(user).listAll(), TaxAgentPO::getId, TaxAgentPO::getName); +// Map taxAgentMap = SalaryEntityUtil.convert2Map(getTaxAgentService(user).listAll(), TaxAgentPO::getId, TaxAgentPO::getName); // 按人员分组核算数据 - Map> relationSalaryAcctEmployeeMap = SalaryEntityUtil.group2Map(salaryAcctEmployees, SalaryAcctEmployeePO::getEmployeeId); +// Map> relationSalaryAcctEmployeeMap = SalaryEntityUtil.group2Map(salaryAcctEmployees, SalaryAcctEmployeePO::getEmployeeId); Map salaryAcctEmployeeMap = SalaryEntityUtil.convert2Map(salaryAcctEmployees, salaryAcctEmployee -> salaryAcctEmployee.getEmployeeId() + "-" + salaryAcctEmployee.getTaxAgentId()); Map> singleEmpAcctMap = SalaryEntityUtil.group2Map(salaryAcctResultValues, SalaryAcctResultPO::getSalaryAcctEmpId); List employeeIds = list.stream().map(SalarySendInfoListDTO::getEmployeeId).distinct().collect(Collectors.toList());