From d3c82acac142f6d8a511c015d84fa47f053841b2 Mon Sep 17 00:00:00 2001 From: MustangDeng <670124965@qq.com> Date: Mon, 6 Jun 2022 13:56:47 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=91=E9=80=81=E6=92=A4=E5=9B=9E=E5=B7=A5?= =?UTF-8?q?=E8=B5=84=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../salaryBill/po/SalarySendInfoPO.java | 1 + .../service/impl/SIAccountServiceImpl.java | 1 + .../service/impl/SalarySendServiceImpl.java | 93 +++++++++++++++++++ 3 files changed, 95 insertions(+) diff --git a/src/com/engine/salary/entity/salaryBill/po/SalarySendInfoPO.java b/src/com/engine/salary/entity/salaryBill/po/SalarySendInfoPO.java index 818da9c59..582cc097d 100644 --- a/src/com/engine/salary/entity/salaryBill/po/SalarySendInfoPO.java +++ b/src/com/engine/salary/entity/salaryBill/po/SalarySendInfoPO.java @@ -21,6 +21,7 @@ import java.util.Date; //@ElogTransform(name = "工资单发放信息表") public class SalarySendInfoPO { + public Object get; /** * 主键id */ diff --git a/src/com/engine/salary/service/impl/SIAccountServiceImpl.java b/src/com/engine/salary/service/impl/SIAccountServiceImpl.java index 12ff7ea60..72a5b1f8d 100644 --- a/src/com/engine/salary/service/impl/SIAccountServiceImpl.java +++ b/src/com/engine/salary/service/impl/SIAccountServiceImpl.java @@ -89,6 +89,7 @@ public class SIAccountServiceImpl extends Service implements SIAccountService { Long employeeId = (long)user.getUID(); Map datas = new HashMap<>(); + //福利台账列表 PageInfo pageInfo = siAccountBiz.listPage(queryParam,employeeId); Collection insuranceAccountBatchPOS = pageInfo.getList(); diff --git a/src/com/engine/salary/service/impl/SalarySendServiceImpl.java b/src/com/engine/salary/service/impl/SalarySendServiceImpl.java index 72c582c73..72e2f42a3 100644 --- a/src/com/engine/salary/service/impl/SalarySendServiceImpl.java +++ b/src/com/engine/salary/service/impl/SalarySendServiceImpl.java @@ -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 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 list, SalarySendGrantParam param, SalarySendPO salarySend) { + Date salaryMonth = salarySend.getSalaryMonth(); + String month = DateUtil.format(salaryMonth, "yyyy-MM"); + new Thread() { + public void run() { + List 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 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 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> getEnableSendList(SalarySendPO salarySend, Collection ids, SalaryTemplatePO salaryTemplate) { // 1.根据模板获取薪资项目设置 List 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.工作簿名称