Merge remote-tracking branch 'origin/release/2.8.3.2306.01' into release/2.8.3.2306.01

This commit is contained in:
sy 2023-06-07 18:41:22 +08:00
commit 5a54b83b4a
43 changed files with 2360 additions and 400 deletions

View File

@ -10,7 +10,7 @@ import com.engine.salary.constant.SalaryDefaultTenantConstant;
import com.engine.salary.encrypt.AESEncryptUtil;
import com.engine.salary.encrypt.EncryptUtil;
import com.engine.salary.entity.datacollection.DataCollectionEmployee;
import com.engine.salary.entity.salaryacct.dto.SalaryAcctProgressDTO;
import com.engine.salary.entity.progress.ProgressDTO;
import com.engine.salary.entity.siaccount.dto.InsuranceAccountViewListDTO;
import com.engine.salary.entity.siaccount.dto.SIAccountUtilDTO;
import com.engine.salary.entity.siaccount.param.*;
@ -28,10 +28,10 @@ import com.engine.salary.mapper.siarchives.InsuranceBaseInfoMapper;
import com.engine.salary.mapper.sicategory.ICategoryMapper;
import com.engine.salary.mapper.sischeme.InsuranceSchemeDetailMapper;
import com.engine.salary.mapper.taxagent.TaxAgentMapper;
import com.engine.salary.service.SalaryAcctProgressService;
import com.engine.salary.service.ProgressService;
import com.engine.salary.service.SalaryEmployeeService;
import com.engine.salary.service.TaxAgentService;
import com.engine.salary.service.impl.SalaryAcctProgressServiceImpl;
import com.engine.salary.service.impl.ProgressServiceImpl;
import com.engine.salary.service.impl.SalaryEmployeeServiceImpl;
import com.engine.salary.service.impl.TaxAgentServiceImpl;
import com.engine.salary.sys.entity.vo.OrderRuleVO;
@ -113,8 +113,8 @@ public class SIAccountBiz extends Service {
return MapperProxyFactory.getProxy(InsuranceCompensationMapper.class);
}
private SalaryAcctProgressService getSalaryAcctProgressService(User user) {
return (SalaryAcctProgressService) ServiceUtil.getService(SalaryAcctProgressServiceImpl.class, user);
private ProgressService getSalaryAcctProgressService(User user) {
return (ProgressService) ServiceUtil.getService(ProgressServiceImpl.class, user);
}
private SIAccountDetailTempMapper getSIAccountDetailTempMapper() {
@ -251,13 +251,13 @@ public class SIAccountBiz extends Service {
public void accounting(AccountParam param, Long employeeId, String tenantKey, String currentUserName) {
//薪资核算进度暂未实现
SalaryAcctProgressDTO salaryAcctProgressDTO = getSalaryAcctProgressService(user).getProgress(SalaryCacheKey.ACCT_PROGRESS + param.getBillMonth());
ProgressDTO salaryAcctProgressDTO = getSalaryAcctProgressService(user).getProgress(SalaryCacheKey.ACCT_PROGRESS + param.getBillMonth());
if (salaryAcctProgressDTO != null && salaryAcctProgressDTO.getProgress().compareTo(BigDecimal.ONE) < 0) {
return;
}
// 初始化进度
SalaryAcctProgressDTO initProgress = new SalaryAcctProgressDTO()
ProgressDTO initProgress = new ProgressDTO()
.setTitle(SalaryI18nUtil.getI18nLabel(97515, "核算中"))
.setTitleLabelId(97515L)
.setTotalQuantity(NumberUtils.INTEGER_ONE)
@ -341,7 +341,7 @@ public class SIAccountBiz extends Service {
//salaryAcctProgressService.initProgress(tenantKey + param.getBillMonth(), salaryAcctProgressDTO, employeeId, tenantKey);
// 初始化进度
SalaryAcctProgressDTO initProgress = new SalaryAcctProgressDTO()
ProgressDTO initProgress = new ProgressDTO()
.setTitle(SalaryI18nUtil.getI18nLabel(97515, "核算中"))
.setTitleLabelId(97515L)
.setTotalQuantity(ids.size())

View File

@ -12,4 +12,25 @@ public class SalaryArchiveConstant {
* 包含负数正数小数00.00000等
*/
public static final String NUMBER_REGEX = "(-?[1-9]\\d*\\.?\\d+)|(-?0\\.\\d*[0-9])|(\\d+)";
/**
* 列表中薪资项目动态列后缀标识
*/
public static final String DYNAMIC_SUFFIX = "_salaryItem";
/**
* 调整前
*/
public static final String ADJUST_BEFORE = "_adjustBefore";
/**
* 调整后
*/
public static final String ADJUST_AFTER = "_adjustAfter";
/**
* 调整后
*/
public static final String ZERO_IGNORE_REGEX = "\\.00";
}

View File

@ -1,4 +1,4 @@
package com.engine.salary.entity.salaryacct.dto;
package com.engine.salary.entity.progress;
import lombok.AllArgsConstructor;
import lombok.Builder;
@ -10,18 +10,19 @@ import java.io.Serializable;
import java.math.BigDecimal;
/**
* @description: 核算进度
* @author: xiajun
* @modified By: xiajun
* @date: Created in 12/13/21 1:34 PM
* @version:v1.0
*/
* 进度
* <p>Copyright: Copyright (c) 2022</p>
* <p>Company: 泛微软件</p>
*
* @author qiantao
* @version 1.0
**/
@Data
@Builder
@Accessors(chain = true)
@NoArgsConstructor
@AllArgsConstructor
public class SalaryAcctProgressDTO implements Serializable {
public class ProgressDTO implements Serializable {
/**
* 当前步骤名称

View File

@ -0,0 +1,622 @@
package com.engine.salary.entity.salaryBill.bo;
import com.cloudstore.dev.api.bean.MessageBean;
import com.cloudstore.dev.api.bean.MessageType;
import com.cloudstore.dev.api.util.Util_Message;
import com.engine.salary.annotation.SalaryFormulaVar;
import com.engine.salary.constant.SalaryArchiveConstant;
import com.engine.salary.constant.SalaryTemplateSalaryItemSetGroupConstant;
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;
import com.engine.salary.util.SalaryI18nUtil;
import com.google.common.collect.Maps;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import weaver.common.MessageUtil;
import weaver.hrm.company.SubCompanyComInfo;
import weaver.hrm.resource.ResourceComInfo;
import java.io.IOException;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.util.*;
public class SalaryBillBO {
private static final Logger log = LoggerFactory.getLogger(SalaryBillBO.class);
@Override
public String toString() {
return "SalaryBillBO{}";
}
//
// /**
// * 根据模板内容转为工资单模板对象
// * 注意不要通过反序列化可能会因为历史原因修改字段名称而无法序列化
// *
// * @param salaryTemplateContent
// * @return
// */
// public static SalaryTemplatePO buildSalaryTemplateContent(String salaryTemplateContent) {
// Map<String, Object> map = JsonUtil.parseMap(salaryTemplateContent, Object.class);
// return SalaryTemplatePO.builder()
// .id(Long.valueOf(map.getOrDefault("id", "0").toString()))
// .name(map.getOrDefault("name", "").toString())
// .salarySobId(Long.valueOf(map.getOrDefault("salarySobId", "0").toString()))
// .useType(Integer.valueOf(map.getOrDefault("useType", "0").toString()))
// .description(map.getOrDefault("description", "").toString())
// .emailStatus(Integer.valueOf(map.getOrDefault("emailStatus", "0").toString()))
// .sendEmailId(Long.valueOf(map.getOrDefault("sendEmailId", "0").toString()))
//// .msgStatus(Integer.valueOf(map.getOrDefault("msgStatus","0").toString()))
//// .imStatus(Integer.valueOf(map.getOrDefault("imStatus","0").toString()))
//// .cloudBridgeStatus(Integer.valueOf(map.getOrDefault("cloudBridgeStatus","0").toString()))
// .theme(map.getOrDefault("theme", "").toString())
// .background(map.getOrDefault("background", "").toString())
// .textContent(map.getOrDefault("textContent", "").toString())
// .textContentPosition(Integer.valueOf(map.getOrDefault("textContentPosition", "0").toString()))
// .salaryItemNullStatus(Integer.valueOf(map.getOrDefault("salaryItemNullStatus", "0").toString()))
// .salaryItemZeroStatus(Integer.valueOf(map.getOrDefault("salaryItemZeroStatus", "0").toString()))
// .salaryItemSetting(map.getOrDefault("salaryItemSetting", "").toString())
// .replenishName(map.getOrDefault("replenishName", "").toString())
//// .replTheme(map.getOrDefault("replTheme","").toString())
//// .replBackground(map.getOrDefault("replBackground","").toString())
//// .replTextContent(map.getOrDefault("replTextContent","").toString())
//// .replTextContentPosition(Integer.valueOf(map.getOrDefault("replTextContentPosition","0").toString()))
//// .replSalaryItemNullStatus(Integer.valueOf(map.getOrDefault("replSalaryItemNullStatus","0").toString()))
//// .replSalaryItemZeroStatus(Integer.valueOf(map.getOrDefault("replSalaryItemZeroStatus","0").toString()))
//// .replenishSalaryItemSetting(map.getOrDefault("replenishSalaryItemSetting","").toString())
// .build();
// }
/**
* 构建人员字段
* 与SalaryAcctResultBO.buildEmployeeFieldName()的key value对调了一下
*
* @return
*/
public static Map<String, String> buildEmployeeFieldName() {
Field[] declaredFields = SalaryFormulaEmployeeDTO.class.getDeclaredFields();
Map<String, String> employeeFieldNameMap = Maps.newHashMapWithExpectedSize(declaredFields.length);
for (Field declaredField : declaredFields) {
if (!declaredField.isAnnotationPresent(SalaryFormulaVar.class)) {
continue;
}
SalaryFormulaVar annotation = declaredField.getAnnotation(SalaryFormulaVar.class);
employeeFieldNameMap.put(SalaryI18nUtil.getI18nLabel(annotation.labelId(), annotation.defaultLabel()), declaredField.getName());
}
return employeeFieldNameMap;
}
/**
* 构建工资单中的人员信息
*
* @param simpleEmployee
*/
public static void buildEmployeeInfo(SalaryBillSendDTO salaryBillSendParam, DataCollectionEmployee simpleEmployee) {
SalaryTemplateSalaryItemSetListDTO employeeInformation = salaryBillSendParam.getEmployeeInformation();
Map<String, String> 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(salaryBillSendParam.getTaxAgentName())
.departmentName(simpleEmployee.getDepartmentName())
.email(org.apache.commons.lang3.StringUtils.isEmpty(simpleEmployee.getEmail()) ? "" : simpleEmployee.getEmail())
// .gradeName(simpleEmployee.getGrade() == null ? "" : simpleEmployee.getGrade().getName())
// .hireDate(SalaryDateUtil.getFormatLocalDate(simpleEmployee.getHiredate()))
// .sex(simpleEmployee.getSex() == null ? "" : simpleEmployee.getSex().getDescription())
.mobile(org.apache.commons.lang3.StringUtils.isEmpty(simpleEmployee.getMobile()) ? "" : simpleEmployee.getMobile())
.jobtitleName(simpleEmployee.getJobtitleName())
// .status(StringUtils.isEmpty(simpleEmployee.getPersonnelStatus()) ? "" : simpleEmployee.getPersonnelStatus())
.telephone(org.apache.commons.lang3.StringUtils.isEmpty(simpleEmployee.getTelephone()) ? "" : simpleEmployee.getTelephone())
.username(org.apache.commons.lang3.StringUtils.isEmpty(simpleEmployee.getUsername()) ? "" : simpleEmployee.getUsername())
.workcode(simpleEmployee.getWorkcode())
.build();
List<SalaryTemplateSalaryItemListDTO> items = employeeInformation.getItems();
// 1.SalaryAcctResultBO.buildEmployeeFieldName()的取法
// Set<Map.Entry<String, String>> entries = employeeField.entrySet();
// for (SalaryTemplateSalaryItemListDTO e : items) {
// Optional<Map.Entry<String, String>> entry = entries.stream().filter(f -> Objects.equals(e.getName(), f.getValue())).findFirst();
// if (entry.isPresent()) {
// String key = entry.get().getKey();
// if (org.apache.commons.lang3.StringUtils.isNotBlank(key)) {
// String getter = "get" + key.substring(0, 1).toUpperCase() + key.substring(1);
// try {
// Method method = salaryFormulaEmployeeDTO.getClass().getMethod(getter);
// Object invoke = method.invoke(salaryFormulaEmployeeDTO);
// e.setSalaryItemValue((String) invoke);
// } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException ex) {
// log.error("no such method", e);
// }
// }
// }
// }
// 2.SalaryBillBO.buildEmployeeFieldName()
for (SalaryTemplateSalaryItemListDTO e : items) {
String employeeFieldName = employeeField.get(e.getName());
if (!StringUtils.isEmpty(employeeFieldName)) {
String getter = "get" + employeeFieldName.substring(0, 1).toUpperCase() + employeeFieldName.substring(1);
try {
Method method = salaryFormulaEmployeeDTO.getClass().getMethod(getter);
Object invoke = method.invoke(salaryFormulaEmployeeDTO);
e.setSalaryItemValue((String) invoke);
} catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException ex) {
log.error("no such method", e);
}
}
}
}
}
/**
* 获取工资单标题
*
* @return
*/
public static String getBillTitle(String theme, Date salaryMonth, Long employeeId) {
String companyName = "";
if (theme.contains("${companyName}")) {
if (employeeId != null) {
ResourceComInfo resourceComInfo = null;
SubCompanyComInfo subCompanyComInfo = new SubCompanyComInfo();
try {
resourceComInfo = new ResourceComInfo();
subCompanyComInfo = new SubCompanyComInfo();
} catch (Exception e) {
log.error("资源异常", e);
}
companyName = subCompanyComInfo.getSubCompanyname(resourceComInfo.getSubCompanyID(employeeId + ""));
}
}
return theme
.replace("${companyName}", companyName)
.replace("${salaryMonth}", new SimpleDateFormat("yyyy年MM月").format(salaryMonth));
}
// /**
// * 构建发送消息
// *
// * @param e
// * @param allEmployeeMap
// * @param salaryBillSendParam
// * @param currentEmployeeId
// * @param currentTenantKey
// * @return
// */
// public static SendMessageEntity buildSendMessage(Map<String, Object> e, Map<String, SimpleEmployee> allEmployeeMap, SalaryBillSendDTO salaryBillSendParam, Long currentEmployeeId, String currentTenantKey) {
// // 构建用户基本信息
// SalaryBillBO.buildEmployeeInfo(salaryBillSendParam.getEmployeeInformation(), allEmployeeMap.get(e.get("employeeId").toString()), salaryBillSendParam.getEmployeeField());
// // 消息接收者
// List<UserEntity> receivers = Collections.singletonList(SalaryBillBO.buildUser(Long.valueOf(e.get("employeeId").toString()), Optional.ofNullable(e.get("email")).orElse("").toString(), currentTenantKey));
// Entity entity = SalaryBillBO.buildEntity(e.get("id").toString(), currentEmployeeId, salaryBillSendParam.getEntityName());
// EmailEntity emailInfo = new EmailEntity();
// // 邮箱打开
// if (salaryBillSendParam.isEnableEmail()) {
// String emailContent = SalaryBillBO.buildEmailContent(e, salaryBillSendParam);
// emailInfo = SalaryBillBO.buildEmailInfo(salaryBillSendParam.getText(), emailContent, salaryBillSendParam.getSalaryTemplate().getSendEmailId());
// }
// return SalaryBillBO.buildSendMessageEntity(salaryBillSendParam, receivers, entity, emailInfo);
// }
/**
* 发送Em消息
*/
public static void sendMsg(SalaryBillSendDTO salaryBillSendParam, Long id, Long employeeId) {
SalaryTemplatePO template = salaryBillSendParam.getSalaryTemplate();
String background = template.getBackground();
String billTitle = getBillTitle(template.getTheme(), salaryBillSendParam.getSalaryDate(), employeeId);
MessageType messageType = MessageType.newInstance(499); // 消息来源见文档第四点补充 必填
Set<String> userIdList = new HashSet<>(); // 接收人id 必填
userIdList.add(employeeId.toString());
String title = billTitle; // 标题
String context = "点击查看详情"; // 内容
// PC端链接
String linkUrl = weaver.general.GCONST.getContextPath() + "/spa/hrmSalary/static/index.html#/main/hrmSalary/mobilepayroll?id=" + id + "&recipient=" + employeeId;
// 移动端链接
String linkMobileUrl = weaver.general.GCONST.getContextPath() + "/spa/hrmSalary/static/index.html#/main/hrmSalary/mobilepayroll?type=phone&id=" + id + "&recipient=" + employeeId;
try {
MessageBean messageBean = Util_Message.createMessage(messageType, userIdList, title, context, linkUrl, linkMobileUrl);
messageBean.setCreater(Integer.parseInt(salaryBillSendParam.getSendUser().getUID() + ""));// 创建人id
messageBean.setBizState("0");// 需要修改消息为已处理等状态时传入,表示消息最初状态为待处理
messageBean.setTargetId("499|" + id); //消息来源code +|+业务id需要修改消息为已处理等状态时传入
if (StringUtils.isNotBlank(background)) {
messageBean.setPictureUrl(background);
} else {
messageBean.setPictureUrl("/hrm/hrm_e9/images/payroll.jpg?pictype=jpg");
}
Util_Message.store(messageBean);
} catch (IOException e) {
e.printStackTrace();
}
}
public static void sendEmail(Map<String, Object> e, Map<String, DataCollectionEmployee> allEmployeeMap, SalaryBillSendDTO salaryBillSendParam) {
// 消息接收者
String receivers = Optional.ofNullable(e.get("email")).orElse("").toString();
String title = getBillTitle(salaryBillSendParam.getSalaryTemplate().getTheme(), salaryBillSendParam.getSalaryDate(), Long.valueOf(e.get("employeeId").toString()));
String emailContent = SalaryBillBO.buildEmailContent(e, salaryBillSendParam);
if (StringUtils.isNotBlank(receivers)) {
MessageUtil.sendEmail(receivers, title, emailContent);
}
}
public static void sendSMS(SalaryBillSendDTO salaryBillSendParam, Long id, Long employeeId) {
// try {
// MessageUtil.sendSMS(mobile, content);
// } catch (Exception e) {
// kqLog.info("SendSMS error.resourceId:" + resourceId + ">>>>>>mobile>>>>>>" + mobile);
// log.writeLog(e);
// }
}
// /**
// * 构建发送消息
// *
// * @return
// */
// public static SendMessageEntity buildSendMessageEntity(SalaryBillSendDTO salaryBillSendParam, List<UserEntity> receivers, Entity entity, EmailEntity emailInfo) {
// SendMessageEntity smg = new SendMessageEntity();
// // 模块
// smg.setModule(MessageModule.HRSA);
// // 事件
// smg.setEvent(MessageEvent.PAYROLL);
//
// // 发送者
// smg.setSender(salaryBillSendParam.getSendUser() == null ? UserEntity.SYSTEM_USER : salaryBillSendParam.getSendUser());
// // 接收者
// smg.setReceivers(receivers);
// // 发送通道
// smg.setChannels(salaryBillSendParam.getSendChannels());
//
// // 消息内容
// smg.setText(salaryBillSendParam.getTitle());
//
// // 1.im
// smg.setEntity(entity);
// // 2.云桥
// smg.setPcUrl(entity.getPcUrl());
// smg.setAppUrl(entity.getH5Url());
// smg.setTitle(salaryBillSendParam.getTitle());
// smg.setContent(salaryBillSendParam.getTitle());
// smg.setPicUrl(salaryBillSendParam.getPicUrl());
// // 3.邮件
// smg.setEmailInfo(emailInfo);
//
// return smg;
// }
//
// /**
// * 构建用户
// *
// * @return
// */
// public static UserEntity buildUser(Long employeeId, String email, String tenantKey) {
// UserEntity user = new UserEntity(employeeId, tenantKey);
// if (!StringUtils.isEmpty(email)) {
// user.setEmail(email);
// }
// return user;
// }
/**
* 构建发送通道
*
* @param salaryTemplate
* @return
*/
public static Set<MessageChannelEnum> buildSendChannels(SalaryTemplatePO salaryTemplate) {
Set<MessageChannelEnum> 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;
}
//
// /**
// * 构建实体
// *
// * @param id
// * @param currentEmployeeId
// * @param name
// * @return
// */
// public static Entity buildEntity(String id, Long currentEmployeeId, String name) {
// Entity e = new Entity();
// e.setId(String.valueOf(IdGenerator.generate()));
// e.setModule(EntityType.hrmsalary.name());
// e.setName(name);
// e.setH5Url("/mobile/salary/mySalaryBill/view/" + id);
//// e.setH5LinkeType(1);
// e.setPcUrl("/sp/salary/mySalaryBill/view/" + id);
//// e.setPcLinkeType(0);
//
// // im添加创建人创建时间可在对应通道的模板中的内容或辅助信息标题等加上变量${creator}$和${createTime}$
// e.setCreatorId(currentEmployeeId);
// e.setCreateTime(new Date());
// return e;
// }
//
// /**
// * 构建邮件信息
// *
// * @param emailSubject 邮件主题
// * @param emailContent 邮件内容
// * @param mailUserAccountId 邮箱账号id
// * @return
// */
// public static EmailEntity buildEmailInfo(String emailSubject, String emailContent, Long mailUserAccountId) {
// EmailEntity entity = new EmailEntity();
// entity.setEmailContent(emailContent);
// entity.setEmailSubject(emailSubject);
// // 发送者邮箱
// entity.setMailUserAccountId(mailUserAccountId);
// return entity;
// }
//
// /**
// * 构建撤回消息
// *
// * @param msgId
// * @param text
// * @param title
// * @param currentEmployeeId
// * @param currentTenantKey
// * @return
// */
// public static CancleMessageEntity buildCancleMessageEntity(long msgId, String text, String title, Long currentEmployeeId, String currentTenantKey) {
// CancleMessageEntity cme = new CancleMessageEntity();
// cme.setMsgId(msgId);
// // 模块
// cme.setModule(MessageModule.HRSA);
// // 事件
// cme.setEvent(MessageEvent.PAYROLL);
//
// cme.setText(text);
//
// Entity entity = new Entity();
// entity.setId(String.valueOf(IdGenerator.generate()));
// entity.setModule(EntityType.hrmsalary.name());
// entity.setName(title);
// cme.setEntity(entity);
// UserEntity user = new UserEntity(currentEmployeeId, currentTenantKey);
// cme.setOperator(user);
// return cme;
// }
/**
* 构建邮件内容
* 注意样式只能在标签style属性中使用否则样式不生效
*
* @param e
* @param salaryBillSendParam
* @return
*/
public static String buildEmailContent(Map<String, Object> e, SalaryBillSendDTO salaryBillSendParam) {
StringBuilder emailContent = new StringBuilder();
emailContent.append("<div style='display: flex;flex-direction: column;justify-content: flex-start;align-items: center;padding: 16px;'>");
// 1.标题
emailContent.append("<div style='width: 100%;min-height: 22px; line-height: 30px; font-family: PingFangSC-Medium;font-size: 22px;color: #020202;font-weight: 500;text-align: center;'>");
// emailContent.append(salaryBillSendParam.getTitle());
emailContent.append(getBillTitle(salaryBillSendParam.getSalaryTemplate().getTheme(), salaryBillSendParam.getSalaryDate(), Long.valueOf(e.get("employeeId").toString())));
emailContent.append("</div>");
// 2.发送时间
emailContent.append("<div style='width: 100%;margin-top: 16px;text-align: center;height: 14px;font-family: PingFangSC-Regular;font-size: 14px;color: #999999;line-height: 14px;font-weight: 400;'>");
emailContent.append(SalaryDateUtil.getFormatLocalDateTime(LocalDateTime.now()));
emailContent.append("</div>");
// 3.背景图-base64
// if (!StringUtils.isEmpty(salaryBillSendParam.getBackgroundBase64())) {
// emailContent.append("<div style='margin-top: 32px;'><img src='data:image/jpg;base64,");
// emailContent.append(salaryBillSendParam.getBackgroundBase64());
// emailContent.append("'/></div>");
// }
// 3.背景图-url
// if (StringUtils.isNotEmpty(salaryBillSendParam.getSalaryTemplate().getBackground())) {
// emailContent.append("<div style='margin-top: 32px;'><img src='");
// emailContent.append(salaryBillSendParam.getPicUrl());
// emailContent.append("'/></div>");
// }
// 是否只有一个分组如果是则将文本内容放进薪资项目表格前后
boolean isOnlyOneGroup = salaryBillSendParam.getSalaryItemSetList().stream().filter(st -> CollectionUtils.isNotEmpty(st.getItems())).count() == 1;
if (isOnlyOneGroup) {
buildOnlyOneGroupMailMain(emailContent, e, salaryBillSendParam);
} else {
buildMailMain(emailContent, e, salaryBillSendParam);
}
emailContent.append("</div>");
return emailContent.toString();
}
/**
* 构建邮件内容主体
*
* @param emailContent
* @param e
* @param salaryBillSendParam
*/
private static void buildMailMain(StringBuilder emailContent, Map<String, Object> e, SalaryBillSendDTO salaryBillSendParam) {
// 薪资项是否显示
boolean isHideNull = salaryBillSendParam.getSalaryTemplate().getSalaryItemNullStatus().equals(SalaryTemplateWhetherEnum.TRUE.getValue());
boolean isHideZero = salaryBillSendParam.getSalaryTemplate().getSalaryItemZeroStatus().equals(SalaryTemplateWhetherEnum.TRUE.getValue());
// 3.文本内容-如果在薪资项目前
emailContent.append("<div style='width: 100%;margin-top: 16px;text-align: center;min-height: 12px;font-family: PingFangSC-Regular;font-size: 12px;color: #111111;");
emailContent.append(salaryBillSendParam.getSalaryTemplate().getTextContentPosition() == SalaryTemplateTextContentPositionEnum.BEFORE.getValue() ? "" : "display: none");
emailContent.append("'>");
emailContent.append(salaryBillSendParam.getSalaryTemplate().getTextContent());
emailContent.append("</div>");
// 4.薪资项目内容
emailContent.append("<div style='margin-top: 16px;width: 100%;'>");
for (SalaryTemplateSalaryItemSetListDTO salaryItemSet : salaryBillSendParam.getSalaryItemSetList()) {
if (CollectionUtils.isEmpty(salaryItemSet.getItems())) {
continue;
}
emailContent.append("<div style='margin-bottom: 16px;'>");
if (!salaryItemSet.getGroupId().equals(SalaryTemplateSalaryItemSetGroupConstant.NO_TYPE_GROUP_ID)) {
emailContent.append("<div style='padding: 0 16px;width: 100%;font-family: PingFangSC-Regular;font-size: 18px;box-sizing: border-box;'>");
// 4.1.薪资项目组名
emailContent.append(salaryItemSet.getGroupName());
emailContent.append("</div>");
}
emailContent.append("<div style='margin-top: 16px;width: 100%;display: flex;flex-direction: column;align-items: flex-start;box-sizing: border-box;'>");
for (int i = 0; i < salaryItemSet.getItems().size(); i++) {
SalaryTemplateSalaryItemListDTO salaryItem = salaryItemSet.getItems().get(i);
// 员工基本信息
if (salaryItemSet.getGroupId().equals(SalaryTemplateSalaryItemSetGroupConstant.EMPLOYEE_INFO_GROUP_ID) && salaryBillSendParam.getEmployeeInformation() != null) {
Optional<SalaryTemplateSalaryItemListDTO> optionalEmpItem = salaryBillSendParam.getEmployeeInformation().getItems().stream().filter(f -> f.getId().equals(salaryItem.getId())).findFirst();
// 4.2.员工信息
emailContent.append("<div style='border: 1px solid #e5e5e5;border-bottom: none;width: 100%;display: flex;justify-content: flex-start;align-items: center;box-sizing: border-box;");
emailContent.append(i == (salaryItemSet.getItems().size() - 1) ? "border-bottom: 1px solid #e5e5e5;" : "");
emailContent.append("'>");
emailContent.append("<div style='min-height: 60px;padding: 0 16px;flex: 2;background: #fbfbfb;border-right: 1px solid #e5e5e5;display: flex;align-items: center;justify-content: left;' title={name}>");
emailContent.append("<span class='text'>");
emailContent.append((optionalEmpItem.isPresent() ? optionalEmpItem.get().getName() : ""));
emailContent.append("</span>");
emailContent.append("</div>");
emailContent.append("<div style='min-height: 60px;flex: 8;padding-left: 16px;background: #ffffff;display: flex;align-items: center;justify-content: left;'>");
emailContent.append((optionalEmpItem.isPresent() ? optionalEmpItem.get().getSalaryItemValue() : ""));
emailContent.append("</div>");
emailContent.append("</div>");
} else {
for (Object keyName : e.keySet()) {
if ((salaryItem.getId() + SalaryArchiveConstant.DYNAMIC_SUFFIX).equals(keyName.toString())) {
boolean isHide = (isHideNull && e.get(keyName.toString()) != null) || (isHideZero && "0.00".equals(e.get(keyName.toString())));
// 4.2.薪资项目
emailContent.append("<div style='border: 1px solid #e5e5e5;border-bottom: none;width: 100%;display: flex;justify-content: flex-start;align-items: center;box-sizing: border-box;");
emailContent.append(i == (salaryItemSet.getItems().size() - 1) ? "border-bottom: 1px solid #e5e5e5;" : "");
emailContent.append((isHide ? "display: none" : ""));
emailContent.append("'>");
emailContent.append("<div style='min-height: 60px;padding: 0 16px;flex: 2;background: #fbfbfb;border-right: 1px solid #e5e5e5;display: flex;align-items: center;justify-content: left;' title={name}>");
emailContent.append("<span class='text'>");
emailContent.append(salaryItem.getName());
emailContent.append("</span>");
emailContent.append("</div>");
emailContent.append("<div style='min-height: 60px;flex: 8;padding-left: 16px;background: #ffffff;display: flex;align-items: center;justify-content: left;'>");
emailContent.append(e.get(keyName.toString()));
emailContent.append("</div>");
emailContent.append("</div>");
break;
}
}
}
}
emailContent.append("</div>");
emailContent.append("</div>");
}
emailContent.append("</div>");
// 5.文本内容-如果在薪资项目后
emailContent.append("<div style='width: 100%;margin-top: 16px;text-align: center;min-height: 12px;font-family: PingFangSC-Regular;font-size: 12px;color: #111111;");
emailContent.append(salaryBillSendParam.getSalaryTemplate().getTextContentPosition() == SalaryTemplateTextContentPositionEnum.AFTER.getValue() ? "" : "display: none");
emailContent.append("'>");
emailContent.append(salaryBillSendParam.getSalaryTemplate().getTextContent());
emailContent.append("</div>");
}
/**
* 构建邮件内容主体
* <p>
* 只有无分类则将文本内容放进薪资项目表格前后
*
* @param emailContent
* @param e
* @param salaryBillSendParam
*/
private static void buildOnlyOneGroupMailMain(StringBuilder emailContent, Map<String, Object> e, SalaryBillSendDTO salaryBillSendParam) {
// 薪资项是否显示
boolean isHideNull = salaryBillSendParam.getSalaryTemplate().getSalaryItemNullStatus().equals(SalaryTemplateWhetherEnum.TRUE.getValue());
boolean isHideZero = salaryBillSendParam.getSalaryTemplate().getSalaryItemZeroStatus().equals(SalaryTemplateWhetherEnum.TRUE.getValue());
// 4.薪资项目内容
emailContent.append("<div style='margin-top: 16px;width: 100%;'>");
for (SalaryTemplateSalaryItemSetListDTO salaryItemSet : salaryBillSendParam.getSalaryItemSetList()) {
if (CollectionUtils.isEmpty(salaryItemSet.getItems())) {
continue;
}
emailContent.append("<div style='margin-bottom: 16px;'>");
emailContent.append("<div style='margin-top: 16px;width: 100%;display: flex;flex-direction: column;align-items: flex-start;box-sizing: border-box;'>");
// 3.文本内容-如果在薪资项目前
emailContent.append("<div style='border: 1px solid #e5e5e5;border-bottom: none;width: 100%;display: flex;justify-content: flex-start;align-items: center;box-sizing: border-box;");
emailContent.append(salaryBillSendParam.getSalaryTemplate().getTextContentPosition() == SalaryTemplateTextContentPositionEnum.BEFORE.getValue() ? "" : "display: none");
emailContent.append("'>");
emailContent.append("<div style='min-height: 60px;padding: 0 16px;flex: 2;background: #fbfbfb;border-right: 1px solid #e5e5e5;display: flex;align-items: center;justify-content: left;align-self: stretch;' title={name}>");
emailContent.append("<span class='text'>");
emailContent.append(salaryBillSendParam.getRemarkI18n());
emailContent.append("</span>");
emailContent.append("</div>");
emailContent.append("<div style='min-height: 60px;flex: 8;padding-left: 16px;background: #ffffff;display: flex;align-items: center;justify-content: left;'>");
emailContent.append(salaryBillSendParam.getSalaryTemplate().getTextContent());
emailContent.append("</div>");
emailContent.append("</div>");
for (int i = 0; i < salaryItemSet.getItems().size(); i++) {
SalaryTemplateSalaryItemListDTO salaryItem = salaryItemSet.getItems().get(i);
for (Object keyName : e.keySet()) {
if ((salaryItem.getId() + SalaryArchiveConstant.DYNAMIC_SUFFIX).equals(keyName.toString())) {
boolean isHide = (isHideNull && e.get(keyName.toString()) != null) || (isHideZero && "0.00".equals(e.get(keyName.toString())));
// 4.2.薪资项目
emailContent.append("<div style='border: 1px solid #e5e5e5;border-bottom: none;width: 100%;display: flex;justify-content: flex-start;align-items: center;box-sizing: border-box;");
emailContent.append(i == (salaryItemSet.getItems().size() - 1) && salaryBillSendParam.getSalaryTemplate().getTextContentPosition() == SalaryTemplateTextContentPositionEnum.BEFORE.getValue() ? "border-bottom: 1px solid #e5e5e5;" : "");
emailContent.append((isHide ? "display: none" : ""));
emailContent.append("'>");
emailContent.append("<div style='min-height: 60px;padding: 0 16px;flex: 2;background: #fbfbfb;border-right: 1px solid #e5e5e5;display: flex;align-items: center;justify-content: left;' title={name}>");
emailContent.append("<span class='text'>");
emailContent.append(salaryItem.getName());
emailContent.append("</span>");
emailContent.append("</div>");
emailContent.append("<div style='min-height: 60px;flex: 8;padding-left: 16px;background: #ffffff;display: flex;align-items: center;justify-content: left;'>");
emailContent.append(e.get(keyName.toString()));
emailContent.append("</div>");
emailContent.append("</div>");
break;
}
}
}
// 5.文本内容-如果在薪资项目后
emailContent.append("<div style='border: 1px solid #e5e5e5;border-bottom: none;width: 100%;display: flex;justify-content: flex-start;align-items: center;box-sizing: border-box;");
emailContent.append(salaryBillSendParam.getSalaryTemplate().getTextContentPosition() == SalaryTemplateTextContentPositionEnum.AFTER.getValue() ? "border-bottom: 1px solid #e5e5e5;" : "display: none");
emailContent.append("'>");
emailContent.append("<div style='min-height: 60px;padding: 0 16px;flex: 2;background: #fbfbfb;border-right: 1px solid #e5e5e5;display: flex;align-items: center;justify-content: left;align-self: stretch;' title={name}>");
emailContent.append("<span class='text'>");
emailContent.append(salaryBillSendParam.getRemarkI18n());
emailContent.append("</span>");
emailContent.append("</div>");
emailContent.append("<div style='min-height: 60px;flex: 8;padding-left: 16px;background: #ffffff;display: flex;align-items: center;justify-content: left;'>");
emailContent.append(salaryBillSendParam.getSalaryTemplate().getTextContent());
emailContent.append("</div>");
emailContent.append("</div>");
emailContent.append("</div>");
emailContent.append("</div>");
}
emailContent.append("</div>");
}
}

View File

@ -10,10 +10,13 @@ import com.engine.salary.entity.salarysob.dto.SalarySobItemAggregateDTO;
import com.engine.salary.util.JsonUtil;
import com.engine.salary.util.SalaryI18nUtil;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import java.util.Date;
import java.util.LinkedList;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
/**
* @Description: 工资单
@ -25,6 +28,23 @@ public class SalaryTemplateBO {
return "SalaryTemplateBO{}";
}
/**
* 获取人员信息项目分类
*
* @param salaryItemSetting
* @return
*/
public static SalaryTemplateSalaryItemSetListDTO getEmployeeInformation(List<SalaryTemplateSalaryItemSetListDTO> salaryItemSetting) {
Optional<SalaryTemplateSalaryItemSetListDTO> optionalEmployeeInformation = salaryItemSetting.stream().filter(e -> SalaryTemplateSalaryItemSetGroupConstant.EMPLOYEE_INFO_GROUP_ID.equals(e.getGroupId())).findFirst();
SalaryTemplateSalaryItemSetListDTO employeeInformation = optionalEmployeeInformation.orElse(null);
// 排除名称为空的
if (employeeInformation != null && org.apache.commons.collections.CollectionUtils.isNotEmpty(employeeInformation.getItems())) {
employeeInformation.setItems(employeeInformation.getItems().stream().filter(e -> StringUtils.isNotEmpty(e.getName())).collect(Collectors.toList()));
}
return employeeInformation;
}
/**
* 保存参数转表数据
* @param saveParam

View File

@ -0,0 +1,87 @@
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 lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import weaver.hrm.User;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Set;
/**
* 工资单发放信息
* <p>Copyright: Copyright (c) 2022</p>
* <p>Company: 泛微软件</p>
*
* @author qiantao
* @version 1.0
**/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
//工资单发放信息
public class SalaryBillSendDTO {
/**
* 薪资所属月
*/
private Date salaryDate;
//消息标题
private String title;
//消息内容
private String text;
//工资单预览实体名
private String entityName;
//发送通道
private Set<MessageChannelEnum> sendChannels;
//发送者
private User sendUser;
//工资单模板
private SalaryTemplatePO salaryTemplate;
//工资单背景图base64编码
private String backgroundBase64;
//云桥工资单消息图
private String picUrl;
//扣缴义务人名称
private String taxAgentName;
//工资单模板-薪资项目设置
private List<SalaryTemplateSalaryItemSetListDTO> salaryItemSetList;
//工资单模板-员工基本信息
private SalaryTemplateSalaryItemSetListDTO employeeInformation;
//工资单模板-对应人员字段
private Map<String, String> employeeField;
//工资单模板-发放说明标签国际化
private String remarkI18n;
//邮件是否可以发送邮件
private boolean isEnableEmail;
//工资单发放
private SalarySendPO salarySend;
//收入所得项目类型
private List<String> incomeCategorys;
//薪资项目收入所得类型
private Map<String, String> salaryItemIncomeCategoryMap;
}

View File

@ -30,6 +30,7 @@ public class SalarySendInfoListDTO {
@TableTitle(title = "个税扣缴义务人", dataIndex = "taxAgent", key = "taxAgent")
private String taxAgent;
private Long taxAgentId;
@TableTitle(title = "部门", dataIndex = "department", key = "department")
@ -47,5 +48,12 @@ public class SalarySendInfoListDTO {
@TableTitle(title = "发送状态", dataIndex = "sendStatus", key = "sendStatus")
private String sendStatus;
private String email;
private Long salaryAcctRecordId;
/**
* 核算类型0正常1补发
*/
private Integer salaryAcctType;
}

View File

@ -7,7 +7,6 @@ import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.Collection;
import java.util.List;
/**
@ -23,7 +22,7 @@ import java.util.List;
public class SalarySendGrantParam {
// 主键id
private Collection<Long> ids;
private List<Long> ids;
// 工资单发放Id
private Long salarySendId;

View File

@ -1,39 +1,33 @@
package com.engine.salary.entity.salaryBill.param;
import com.engine.salary.exception.SalaryRunTimeException;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.Collection;
import java.util.List;
/**
* @Description: 工资单撤回参数
* @Author: wangxiangzhong
* @Date: 2021/12/13 16:18
*/
* 工资单发送参数
* <p>Copyright: Copyright (c) 2022</p>
* <p>Company: 泛微软件</p>
*
* @author qiantao
* @version 1.0
**/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
////"工资单撤回参数")
public class SalarySendWithdrawParam {
// 主键id")
private Collection<Long> ids;
// 主键id")
private List<Long> ids;
// 工资单发放Id")
// 工资单发放Id")
private Long salarySendId;
//发送范围
private List<Long> salarySendRangeIds;
public static String checkParam(SalarySendWithdrawParam param, Long employeeId, String tenantKey) {
if (param.getSalarySendId() == null) {
throw new SalaryRunTimeException("工资单发放Id必传");
}
return "";
}
}

View File

@ -20,101 +20,101 @@ import java.util.List;
@Builder
@NoArgsConstructor
@AllArgsConstructor
////"工资单模板保存参数")
//"工资单模板保存参数
public class SalaryTemplateSaveParam {
// 主键")
// 主键
private Long id;
// 模板名称")
// 模板名称
private String name;
// 薪资账套表的主键id")
// 薪资账套表的主键id
private Long salarySobId;
// 备注")
// 备注
private String description;
// 邮箱开启状态falsetrue")
// 邮箱开启状态falsetrue
private Boolean emailStatus;
// 发送地址")
// 发送地址
private Long sendEmail;
// 消息中心开启状态falsetrue")
// 消息中心开启状态falsetrue
private Boolean msgStatus;
// 主题")
// 主题
private String theme;
// 背景图")
// 背景图
private String background;
// 文本内容")
// 文本内容
private String textContent;
// 文本内容位置1薪资项目前2薪资项目后")
// 文本内容位置1薪资项目前2薪资项目后
private Integer textContentPosition;
// 薪资项为空时不显示开启状态falsetrue")
// 薪资项为空时不显示开启状态falsetrue
private Boolean salaryItemNullStatus;
// 薪资项为0时不显示开启状态falsetrue")
// 薪资项为0时不显示开启状态falsetrue
private Boolean salaryItemZeroStatus;
// 薪资项目设置")
// 薪资项目设置
private List<SalaryTemplateSalaryItemSetListDTO> salaryItemSetting;
// 补发工资单模板名称")
// 补发工资单模板名称
private String replenishName;
// 补发工资单名单生成规则")
// 补发工资单名单生成规则
private String replenishRule;
// 补发薪资项目设置")
// 补发薪资项目设置
private List<SalaryTemplateSalaryItemSetListDTO> replenishSalaryItemSetting;
public static void checkParam(SalaryTemplateSaveParam saveParam) {
if (saveParam.getSalarySobId() == null) {
throw new SalaryRunTimeException("薪资账套表的主键id必传");
throw new SalaryRunTimeException("薪资账套表的主键id必传;");
}
if (StringUtils.isEmpty(saveParam.getName())) {
throw new SalaryRunTimeException("工资单模板名称必填");
throw new SalaryRunTimeException("工资单模板名称必填;");
}
if (StringUtils.isEmpty(saveParam.getTheme())) {
throw new SalaryRunTimeException("工资单主题必填");
throw new SalaryRunTimeException("工资单主题必填;");
}
if (StringUtils.isEmpty(saveParam.getReplenishName())) {
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel( 139737, "补发工资单模板名称必填"));
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(139737, "补发工资单模板名称必填"));
}
if (saveParam.getName().equals(saveParam.getReplenishName())) {
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel( 140557, "工资单模板名称和补发工资单模板名称不可相同"));
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(140557, "工资单模板名称和补发工资单模板名称不可相同"));
}
if (StringUtils.isEmpty(saveParam.getReplenishRule())) {
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel( 139738, "补发工资单名单生成规则必填"));
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(139738, "补发工资单名单生成规则必填"));
}
if (saveParam.getEmailStatus() && saveParam.getSendEmail() == null) {
throw new SalaryRunTimeException("开启邮箱后,发送地址必选");
throw new SalaryRunTimeException("开启邮箱后,发送地址必选;");
}
if (StringUtils.isNotEmpty(saveParam.getTextContent()) && saveParam.getTextContentPosition() == null) {
throw new SalaryRunTimeException("文本内容不为空时,文本内容位置必选");
throw new SalaryRunTimeException("文本内容不为空时,文本内容位置必选;");
}
if (saveParam.getTextContentPosition() !=null && saveParam.getTextContentPosition().equals(SalaryTemplateTextContentPositionEnum.BEFORE.getValue()) && saveParam.getTextContentPosition().equals(SalaryTemplateTextContentPositionEnum.AFTER.getValue())) {
throw new SalaryRunTimeException("文本内容位置参数不对");
if (saveParam.getTextContentPosition() != null && saveParam.getTextContentPosition().equals(SalaryTemplateTextContentPositionEnum.BEFORE.getValue()) && saveParam.getTextContentPosition().equals(SalaryTemplateTextContentPositionEnum.AFTER.getValue())) {
throw new SalaryRunTimeException("文本内容位置参数不对;");
}
if (CollectionUtils.isEmpty(saveParam.getReplenishSalaryItemSetting())) {
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel( 140509, "补发工资单模板的薪资项目设置不能为空"));
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(140509, "补发工资单模板的薪资项目设置不能为空"));
}
}
}

