发送撤回工资单

This commit is contained in:
MustangDeng 2022-06-06 13:56:47 +08:00
parent d0869e5daa
commit d3c82acac1
3 changed files with 95 additions and 0 deletions

View File

@ -21,6 +21,7 @@ import java.util.Date;
//@ElogTransform(name = "工资单发放信息表")
public class SalarySendInfoPO {
public Object get;
/**
* 主键id
*/

View File

@ -89,6 +89,7 @@ public class SIAccountServiceImpl extends Service implements SIAccountService {
Long employeeId = (long)user.getUID();
Map<String,Object> datas = new HashMap<>();
//福利台账列表
PageInfo<InsuranceAccountBatchPO> pageInfo = siAccountBiz.listPage(queryParam,employeeId);
Collection<InsuranceAccountBatchPO> insuranceAccountBatchPOS = pageInfo.getList();

View File

@ -1,7 +1,11 @@
package com.engine.salary.service.impl;
import cn.hutool.core.date.DateUtil;
import com.alibaba.fastjson.JSONArray;
import com.api.formmode.mybatis.util.SqlProxyHandle;
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.common.util.ServiceUtil;
import com.engine.core.impl.Service;
import com.engine.salary.biz.SalarySendBiz;
@ -48,6 +52,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import weaver.hrm.User;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.text.SimpleDateFormat;
@ -665,6 +670,9 @@ public class SalarySendServiceImpl extends Service implements SalarySendService
// }
// });
// 发送消息
sendMessage(true, list, param, salarySend);
Map<String, Object> map = new HashMap<>(2);
map.put("sendNum", sendNum);
map.put("sendTotal", sendTotal);
@ -672,6 +680,80 @@ public class SalarySendServiceImpl extends Service implements SalarySendService
return map;
}
/**
* 发送消息
* @param sendFlag true 发送 false 撤回
* @param list
* @param param
* @param salarySend
*/
private void sendMessage(boolean sendFlag, List<SalarySendInfoPO> list, SalarySendGrantParam param, SalarySendPO salarySend) {
Date salaryMonth = salarySend.getSalaryMonth();
String month = DateUtil.format(salaryMonth, "yyyy-MM");
new Thread() {
public void run() {
List<Long> collect = new ArrayList<>();
if(CollectionUtils.isNotEmpty(param.getIds())) {
collect = new ArrayList<>(param.getIds());
} else {
collect = list.stream().map(item -> item.getId()).collect(Collectors.toList());
}
collect.forEach(item -> {
SalarySendInfoPO po = SalarySendInfoPO.builder().id(item).build();
List<SalarySendInfoPO> salarySendInfoPOS = salarySendInfoMapper.listSome(po);
if(CollectionUtils.isNotEmpty(salarySendInfoPOS)) {
Long employeeId = salarySendInfoPOS.get(0).getEmployeeId();
if(sendFlag) {
sendPayRollEMMessage(item, employeeId ,month);
} else {
withdrawPayrollEMMessage(item, employeeId);
}
}
});
}
}.start();
}
/**
* 发送Em消息
*/
private void sendPayRollEMMessage(Long id, Long employeeId, String month) {
MessageType messageType = MessageType.newInstance(499); // 消息来源见文档第四点补充 必填
Set<String> userIdList = new HashSet<>(); // 接收人id 必填
String title = month + " 工资单"; // 标题
String context = "点击查看详情"; // 内容
String linkUrl = "/spa/hrmSalary/static/index.html#/main/hrmSalary/mobilepayroll?id=" + id; // PC端链接
String linkMobileUrl = "/spa/hrmSalary/static/index.html#/main/hrmSalary/mobilepayroll?type=phone&id=" + id; // 移动端链接
try {
MessageBean messageBean = Util_Message.createMessage(messageType, userIdList, title, context, linkUrl, linkMobileUrl);
messageBean.setCreater(user.getUID());// 创建人id
messageBean.setUserId(employeeId.intValue());
messageBean.setBizState("0");// 需要修改消息为已处理等状态时传入,表示消息最初状态为待处理
messageBean.setTargetId("499|" + id); //消息来源code +|+业务id需要修改消息为已处理等状态时传入
Util_Message.store(messageBean);
} catch (IOException e) {
e.printStackTrace();
}
}
/**
* 撤回EM消息
* @param id
*/
private void withdrawPayrollEMMessage(Long id, Long employeeId) {
try {
MessageBean messageBean = Util_Message.createMessage();
messageBean.setUserList(new HashSet<>());//接收人id
messageBean.setUserId(employeeId.intValue());
messageBean.setTargetId("499|" + id); //code + | + 业务id
//messageBean.setMessageType(MessageType.newInstance(121));//消息来源code(传了代表code也做为删除时的条件默认不传
Util_Message.delMessageTargetid(messageBean);
} catch (Exception e) {
e.printStackTrace();
}
}
private List<Map<String, Object>> getEnableSendList(SalarySendPO salarySend, Collection<Long> ids, SalaryTemplatePO salaryTemplate) {
// 1.根据模板获取薪资项目设置
List<SalaryTemplateSalaryItemListDTO> salaryItems = getSalaryItemsSetting(salaryTemplate);
@ -687,6 +769,9 @@ public class SalarySendServiceImpl extends Service implements SalarySendService
return listMaps;
}
// /**
// * 发送消息
// *
@ -819,6 +904,10 @@ public class SalarySendServiceImpl extends Service implements SalarySendService
// salarySend,
// salarySendNew);
SalarySendGrantParam grantParam = SalarySendGrantParam.builder().ids(param.getIds()).salarySendId(param.getSalarySendId()).build();
// 撤回消息
sendMessage(false, list, grantParam, salarySend);
// // 3.异步发送消息先修改数据再发消息避免出错后无法撤回
// taskExecutor.execute(() -> {
// try {
@ -846,6 +935,10 @@ public class SalarySendServiceImpl extends Service implements SalarySendService
return map;
}
@Override
public XSSFWorkbook exportInfoList(SalarySendInfoQueryParam queryParam) {
// 1.工作簿名称