diff --git a/src/com/customization/salary/CustomSalarySend.java b/src/com/customization/salary/CustomSalarySend.java new file mode 100644 index 000000000..4570f5d9c --- /dev/null +++ b/src/com/customization/salary/CustomSalarySend.java @@ -0,0 +1,32 @@ +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 Map grant(SalarySendGrantParam queryParam) { + BaseBean baseBean = new BaseBean(); + baseBean.writeLog("拦截工资单发送方法..."); + + //todo do some thing + + Object o = executeMethod(queryParam); + + //todo do some thing + return (Map)o; + } + + @Override + public Map withdraw(SalarySendWithdrawParam queryParam) { + return null; + } +} diff --git a/src/com/engine/salary/entity/salaryBill/bo/SalaryBillBO.java b/src/com/engine/salary/entity/salaryBill/bo/SalaryBillBO.java index d71419ae8..553f67d16 100644 --- a/src/com/engine/salary/entity/salaryBill/bo/SalaryBillBO.java +++ b/src/com/engine/salary/entity/salaryBill/bo/SalaryBillBO.java @@ -7,7 +7,9 @@ import com.engine.salary.entity.datacollection.DataCollectionEmployee; import com.engine.salary.entity.salaryBill.dto.SalaryBillSendDTO; import com.engine.salary.entity.salaryBill.dto.SalaryTemplateSalaryItemListDTO; import com.engine.salary.entity.salaryBill.dto.SalaryTemplateSalaryItemSetListDTO; +import com.engine.salary.entity.salaryBill.po.SalaryTemplatePO; import com.engine.salary.entity.salaryformula.dto.SalaryFormulaEmployeeDTO; +import com.engine.salary.enums.salarybill.MessageChannelEnum; import com.engine.salary.enums.salarybill.SalaryTemplateTextContentPositionEnum; import com.engine.salary.enums.salarybill.SalaryTemplateWhetherEnum; import com.engine.salary.util.SalaryDateUtil; @@ -94,18 +96,20 @@ public class SalaryBillBO { /** * 构建工资单中的人员信息 * - * @param employeeInformation * @param simpleEmployee - * @param employeeField */ - public static void buildEmployeeInfo(SalaryTemplateSalaryItemSetListDTO employeeInformation, DataCollectionEmployee simpleEmployee, Map employeeField) { + public static void buildEmployeeInfo(SalaryBillSendDTO salaryBillSendParam, DataCollectionEmployee simpleEmployee) { + + SalaryTemplateSalaryItemSetListDTO employeeInformation = salaryBillSendParam.getEmployeeInformation(); + Map employeeField = salaryBillSendParam.getEmployeeField(); + 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") + .taxAgentName(salaryBillSendParam.getTaxAgentName()) .departmentName(simpleEmployee.getDepartmentName()) .email(org.apache.commons.lang3.StringUtils.isEmpty(simpleEmployee.getEmail()) ? "" : simpleEmployee.getEmail()) // .gradeName(simpleEmployee.getGrade() == null ? "" : simpleEmployee.getGrade().getName()) @@ -200,7 +204,7 @@ public class SalaryBillBO { // 消息接收者 String receivers = Optional.ofNullable(e.get("email")).orElse("").toString(); String emailContent = SalaryBillBO.buildEmailContent(e, salaryBillSendParam); - MessageUtil.sendEmail(receivers,salaryBillSendParam.getText(),emailContent); + MessageUtil.sendEmail(receivers, salaryBillSendParam.getText(), emailContent); } // /** @@ -251,26 +255,26 @@ public class SalaryBillBO { // } // return user; // } -// -// /** -// * 构建发送通道 -// * -// * @param salaryTemplate -// * @return -// */ -// public static Set buildSendChannels(SalaryTemplatePO salaryTemplate) { -// Set channels = new HashSet<>(); -// if (salaryTemplate.getEmailStatus() != null && salaryTemplate.getEmailStatus().equals(SalaryTemplateWhetherEnum.TRUE.getValue())) { -// channels.add(MessageChannelEnum.EMAIL); -// } -// if (salaryTemplate.getImStatus() != null && salaryTemplate.getImStatus().equals(SalaryTemplateWhetherEnum.TRUE.getValue())) { -// channels.add(MessageChannelEnum.IM); -// } -// if (salaryTemplate.getCloudBridgeStatus() != null && salaryTemplate.getCloudBridgeStatus().equals(SalaryTemplateWhetherEnum.TRUE.getValue())) { -// channels.add(MessageChannelEnum.CLOUD_BRIDGE); -// } -// return channels; -// } + + /** + * 构建发送通道 + * + * @param salaryTemplate + * @return + */ + public static Set buildSendChannels(SalaryTemplatePO salaryTemplate) { + Set channels = new HashSet<>(); + if (salaryTemplate.getMsgStatus() == null || salaryTemplate.getMsgStatus().equals(SalaryTemplateWhetherEnum.TRUE.getValue())) { + channels.add(MessageChannelEnum.MSG); + } + if (salaryTemplate.getEmailStatus() != null && salaryTemplate.getEmailStatus().equals(SalaryTemplateWhetherEnum.TRUE.getValue()) && MessageUtil.checkSendEmail()) { + channels.add(MessageChannelEnum.EMAIL); + } + if (salaryTemplate.getSmsStatus() != null && salaryTemplate.getSmsStatus().equals(SalaryTemplateWhetherEnum.TRUE.getValue()) && MessageUtil.checkSendSMS()) { + channels.add(MessageChannelEnum.SMS); + } + return channels; + } // // /** // * 构建实体 diff --git a/src/com/engine/salary/entity/salaryBill/dto/SalaryBillSendDTO.java b/src/com/engine/salary/entity/salaryBill/dto/SalaryBillSendDTO.java index 39403fb18..6e246f13d 100644 --- a/src/com/engine/salary/entity/salaryBill/dto/SalaryBillSendDTO.java +++ b/src/com/engine/salary/entity/salaryBill/dto/SalaryBillSendDTO.java @@ -2,6 +2,7 @@ package com.engine.salary.entity.salaryBill.dto; import com.engine.salary.entity.salaryBill.po.SalarySendPO; import com.engine.salary.entity.salaryBill.po.SalaryTemplatePO; +import com.engine.salary.enums.salarybill.MessageChannelEnum; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.AllArgsConstructor; @@ -36,7 +37,7 @@ public class SalaryBillSendDTO { private String entityName; @ApiModelProperty("发送通道") - private Set sendChannels; + private Set sendChannels; @ApiModelProperty("发送者") private User sendUser; @@ -50,8 +51,8 @@ public class SalaryBillSendDTO { @ApiModelProperty("云桥工资单消息图") private String picUrl; - @ApiModelProperty("租户名") - private String tenantName; + @ApiModelProperty("扣缴义务人名称") + private String taxAgentName; @ApiModelProperty("工资单模板-薪资项目设置") private List salaryItemSetList; diff --git a/src/com/engine/salary/entity/salaryBill/po/SalaryTemplatePO.java b/src/com/engine/salary/entity/salaryBill/po/SalaryTemplatePO.java index de19e6af6..2cfa80624 100644 --- a/src/com/engine/salary/entity/salaryBill/po/SalaryTemplatePO.java +++ b/src/com/engine/salary/entity/salaryBill/po/SalaryTemplatePO.java @@ -47,19 +47,26 @@ public class SalaryTemplatePO { private String description; /** - * 邮箱开启状态。0:关、1:开 + * 消息中心开启状态。0:关、1:开 ,默认开启 + */ + private Integer msgStatus; + + /** + * 邮箱开启状态。0:关、1:开,默认关闭 */ private Integer emailStatus; + /** * 发送地址:公共邮箱账号id */ private Long sendEmailId; + /** - * 消息中心开启状态。0:关、1:开 + * 短信开启状态。0:关、1:开,默认关闭 */ - private Integer msgStatus; + private Integer smsStatus; /** * 主题 diff --git a/src/com/engine/salary/enums/salarybill/MessageChannelEnum.java b/src/com/engine/salary/enums/salarybill/MessageChannelEnum.java new file mode 100644 index 000000000..164d0e168 --- /dev/null +++ b/src/com/engine/salary/enums/salarybill/MessageChannelEnum.java @@ -0,0 +1,73 @@ +package com.engine.salary.enums.salarybill; + +import com.engine.salary.enums.BaseEnum; + +import java.util.Arrays; + +/** + * 消息通道 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public enum MessageChannelEnum implements BaseEnum { + + MSG(0, "系统消息", 93212), + EMAIL(1, "邮件", 93286), + SMS(2, "短信", 93287); + + private int value; + + private String defaultLabel; + + private int labelId; + + MessageChannelEnum(int value, String defaultLabel, int labelId) { + this.value = value; + this.defaultLabel = defaultLabel; + this.labelId = labelId; + } + + @Override + public Integer getValue() { + return value; + } + + @Override + public String getDefaultLabel() { + return defaultLabel; + } + + @Override + public Integer getLabelId() { + return labelId; + } + + public static String getDefaultLabelByValue(Integer value) { + if (value == null) { + return ""; + } + MessageChannelEnum[] enumAry = MessageChannelEnum.values(); + for(int i = 0; i < Arrays.asList(enumAry).size(); i++){ + if (Integer.valueOf(enumAry[i].getValue()).equals(value)) { + return enumAry[i].getDefaultLabel(); + } + } + return ""; + } + + public static String getNameByValue(Integer value) { + if (value == null) { + return ""; + } + MessageChannelEnum[] enumAry = MessageChannelEnum.values(); + for(int i = 0; i < Arrays.asList(enumAry).size(); i++){ + if (Integer.valueOf(enumAry[i].getValue()).equals(value)) { + return enumAry[i].name(); + } + } + return ""; + } +} diff --git a/src/com/engine/salary/mapper/salarybill/SalaryTemplateMapper.xml b/src/com/engine/salary/mapper/salarybill/SalaryTemplateMapper.xml index 0c103ca79..580cdc5b8 100644 --- a/src/com/engine/salary/mapper/salarybill/SalaryTemplateMapper.xml +++ b/src/com/engine/salary/mapper/salarybill/SalaryTemplateMapper.xml @@ -9,6 +9,7 @@ + @@ -37,6 +38,7 @@ , t.use_type , t.description , t.email_status + , t.sms_status , t.send_email_id , t.msg_status , t.theme @@ -61,6 +63,7 @@ use_type, description, email_status, + sms_status, send_email_id, msg_status, theme, @@ -352,6 +355,9 @@ email_status=#{emailStatus}, + + sms_status=#{smsStatus}, + send_email_id=#{sendEmailId}, @@ -433,6 +439,9 @@ msg_status, + + sms_status, + theme, @@ -504,6 +513,9 @@ #{msgStatus}, + + #{smsStatus}, + #{theme}, @@ -585,6 +597,9 @@ msg_status, + + sms_status, + theme, @@ -656,6 +671,9 @@ #{msgStatus}, + + #{smsStatus}, + #{theme}, diff --git a/src/com/engine/salary/service/impl/SalaryBillServiceImpl.java b/src/com/engine/salary/service/impl/SalaryBillServiceImpl.java index cfce8e6a3..f87cef9e8 100644 --- a/src/com/engine/salary/service/impl/SalaryBillServiceImpl.java +++ b/src/com/engine/salary/service/impl/SalaryBillServiceImpl.java @@ -18,8 +18,9 @@ import com.engine.salary.entity.salaryBill.po.SalaryTemplatePO; import com.engine.salary.entity.salaryacct.po.SalaryAcctEmployeePO; import com.engine.salary.entity.salaryacct.po.SalaryAcctResultPO; import com.engine.salary.entity.salarysob.po.SalarySobPO; +import com.engine.salary.entity.taxagent.po.TaxAgentPO; +import com.engine.salary.enums.salarybill.MessageChannelEnum; import com.engine.salary.enums.salarybill.SalarySendStatusEnum; -import com.engine.salary.enums.salarybill.SalaryTemplateWhetherEnum; import com.engine.salary.exception.SalaryRunTimeException; import com.engine.salary.mapper.salarybill.SalarySendInfoMapper; import com.engine.salary.mapper.salarybill.SalarySendMapper; @@ -34,7 +35,6 @@ import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.math.NumberUtils; -import weaver.common.MessageUtil; import weaver.hrm.User; import java.time.LocalDateTime; @@ -122,15 +122,16 @@ public class SalaryBillServiceImpl extends Service implements SalaryBillService throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100518, "没有默认模板,无法发送")); } SalaryTemplatePO salaryTemplate = salaryTemplates.get(0); + // 发送通道 -// Set sendChannels = SalaryBillBO.buildSendChannels(salaryTemplate); -// if (CollectionUtils.isEmpty(sendChannels)) { -// throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(149767, "工资单模板至少开启一个发送通道")); -// } -// boolean isReplenish = NumberUtils.INTEGER_ONE.equals(salarySend.getSalaryAcctType()); -// if (isReplenish && StringUtils.isEmpty(salaryTemplate.getReplTheme())) { -// throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(204428, "请完善补发工资单模板设置")); -// } + Set sendChannels = SalaryBillBO.buildSendChannels(salaryTemplate); + if (CollectionUtils.isEmpty(sendChannels)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(149767, "工资单模板至少开启一个发送通道")); + } + boolean isReplenish = NumberUtils.INTEGER_ONE.equals(salarySend.getSalaryAcctType()); + if (isReplenish && StringUtils.isEmpty(salaryTemplate.getReplenishName())) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(204428, "请完善补发工资单模板设置")); + } // 2.检查是否正在发送中 // SalaryBillProgressDTO salaryBillProgress = salaryBillProgressService.getProgress(SalaryCacheKey.SALARY_GRANT_PROGRESS, "" + param.getSalarySendId()); // if (Objects.nonNull(salaryBillProgress) && salaryBillProgress.isStatus() @@ -148,7 +149,7 @@ public class SalaryBillServiceImpl extends Service implements SalaryBillService LocalRunnable localRunnable = new LocalRunnable() { @Override public void execute() { - handleGrant(salarySend, ids, salarySob, salaryTemplate, "tenantName"); + handleGrant(salarySend, ids, salarySob, salaryTemplate); } }; ThreadPoolUtil.fixedPoolExecute(ModulePoolEnum.OTHER, "salaryBillGrant", localRunnable); @@ -164,27 +165,21 @@ public class SalaryBillServiceImpl extends Service implements SalaryBillService * @param ids * @param salarySob * @param salaryTemplate - * @param tenantName */ - private void handleGrant(SalarySendPO salarySend, List ids, SalarySobPO salarySob, SalaryTemplatePO salaryTemplate, String tenantName) { + private void handleGrant(SalarySendPO salarySend, List ids, SalarySobPO salarySob, SalaryTemplatePO salaryTemplate) { try { - long l = System.currentTimeMillis(); - // 开启分权或且是非薪酬模块总管理员且发送全部,谁能进来就是能看全部 - // ids = getIdsForDevolution(salarySend, ids); -// List incomeCategorys = salarySob == null || salarySob.getIncomeCategory() == null ? Lists.newArrayList() : JsonUtil.parseList(salarySob.getIncomeCategory(), String.class); - // 邮箱打开 - boolean isEnableEmail = MessageUtil.checkSendEmail() && salaryTemplate.getEmailStatus().equals(SalaryTemplateWhetherEnum.TRUE.getValue()); + + TaxAgentPO taxAgentPO = getTaxAgentService(user).getById(salarySob.getTaxAgentId()); // 1.构建发送参数 - SalaryBillSendDTO salaryBillSendParam = buildSendParams(salarySend, null, salarySob, tenantName, salaryTemplate, true); + SalaryBillSendDTO salaryBillSendParam = buildSendParams(salarySend, null, salarySob, taxAgentPO.getName(), salaryTemplate, true); // 2.获取可发送的列表,此步最耗时,需要解密核算数据 - long l2 = System.currentTimeMillis(); List> enableSendList = getEnableSendList(salarySend, ids, null, true); - long l3 = System.currentTimeMillis(); + // 3.发送消息:先修改数据再发消息,避免出错后无法撤回 List successIds = sendMessage(enableSendList, salaryBillSendParam); - long l4 = System.currentTimeMillis(); + LocalDateTime sendTime = LocalDateTime.now(); // 4.发放 @@ -192,7 +187,6 @@ public class SalaryBillServiceImpl extends Service implements SalaryBillService // 5.更新数量 // updateSendNum(salarySend, salarySob, sendTime, SalaryI18nUtil.getI18nLabel(93215, "工资单发放")); - long l5 = System.currentTimeMillis(); int total = enableSendList.size(); int successCount = successIds.size(); @@ -218,32 +212,24 @@ public class SalaryBillServiceImpl extends Service implements SalaryBillService * @param salarySend * @param incomeCategorys * @param salarySob - * @param tenantName + * @param taxAgentName * @param salaryTemplate * @param isEnableEmail * @return */ - private SalaryBillSendDTO buildSendParams(SalarySendPO salarySend, List incomeCategorys, SalarySobPO salarySob, String tenantName, SalaryTemplatePO salaryTemplate, boolean isEnableEmail) { - String currentTenantKey = salarySend.getTenantKey(); - // 云桥发送控制 -// salaryTemplate.setCloudBridgeStatus(getSalaryTemplateService(user).isEnableEbridge(currentTenantKey) ? salaryTemplate.getCloudBridgeStatus() : SalaryTemplateWhetherEnum.FALSE.getValue()); + private SalaryBillSendDTO buildSendParams(SalarySendPO salarySend, List incomeCategorys, SalarySobPO salarySob, String taxAgentName, SalaryTemplatePO salaryTemplate, boolean isEnableEmail) { // 发送通道 -// Set sendChannels = SalaryBillBO.buildSendChannels(salaryTemplate); - // 空的发个毛线 -// if (CollectionUtils.isEmpty(sendChannels)) { -// return null; -// } -// List salarySobItems = salarySobItemService.listBySalarySobId(salarySob == null ? 0L : salarySob.getId()); -// Map salaryItemIncomeCategoryMap = SalaryEntityUtil.convert2Map(salarySobItems, -// salarySobItemPO -> salarySobItemPO.getSalaryItemId().toString(), SalarySobItemPO::getIncomeCategory); - + Set sendChannels = SalaryBillBO.buildSendChannels(salaryTemplate); + if (CollectionUtils.isEmpty(sendChannels)) { + return null; + } Date salaryMonth = salarySend.getSalaryMonth(); boolean isReplenish = NumberUtils.INTEGER_ONE.equals(salarySend.getSalaryAcctType()); // SalaryTemplateBO.copyShowSet(isReplenish, salaryTemplate); // 消息标题 - String title = SalaryBillBO.getBillTitle(salaryTemplate.getTheme(), salaryMonth, tenantName); + String title = SalaryBillBO.getBillTitle(salaryTemplate.getTheme(), salaryMonth, taxAgentName); // 云桥企业微信消息图 String domain = ""; @@ -261,8 +247,6 @@ public class SalaryBillServiceImpl extends Service implements SalaryBillService // 工资单预览实体名 String entityName = SalaryI18nUtil.getI18nLabel(94626, "工资单"); - User sendUser = null; - // 获取人员信息项目分类 List salaryItemSetList = JSONArray.parseArray(isReplenish ? salaryTemplate.getReplenishSalaryItemSetting() : salaryTemplate.getSalaryItemSetting(), SalaryTemplateSalaryItemSetListDTO.class); // 国际化处理 @@ -287,17 +271,17 @@ public class SalaryBillServiceImpl extends Service implements SalaryBillService // 工资单预览实体名 .entityName(entityName) // 发送通道 -// .sendChannels(sendChannels) + .sendChannels(sendChannels) // 发送者 - .sendUser(sendUser) + .sendUser(user) // 工资单模板 .salaryTemplate(salaryTemplate) // 工资单背景图base64编码 .backgroundBase64(backgroundBase64) // 云桥工资单消息图 .picUrl(picUrl) - // 租户名 - .tenantName(tenantName) + // 扣缴义务人名称 + .taxAgentName(taxAgentName) // 工资单模板-薪资项目设置 .salaryItemSetList(salaryItemSetList) // 工资单模板-员工基本信息 @@ -401,6 +385,8 @@ public class SalaryBillServiceImpl extends Service implements SalaryBillService return enableSendList.stream().map(e -> Long.valueOf(e.get("id").toString())).collect(Collectors.toList()); } + Set sendChannels = salaryBillSendParam.getSendChannels(); + // 获取人员完整信息 Map allEmployeeMap = this.getEmployeeWholeInfo(enableSendList); @@ -409,10 +395,13 @@ public class SalaryBillServiceImpl extends Service implements SalaryBillService AtomicInteger part = new AtomicInteger(0); int total = enableSendList.size(); 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); + + if(!sendChannels.contains(MessageChannelEnum.EMAIL)){ + // 构建发送消息 + SalaryBillBO.buildEmployeeInfo(salaryBillSendParam, allEmployeeMap.get(e.get("employeeId").toString())); + SalaryBillBO.sendEmail(e, allEmployeeMap, salaryBillSendParam); + } + /** 发送工资单 **********************************************************/ // WeaResult sendResult = asyncSystemMessageRest.sendMsg(message); // if (sendResult.isStatus()) { diff --git a/src/com/engine/salary/service/impl/SalarySendServiceImpl.java b/src/com/engine/salary/service/impl/SalarySendServiceImpl.java index 82c9148f4..142dd839b 100644 --- a/src/com/engine/salary/service/impl/SalarySendServiceImpl.java +++ b/src/com/engine/salary/service/impl/SalarySendServiceImpl.java @@ -65,7 +65,6 @@ import org.apache.commons.lang3.math.NumberUtils; import org.apache.poi.xssf.usermodel.XSSFWorkbook; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import weaver.common.MessageUtil; import weaver.hrm.User; import weaver.hrm.company.SubCompanyComInfo; import weaver.hrm.resource.ResourceComInfo; @@ -494,11 +493,11 @@ public class SalarySendServiceImpl extends Service implements SalarySendService encryptUtil.decryptList(salaryAcctResultPOS, SalaryAcctResultPO.class); SalaryAcctRecordPO salaryAcctRecordPO = getSalaryAcctRecordService(user).getById(salarySendInfo.getSalaryAcctRecordId()); - if(salaryAcctRecordPO == null){ + if (salaryAcctRecordPO == null) { throw new SalaryRunTimeException("薪资核算记录不存在!"); } - List> salaryAcctResultS =null; - if(Objects.equals(salaryAcctRecordPO.getBackCalcStatus(),NumberUtils.INTEGER_ONE) && !isReplenish){ + List> salaryAcctResultS = null; + if (Objects.equals(salaryAcctRecordPO.getBackCalcStatus(), NumberUtils.INTEGER_ONE) && !isReplenish) { // 该记录回算过,并且获取的不是回算后的工资单 salaryAcctResultS = salaryAcctResultPOS.stream().map(m -> { Map map = new LinkedHashMap<>(); @@ -506,7 +505,7 @@ public class SalarySendServiceImpl extends Service implements SalarySendService map.put("resultValue", m.getOriginResultValue()); return map; }).collect(Collectors.toList()); - }else{ + } else { salaryAcctResultS = salaryAcctResultPOS.stream().map(m -> { Map map = new LinkedHashMap<>(); map.put("salaryItemId", m.getSalaryItemId()); @@ -1027,10 +1026,6 @@ public class SalarySendServiceImpl extends Service implements SalarySendService */ private void sendPayRollEMMessage(SalarySendInfoPO po, SalaryTemplatePO template, Long employeeId) { - - boolean canSendSms = MessageUtil.checkSendSMS(); - boolean canSendEmail = MessageUtil.checkSendEmail(); - // try { // MessageUtil.sendSMS(mobile, content); // } catch (Exception e) { @@ -1172,6 +1167,7 @@ public class SalarySendServiceImpl extends Service implements SalarySendService Long salarySendId = param.getSalarySendId(); Collection ids = param.getIds(); + // 获取可撤回的工资单 if (param.getSalarySendRangeIds() != null) { //如果传了范围id,则使用范围id撤回 ids = getSalarySendRangeService(user) @@ -1185,33 +1181,14 @@ public class SalarySendServiceImpl extends Service implements SalarySendService if (salarySend == null) { throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100512, "工资单发放不存在")); } -// // 获取可撤回的工资单 -// List enableWithdrawList = new LambdaQueryChainWrapper<>(salarySendInfoMapper) -// .eq(SalarySendInfoPO::getDeleteType, 0) -// .eq(SalarySendInfoPO::getTenantKey, currentTenantKey) -// .eq(SalarySendInfoPO::getSalarySendId, salarySendId) -// .eq(SalarySendInfoPO::getSendStatus, SalarySendStatusEnum.ALREADYSEND.getValue()) -// .in(CollectionUtils.isNotEmpty(ids), SalarySendInfoPO::getId, ids) -// .list(); + // 撤回 -// new LambdaUpdateChainWrapper<>(salarySendInfoMapper) -// .eq(SalarySendInfoPO::getDeleteType, 0) -// .eq(SalarySendInfoPO::getSalarySendId, salarySendId) -// .eq(SalarySendInfoPO::getSendStatus, SalarySendStatusEnum.ALREADYSEND.getValue()) -// .in(CollectionUtils.isNotEmpty(ids), SalarySendInfoPO::getId, ids) -// .set(SalarySendInfoPO::getSendStatus, SalarySendStatusEnum.WITHDRAW.getValue()) -// .update(); SalarySendInfoPO po = new SalarySendInfoPO(); po.setSendStatus(SalarySendStatusEnum.WITHDRAW.getValue()); - List statusList = new ArrayList<>(); statusList.add(SalarySendStatusEnum.ALREADYSEND.getValue()); salarySendInfoMapper.updateGrantWithdraw(po, salarySendId, statusList, ids); -// List list = new LambdaQueryChainWrapper<>(salarySendInfoMapper) -// .eq(SalarySendInfoPO::getDeleteType, 0) -// .eq(SalarySendInfoPO::getTenantKey, currentTenantKey) -// .eq(SalarySendInfoPO::getSalarySendId, salarySendId).list(); po = new SalarySendInfoPO(); po.setDeleteType(0); @@ -1231,11 +1208,6 @@ public class SalarySendServiceImpl extends Service implements SalarySendService salarySendNew.setSendTotal(sendTotal); mapper.updateById(salarySendNew); -// List salarySobs = new LambdaQueryChainWrapper<>(salarySobMapper) -// .eq(SalarySobPO::getTenantKey, TenantContext.getCurrentTenantKey()) -// .eq(SalarySobPO::getDeleteType, 0) -// .eq(SalarySobPO::getId, salarySend.getSalarySobId()) -// .list(); // 记录日志 // SalaryLoggerUtil.recordUpdateSingleLog(salarySendLoggerTemplate, // salarySend.getId(), @@ -1247,28 +1219,10 @@ public class SalarySendServiceImpl extends Service implements SalarySendService SalarySendGrantParam grantParam = SalarySendGrantParam.builder().ids(param.getIds()).salarySendId(param.getSalarySendId()).build(); - // 撤回消息 + + // 异步发送消息:先修改数据再发消息,避免出错后无法撤回撤回消息 sendMessage(false, list, grantParam, salarySend); -// // 3.异步发送消息:先修改数据再发消息,避免出错后无法撤回 -// taskExecutor.execute(() -> { -// try { -// DSTenantKeyThreadVar.tenantKey.set(currentTenantKey); -// -// String text = "工资单撤回测试消息文案,不好意思,弄错了"; -// String title = SalaryI18nUtil.getI18nLabel(currentTenantKey, currentEmployeeId, 94626, "工资单"); -// enableWithdrawList.forEach(e->{ -// CancleMessageEntity cme = SalarySendBO.buildCancleMessageEntity(e.getEmployeeId(), -// e.getMsgId(), -// text, -// title, -// currentEmployeeId, -// currentTenantKey); -// log.info("撤回结果===:{}", JsonUtil.toJsonString(asyncSystemMessageRest.cancleMsg(cme))); -// }); -// } finally { -// DSTenantKeyThreadVar.tenantKey.remove(); -// } -// }); + Map map = new HashMap<>(2); map.put("sendNum", sendNum); @@ -1447,7 +1401,7 @@ public class SalarySendServiceImpl extends Service implements SalarySendService // 查询薪资核算所用薪资账套的薪资项目 List salarySobItemPOS = getSalarySobItemService(user).listBySalarySobId(salaryAcctRecordPO.getSalarySobId()); Set salaryItemIds = SalaryEntityUtil.properties(salarySobItemPOS, SalarySobItemPO::getSalaryItemId); - if(Objects.equals(salaryAcctRecordPO.getBackCalcStatus(), NumberUtils.INTEGER_ONE)){ + if (Objects.equals(salaryAcctRecordPO.getBackCalcStatus(), NumberUtils.INTEGER_ONE)) { // 是回算,获取回算项 List salarySobBackItemPOS = getSalarySobBackItemService(user).listBySalarySobId(salaryAcctRecordPO.getSalarySobId()); salaryItemIds.addAll(salarySobBackItemPOS.stream().map(SalarySobBackItemPO::getSalaryItemId).collect(Collectors.toList())); @@ -1479,7 +1433,7 @@ public class SalarySendServiceImpl extends Service implements SalarySendService @Override public void deleteBySalaryAcctRecordIds(Collection ids) { - if(CollectionUtils.isNotEmpty(ids)){ + if (CollectionUtils.isNotEmpty(ids)) { getSalarySendMapper().deleteBySalaryAcctRecordIds(ids); getSalarySendInfoMapper().deleteBySalaryAcctRecordIds(ids); } diff --git a/src/com/engine/salary/wrapper/SalarySendWrapper.java b/src/com/engine/salary/wrapper/SalarySendWrapper.java index 37896c483..2f4a79838 100644 --- a/src/com/engine/salary/wrapper/SalarySendWrapper.java +++ b/src/com/engine/salary/wrapper/SalarySendWrapper.java @@ -31,6 +31,7 @@ import com.engine.salary.util.SalaryEntityUtil; import com.engine.salary.util.SalaryI18nUtil; import com.engine.salary.util.page.PageInfo; import com.engine.salary.util.page.SalaryPageUtil; +import com.engine.salary.wrapper.proxy.SalarySendWrapperProxy; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.math.NumberUtils; @@ -49,7 +50,7 @@ import java.util.stream.Collectors; * @Author: wangxiangzhong * @Date: 2022/3/16 13:57 */ -public class SalarySendWrapper extends Service { +public class SalarySendWrapper extends Service implements SalarySendWrapperProxy { private TaxAgentService getTaxAgentService(User user) { return ServiceUtil.getService(TaxAgentServiceImpl.class, user); } diff --git a/src/com/engine/salary/wrapper/proxy/SalarySendWrapperProxy.java b/src/com/engine/salary/wrapper/proxy/SalarySendWrapperProxy.java new file mode 100644 index 000000000..df063f4cd --- /dev/null +++ b/src/com/engine/salary/wrapper/proxy/SalarySendWrapperProxy.java @@ -0,0 +1,34 @@ +package com.engine.salary.wrapper.proxy; + +import com.engine.salary.entity.salaryBill.param.SalarySendGrantParam; +import com.engine.salary.entity.salaryBill.param.SalarySendWithdrawParam; + +import java.util.Map; + +/** + * 工资单发放代理 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public interface SalarySendWrapperProxy { + + /** + * 工资单发放 + * + * @param queryParam + * @return + */ + Map grant(SalarySendGrantParam queryParam); + + /** + * 工资单撤回 + * + * @param queryParam + * @return + */ + Map withdraw(SalarySendWithdrawParam queryParam); + +}