View File

@ -8,25 +8,23 @@ import lombok.NoArgsConstructor;
import java.util.Date;
/**
* @Description: 工资单发放信息
* @Author: wangxiangzhong
* @Date: 2021-12-11 11:29
* 工资单发放信息
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
////hrsa_salary_send_info")
//工资单发放信息表")
//hrsa_salary_send_info
public class SalarySendInfoPO {
public Object get;
/**
* 主键id
*/
private Long id;
// 工资单发放id
/**
* 工资单发放id
*/
private Long salarySendId;
/**

View File

@ -47,19 +47,26 @@ public class SalaryTemplatePO {
private String description;
/**
* 邮箱开启状态01
* 消息中心开启状态01 ,默认开启
*/
private Integer msgStatus;
/**
* 邮箱开启状态01默认关闭
*/
private Integer emailStatus;
/**
* 发送地址:公共邮箱账号id
*/
private Long sendEmailId;
/**
* 消息中心开启状态01
* 短信开启状态01默认关闭
*/
private Integer msgStatus;
private Integer smsStatus;
/**
* 主题

View File

@ -1,39 +0,0 @@
//package com.engine.salary.entity.salaryacct.dto;
//
//import com.fasterxml.jackson.databind.annotation.JsonSerialize;
//import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
//import com.weaver.hrm.salary.common.WeaTableColumnWapper;
//import io.swagger.annotations.ApiModel;
//import io.swagger.annotations.ApiModelProperty;
//import lombok.AllArgsConstructor;
//import lombok.Builder;
//import lombok.Data;
//import lombok.NoArgsConstructor;
//
//import java.util.List;
//import java.util.Map;
//
///**
// * @description: 核算结果列表
// * @author: xiajun
// * @modified By: xiajun
// * @date: Created in 12/6/21 6:53 PM
// * @version:v1.0
// */
//@Data
//@Builder
//@NoArgsConstructor
//@AllArgsConstructor
////"核算结果列表")
//public class SalaryAccResultListDTO {
//
// //动态表头")
// private List<WeaTableColumnWapper> columns;
//
// //列表数据")
// private List<Map<String, Object>> data;
//
// @JsonSerialize(using = ToStringSerializer.class)
// //列表总数")
// private Long total;
//}

View File

@ -1,24 +0,0 @@
//package com.engine.salary.entity.salaryacct.dto;
//
//import io.swagger.annotations.ApiModelProperty;
//import lombok.AllArgsConstructor;
//import lombok.Builder;
//import lombok.Data;
//import lombok.NoArgsConstructor;
//
///**
// * @description: 薪资核算
// * @author: xiajun
// * @modified By: xiajun
// * @date: Created in 12/16/21 8:40 PM
// * @version:v1.0
// */
//@Data
//@Builder
//@NoArgsConstructor
//@AllArgsConstructor
//public class SalaryAcctDTO {
//
// //是否正在核算")
// private boolean acctInProgress;
//}

View File

@ -0,0 +1,73 @@
package com.engine.salary.enums.salarybill;
import com.engine.salary.enums.BaseEnum;
import java.util.Arrays;
/**
* 消息通道
* <p>Copyright: Copyright (c) 2022</p>
* <p>Company: 泛微软件</p>
*
* @author qiantao
* @version 1.0
**/
public enum MessageChannelEnum implements BaseEnum<Integer> {
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 "";
}
}

View File

@ -6,7 +6,7 @@ import com.engine.salary.entity.datacollection.DataCollectionEmployee;
import com.engine.salary.entity.datacollection.dto.AttendQuoteFieldListDTO;
import com.engine.salary.entity.salaryacct.bo.SalaryAcctCalculateBO;
import com.engine.salary.entity.salaryacct.bo.SalaryAcctCalculatePriorityBO;
import com.engine.salary.entity.salaryacct.dto.SalaryAcctProgressDTO;
import com.engine.salary.entity.progress.ProgressDTO;
import com.engine.salary.entity.salaryacct.po.SalaryAcctEmployeePO;
import com.engine.salary.entity.salaryacct.po.SalaryAcctRecordPO;
import com.engine.salary.entity.salaryacct.po.SalaryAcctResultPO;
@ -109,8 +109,8 @@ public class SalaryAcctManager extends Service {
return ServiceUtil.getService(SalaryAcctCalculateServiceImpl.class, user);
}
private SalaryAcctProgressService getSalaryAcctProgressService(User user) {
return ServiceUtil.getService(SalaryAcctProgressServiceImpl.class, user);
private ProgressService getSalaryAcctProgressService(User user) {
return ServiceUtil.getService(ProgressServiceImpl.class, user);
}
private DataSourceTransactionManager dataSourceTransactionManager;
@ -202,12 +202,12 @@ public class SalaryAcctManager extends Service {
simpleEmployee.setEmployeeId((long) user.getUID());
// 检查是否正在核算中
SalaryAcctProgressDTO salaryAcctProgressDTO = getSalaryAcctProgressService(user).getProgress("SUPPLEMENT_ACCT_PROGRESS_" + salaryAcctRecordId);
ProgressDTO salaryAcctProgressDTO = getSalaryAcctProgressService(user).getProgress("SUPPLEMENT_ACCT_PROGRESS_" + salaryAcctRecordId);
if (Objects.nonNull(salaryAcctProgressDTO) && salaryAcctProgressDTO.isStatus() && Optional.ofNullable(salaryAcctProgressDTO.getProgress()).orElse(BigDecimal.ZERO).compareTo(BigDecimal.ONE) < 0) {
return;
}
// 初始化进度
SalaryAcctProgressDTO initProgress = new SalaryAcctProgressDTO()
ProgressDTO initProgress = new ProgressDTO()
.setTitle(SalaryI18nUtil.getI18nLabel(97515, "核算中"))
.setTitleLabelId(97515L)
.setTotalQuantity(NumberUtils.INTEGER_ONE)
@ -297,7 +297,7 @@ public class SalaryAcctManager extends Service {
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(103378, "薪资核算人员不能为空"));
}
// 11.1初始化进度
SalaryAcctProgressDTO initProgress = new SalaryAcctProgressDTO().setTitle(SalaryI18nUtil.getI18nLabel(97515, "核算中")).setTitleLabelId(97515L).setTotalQuantity(salaryAcctEmployeePOS.size() * 2 + 1).setCalculatedQuantity(0).setProgress(BigDecimal.ZERO).setStatus(true).setMessage(StringUtils.EMPTY);
ProgressDTO initProgress = new ProgressDTO().setTitle(SalaryI18nUtil.getI18nLabel(97515, "核算中")).setTitleLabelId(97515L).setTotalQuantity(salaryAcctEmployeePOS.size() * 2 + 1).setCalculatedQuantity(0).setProgress(BigDecimal.ZERO).setStatus(true).setMessage(StringUtils.EMPTY);
getSalaryAcctProgressService(user).initProgress("SUPPLEMENT_ACCT_PROGRESS_" + salaryAcctRecordId, initProgress);
// 12对薪资核算人员进行拆分
List<List<SalaryAcctEmployeePO>> partition = Lists.partition(salaryAcctEmployeePOS, 5000);

View File

@ -14,6 +14,7 @@
<result column="update_time" property="updateTime"/>
<result column="delete_type" property="deleteType"/>
<result column="tenant_key" property="tenantKey"/>
<result column="back_calc_status" property="backCalcStatus"/>
<result column="lock_salary_item_ids" property="lockSalaryItemIds" typeHandler="com.engine.salary.handle.SalaryListTypeHandler"/>
</resultMap>

View File

@ -157,6 +157,9 @@
<sql id="salarySendInfoColumn">
t1.id,
t1.salary_acct_record_id as salaryAcctRecordId,
t1.salary_acct_type as salaryAcctType,
t1.tax_agent_id as taxAgentId,
e.lastname as username,
t2.name AS tax_agent,
d.departmentname AS department,

View File

@ -9,6 +9,7 @@
<result column="use_type" property="useType"/>
<result column="description" property="description"/>
<result column="email_status" property="emailStatus"/>
<result column="sms_status" property="smsStatus"/>
<result column="send_email_id" property="sendEmailId"/>
<result column="msg_status" property="msgStatus"/>
<result column="theme" property="theme"/>
@ -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 @@
<if test="emailStatus != null">
email_status=#{emailStatus},
</if>
<if test="smsStatus != null">
sms_status=#{smsStatus},
</if>
<if test="sendEmailId != null">
send_email_id=#{sendEmailId},
</if>
@ -433,6 +439,9 @@
<if test="msgStatus != null">
msg_status,
</if>
<if test="smsStatus != null">
sms_status,
</if>
<if test="theme != null">
theme,
</if>
@ -504,6 +513,9 @@
<if test="msgStatus != null">
#{msgStatus},
</if>
<if test="smsStatus != null">
#{smsStatus},
</if>
<if test="theme != null">
#{theme},
</if>
@ -585,6 +597,9 @@
<if test="msgStatus != null">
msg_status,
</if>
<if test="smsStatus != null">
sms_status,
</if>
<if test="theme != null">
theme,
</if>
@ -656,6 +671,9 @@
<if test="msgStatus != null">
#{msgStatus},
</if>
<if test="smsStatus != null">
#{smsStatus},
</if>
<if test="theme != null">
#{theme},
</if>

View File

@ -93,13 +93,13 @@ public class SalaryStatisticsReportServiceImpl extends Service implements Salary
}
// private ExtEmployeeService extEmployeeService;
// @Autowired
//
// private HrmCommonEmployeeService hrmCommonEmployeeService;
// @RpcReference
//
// private HrmJobCallRemoteService hrmJobCallRemoteService;
// @RpcReference
//
// private RemoteUserInfoService remoteUserInfoService;
// @Autowired
//
// private HrmCommonHrmStatusService hrmCommonHrmStatusService;
// (name = "salaryStatReportLoggerTemplate")
// private LoggerTemplate salaryStatReportLoggerTemplate;

View File

@ -8,7 +8,7 @@ public class SubTableExportServiceImpl extends Service implements SubTableExport
// private Logger logger = LoggerFactory.getLogger(this.getClass());
//
// @Autowired
//
// private SalaryBatchService salaryBatchService;
//
// @Override

View File

@ -1,18 +1,18 @@
package com.engine.salary.service;
import com.engine.salary.entity.salaryacct.dto.SalaryAcctProgressDTO;
import com.engine.salary.entity.progress.ProgressDTO;
import java.math.BigDecimal;
/**
* 核算进度
* 进度
* <p>Copyright: Copyright (c) 2022</p>
* <p>Company: 泛微软件</p>
*
* @author qiantao
* @version 1.0
**/
public interface SalaryAcctProgressService {
public interface ProgressService {
/**
* 初始化核算进度条
@ -20,7 +20,7 @@ public interface SalaryAcctProgressService {
* @param salaryAcctProgress
* @return
*/
void initProgress(String cacheKey, SalaryAcctProgressDTO salaryAcctProgress);
void initProgress(String cacheKey, ProgressDTO salaryAcctProgress);
/**
* 更新进度条
@ -31,7 +31,12 @@ public interface SalaryAcctProgressService {
void getAndAddCalculatedQty(String cacheKey, Integer calculatedQuantity);
//
/**
* 更新进度条
* @param cacheKey
* @param calculatedQuantity
* @param message
*/
void getAndAddCalculatedQty(String cacheKey, Integer calculatedQuantity, String message);
/**
@ -50,6 +55,14 @@ public interface SalaryAcctProgressService {
*/
void finish(String cacheKey, boolean checkStatus);
/**
* 完成
* @param cacheKey
* @param checkStatus
* @param message
*/
void finish(String cacheKey, boolean checkStatus,String message);
/**
* 更新进度条
*
@ -61,7 +74,7 @@ public interface SalaryAcctProgressService {
* 获取进度条
* @return
*/
SalaryAcctProgressDTO getProgress(String cacheKey);
ProgressDTO getProgress(String cacheKey);
/**
* 删除redis中的缓存
@ -69,5 +82,5 @@ public interface SalaryAcctProgressService {
* @param cacheKey
* @return
*/
SalaryAcctProgressDTO del(String cacheKey);
ProgressDTO del(String cacheKey);
}

View File

@ -0,0 +1,63 @@
package com.engine.salary.service;
import com.engine.salary.entity.salaryBill.param.SalarySendGrantParam;
import java.util.List;
import java.util.Map;
/**
* 工资单
* <p>Copyright: Copyright (c) 2022</p>
* <p>Company: 泛微软件</p>
*
* @author qiantao
* @version 1.0
**/
public interface SalaryBillService {
/**
* 工资单发放
*
* @param queryParam
*/
Map<String, Object> grant(SalarySendGrantParam queryParam);
/**
* 获取内容
* @param sendId
* @param ids
* @return
*/
List<Map<String, Object>> getSendInfoList(Long sendId, List<Long> ids);
/**
* 工资单撤回
*
* @param queryParam
* @param isRange
* @param rangeIds
* @param currentEmployeeId
* @param currentTenantKey
*/
// void withdraw(SalarySendWithdrawParam queryParam, boolean isRange, List<Long> rangeIds);
/**
* 我的工资单
*
* @param salaryInfoId
* @param currentEmployeeId
* @param currentTenantKey
* @return
*/
// Map<String, Object> mySalaryBill(Long salaryInfoId);
/**
* 我的工资单列表详情
*
* @param page
* @param queryParam
* @param tenantKey
* @return
*/
// Page<SalaryMySalaryBillListDTO> mySalaryBillListPage(Page<SalaryMySalaryBillListDTO> page, SalaryBillQueryParam queryParam, String tenantKey);
}

View File

@ -4,7 +4,9 @@ import com.engine.salary.entity.salaryBill.dto.*;
import com.engine.salary.entity.salaryBill.param.*;
import com.engine.salary.entity.salaryBill.po.SalarySendPO;
import com.engine.salary.entity.salaryBill.po.SalaryTemplatePO;
import com.engine.salary.entity.salaryacct.po.SalaryAcctEmployeePO;
import com.engine.salary.entity.salaryacct.po.SalaryAcctRecordPO;
import com.engine.salary.entity.salaryacct.po.SalaryAcctResultPO;
import com.engine.salary.util.page.PageInfo;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
@ -121,6 +123,15 @@ public interface SalarySendService {
*/
List<Map<String, Object>> buildDetailList(List<SalaryTemplateSalaryItemListDTO> salaryItems, List<SalarySendDetailListDTO> records, Long salaryAccountingId);
/**
* 构建详情列表
*
* @param records
* @param salaryAcctResultValues
* @return
*/
List<Map<String, Object>> buildDetailList(List<SalarySendInfoListDTO> records,List<SalaryAcctEmployeePO> salaryAcctEmployees, List<SalaryAcctResultPO> salaryAcctResultValues);
/**
* 导出-工资单发放详情列表
*

View File

@ -52,9 +52,9 @@ public class AttendQuoteFieldServiceImpl extends Service implements AttendQuoteF
}
// @RpcReference
//
// private RemoteAttendInitVacationService remoteAttendInitVacationService;
// @Autowired
//
// private LoggerTemplate attendQuoteFieldLoggerTemplate;

View File

@ -49,7 +49,7 @@ public class AttendQuoteFieldSettingServiceImpl extends Service implements Atten
// private AttendQuoteFieldSettingMapper mapper;
//
// private AttendQuoteFieldMapper attendQuoteFieldMapper;
// @Autowired
//
// private LoggerTemplate attendQuoteFieldSettingLoggerTemplate;
private AttendQuoteFieldService getAttendQuoteFieldService(User user) {
return (AttendQuoteFieldService) ServiceUtil.getService(AttendQuoteFieldServiceImpl.class, user);

View File

@ -0,0 +1,145 @@
package com.engine.salary.service.impl;
import com.cloudstore.dev.api.util.Util_DataCache;
import com.engine.core.impl.Service;
import com.engine.salary.entity.progress.ProgressDTO;
import com.engine.salary.service.ProgressService;
import com.engine.salary.util.JsonUtil;
import org.apache.commons.lang3.StringUtils;
import weaver.wechat.util.Utils;
import java.math.BigDecimal;
import java.math.RoundingMode;
/**
* 进度条
* <p>Copyright: Copyright (c) 2022</p>
* <p>Company: 泛微软件</p>
*
* @author qiantao
* @version 1.0
**/
public class ProgressServiceImpl extends Service implements ProgressService {
@Override
public void initProgress(String cacheKey, ProgressDTO progressDTO) {
Util_DataCache.setObjVal(cacheKey, JsonUtil.toJsonString(progressDTO));
}
@Override
public synchronized void getAndAddCalculatedQty(String cacheKey, Integer calculatedQuantity) {
String resultStr = (String) Util_DataCache.getObjVal(cacheKey);
if (StringUtils.isNotEmpty(resultStr)) {
ProgressDTO progressDTO = JsonUtil.parseObject(resultStr, ProgressDTO.class);
if (progressDTO == null || !progressDTO.isStatus()) {
return;
}
Integer currentCalculatedQuantity = progressDTO.getCalculatedQuantity() + calculatedQuantity;
progressDTO.setCalculatedQuantity(
currentCalculatedQuantity > progressDTO.getTotalQuantity() ? progressDTO.getTotalQuantity() : currentCalculatedQuantity);
BigDecimal progress = BigDecimal.valueOf(progressDTO.getCalculatedQuantity())
.divide(BigDecimal.valueOf(progressDTO.getTotalQuantity()), 4, RoundingMode.HALF_DOWN);
progressDTO.setProgress(progress.compareTo(BigDecimal.ONE) > 0 ? BigDecimal.ONE : progress);
Util_DataCache.setObjVal(cacheKey, JsonUtil.toJsonString(progressDTO));
}
}
@Override
public synchronized void getAndAddCalculatedQty(String cacheKey, Integer calculatedQuantity, String message) {
String resultStr = (String) Util_DataCache.getObjVal(cacheKey);
if (StringUtils.isNotEmpty(resultStr)) {
ProgressDTO progressDTO = JsonUtil.parseObject(resultStr, ProgressDTO.class);
if (progressDTO == null || (progressDTO.isStatus())) {
return;
}
Integer currentCalculatedQuantity = progressDTO.getCalculatedQuantity() + calculatedQuantity;
progressDTO.setCalculatedQuantity(
currentCalculatedQuantity > progressDTO.getTotalQuantity() ? progressDTO.getTotalQuantity() : currentCalculatedQuantity);
BigDecimal progress = BigDecimal.valueOf(progressDTO.getCalculatedQuantity())
.divide(BigDecimal.valueOf(progressDTO.getTotalQuantity()), 4, RoundingMode.HALF_DOWN);
progressDTO.setProgress(progress.compareTo(BigDecimal.ONE) > 0 ? BigDecimal.ONE : progress);
if (StringUtils.isNotBlank(message)) {
progressDTO.setMessage(Utils.null2String(progressDTO.getMessage()) + message);
}
Util_DataCache.setObjVal(cacheKey, JsonUtil.toJsonString(progressDTO));
}
}
@Override
public void fail(String cacheKey, String message) {
ProgressDTO progressDTO = new ProgressDTO();
progressDTO.setStatus(false);
progressDTO.setMessage(message);
progressDTO.setCheckStatus(true);
Util_DataCache.setObjVal(cacheKey, JsonUtil.toJsonString(progressDTO));
}
@Override
public void finish(String cacheKey, boolean checkStatus) {
String resultStr = (String) Util_DataCache.getObjVal(cacheKey);
if (StringUtils.isNotEmpty(resultStr)) {
ProgressDTO progressDTO = JsonUtil.parseObject(resultStr, ProgressDTO.class);
if (progressDTO == null || !progressDTO.isStatus()) {
return;
}
progressDTO.setTitle("操作完成");
progressDTO.setCalculatedQuantity(progressDTO.getTotalQuantity());
progressDTO.setProgress(BigDecimal.ONE);
progressDTO.setCheckStatus(checkStatus);
Util_DataCache.setObjVal(cacheKey, JsonUtil.toJsonString(progressDTO));
}
}
@Override
public void finish(String cacheKey, boolean checkStatus, String message) {
String resultStr = (String) Util_DataCache.getObjVal(cacheKey);
if (StringUtils.isNotEmpty(resultStr)) {
ProgressDTO progressDTO = JsonUtil.parseObject(resultStr, ProgressDTO.class);
if (progressDTO == null || !progressDTO.isStatus()) {
return;
}
progressDTO.setTitle("操作完成");
progressDTO.setCalculatedQuantity(progressDTO.getTotalQuantity());
progressDTO.setProgress(BigDecimal.ONE);
progressDTO.setCheckStatus(checkStatus);
progressDTO.setMessage(message);
Util_DataCache.setObjVal(cacheKey, JsonUtil.toJsonString(progressDTO));
}
}
@Override
public void updateProgress(String cacheKey, BigDecimal progress, boolean checkStatus) {
String resultStr = (String) Util_DataCache.getObjVal(cacheKey);
if (StringUtils.isNotEmpty(resultStr)) {
ProgressDTO progressDTO = JsonUtil.parseObject(resultStr, ProgressDTO.class);
if (progressDTO == null || !progressDTO.isStatus()) {
return;
}
progressDTO.setTitle("处理中");
progressDTO.setCalculatedQuantity(progressDTO.getTotalQuantity());
progressDTO.setProgress(progress);
progressDTO.setCheckStatus(checkStatus);
Util_DataCache.setObjVal(cacheKey, JsonUtil.toJsonString(progressDTO));
}
}
@Override
public ProgressDTO getProgress(String cacheKey) {
String resultStr = (String) Util_DataCache.getObjVal(cacheKey);
if (StringUtils.isEmpty(resultStr)) {
return null;
}
return JsonUtil.parseObject(resultStr, ProgressDTO.class);
}
@Override
public ProgressDTO del(String cacheKey) {
Util_DataCache.clearVal(cacheKey);
ProgressDTO salaryAcctProgressDTO = new ProgressDTO();
salaryAcctProgressDTO.setMessage("操作失败");
salaryAcctProgressDTO.setStatus(false);
return salaryAcctProgressDTO;
}
}

View File

@ -97,8 +97,8 @@ public class SalaryAcctCalculateServiceImpl extends Service implements SalaryAcc
return (SalaryAcctResultTempService) ServiceUtil.getService(SalaryAcctResultTempServiceImpl.class, user);
}
private SalaryAcctProgressService getSalaryAcctProgressService(User user) {
return (SalaryAcctProgressService) ServiceUtil.getService(SalaryAcctProgressServiceImpl.class, user);
private ProgressService getSalaryAcctProgressService(User user) {
return (ProgressService) ServiceUtil.getService(ProgressServiceImpl.class, user);
}
private SalaryAcctEmployeeService getSalaryAcctEmployeeService(User user) {

View File

@ -1,128 +0,0 @@
package com.engine.salary.service.impl;
import com.cloudstore.dev.api.util.Util_DataCache;
import com.engine.core.impl.Service;
import com.engine.salary.entity.salaryacct.dto.SalaryAcctProgressDTO;
import com.engine.salary.service.SalaryAcctProgressService;
import com.engine.salary.util.JsonUtil;
import org.apache.commons.lang3.StringUtils;
import weaver.wechat.util.Utils;
import java.math.BigDecimal;
import java.math.RoundingMode;
/**
* 核算进度条
* <p>Copyright: Copyright (c) 2022</p>
* <p>Company: 泛微软件</p>
*
* @author qiantao
* @version 1.0
**/
public class SalaryAcctProgressServiceImpl extends Service implements SalaryAcctProgressService {
@Override
public void initProgress(String cacheKey, SalaryAcctProgressDTO salaryAcctProgress) {
Util_DataCache.setObjVal(cacheKey, JsonUtil.toJsonString(salaryAcctProgress));
}
@Override
public synchronized void getAndAddCalculatedQty(String cacheKey, Integer calculatedQuantity) {
String resultStr = (String) Util_DataCache.getObjVal(cacheKey);
if (StringUtils.isNotEmpty(resultStr)) {
SalaryAcctProgressDTO salaryAcctProgress = JsonUtil.parseObject(resultStr, SalaryAcctProgressDTO.class);
if (salaryAcctProgress == null || !salaryAcctProgress.isStatus()) {
return;
}
Integer currentCalculatedQuantity = salaryAcctProgress.getCalculatedQuantity() + calculatedQuantity;
salaryAcctProgress.setCalculatedQuantity(
currentCalculatedQuantity > salaryAcctProgress.getTotalQuantity() ? salaryAcctProgress.getTotalQuantity() : currentCalculatedQuantity);
BigDecimal progress = BigDecimal.valueOf(salaryAcctProgress.getCalculatedQuantity())
.divide(BigDecimal.valueOf(salaryAcctProgress.getTotalQuantity()), 4, RoundingMode.HALF_DOWN);
salaryAcctProgress.setProgress(progress.compareTo(BigDecimal.ONE) > 0 ? BigDecimal.ONE : progress);
Util_DataCache.setObjVal(cacheKey, JsonUtil.toJsonString(salaryAcctProgress));
}
}
@Override
public synchronized void getAndAddCalculatedQty(String cacheKey, Integer calculatedQuantity, String message) {
String resultStr = (String) Util_DataCache.getObjVal(cacheKey);
if (StringUtils.isNotEmpty(resultStr)) {
SalaryAcctProgressDTO salaryAcctProgress = JsonUtil.parseObject(resultStr, SalaryAcctProgressDTO.class);
if (salaryAcctProgress == null || !salaryAcctProgress.isStatus()) {
return;
}
Integer currentCalculatedQuantity = salaryAcctProgress.getCalculatedQuantity() + calculatedQuantity;
salaryAcctProgress.setCalculatedQuantity(
currentCalculatedQuantity > salaryAcctProgress.getTotalQuantity() ? salaryAcctProgress.getTotalQuantity() : currentCalculatedQuantity);
BigDecimal progress = BigDecimal.valueOf(salaryAcctProgress.getCalculatedQuantity())
.divide(BigDecimal.valueOf(salaryAcctProgress.getTotalQuantity()), 4, RoundingMode.HALF_DOWN);
salaryAcctProgress.setProgress(progress.compareTo(BigDecimal.ONE) > 0 ? BigDecimal.ONE : progress);
if (StringUtils.isNotBlank(message)) {
salaryAcctProgress.setMessage(Utils.null2String(salaryAcctProgress.getMessage()) + message);
}
Util_DataCache.setObjVal(cacheKey, JsonUtil.toJsonString(salaryAcctProgress));
}
}
@Override
public void fail(String cacheKey, String message) {
SalaryAcctProgressDTO salaryAcctProgress = new SalaryAcctProgressDTO();
salaryAcctProgress.setStatus(false);
salaryAcctProgress.setMessage(message);
salaryAcctProgress.setCheckStatus(true);
Util_DataCache.setObjVal(cacheKey, JsonUtil.toJsonString(salaryAcctProgress));
}
@Override
public void finish(String cacheKey, boolean checkStatus) {
String resultStr = (String) Util_DataCache.getObjVal(cacheKey);
if (StringUtils.isNotEmpty(resultStr)) {
SalaryAcctProgressDTO salaryAcctProgress = JsonUtil.parseObject(resultStr, SalaryAcctProgressDTO.class);
if (salaryAcctProgress == null || !salaryAcctProgress.isStatus()) {
return;
}
salaryAcctProgress.setTitle("核算完成");
salaryAcctProgress.setCalculatedQuantity(salaryAcctProgress.getTotalQuantity());
salaryAcctProgress.setProgress(BigDecimal.ONE);
salaryAcctProgress.setCheckStatus(checkStatus);
Util_DataCache.setObjVal(cacheKey, JsonUtil.toJsonString(salaryAcctProgress));
}
}
@Override
public void updateProgress(String cacheKey, BigDecimal progress, boolean checkStatus) {
String resultStr = (String) Util_DataCache.getObjVal(cacheKey);
if (StringUtils.isNotEmpty(resultStr)) {
SalaryAcctProgressDTO salaryAcctProgress = JsonUtil.parseObject(resultStr, SalaryAcctProgressDTO.class);
if (salaryAcctProgress == null || !salaryAcctProgress.isStatus()) {
return;
}
salaryAcctProgress.setTitle("核算中");
salaryAcctProgress.setCalculatedQuantity(salaryAcctProgress.getTotalQuantity());
salaryAcctProgress.setProgress(progress);
salaryAcctProgress.setCheckStatus(checkStatus);
Util_DataCache.setObjVal(cacheKey, JsonUtil.toJsonString(salaryAcctProgress));
}
}
@Override
public SalaryAcctProgressDTO getProgress(String cacheKey) {
String resultStr = (String) Util_DataCache.getObjVal(cacheKey);
if (StringUtils.isEmpty(resultStr)) {
return null;
}
return JsonUtil.parseObject(resultStr, SalaryAcctProgressDTO.class);
}
@Override
public SalaryAcctProgressDTO del(String cacheKey) {
Util_DataCache.clearVal(cacheKey);
SalaryAcctProgressDTO salaryAcctProgressDTO = new SalaryAcctProgressDTO();
salaryAcctProgressDTO.setMessage("核算失败");
salaryAcctProgressDTO.setStatus(false);
return salaryAcctProgressDTO;
}
}

View File

@ -11,7 +11,7 @@ import com.engine.salary.entity.report.bo.SalaryAcctResultReportBO;
import com.engine.salary.entity.report.po.SalaryAcctResultReportPO;
import com.engine.salary.entity.salaryacct.bo.*;
import com.engine.salary.entity.salaryacct.dto.ConsolidatedTaxDetailDTO;
import com.engine.salary.entity.salaryacct.dto.SalaryAcctProgressDTO;
import com.engine.salary.entity.progress.ProgressDTO;
import com.engine.salary.entity.salaryacct.dto.SalaryAcctResultDetailDTO;
import com.engine.salary.entity.salaryacct.dto.SalaryAcctResultListColumnDTO;
import com.engine.salary.entity.salaryacct.param.*;
@ -124,8 +124,8 @@ public class SalaryAcctResultServiceImpl extends Service implements SalaryAcctRe
return ServiceUtil.getService(SalaryAcctCalculateServiceImpl.class, user);
}
private SalaryAcctProgressService getSalaryAcctProgressService(User user) {
return ServiceUtil.getService(SalaryAcctProgressServiceImpl.class, user);
private ProgressService getSalaryAcctProgressService(User user) {
return ServiceUtil.getService(ProgressServiceImpl.class, user);
}
private DataSourceTransactionManager dataSourceTransactionManager;
@ -731,7 +731,7 @@ public class SalaryAcctResultServiceImpl extends Service implements SalaryAcctRe
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(103378, "薪资核算人员不能为空"));
}
// 11.1初始化进度
SalaryAcctProgressDTO initProgress = new SalaryAcctProgressDTO().setTitle(SalaryI18nUtil.getI18nLabel(97515, "核算中")).setTitleLabelId(97515L).setTotalQuantity(salaryAcctEmployeePOS.size() * 2 + 1).setCalculatedQuantity(0).setProgress(BigDecimal.ZERO).setStatus(true).setMessage(StringUtils.EMPTY);
ProgressDTO initProgress = new ProgressDTO().setTitle(SalaryI18nUtil.getI18nLabel(97515, "核算中")).setTitleLabelId(97515L).setTotalQuantity(salaryAcctEmployeePOS.size() * 2 + 1).setCalculatedQuantity(0).setProgress(BigDecimal.ZERO).setStatus(true).setMessage(StringUtils.EMPTY);
getSalaryAcctProgressService(user).initProgress(SalaryCacheKey.ACCT_PROGRESS + calculateParam.getSalaryAcctRecordId(), initProgress);
// 12对薪资核算人员进行拆分
List<List<SalaryAcctEmployeePO>> partition = Lists.partition(salaryAcctEmployeePOS, 5000);

View File

@ -98,9 +98,9 @@ public class SalaryArchiveExcelServiceImpl extends Service implements SalaryArch
// private SalaryArchiveSobService salaryArchiveSobService;
//
// private SalaryEmployeeService salaryEmployeeService;
// @Autowired
//
// private HrmCommonHrmStatusService hrmCommonHrmStatusService;
// @Autowired
//
// private BaseEnvInfoService baseEnvInfoService;
// @Override

View File

@ -0,0 +1,990 @@
package com.engine.salary.service.impl;
import com.alibaba.fastjson.JSONArray;
import com.api.formmode.mybatis.util.SqlProxyHandle;
import com.engine.common.util.ServiceUtil;
import com.engine.core.impl.Service;
import com.engine.salary.biz.SalarySendBiz;
import com.engine.salary.biz.SalarySendInfoBiz;
import com.engine.salary.cache.SalaryCacheKey;
import com.engine.salary.entity.datacollection.DataCollectionEmployee;
import com.engine.salary.entity.progress.ProgressDTO;
import com.engine.salary.entity.salaryBill.bo.SalaryBillBO;
import com.engine.salary.entity.salaryBill.bo.SalaryTemplateBO;
import com.engine.salary.entity.salaryBill.dto.SalaryBillSendDTO;
import com.engine.salary.entity.salaryBill.dto.SalarySendInfoListDTO;
import com.engine.salary.entity.salaryBill.dto.SalaryTemplateSalaryItemSetListDTO;
import com.engine.salary.entity.salaryBill.param.SalarySendGrantParam;
import com.engine.salary.entity.salaryBill.param.SalarySendInfoQueryParam;
import com.engine.salary.entity.salaryBill.po.SalarySendInfoPO;
import com.engine.salary.entity.salaryBill.po.SalarySendPO;
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.salarysend.SalarySendGrantTypeEnum;
import com.engine.salary.exception.SalaryRunTimeException;
import com.engine.salary.mapper.salarybill.SalarySendInfoMapper;
import com.engine.salary.mapper.salarybill.SalarySendMapper;
import com.engine.salary.service.*;
import com.engine.salary.util.JsonUtil;
import com.engine.salary.util.SalaryEntityUtil;
import com.engine.salary.util.SalaryI18nUtil;
import com.google.common.collect.Lists;
import com.weaver.util.threadPool.ThreadPoolUtil;
import com.weaver.util.threadPool.constant.ModulePoolEnum;
import com.weaver.util.threadPool.entity.LocalRunnable;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.beanutils.BeanUtils;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.math.NumberUtils;
import weaver.hrm.User;
import java.lang.reflect.InvocationTargetException;
import java.math.BigDecimal;
import java.util.*;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;
/**
* 工资单发放
* <p>Copyright: Copyright (c) 2022</p>
* <p>Company: 泛微软件</p>
*
* @author qiantao
* @version 1.0
**/
@Slf4j
public class SalaryBillServiceImpl extends Service implements SalaryBillService {
private SalarySendMapper getSalarySendMapper() {
return SqlProxyHandle.getProxy(SalarySendMapper.class);
}
private SalarySendInfoMapper getSalarySendInfoMapper() {
return SqlProxyHandle.getProxy(SalarySendInfoMapper.class);
}
private SalaryTemplateService getSalaryTemplateService(User user) {
return ServiceUtil.getService(SalaryTemplateServiceImpl.class, user);
}
private SalarySendService getSalarySendService(User user) {
return ServiceUtil.getService(SalarySendServiceImpl.class, user);
}
private SalarySobService getSalarySobService(User user) {
return ServiceUtil.getService(SalarySobServiceImpl.class, user);
}
private SalaryAcctResultService getSalaryAcctResultService(User user) {
return ServiceUtil.getService(SalaryAcctResultServiceImpl.class, user);
}
private SalaryAcctEmployeeService getSalaryAcctEmployeeService(User user) {
return ServiceUtil.getService(SalaryAcctEmployeeServiceImpl.class, user);
}
private TaxAgentService getTaxAgentService(User user) {
return ServiceUtil.getService(TaxAgentServiceImpl.class, user);
}
private SalarySendRangeService getSalarySendRangeService(User user) {
return ServiceUtil.getService(SalarySendRangeServiceImpl.class, user);
}
private SalaryAcctRecordService getSalaryAcctRecordService(User user) {
return ServiceUtil.getService(SalaryAcctRecordServiceImpl.class, user);
}
private SalaryEmployeeService getSalaryEmployeeService(User user) {
return ServiceUtil.getService(SalaryEmployeeServiceImpl.class, user);
}
private SalarySendInfoBiz salarySendInfoMapper = new SalarySendInfoBiz();
private SalarySendBiz mapper = new SalarySendBiz();
private SalaryEmployeeService salaryEmployeeService;
private SalarySobItemService salarySobItemService;
private ProgressService getProgressService(User user) {
return ServiceUtil.getService(ProgressServiceImpl.class, user);
}
/**
* 工资单发放 start
**********************************************************************/
@Override
public Map<String, Object> grant(SalarySendGrantParam param) {
// 1.检查和获取工资单发放
SalarySendPO salarySend = checkAndGetSalarySend(param.getSalarySendId());
// // 已经冻结不能操作
// if (salarySend.getSendStatus().equals(NumberUtils.INTEGER_ONE)) {
// return;
// }
// 获取默认模板
SalarySobPO salarySob = getSalarySobService(user).getById(salarySend.getSalarySobId());
List<SalaryTemplatePO> salaryTemplates = salarySob == null ? Lists.newArrayList() : getSalaryTemplateService(user).getDefaultTemplates(Arrays.asList(salarySend.getSalarySobId(), salarySob.getId()));
if (CollectionUtils.isEmpty(salaryTemplates)) {
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100518, "没有默认模板,无法发送"));
}
SalaryTemplatePO salaryTemplate = salaryTemplates.get(0);
// 发送通道
Set<MessageChannelEnum> 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.检查是否正在发送中
ProgressDTO salaryBillProgress = getProgressService(user).getProgress(SalaryCacheKey.SALARY_GRANT_PROGRESS + "_" + param.getSalarySendId());
if (Objects.nonNull(salaryBillProgress) && salaryBillProgress.isStatus()
&& Optional.ofNullable(salaryBillProgress.getProgress()).orElse(BigDecimal.ZERO).compareTo(BigDecimal.ONE) < 0) {
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(136104, "有其他人员正在发送中,请等待其他人员发送结束后再操作"));
}
// 初始化进度
ProgressDTO initProgress = ProgressDTO.builder()
.title(SalaryI18nUtil.getI18nLabel(136097, "发送中"))
.totalQuantity(NumberUtils.INTEGER_ZERO)
.calculatedQuantity(NumberUtils.INTEGER_ZERO)
.progress(BigDecimal.ZERO)
.status(true)
.message("")
.build();
getProgressService(user).initProgress(SalaryCacheKey.SALARY_GRANT_PROGRESS + "_" + salarySend.getId(), initProgress);
List<Long> ids = param.getIds();
if (param.getSalarySendRangeIds() != null) {
//如果传了范围id则使用范围id发放
ids = getSalarySendRangeService(user)
.getSendInfoIdsBySendId(salarySend.getId(), param.getSalarySendRangeIds(), SalarySendGrantTypeEnum.GRANT);
if (ids.isEmpty()) {// 由于查出来是空的会导致全部发放在此进行拦截
throw new SalaryRunTimeException("工资发放范围内没有匹配员工");
}
}
// 异步执行
List<Long> finalIds = ids;
LocalRunnable localRunnable = new LocalRunnable() {
@Override
public void execute() {
handleGrant(salarySend, finalIds, salarySob, salaryTemplate);
}
};
ThreadPoolUtil.fixedPoolExecute(ModulePoolEnum.OTHER, "salaryBillGrant", localRunnable);
return new HashMap<>();
}
/**
* 处理发送
* 注意
* 1.IM和云桥通道是发送完成后只需要在预览时获取核算数据所以发送时可以忽略获取核算数据
* 2.邮件通道需要在发送时获取拼凑成html代码有图片会转化为base64编码变慢且图片越大越慢
*
* @param salarySend
* @param ids
* @param salarySob
* @param salaryTemplate
*/
private void handleGrant(SalarySendPO salarySend, List<Long> ids, SalarySobPO salarySob, SalaryTemplatePO salaryTemplate) {
try {
TaxAgentPO taxAgentPO = getTaxAgentService(user).getById(salarySob.getTaxAgentId());
// 1.构建发送参数
SalaryBillSendDTO salaryBillSendParam = buildSendParams(salarySend, taxAgentPO.getName(), salaryTemplate);
// 2.获取可发送的列表此步最耗时需要解密核算数据
List<Map<String, Object>> enableSendList = getEnableSendList(salarySend, ids, salaryBillSendParam);
// 3.发送消息先修改数据再发消息避免出错后无法撤回
List<Long> successIds = sendMessage(enableSendList, salaryBillSendParam);
// 4.发放
grantSendInfo(successIds, salarySend, salaryTemplate);
// 5.更新数量
updateSendNum(salarySend, salarySob);
int total = enableSendList.size();
int successCount = successIds.size();
String messsage = SalaryI18nUtil.getI18nLabel(139208, "发送完成") + ": "
+ SalaryI18nUtil.getI18nLabel(134807, "成功条数") + "[" + (successCount) + "], "
+ SalaryI18nUtil.getI18nLabel(134808, "失败条数") + "[" + (total - successCount) + "]";
// 发送进度完成
getProgressService(user).finish(SalaryCacheKey.SALARY_GRANT_PROGRESS + "_" + salarySend.getId(), true, messsage);
// log.info("工资单发送组装耗时:{}毫秒;工资单发送消息中心耗时:{}毫秒;工资单数据更改总耗时:{}毫秒;工资单发送总耗时:{}毫秒;工资单云桥图片地址:{}", l3 - l2, l4 - l3, l5 - l4, System.currentTimeMillis() - l,
// salaryBillSendParam == null ? "" : salaryBillSendParam.getPicUrl());
} catch (Exception e) {
log.info("发送出错:{}", e.getMessage(), e);
// 发送进度失败
getProgressService(user).fail(SalaryCacheKey.SALARY_GRANT_PROGRESS + "_" + salarySend.getId(), SalaryI18nUtil.getI18nLabel(136118, "工资单发送出错") + ": " + e.getMessage());
} finally {
}
}
/**
* 构建发送参数
*
* @param salarySend
* @param taxAgentName
* @param salaryTemplate
* @return
*/
private SalaryBillSendDTO buildSendParams(SalarySendPO salarySend, String taxAgentName, SalaryTemplatePO salaryTemplate) {
// 发送通道
Set<MessageChannelEnum> 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, 0L);
// 云桥企业微信消息图
String domain = "";
// todo 访问本项目中的图片需要登陆才能访问且变成空白所以还是得改成公网或者后续鉴权忽略
// StringUtils.isEmpty(server) || StringUtils.isEmpty(staticPathPattern) ? "https://wx.weaver.com.cn/main/salary/cover.png" : (server+staticPathPattern).replace("**", "salary_bill.png");
String picUrl = domain + String.format("/papi/file/preview?type=imgs&fileId=%s&random=123456", salaryTemplate.getBackground()); // "https://wx.weaver.com.cn/main/salary/cover.png";
String backgroundBase64 = "";
// if (StringUtils.isNotBlank(salaryTemplate.getBackground()) && isEnableEmail) {
// 2.base64码的方式这种方式可以不管图片地址是否是内外网缺点是内容太长
// FileData fileByte = fileDownloadClient.getFileByte(Long.valueOf(salaryTemplate.getBackground()));
// backgroundBase64 = Base64Encoder.encode(fileByte.getData());
// 千万不要这样做否则存入salaryTemplate字段会变的很大 salaryTemplate.setBackground(backgroundBase64);
// }
// 工资单预览实体名
String entityName = SalaryI18nUtil.getI18nLabel(94626, "工资单");
// 获取人员信息项目分类
List<SalaryTemplateSalaryItemSetListDTO> salaryItemSetList = JSONArray.parseArray(isReplenish ? salaryTemplate.getReplenishSalaryItemSetting() : salaryTemplate.getSalaryItemSetting(), SalaryTemplateSalaryItemSetListDTO.class);
// 国际化处理
// salaryItemSetList = SalaryTemplateBO.handleI18n(salaryItemSetList);
SalaryTemplateSalaryItemSetListDTO employeeInformation = SalaryTemplateBO.getEmployeeInformation(salaryItemSetList);
Map<String, String> employeeField = SalaryBillBO.buildEmployeeFieldName();
String remarkI18n = SalaryI18nUtil.getI18nLabel(140036, "发放说明");
if (StringUtils.isNotEmpty(salaryTemplate.getTextContent())) {
String yearI18n = SalaryI18nUtil.getI18nLabel(100325, "");
String monthI18n = SalaryI18nUtil.getI18nLabel(100326, "");
salaryTemplate
.setTextContent(salaryTemplate.getTextContent().replace("${salaryMonth}", salaryMonth.getYear() + yearI18n + salaryMonth.getMonth() + monthI18n));
}
return SalaryBillSendDTO.builder()
.salaryDate(salaryMonth)
// 消息标题
// .title(title)
// 消息内容目前跟title一样
// .text(title)
// 工资单预览实体名
.entityName(entityName)
// 发送通道
.sendChannels(sendChannels)
// 发送者
.sendUser(user)
// 工资单模板
.salaryTemplate(salaryTemplate)
// 工资单背景图base64编码
.backgroundBase64(backgroundBase64)
// 云桥工资单消息图
.picUrl(picUrl)
// 扣缴义务人名称
.taxAgentName(taxAgentName)
// 工资单模板-薪资项目设置
.salaryItemSetList(salaryItemSetList)
// 工资单模板-员工基本信息
.employeeInformation(employeeInformation)
// 工资单模板-对应人员字段
.employeeField(employeeField)
// 工资单模板-发放说明标签国际化
.remarkI18n(remarkI18n)
// 邮件是否可以发送邮件
// .isEnableEmail(isEnableEmail)
// 工资单发放
.salarySend(salarySend)
// 收入所得项目类型
// .incomeCategorys(incomeCategorys)
//薪资项目收入所得类型
// .salaryItemIncomeCategoryMap(salaryItemIncomeCategoryMap)
.build();
}
/**
* 获取可发送数据
*
* @param salarySend
* @param ids
* @return
*/
private List<Map<String, Object>> getEnableSendList(SalarySendPO salarySend, List<Long> ids, SalaryBillSendDTO salaryBillSendParam) {
SalarySendInfoQueryParam queryParam = new SalarySendInfoQueryParam();
queryParam.setSalarySendId(salarySend.getId());
// 空就是所有
queryParam.setIds(ids);
queryParam.setSendStatuss(Arrays.asList(SalarySendStatusEnum.UNSEND.getValue(), SalarySendStatusEnum.WITHDRAW.getValue()));
// 2.获取基本数据
List<SalarySendInfoListDTO> list = Lists.newArrayList();
if (CollectionUtils.isEmpty(ids)) {
list = getSalarySendInfoMapper().list(queryParam);
} else {
List<List<Long>> partition = Lists.partition(ids, 500);
for (List<Long> idsPart : partition) {
queryParam.setIds(idsPart);
list.addAll(getSalarySendInfoMapper().list(queryParam));
}
}
// // 是否是合并计税
// boolean isMerge = this.getSalarySendService(user).isMergeBySalarySend(salarySend);
List<SalaryAcctEmployeePO> salaryAcctEmployeeList = this.getSalaryAcctEmployeeService(user).listBySalaryAcctRecordId(salarySend.getSalaryAccountingId());
List<Long> acctEmployeeIds = salaryAcctEmployeeList.stream().map(SalaryAcctEmployeePO::getEmployeeId).distinct().collect(Collectors.toList());
list = list.stream().filter(f -> acctEmployeeIds.contains(f.getEmployeeId())).collect(Collectors.toList());
List<Long> employeeIds = list.stream().map(SalarySendInfoListDTO::getEmployeeId).collect(Collectors.toList());
// 初始化进度
ProgressDTO initProgress = ProgressDTO.builder()
.title("发送中")
.totalQuantity(employeeIds.size() * 2 + 1)
.status(true)
.calculatedQuantity(NumberUtils.INTEGER_ZERO)
.progress(BigDecimal.ZERO)
.message("")
.build();
getProgressService(user).initProgress(SalaryCacheKey.SALARY_GRANT_PROGRESS + "_" + salarySend.getId(), initProgress);
// 3.组装详情数据
// 获取薪资项目数据
List<SalaryAcctEmployeePO> salaryAcctEmployees = Lists.newArrayList();
List<SalaryAcctResultPO> salaryAcctResultValues = Lists.newArrayList();
//是否需要发送邮件
Boolean isEnableEmail = salaryBillSendParam.getSendChannels().contains(MessageChannelEnum.EMAIL);
if (CollectionUtils.isNotEmpty(ids)) {
int partSize = 100;// 分片大小,越小进度条跑得越短平快但是总体速度更慢
List<List<Long>> partition = Lists.partition(employeeIds, partSize);
for (List<Long> part : partition) {
// 更新进度
getProgressService(user).getAndAddCalculatedQty(SalaryCacheKey.SALARY_GRANT_PROGRESS + "_" + salarySend.getId(), part.size());
/** 注意只有邮件才需要加密的核算数据 */
if (isEnableEmail) {
List<SalaryAcctEmployeePO> 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 {
/** 注意只有邮件才需要加密的核算数据 */
if (isEnableEmail) {
salaryAcctEmployees = getSalaryAcctEmployeeService(user).listBySalaryAcctRecordId(salarySend.getSalaryAccountingId());
salaryAcctResultValues = getSalaryAcctResultService(user).listBySalaryAcctRecordIds(Collections.singletonList(salarySend.getSalaryAccountingId()));
}
}
// 外部人员
// List<ExtEmployeePO> extEmployeeList = extEmployeeService.listAllWithDeleted(currentTenantKey);
return getSalarySendService(user)
.buildDetailList(list, salaryAcctEmployees, salaryAcctResultValues);
}
public List<Map<String, Object>> getSendInfoList(Long sendId, List<Long> 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<SalarySendInfoListDTO> list = Lists.newArrayList();
if (CollectionUtils.isEmpty(ids)) {
list = getSalarySendInfoMapper().list(queryParam);
} else {
List<List<Long>> partition = Lists.partition(ids, 500);
for (List<Long> idsPart : partition) {
queryParam.setIds(idsPart);
list.addAll(getSalarySendInfoMapper().list(queryParam));
}
}
List<SalaryAcctEmployeePO> salaryAcctEmployeeList = this.getSalaryAcctEmployeeService(user).listBySalaryAcctRecordId(salarySend.getSalaryAccountingId());
List<Long> acctEmployeeIds = salaryAcctEmployeeList.stream().map(SalaryAcctEmployeePO::getEmployeeId).distinct().collect(Collectors.toList());
list = list.stream().filter(f -> acctEmployeeIds.contains(f.getEmployeeId())).collect(Collectors.toList());
List<Long> employeeIds = list.stream().map(SalarySendInfoListDTO::getEmployeeId).collect(Collectors.toList());
// 3.组装详情数据
// 获取薪资项目数据
List<SalaryAcctEmployeePO> salaryAcctEmployees = Lists.newArrayList();
List<SalaryAcctResultPO> salaryAcctResultValues = Lists.newArrayList();
//是否需要发送邮件
if (CollectionUtils.isNotEmpty(ids)) {
int partSize = 100;// 分片大小,越小进度条跑得越短平快但是总体速度更慢
List<List<Long>> partition = Lists.partition(employeeIds, partSize);
for (List<Long> part : partition) {
// 更新进度
List<SalaryAcctEmployeePO> 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);
}
/**
* 发送消息
*
* @param enableSendList
* @param salaryBillSendParam
*/
private List<Long> sendMessage(List<Map<String, Object>> enableSendList, SalaryBillSendDTO salaryBillSendParam) {
if (CollectionUtils.isEmpty(enableSendList)) {
return Collections.emptyList();
}
if (salaryBillSendParam == null) {
return enableSendList.stream().map(e -> Long.valueOf(e.get("id").toString())).collect(Collectors.toList());
}
Set<MessageChannelEnum> sendChannels = salaryBillSendParam.getSendChannels();
// 获取人员完整信息
Map<String, DataCollectionEmployee> allEmployeeMap = this.getEmployeeWholeInfo(enableSendList);
List<SalarySendInfoPO> sendInfoUpdateList = Lists.newArrayList();
AtomicInteger index = new AtomicInteger(0);
AtomicInteger part = new AtomicInteger(0);
int total = enableSendList.size();
enableSendList.forEach(e -> {
if (sendChannels.contains(MessageChannelEnum.MSG)) {
SalaryBillBO.sendMsg(salaryBillSendParam, Long.valueOf(e.get("id").toString()), Long.valueOf(e.get("employeeId").toString()));
}
if (sendChannels.contains(MessageChannelEnum.EMAIL)) {
// 构建发送消息
SalaryBillBO.buildEmployeeInfo(salaryBillSendParam, allEmployeeMap.get(e.get("employeeId").toString()));
SalaryBillBO.sendEmail(e, allEmployeeMap, salaryBillSendParam);
}
/** 发送工资单 **********************************************************/
sendInfoUpdateList.add(SalarySendInfoPO.builder()
.id(Long.valueOf(e.get("id").toString()))
.build());
// 更新发送进度
index.addAndGet(1);
part.addAndGet(1);
if (index.get() % 100 == 0 || index.get() >= total) {
getProgressService(user).getAndAddCalculatedQty(SalaryCacheKey.SALARY_GRANT_PROGRESS + "_" + salaryBillSendParam.getSalarySend().getId(), part.get());
part.set(0);
}
});
// 批量修改发送消息id
if (CollectionUtils.isNotEmpty(sendInfoUpdateList)) {
// sqlserver数据库处理每个分片数量约=2100/插入字段数
List<List<SalarySendInfoPO>> partition = Lists.partition(sendInfoUpdateList, 500);
// partition.forEach(updatePart -> getSalarySendInfoMapper().batchUpdateMsgId(updatePart));
}
return sendInfoUpdateList.stream().map(SalarySendInfoPO::getId).collect(Collectors.toList());
}
/**
* 获取人员完整信息
*
* @param enableSendList
* @return
*/
private Map<String, DataCollectionEmployee> getEmployeeWholeInfo(List<Map<String, Object>> enableSendList) {
List<Long> ids = enableSendList.stream().map(e -> Long.valueOf(e.get("employeeId").toString())).collect(Collectors.toList());
// 获取所有人员信息
List<DataCollectionEmployee> simpleEmployees = getSalaryEmployeeService(user).getEmployeeByIdsAll(ids);
return SalaryEntityUtil.convert2Map(simpleEmployees, e -> e.getEmployeeId() + "");
}
// /** 工资单发放 end **********************************************************************/
/**
* 检查和获取工资单发放信息
*
* @param salarySendId
* @return
*/
private SalarySendPO checkAndGetSalarySend(Long salarySendId) {
if (salarySendId == null) {
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100327, "工资单发放Id必传"));
}
SalarySendPO salarySend = this.getSalarySendService(user).getById(salarySendId);
if (salarySend == null) {
throw new SalaryRunTimeException(String.format(SalaryI18nUtil.getI18nLabel(100512, "工资单发放不存在") + "[id:%s]", salarySendId));
}
return salarySend;
}
// /**
// * 分权处理
// *
// * @param salarySend
// * @param ids
// * @param currentEmployeeId
// * @param currentTenantKey
// * @return
// */
// private List<Long> getIdsForDevolution(SalarySendPO salarySend, List<Long> ids) {
// // 开启分权或且是非薪酬模块总管理员且发送全部
// if (getTaxAgentService(user).isOpenDevolution(currentTenantKey) && !getTaxAgentService(user).isChief(currentEmployeeId) && CollectionUtils.isEmpty(ids)) {
// List<SalaryAcctEmployeePO> salaryAcctEmployees = getSalaryAcctEmployeeService(user)
// .listByRecordIds(Collections.singletonList(salarySend.getSalaryAccountingId()));
//
// List<Long> taxAgentIdsAsAdmin = getTaxAgentService(user).listAllTaxAgentsAsAdmin(currentEmployeeId).stream().map(TaxAgentPO::getId)
// .collect(Collectors.toList());
// List<TaxAgentManageRangeEmployeeDTO> taxAgentEmployees = getTaxAgentService(user).listTaxAgentAndEmployeeTree(currentEmployeeId).stream()
// .filter(t -> !taxAgentIdsAsAdmin.contains(t.getTaxAgentId())).collect(Collectors.toList());
// Map<Long, List<Long>> taxAgentEmployeesMap = SalaryEntityUtil.convert2Map(taxAgentEmployees, TaxAgentManageRangeEmployeeDTO::getTaxAgentId,
// v -> v.getEmployeeList().stream().map(TaxAgentManageRangeEmployeeDTO.TaxAgentEmployee::getEmployeeId).collect(Collectors.toList()));
//
// List<ExtEmployeePO> extEmployeeList = extEmployeeService.listCanUse(currentEmployeeId);
// // 工资单发放信息过滤
// List<SalarySendInfoPO> salarySendInfos = new LambdaQueryChainWrapper<>(getSalarySendInfoMapper())
// /** 注意需要啥就加载啥避免加载大字段salaryTemplate */
// .select(SalarySendInfoPO::getId, SalarySendInfoPO::getEmployeeId, SalarySendInfoPO::getCreator)
// .eq(SalarySendInfoPO::getDeleteType, 0)
// .eq(SalarySendInfoPO::getTenantKey)
// .eq(SalarySendInfoPO::getSalarySendId, salarySend.getId())
// .list();
//
// List<Long> acctEmployeeIds = salaryAcctEmployees.stream().filter(f ->
// // 作为管理员
// taxAgentIdsAsAdmin.contains(f.getTaxAgentId())
// // 作为分管理员
// || TaxAgentBO.checkTaxAgentAndEmployee(taxAgentEmployeesMap, f.getTaxAgentId(), f.getEmployeeId())
// // 外部人员
// || extEmployeeList.stream().anyMatch(t -> t.getTaxAgentId().equals(f.getTaxAgentId()) && t.getId().equals(f.getEmployeeId()))
// ).map(SalaryAcctEmployeePO::getEmployeeId).collect(Collectors.toList());
//
// ids = salarySendInfos.stream().filter(f -> acctEmployeeIds.contains(f.getEmployeeId()) || currentEmployeeId.equals(f.getCreator())).map(SalarySendInfoPO::getId)
// .distinct().collect(Collectors.toList());
// }
// return ids;
// }
/**
* 发放工资单更新信息
*
* @param ids
* @param salarySend
* @param salaryTemplate
*/
private void grantSendInfo(List<Long> ids, SalarySendPO salarySend, SalaryTemplatePO salaryTemplate) {
List<List<Long>> partition = Lists.partition(ids, 500);
Date sendTime = new Date();
SalarySendInfoPO po = new SalarySendInfoPO();
po.setSendStatus(SalarySendStatusEnum.ALREADYSEND.getValue());
po.setSendTime(sendTime);
po.setSalaryTemplate(JsonUtil.toJsonString(salaryTemplate));
partition.forEach(idsp -> {
salarySendInfoMapper.updateGrantWithdraw(po, salarySend.getId(), Arrays.asList(SalarySendStatusEnum.UNSEND.getValue(), SalarySendStatusEnum.WITHDRAW.getValue()), idsp);
});
}
// /**
// * 撤回工资单更新信息
// *
// * @param ids
// * @param salarySend
// * @param currentTenantKey
// */
// private void withdrawSendInfo(List<Long> ids, SalarySendPO salarySend) {
// List<List<Long>> partition = Lists.partition(ids, DbCrudConstant.DEF_PART_SIZE);
// partition.forEach(part -> new LambdaUpdateChainWrapper<>(getSalarySendInfoMapper())
// .eq(SalarySendInfoPO::getDeleteType, 0)
// .eq(SalarySendInfoPO::getTenantKey)
// .eq(SalarySendInfoPO::getSalarySendId, salarySend.getId())
// .eq(SalarySendInfoPO::getSendStatus, SalarySendStatusEnum.ALREADYSEND.getValue())
// .in(SalarySendInfoPO::getId, part)
// .set(SalarySendInfoPO::getSendStatus, SalarySendStatusEnum.WITHDRAW.getValue())
// .update());
// }
//
/**
* 更新发送数量
*
* @param salarySend
* @param salarySob
*/
private void updateSendNum(SalarySendPO salarySend, SalarySobPO salarySob) {
List<SalarySendInfoPO> list = salarySendInfoMapper.listSome(SalarySendInfoPO.builder().salarySendId(salarySend.getId()).build());
List<SalarySendInfoPO> sendList = list.stream().filter(e -> e.getSendStatus().equals(SalarySendStatusEnum.ALREADYSEND.getValue())).collect(Collectors.toList());
int sendNum = sendList.size();
int sendTotal = list.size();
SalarySendPO salarySendNew = new SalarySendPO();
try {
BeanUtils.copyProperties(salarySendNew, salarySend);
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
}
salarySendNew.setSendNum(sendNum);
salarySendNew.setSendTotal(sendTotal);
salarySendNew.setLastSendTime(new Date());
mapper.updateById(salarySendNew);
}
// /**
// * 工资单撤回 start
// **********************************************************************/
// @Override
// @Transactional(rollbackFor = Exception.class)
// public void withdraw(SalarySendWithdrawParam param, boolean isRange, List<Long> rangeIds) {
// // 1.检查和获取工资单发放
// SalarySendPO salarySend = checkAngGetSalarySend(param.getSalarySendId());
//// // 已经冻结不能操作
//// if (salarySend.getSendStatus().equals(NumberUtils.INTEGER_ONE)) {
//// return;
//// }
//
// // 检查是否正在撤回中
// SalaryBillProgressDTO salaryBillProgress = getProgressService(user)
// .getProgress(SalaryCacheKey.SALARY_WITHDRAW_PROGRESS, "" + salarySend.getId());
// if (Objects.nonNull(salaryBillProgress) && salaryBillProgress.isStatus()
// && Optional.ofNullable(salaryBillProgress.getProgress()).orElse(BigDecimal.ZERO).compareTo(BigDecimal.ONE) < 0) {
// throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(136105, "有其他人员正在撤回中,请等待其他人员撤回结束后再操作"));
// }
//
// // 初始化进度
// SalaryBillProgressDTO initProgress = getProgressService(user)
// .buildInitProgress("撤回中", 136106, NumberUtils.INTEGER_ONE, NumberUtils.INTEGER_ZERO, BigDecimal.ZERO);
// getProgressService(user).initProgress(SalaryCacheKey.SALARY_WITHDRAW_PROGRESS, "" + salarySend.getId(), initProgress);
//
// List<Long> ids = isRange ? getSalarySendRangeService(user).getSendInfoIdsBySalarySendIdAndOperateType(salarySend.getId(), rangeIds, SalarySendOperateTypeEnum.WITHDRAW) : param.getIds();
// // 异步执行撤回
// LocalRunnable localRunnable = new LocalRunnable() {
// @Override
// public void execute() {
// handleWithdraw(salarySend, ids);
// }
// };
// ThreadPoolUtil.fixedPoolExecute(ModulePoolEnum.OTHER, "salaryBillWithdraw", localRunnable);
// }
//
// /**
// * 处理撤回
// *
// * @param salarySend
// * @param ids
// * @param currentEmployeeId
// * @param currentTenantKey
// */
// private void handleWithdraw(SalarySendPO salarySend, List<Long> ids) {
// try {
// DSTenantKeyThreadVar.tenantKey.set(currentTenantKey);
//
// // 开启分权或且是非薪酬模块总管理员且发送全部,谁能进来就是能看全部
// // ids = getIdsForDevolution(salarySend, ids);
//
// // 获取可撤回的工资单
// List<SalarySendInfoPO> enableWithdrawList = Lists.newArrayList();
// if (CollectionUtils.isEmpty(ids)) {
// List<SalaryAcctEmployeePO> salaryAcctEmployees = this.getSalarySendService(user).getSalaryAcctEmployees(salarySend.getSalaryAccountingId(), null);
// List<Long> acctEmployeeIds = salaryAcctEmployees.stream().map(SalaryAcctEmployeePO::getEmployeeId).distinct().collect(Collectors.toList());
// List<List<Long>> partition = Lists.partition(acctEmployeeIds, DbCrudConstant.DEF_PART_SIZE);
// for (List<Long> part : partition) {
// enableWithdrawList.addAll(new LambdaQueryChainWrapper<>(getSalarySendInfoMapper())
// /** 注意需要啥就加载啥避免加载大字段salaryTemplate */
// .select(SalarySendInfoPO::getId, SalarySendInfoPO::getSendMsgId)
// .eq(SalarySendInfoPO::getDeleteType, 0)
// .eq(SalarySendInfoPO::getTenantKey)
// .eq(SalarySendInfoPO::getSalarySendId, salarySend.getId())
// .eq(SalarySendInfoPO::getSendStatus, SalarySendStatusEnum.ALREADYSEND.getValue())
// .in(SalarySendInfoPO::getEmployeeId, part)
// .list());
// }
// } else {
// List<List<Long>> partition = Lists.partition(ids, DbCrudConstant.DEF_PART_SIZE);
// for (List<Long> part : partition) {
// enableWithdrawList.addAll(new LambdaQueryChainWrapper<>(getSalarySendInfoMapper())
// /** 注意需要啥就加载啥避免加载大字段salaryTemplate */
// .select(SalarySendInfoPO::getId, SalarySendInfoPO::getSendMsgId)
// .eq(SalarySendInfoPO::getDeleteType, 0)
// .eq(SalarySendInfoPO::getTenantKey)
// .eq(SalarySendInfoPO::getSalarySendId, salarySend.getId())
// .eq(SalarySendInfoPO::getSendStatus, SalarySendStatusEnum.ALREADYSEND.getValue())
// .in(SalarySendInfoPO::getId, part)
// .list());
// }
// }
//
// // 初始化进度
// SalaryBillProgressDTO initProgress = getProgressService(user)
// .buildInitProgress("撤回中", 136106, enableWithdrawList.size() * 2 + 1, enableWithdrawList.size(), new BigDecimal("0.5"));
// getProgressService(user).initProgress(SalaryCacheKey.SALARY_WITHDRAW_PROGRESS, "" + salarySend.getId(), initProgress);
//
// // 1.撤回消息先修改数据再发消息避免出错后无法撤回
// String text = SalaryI18nUtil.getI18nLabel(184533, "此工资单已被撤回,如有问题,请联系管理员");
// String title = SalaryI18nUtil.getI18nLabel(94626, "工资单");
// List<Long> sendInfoUpdateIds = Lists.newArrayList();
//
// AtomicInteger index = new AtomicInteger(0);
// AtomicInteger part = new AtomicInteger(0);
// int total = enableWithdrawList.size();
// enableWithdrawList.forEach(e -> {
// if (!e.getSendMsgId().equals(0L)) {
// CancleMessageEntity cme = SalaryBillBO.buildCancleMessageEntity(e.getSendMsgId(), text, title);
// /** 撤回工资单 **********************************************************/
// WeaResult<Object> cancelResult = asyncSystemMessageRest.cancleMsg(cme);
// if (cancelResult.isStatus()) {
// sendInfoUpdateIds.add(e.getId());
// }
// } else {
// sendInfoUpdateIds.add(e.getId());
// }
// // 更新撤回进度
// index.addAndGet(1);
// part.addAndGet(1);
// if (index.get() % 100 == 0 || index.get() >= total) {
// getProgressService(user).getAndAddCalculatedQty(SalaryCacheKey.SALARY_WITHDRAW_PROGRESS, "" + salarySend.getId(), part.get());
// part.set(0);
// }
// });
// if (CollectionUtils.isNotEmpty(sendInfoUpdateIds)) {
// List<List<Long>> partition = Lists.partition(sendInfoUpdateIds, DbCrudConstant.DEF_PART_SIZE);
// partition.forEach(idsPart -> new LambdaUpdateChainWrapper<>(getSalarySendInfoMapper())
// .eq(SalarySendInfoPO::getDeleteType, 0)
// .eq(SalarySendInfoPO::getTenantKey)
// .in(SalarySendInfoPO::getId, idsPart)
// .set(SalarySendInfoPO::getSendMsgId, 0)
// .update());
// }
// // 2.撤回
// withdrawSendInfo(sendInfoUpdateIds, salarySend);
// // 3.更新数量
// updateSendNum(salarySend, getSalarySobService(user).getById(salarySend.getSalarySobId()), null,
// SalaryI18nUtil.getI18nLabel(100521, "撤回工资单发放"));
//
// int successCount = sendInfoUpdateIds.size();
// String messsage = SalaryI18nUtil.getI18nLabel(139211, "撤回完成") + ": "
// + SalaryI18nUtil.getI18nLabel(134807, "成功条数") + "[" + (successCount) + "], "
// + SalaryI18nUtil.getI18nLabel(134808, "失败条数") + "[" + (total - successCount) + "]";
// // 撤回进度完成
// getProgressService(user).finish(SalaryCacheKey.SALARY_WITHDRAW_PROGRESS, "" + salarySend.getId(), messsage, true);
// } catch (Exception e) {
// log.info("撤回出错:{}", e.getMessage(), e);
// // 发送进度失败
// getProgressService(user)
// .fail(SalaryCacheKey.SALARY_WITHDRAW_PROGRESS, "" + salarySend.getId(), SalaryI18nUtil.getI18nLabel(136142, "工资单撤回出错") + ": " + e.getMessage());
// } finally {
// DSTenantKeyThreadVar.tenantKey.remove();
// }
// }
// /** 工资单撤回 end **********************************************************************/
//
// /**
// * 我的工资单 start
// **********************************************************************/
// @Override
// public Map<String, Object> mySalaryBill(Long salaryInfoId) {
// // 企业微信端示例数据
// if (salaryInfoId.equals(1234567890L)) {
// return handle4WeChartDemo(salaryInfoId);
// }
//
// SalarySendInfoPO salarySendInfo = new LambdaQueryChainWrapper<>(getSalarySendInfoMapper())
// .eq(SalarySendInfoPO::getDeleteType, 0)
// .eq(SalarySendInfoPO::getTenantKey)
// .eq(SalarySendInfoPO::getId, salaryInfoId).one();
// if (salarySendInfo == null) {
// throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100511, "工资单信息不存在"));
// }
// // 获取模板
// String salaryTemplateContent = salarySendInfo.getSalaryTemplate();
// if (StringUtils.isBlank(salaryTemplateContent)) {
// throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100513, "没有默认模板,无法查看"));
// }
// SalaryTemplatePO salaryTemplate = SalaryBillBO.buildSalaryTemplateContent(salaryTemplateContent);
//
// // 判断是否是补发
// boolean isReplenish = NumberUtils.INTEGER_ONE.equals(salarySendInfo.getSalaryAcctType());
// SalaryTemplateBO.copyShowSet(isReplenish, salaryTemplate);
//
// // 获取人员信息项目分类
// List<SalaryTemplateSalaryItemSetListDTO> listDTOS = JSONArray.parseArray(isReplenish ? salaryTemplate.getReplenishSalaryItemSetting() : salaryTemplate.getSalaryItemSetting(), SalaryTemplateSalaryItemSetListDTO.class);
// // 国际化处理
// listDTOS = SalaryTemplateBO.handleI18n(listDTOS);
// // 获取人员信息项目分类
// SalaryTemplateSalaryItemSetListDTO employeeInformation = SalaryTemplateBO.getEmployeeInformation(listDTOS);
// // 1.薪资项目赋值
// List<SalaryTemplateSalaryItemSetListDTO> itemSetListDTOS = listDTOS.stream()
// .filter(e -> !SalaryTemplateSalaryItemSetGroupConstant.EMPLOYEE_INFO_GROUP_ID.equals(e.getGroupId())).collect(Collectors.toList());
// // 获取薪资核算数据
// List<SalaryAcctEmployeePO> salaryAcctEmployees = getSalaryAcctEmployeeService(user)
// .listByRecordIdAndEmployeeIds(salarySendInfo.getSalaryAcctRecordId(), Collections.singletonList(salarySendInfo.getEmployeeId()));
// Set<Long> salaryAcctEmployeeIds = SalaryEntityUtil.properties(salaryAcctEmployees, SalaryAcctEmployeePO::getId);
// List<SalaryAcctResultValuePO> salaryAcctResultValues = getSalaryAcctResultService(user).listBySalaryAcctEmployeeIds(salaryAcctEmployeeIds);
//// List<SalaryAcctResultPO> salaryAcctResultList = getSalaryAcctResultService(user).listBySalaryAcctRecordIdsAndEmployeeIds(Collections.singletonList(salarySendInfo.getSalaryAcctRecordId()), Collections.singletonList(currentEmployeeId));
// if (CollectionUtils.isNotEmpty(salaryAcctResultValues)) {
// SalaryAcctRecordPO salaryAcctRecord = getSalaryAcctRecordService(user).getById(salarySendInfo.getSalaryAcctRecordId());
// // 当前查询核算记录是回算但是发放不是回算的那么就取源头核算结果
// boolean isOrigin = salaryAcctRecord != null && !isReplenish && salaryAcctRecord.getBackCalcStatus().equals(NumberUtils.INTEGER_ONE);
// Map<String, String> map = Maps.newHashMap();
// if (salarySendInfo.getTaxAgentId().equals(0L)) {
// for (SalaryAcctResultValuePO salaryAcctResultValue : salaryAcctResultValues) {
// if (isOrigin) {
// if (salaryAcctResultValue.getOriginResultValue() != null && !salaryAcctResultValue.getOriginResultValue().isEmpty()) {
// map.putAll(salaryAcctResultValue.getOriginResultValue());
// }
// } else {
// map.putAll(salaryAcctResultValue.getResultValue());
// }
// }
// } else {
// Map<String, SalaryAcctEmployeePO> salaryAcctEmployeeMap = SalaryEntityUtil
// .convert2Map(salaryAcctEmployees, salaryAcctEmployee -> salaryAcctEmployee.getEmployeeId() + "-" + salaryAcctEmployee.getTaxAgentId());
// Map<Long, SalaryAcctResultValuePO> singleEmpAcctMap = SalaryEntityUtil.convert2Map(salaryAcctResultValues, SalaryAcctResultValuePO::getSalaryAcctEmployeeId);
// SalaryAcctEmployeePO salaryAcctEmployee = salaryAcctEmployeeMap.get(salarySendInfo.getEmployeeId() + "-" + salarySendInfo.getTaxAgentId());
// if (salaryAcctEmployee != null && singleEmpAcctMap.containsKey(salaryAcctEmployee.getId())) {
// SalaryAcctResultValuePO salaryAcctResultValue = singleEmpAcctMap.get(salaryAcctEmployee.getId());
// if (Objects.nonNull(salaryAcctResultValue)) {
// if (isOrigin) {
// if (salaryAcctResultValue.getOriginResultValue() != null && !salaryAcctResultValue.getOriginResultValue().isEmpty()) {
// map.putAll(salaryAcctResultValue.getOriginResultValue());
// }
// } else {
// map.putAll(salaryAcctResultValue.getResultValue());
// }
// }
// }
// }
// org.apache.commons.collections4.CollectionUtils.emptyIfNull(itemSetListDTOS)
// .forEach(item -> item.getItems().forEach(e -> e.setSalaryItemValue(Optional.ofNullable(map.get("" + e.getId())).orElse(""))));
// } else {
// org.apache.commons.collections4.CollectionUtils.emptyIfNull(itemSetListDTOS)
// .forEach(item -> item.getItems().forEach(e -> e.setSalaryItemValue("")));
// }
// // 2.人员信息赋值
// if (employeeInformation != null && CollectionUtils.isNotEmpty(employeeInformation.getItems())) {
// // 如果是外部人员
// if (salarySendInfo.getEmployeeType().equals(SalarySendEmployeeTypeEnum.EXT_EMPLOYEE.getValue())) {
// ExtEmployeePO extEmployeePO = extEmployeeService.getByIdWithDeleted(salarySendInfo.getEmployeeId());
// if (extEmployeePO != null) {
// SimpleEmployee simpleEmployee = new SimpleEmployee();
// simpleEmployee.setId(extEmployeePO.getId());
// simpleEmployee.setUsername(extEmployeePO.getUsername());
// simpleEmployee.setMobile(extEmployeePO.getUsername());
// SalaryBillBO.buildEmployeeInfo(employeeInformation, simpleEmployee, SalaryBillBO.buildEmployeeFieldName());
// }
// } else {
// SimpleEmployee simpleEmployee = hrmCommonEmployeeService.getEmployeeById(salarySendInfo.getEmployeeId());
// if (simpleEmployee != null) {
// // 查询人员状态
// HrmStatus hrmStatusDb = hrmCommonHrmStatusService.getHrmStatusByCodeId(simpleEmployee.getPersonnelStatus());
// simpleEmployee.setPersonnelStatus(hrmStatusDb == null ? "" : hrmStatusDb.getName());
// }
// SalaryBillBO.buildEmployeeInfo(employeeInformation, simpleEmployee, SalaryBillBO.buildEmployeeFieldName());
// }
// }
// // 主题设置
// salaryTemplate.setTheme(SalaryBillBO
// .getBillTitle(salaryTemplate.getTheme(), salarySendInfo.getSalaryMonth(), TenantContext.getCurrentTenant().getTenantName()));
// // 背景图
// if (StringUtils.isNotBlank(salaryTemplate.getBackground())) {
// salaryTemplate.setBackground(String.format("/papi/file/preview?type=imgs&fileId=%s&random=123456", salaryTemplate.getBackground()));
// }
//
// Map<String, Object> resultMap = new LinkedHashMap<>();
// resultMap.put("tenantName", TenantContext.getCurrentTenant().getTenantName());
// resultMap.put("sendTime", SalaryDateUtil.getFormatLocalDateTime(salarySendInfo.getSendTime()));
// resultMap.put("employeeInformation", employeeInformation);
// resultMap.put("salaryGroups", itemSetListDTOS);
// resultMap.put("salaryTemplate", salaryTemplate);
// return resultMap;
// }
//
// /**
// * 企业微信端示例数据
// *
// * @param salaryInfoId
// * @return
// */
// private Map<String, Object> handle4WeChartDemo(Long salaryInfoId) {
// Map<String, Object> resultMap = new LinkedHashMap<>();
// if (salaryInfoId.equals(1234567890L)) {
// List<SalaryTemplateSalaryItemSetListDTO> itemSetListDTOS = Lists.newArrayList();
// List<SalaryTemplateSalaryItemListDTO> items = Lists.newArrayList();
// items.add(SalaryTemplateSalaryItemListDTO.builder().id("735706397435338782").salaryItemValue("5000.00").name(SalaryI18nUtil.getI18nLabel(184508, "基本工资")).sortedIndex(0).build());
// items.add(SalaryTemplateSalaryItemListDTO.builder().id("735706397435338783").salaryItemValue("2000.00").name(SalaryI18nUtil.getI18nLabel(184537, "岗位工资")).sortedIndex(1).build());
// items.add(SalaryTemplateSalaryItemListDTO.builder().id("739465941241856001").salaryItemValue("100.00").name(SalaryI18nUtil.getI18nLabel(184538, "其他补贴")).sortedIndex(2).build());
// items.add(SalaryTemplateSalaryItemListDTO.builder().id("739466138709688320").salaryItemValue("3.00").name(SalaryI18nUtil.getI18nLabel(184539, "绩效分值")).sortedIndex(3).build());
// items.add(SalaryTemplateSalaryItemListDTO.builder().id("739505579468095489").salaryItemValue("600.00").name(SalaryI18nUtil.getI18nLabel(184540, "工时奖金")).sortedIndex(4).build());
// items.add(SalaryTemplateSalaryItemListDTO.builder().id("739505652314767360").salaryItemValue("500.00").name(SalaryI18nUtil.getI18nLabel(184544, "成果奖金")).sortedIndex(5).build());
// items.add(SalaryTemplateSalaryItemListDTO.builder().id("739506094797062145").salaryItemValue("200.00").name(SalaryI18nUtil.getI18nLabel(184545, "考勤扣款")).sortedIndex(6).build());
// items.add(SalaryTemplateSalaryItemListDTO.builder().id("739506691648290816").salaryItemValue("800.00").name(SalaryI18nUtil.getI18nLabel(184546, "餐补")).sortedIndex(7).build());
// items.add(SalaryTemplateSalaryItemListDTO.builder().id("739516333975699456").salaryItemValue("1").name(SalaryI18nUtil.getI18nLabel(184547, "当月缺勤")).sortedIndex(8).build());
// items.add(SalaryTemplateSalaryItemListDTO.builder().id("739516913670455296").salaryItemValue("200.00").name(SalaryI18nUtil.getI18nLabel(184549, "缺勤扣款")).sortedIndex(9).build());
// items.add(SalaryTemplateSalaryItemListDTO.builder().id("735706397435338798").salaryItemValue("200.00").name(SalaryI18nUtil.getI18nLabel(184550, "社保代扣")).sortedIndex(10).build());
// items.add(SalaryTemplateSalaryItemListDTO.builder().id("735706397435338799").salaryItemValue("200.00").name(SalaryI18nUtil.getI18nLabel(184551, "公积金代扣")).sortedIndex(11).build());
// items.add(SalaryTemplateSalaryItemListDTO.builder().id("741652500368097281").salaryItemValue("8800.00").name(SalaryI18nUtil.getI18nLabel(184553, "当月计税收入")).sortedIndex(12).build());
// items.add(SalaryTemplateSalaryItemListDTO.builder().id("735706397435338770").salaryItemValue("0").name(SalaryI18nUtil.getI18nLabel(184555, "当前累计专项附加扣除合计")).sortedIndex(13).build());
// items.add(SalaryTemplateSalaryItemListDTO.builder().id("735706397435338780").salaryItemValue("1000.00").name(SalaryI18nUtil.getI18nLabel(184556, "当月预扣个税")).sortedIndex(14).build());
// items.add(SalaryTemplateSalaryItemListDTO.builder().id("735706397435338800").salaryItemValue("8700.00").name(SalaryI18nUtil.getI18nLabel(184557, "当月实发现金")).sortedIndex(15).build());
// items.add(SalaryTemplateSalaryItemListDTO.builder().id("735706397435338802").salaryItemValue("").name(SalaryI18nUtil.getI18nLabel(84961, "备注")).sortedIndex(16).build());
// itemSetListDTOS.add(SalaryTemplateSalaryItemSetListDTO.builder()
// .groupId("custom_144")
// .groupName(SalaryI18nUtil.getI18nLabel(184561, "工资薪金项目"))
// .sortedIndex(0)
// .items(items)
// .build());
// SalaryTemplatePO salaryTemplate = SalaryTemplatePO.builder()
// .id(759519856313417728L)
// .name(SalaryI18nUtil.getI18nLabel(184563, "测试模板"))
// .description("")
// .theme(SalaryI18nUtil.getI18nLabel(184565, "(示例)工资单明细"))
// .background("")
// .textContent(SalaryI18nUtil.getI18nLabel(184590, "(示例)本数据仅为您收入预发金额,考勤、绩效及各类专项奖励的差异值将根据实际数据后续在下次发薪时统一予以调整,如有异议,请联系****。"))
// .textContentPosition(2)
// .salaryItemNullStatus(0)
// .salaryItemZeroStatus(0)
// .salaryItemSetting(JSON.toJSONString(itemSetListDTOS))
// .build();
// resultMap.put("tenantName", TenantContext.getCurrentTenant().getTenantName());
// resultMap.put("sendTime", SalaryDateUtil.getFormatLocalDateTime(LocalDateTime.now()));
// resultMap.put("employeeInformation", null);
// resultMap.put("salaryGroups", itemSetListDTOS);
// resultMap.put("salaryTemplate", salaryTemplate);
// }
// return resultMap;
// }
//
// @Override
// public Page<SalaryMySalaryBillListDTO> mySalaryBillListPage(Page<SalaryMySalaryBillListDTO> page, SalaryBillQueryParam queryParam, String tenantKey) {
// getSalarySendInfoMapper().mySalaryBillList(page, queryParam, tenantKey);
// return page;
// }
/** 我的工资单 end **********************************************************************/
}

View File

@ -71,7 +71,7 @@ public class SalaryItemServiceImpl extends Service implements SalaryItemService
private SysSalaryItemBiz sysSalaryItemBiz = new SysSalaryItemBiz();
// @Autowired
//
// private LoggerTemplate salaryItemLoggerTemplate;
@Override

View File

@ -9,6 +9,7 @@ import com.engine.common.util.ServiceUtil;
import com.engine.core.impl.Service;
import com.engine.salary.biz.SalarySendBiz;
import com.engine.salary.biz.SalarySendInfoBiz;
import com.engine.salary.constant.SalaryArchiveConstant;
import com.engine.salary.constant.SalaryItemConstant;
import com.engine.salary.constant.SalaryTemplateSalaryItemSetGroupConstant;
import com.engine.salary.encrypt.EncryptUtil;
@ -162,29 +163,10 @@ public class SalarySendServiceImpl extends Service implements SalarySendService
}
private SalaryBillService getSalaryBillService(User user) {
return ServiceUtil.getService(SalaryBillServiceImpl.class, user);
}
// @RpcReference
// private FileDownloadClient fileDownloadClient;
// /**
// * 同步用RpcReference
// */
// @RpcReference
// private SystemMessageRest systemMessageRest;
// /**
// * 异步用Autowired
// */
// @Autowired
// private AsyncSystemMessageRest asyncSystemMessageRest;
// @RpcReference
// private MailBaseService mailBaseService;
//
// private SalaryBatchService salaryBatchService;
// @Autowired
// private LoggerTemplate salarySendLoggerTemplate;
// @Autowired
// private HrmCommonEmployeeService hrmCommonEmployeeService;
// @Autowired
// private ExecutorService taskExecutor;
@Override
public SalarySendPO getById(Long salarySendId) {
@ -511,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<Map<String, Object>> salaryAcctResultS =null;
if(Objects.equals(salaryAcctRecordPO.getBackCalcStatus(),NumberUtils.INTEGER_ONE) && !isReplenish){
List<Map<String, Object>> salaryAcctResultS = null;
if (Objects.equals(salaryAcctRecordPO.getBackCalcStatus(), NumberUtils.INTEGER_ONE) && !isReplenish) {
// 该记录回算过,并且获取的不是回算后的工资单
salaryAcctResultS = salaryAcctResultPOS.stream().map(m -> {
Map<String, Object> map = new LinkedHashMap<>();
@ -523,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<String, Object> map = new LinkedHashMap<>();
map.put("salaryItemId", m.getSalaryItemId());
@ -803,6 +785,97 @@ public class SalarySendServiceImpl extends Service implements SalarySendService
return listMaps;
}
/**
* 组装详情数据
*
* @param list
* @param salaryAcctResultValues
* @return
*/
@Override
public List<Map<String, Object>> buildDetailList(List<SalarySendInfoListDTO> list,
List<SalaryAcctEmployeePO> salaryAcctEmployees, List<SalaryAcctResultPO> salaryAcctResultValues) {
List<Map<String, Object>> listMaps = new ArrayList<>();
if (CollectionUtils.isEmpty(list)) {
return listMaps;
}
// 所有个税扣缴义务人
// Map<Long, String> taxAgentMap = SalaryEntityUtil.convert2Map(getTaxAgentService(user).listAll(), TaxAgentPO::getId, TaxAgentPO::getName);
// 按人员分组核算数据
// Map<Long, List<SalaryAcctEmployeePO>> relationSalaryAcctEmployeeMap = SalaryEntityUtil.group2Map(salaryAcctEmployees, SalaryAcctEmployeePO::getEmployeeId);
Map<String, SalaryAcctEmployeePO> salaryAcctEmployeeMap = SalaryEntityUtil.convert2Map(salaryAcctEmployees, salaryAcctEmployee -> salaryAcctEmployee.getEmployeeId() + "-" + salaryAcctEmployee.getTaxAgentId());
Map<Long, List<SalaryAcctResultPO>> singleEmpAcctMap = SalaryEntityUtil.group2Map(salaryAcctResultValues, SalaryAcctResultPO::getSalaryAcctEmpId);
List<Long> employeeIds = list.stream().map(SalarySendInfoListDTO::getEmployeeId).distinct().collect(Collectors.toList());
// 查询分部 查询部门
List<DataCollectionEmployee> comInfos = getSalaryEmployeeService(user).getEmployeeByIdsAll(employeeIds);
Map<Long, DataCollectionEmployee> empComMap = SalaryEntityUtil.convert2Map(comInfos, DataCollectionEmployee::getEmployeeId);
// 当前查询核算记录是回算但是发放不是回算的那么就取源头核算结果
boolean isOrigin = false;
SalaryAcctRecordPO salaryAcctRecord = CollectionUtils.isEmpty(list) ? null : getSalaryAcctRecordService(user).getById(list.get(0).getSalaryAcctRecordId());
if (Objects.nonNull(salaryAcctRecord) && Objects.nonNull(salaryAcctRecord.getBackCalcStatus())) {
isOrigin = !NumberUtils.INTEGER_ONE.equals(list.get(0).getSalaryAcctType()) && salaryAcctRecord.getBackCalcStatus().equals(NumberUtils.INTEGER_ONE);
}
// 动态列
long l = System.currentTimeMillis();
Map<Long, DataCollectionEmployee> finalEmpSubComMap = empComMap;
boolean finalIsOrigin = isOrigin;
list.forEach(e -> {
Map<String, Object> map = new LinkedHashMap<>();
map.put("id", e.getId() + "");
DataCollectionEmployee hrmDepartmentComInfo = finalEmpSubComMap.get(e.getEmployeeId());
if (hrmDepartmentComInfo != null) {
map.put("subCompanyName", hrmDepartmentComInfo.getSubcompanyName());
} else {
map.put("subCompanyName", "");
}
if (hrmDepartmentComInfo != null) {
map.put("department", e.getDepartment());
}
map.put("employeeId", e.getEmployeeId() + "");
map.put("username", e.getUsername());
map.put("mobile", e.getMobile());
map.put("jobNum", e.getJobNum());
map.put("email", e.getEmail());
// map.put("employeeType", SalarySendEmployeeTypeEnum.getNameByValue(e.getEmployeeType()));
// 单个人的核算数据
List<SalaryAcctResultPO> resultValues = Lists.newArrayList();
// 个税扣缴义务人
// if (incomeCategorys.size() > 1) {
// List<SalaryAcctEmployeePO> acctEmployees = relationSalaryAcctEmployeeMap.getOrDefault(e.getEmployeeId(), Collections.emptyList());
// for (SalaryAcctEmployeePO salaryAcctEmployee : acctEmployees) {
// if (singleEmpAcctMap.containsKey(salaryAcctEmployee.getId())) {
// resultValues.add(singleEmpAcctMap.get(salaryAcctEmployee.getId()));
// }
// }
// } else {
// SalaryAcctEmployeePO salaryAcctEmployee = salaryAcctEmployeeMap.get(e.getEmployeeId() + "-" + e.getTaxAgent());
// if (salaryAcctEmployee != null && singleEmpAcctMap.containsKey(salaryAcctEmployee.getId())) {
// resultValues.add(singleEmpAcctMap.get(salaryAcctEmployee.getId()));
// }
// }
SalaryAcctEmployeePO salaryAcctEmployee = salaryAcctEmployeeMap.get(e.getEmployeeId() + "-" + e.getTaxAgentId());
if (salaryAcctEmployee != null && singleEmpAcctMap.containsKey(salaryAcctEmployee.getId())) {
resultValues.addAll(singleEmpAcctMap.get(salaryAcctEmployee.getId()));
}
// 薪资项目
// singleEmpAcctResultList.forEach(i-> map.put(i.getSalaryItemId() + SalaryArchiveConstant.DYNAMIC_SUFFIX, i.getResultValue()));
for (SalaryAcctResultPO salaryAcctResultValue : resultValues) {
if (finalIsOrigin) {
map.put(salaryAcctResultValue.getSalaryItemId() + SalaryArchiveConstant.DYNAMIC_SUFFIX, salaryAcctResultValue.getResultValue());
} else {
map.put(salaryAcctResultValue.getSalaryItemId() + SalaryArchiveConstant.DYNAMIC_SUFFIX, salaryAcctResultValue.getResultValue());
}
}
listMaps.add(map);
});
log.info("工资单详情构建总耗时:{}毫秒", System.currentTimeMillis() - l);
return listMaps;
}
/**
* 通过薪资账套获取模板的薪资项目
*
@ -950,6 +1023,15 @@ public class SalarySendServiceImpl extends Service implements SalarySendService
* 发送Em消息
*/
private void sendPayRollEMMessage(SalarySendInfoPO po, SalaryTemplatePO template, Long employeeId) {
// try {
// MessageUtil.sendSMS(mobile, content);
// } catch (Exception e) {
// kqLog.info("SendSMS error.resourceId:" + resourceId + ">>>>>>mobile>>>>>>" + mobile);
// log.writeLog(e);
// }
Long id = po.getId();
String background = template.getBackground();
String billTitle = getBillTitle(template.getTheme(), po.getSalaryMonth(), employeeId);
@ -1083,6 +1165,7 @@ public class SalarySendServiceImpl extends Service implements SalarySendService
Long salarySendId = param.getSalarySendId();
Collection<Long> ids = param.getIds();
// 获取可撤回的工资单
if (param.getSalarySendRangeIds() != null) {
//如果传了范围id则使用范围id撤回
ids = getSalarySendRangeService(user)
@ -1096,33 +1179,14 @@ public class SalarySendServiceImpl extends Service implements SalarySendService
if (salarySend == null) {
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100512, "工资单发放不存在"));
}
// // 获取可撤回的工资单
// List<SalarySendInfoPO> 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<Integer> statusList = new ArrayList<>();
statusList.add(SalarySendStatusEnum.ALREADYSEND.getValue());
salarySendInfoMapper.updateGrantWithdraw(po, salarySendId, statusList, ids);
// List<SalarySendInfoPO> list = new LambdaQueryChainWrapper<>(salarySendInfoMapper)
// .eq(SalarySendInfoPO::getDeleteType, 0)
// .eq(SalarySendInfoPO::getTenantKey, currentTenantKey)
// .eq(SalarySendInfoPO::getSalarySendId, salarySendId).list();
po = new SalarySendInfoPO();
po.setDeleteType(0);
@ -1142,11 +1206,6 @@ public class SalarySendServiceImpl extends Service implements SalarySendService
salarySendNew.setSendTotal(sendTotal);
mapper.updateById(salarySendNew);
// List<SalarySobPO> salarySobs = new LambdaQueryChainWrapper<>(salarySobMapper)
// .eq(SalarySobPO::getTenantKey, TenantContext.getCurrentTenantKey())
// .eq(SalarySobPO::getDeleteType, 0)
// .eq(SalarySobPO::getId, salarySend.getSalarySobId())
// .list();
// 记录日志
// SalaryLoggerUtil.recordUpdateSingleLog(salarySendLoggerTemplate,
// salarySend.getId(),
@ -1158,28 +1217,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<String, Object> map = new HashMap<>(2);
map.put("sendNum", sendNum);
@ -1358,7 +1399,7 @@ public class SalarySendServiceImpl extends Service implements SalarySendService
// 查询薪资核算所用薪资账套的薪资项目
List<SalarySobItemPO> salarySobItemPOS = getSalarySobItemService(user).listBySalarySobId(salaryAcctRecordPO.getSalarySobId());
Set<Long> salaryItemIds = SalaryEntityUtil.properties(salarySobItemPOS, SalarySobItemPO::getSalaryItemId);
if(Objects.equals(salaryAcctRecordPO.getBackCalcStatus(), NumberUtils.INTEGER_ONE)){
if (Objects.equals(salaryAcctRecordPO.getBackCalcStatus(), NumberUtils.INTEGER_ONE)) {
// 是回算获取回算项
List<SalarySobBackItemPO> salarySobBackItemPOS = getSalarySobBackItemService(user).listBySalarySobId(salaryAcctRecordPO.getSalarySobId());
salaryItemIds.addAll(salarySobBackItemPOS.stream().map(SalarySobBackItemPO::getSalaryItemId).collect(Collectors.toList()));
@ -1390,7 +1431,7 @@ public class SalarySendServiceImpl extends Service implements SalarySendService
@Override
public void deleteBySalaryAcctRecordIds(Collection<Long> ids) {
if(CollectionUtils.isNotEmpty(ids)){
if (CollectionUtils.isNotEmpty(ids)) {
getSalarySendMapper().deleteBySalaryAcctRecordIds(ids);
getSalarySendInfoMapper().deleteBySalaryAcctRecordIds(ids);
}

View File

@ -12,7 +12,7 @@ import com.engine.salary.service.SalarySobDefaultEmpFieldService;
**/
public class SalarySobDefaultEmpFieldServiceImpl implements SalarySobDefaultEmpFieldService {
// @Autowired
//
// private SalarySobDefaultEmpFieldMapper salarySobDefaultEmpFieldMapper;
//
// @Override

View File

@ -37,7 +37,7 @@ public class SysSalaryItemServiceImpl extends Service implements SysSalaryItemSe
private SysSalaryItemMapper getSysSalaryItemMapper() {
return MapperProxyFactory.getProxy(SysSalaryItemMapper.class);
}
// @Autowired
//
// private LoggerTemplate salaryItemLoggerTemplate;
@Override

View File

@ -535,9 +535,9 @@ public class SalaryBillController {
log.info("salary recipient: {} em_auth_userid: {}", recipient, em_auth_userid);
if (StringUtils.isNotBlank(recipient) && NumberUtils.isCreatable(recipient)) {
user = new User(Integer.parseInt(recipient));
} else if(StringUtils.isNotBlank(em_auth_userid) && NumberUtils.isCreatable(em_auth_userid)){
} else if (StringUtils.isNotBlank(em_auth_userid) && NumberUtils.isCreatable(em_auth_userid)) {
user = new User(Integer.parseInt(em_auth_userid));
}else {
} else {
user = HrmUserVarify.getUser(request, response);
}
return new ResponseResult<Long, Map<String, Object>>(user).run(getSalarySendWrapper(user)::mySalaryBill, salaryInfoId);

View File

@ -1,9 +1,9 @@
package com.engine.salary.web;
import com.engine.common.util.ServiceUtil;
import com.engine.salary.entity.salaryacct.dto.SalaryAcctProgressDTO;
import com.engine.salary.service.SalaryAcctProgressService;
import com.engine.salary.service.impl.SalaryAcctProgressServiceImpl;
import com.engine.salary.entity.progress.ProgressDTO;
import com.engine.salary.service.ProgressService;
import com.engine.salary.service.impl.ProgressServiceImpl;
import com.engine.salary.util.ResponseResult;
import weaver.hrm.HrmUserVarify;
import weaver.hrm.User;
@ -27,8 +27,8 @@ import javax.ws.rs.core.MediaType;
**/
public class SalaryProgressController {
private SalaryAcctProgressService getSalaryAcctProgressService(User user) {
return (SalaryAcctProgressService) ServiceUtil.getService(SalaryAcctProgressServiceImpl.class, user);
private ProgressService getSalaryAcctProgressService(User user) {
return (ProgressService) ServiceUtil.getService(ProgressServiceImpl.class, user);
}
//获取进度条
@ -37,7 +37,7 @@ public class SalaryProgressController {
@Produces(MediaType.APPLICATION_JSON)
public String getRate(@Context HttpServletRequest request, @Context HttpServletResponse response, @QueryParam(value = "cacheKey") String cacheKey) {
User user = HrmUserVarify.getUser(request, response);
return new ResponseResult<String, SalaryAcctProgressDTO>(user).run(getSalaryAcctProgressService(user)::getProgress, cacheKey);
return new ResponseResult<String, ProgressDTO>(user).run(getSalaryAcctProgressService(user)::getProgress, cacheKey);
}
// @ApiOperation("获取进度条")

View File

@ -6,7 +6,7 @@ import com.engine.salary.cache.SalaryCacheKey;
import com.engine.salary.component.WeaTableColumnGroup;
import com.engine.salary.entity.datacollection.DataCollectionEmployee;
import com.engine.salary.entity.salaryacct.dto.ConsolidatedTaxDetailDTO;
import com.engine.salary.entity.salaryacct.dto.SalaryAcctProgressDTO;
import com.engine.salary.entity.progress.ProgressDTO;
import com.engine.salary.entity.salaryacct.dto.SalaryAcctResultDetailDTO;
import com.engine.salary.entity.salaryacct.dto.SalaryAcctResultListColumnDTO;
import com.engine.salary.entity.salaryacct.param.SalaryAcctCalculateParam;
@ -62,8 +62,8 @@ public class SalaryAcctResultWrapper extends Service {
return ServiceUtil.getService(SalaryAcctEmployeeWrapper.class, user);
}
private SalaryAcctProgressService getSalaryAcctProgressService(User user) {
return ServiceUtil.getService(SalaryAcctProgressServiceImpl.class, user);
private ProgressService getSalaryAcctProgressService(User user) {
return ServiceUtil.getService(ProgressServiceImpl.class, user);
}
// private SalaryCheckResultService salaryCheckResultService;
@ -225,12 +225,12 @@ public class SalaryAcctResultWrapper extends Service {
// 检查薪资核算人员的个税扣缴义务人
getSalaryAcctEmployeeWrapper(user).checkTaxAgent(calculateParam.getSalaryAcctRecordId());
// 检查是否正在核算中
SalaryAcctProgressDTO salaryAcctProgressDTO = getSalaryAcctProgressService(user).getProgress(SalaryCacheKey.ACCT_PROGRESS + calculateParam.getSalaryAcctRecordId());
ProgressDTO salaryAcctProgressDTO = getSalaryAcctProgressService(user).getProgress(SalaryCacheKey.ACCT_PROGRESS + calculateParam.getSalaryAcctRecordId());
if (Objects.nonNull(salaryAcctProgressDTO) && salaryAcctProgressDTO.isStatus() && Optional.ofNullable(salaryAcctProgressDTO.getProgress()).orElse(BigDecimal.ZERO).compareTo(BigDecimal.ONE) < 0) {
return;
}
// 初始化进度
SalaryAcctProgressDTO initProgress = new SalaryAcctProgressDTO()
ProgressDTO initProgress = new ProgressDTO()
.setTitle(SalaryI18nUtil.getI18nLabel(97515, "核算中"))
.setTitleLabelId(97515L)
.setTotalQuantity(NumberUtils.INTEGER_ONE)

View File

@ -47,7 +47,7 @@ public class SalaryArchiveTaxAgentWrapper extends Service {
//
// private SalaryBatchService salaryBatchService;
// @Autowired
//
// private ExecutorService taskExecutor;
/**

View File

@ -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;
@ -45,11 +46,14 @@ import java.util.*;
import java.util.stream.Collectors;
/**
* @Description: 工资单发放
* @Author: wangxiangzhong
* @Date: 2022/3/16 13:57
*/
public class SalarySendWrapper extends Service {
* 工资单发放
* <p>Copyright: Copyright (c) 2022</p>
* <p>Company: 泛微软件</p>
*
* @author qiantao
* @version 1.0
**/
public class SalarySendWrapper extends Service implements SalarySendWrapperProxy {
private TaxAgentService getTaxAgentService(User user) {
return ServiceUtil.getService(TaxAgentServiceImpl.class, user);
}
@ -58,6 +62,10 @@ public class SalarySendWrapper extends Service {
return ServiceUtil.getService(SalarySendServiceImpl.class, user);
}
private SalaryBillService getSalaryBillService(User user) {
return ServiceUtil.getService(SalaryBillServiceImpl.class, user);
}
private SalaryTemplateService getSalaryTemplateService(User user) {
return ServiceUtil.getService(SalaryTemplateServiceImpl.class, user);
}
@ -300,13 +308,7 @@ public class SalarySendWrapper extends Service {
}
PageInfo<SalarySendInfoListDTO> pageInfo = getSalarySendService(user).salarySendInfoListPage(queryParam);
List<SalarySendInfoListDTO> list = pageInfo.getList();
list.forEach(e -> {
// 发放状态
int sendStatus = Integer.parseInt(e.getSendStatus());
e.setSendStatus(SalarySendStatusEnum.getDefaultLabelByValue(sendStatus));
// e.setOperation(SalarySendStatusEnum.getNameByValue(sendStatus));
});
return pageInfo;
}
@ -348,7 +350,7 @@ public class SalarySendWrapper extends Service {
* @return
*/
public Map<String, Object> grant(SalarySendGrantParam queryParam) {
return getSalarySendService(user).grant(queryParam);
return getSalaryBillService(user).grant(queryParam);
}
/**

View File

@ -40,7 +40,7 @@ public class SalaryTemplateWrapper extends Service {
private SalaryTemplateService getSalaryTemplateService(User user) {
return ServiceUtil.getService(SalaryTemplateServiceImpl.class, user);
}
// @RpcReference
//
// private MailBaseService mailBaseService;
private SalarySobService getSalarySobService(User user) {

View File

@ -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;
/**
* 工资单发放代理
* <p>Copyright: Copyright (c) 2022</p>
* <p>Company: 泛微软件</p>
*
* @author qiantao
* @version 1.0
**/
public interface SalarySendWrapperProxy {
/**
* 工资单发放
*
* @param queryParam
* @return
*/
Map<String, Object> grant(SalarySendGrantParam queryParam);
/**
* 工资单撤回
*
* @param queryParam
* @return
*/
Map<String, Object> withdraw(SalarySendWithdrawParam queryParam);
}