邮件和企微消息发送优化
This commit is contained in:
		
							parent
							
								
									4a6fb3ff3d
								
							
						
					
					
						commit
						dfac07da3f
					
				|  | @ -307,6 +307,7 @@ public class ClearAccountBillOperation extends AbstractOperationServicePlugIn im | |||
|         DynamicObject pzbinfo;//配置表 | ||||
|         DynamicObject userinfo;//被通知用户 | ||||
|         DynamicObjectCollection users;//配置表中的被通知人集合 | ||||
|         List<Long> receivers = new ArrayList<>(1); | ||||
|         for (int i = 0; i < dos.length; i++) { | ||||
|             prinfo = BusinessDataServiceHelper.loadSingle(dos[i].getPkValue(), dos[i].getDataEntityType().getName()); | ||||
|             //判断当前清账单是否由收款单补推,如果是,则根据清账单上的被通知人进行通知;否则根据配置表 | ||||
|  | @ -345,8 +346,11 @@ public class ClearAccountBillOperation extends AbstractOperationServicePlugIn im | |||
|                         detailinfo = newDetailBill(prinfo, userinfo); | ||||
|                         //发送清账明细单的OA待办 | ||||
|                         JhzjUtils.handleOA(detailinfo, "0", "0"); | ||||
|                         JhzjUtils.sendEmail(userinfo.getString("email"), "请登录资金系统操作清账明细单", | ||||
|                                 detailinfo.getString("billno") + "\n 详情页面" + JhzjUtils.getBillPCURL(detailinfo), "清账明细单新增"); | ||||
|                         receivers.clear(); | ||||
|                         receivers.add(userinfo.getLong("id")); | ||||
|                         String pcurl = JhzjUtils.getBillPCURL(detailinfo); | ||||
|                         JhzjUtils.sendEmail("请登录资金系统操作清账明细单", detailinfo.getString("billno") + | ||||
|                                 "<br> 详情页面 <a href='"+pcurl+"' target='_blank'>"+pcurl+"</a>", receivers, detailinfo); | ||||
|                     } | ||||
|                 } | ||||
|             } | ||||
|  |  | |||
|  | @ -1,7 +1,6 @@ | |||
| package shjh.jhzj7.fi.fi.plugin.operate; | ||||
| 
 | ||||
| import com.sap.db.jdbc.packet.ErrorLevel; | ||||
| import kd.bos.context.RequestContext; | ||||
| import kd.bos.dataentity.entity.DynamicObject; | ||||
| import kd.bos.dataentity.entity.DynamicObjectCollection; | ||||
| import kd.bos.db.DB; | ||||
|  | @ -16,9 +15,7 @@ import kd.sdk.plugin.Plugin; | |||
| import shjh.jhzj7.fi.fi.utils.JhzjUtils; | ||||
| 
 | ||||
| import java.math.BigDecimal; | ||||
| import java.util.ArrayList; | ||||
| import java.util.HashSet; | ||||
| import java.util.List; | ||||
| import java.util.Set; | ||||
| 
 | ||||
| /** | ||||
|  | @ -80,9 +77,6 @@ public class ClearDetailBillOperation extends AbstractOperationServicePlugIn imp | |||
|                     e.setCancel(true); | ||||
|                 } | ||||
|             }else if("reject".equals(eok)){ | ||||
|                 List<Long> receivers = new ArrayList<>(); | ||||
|                 receivers.add(RequestContext.get().getCurrUserId()); | ||||
|                 JhzjUtils.sendWEIXINQY(null,null, receivers); | ||||
|                 //驳回校验 | ||||
|                 if(!"B".equals(prinfo.getString("billstatus"))){ | ||||
|                     //清账明细单【单据状态】=已提交,才允许点击驳回按钮 | ||||
|  | @ -349,7 +343,7 @@ public class ClearDetailBillOperation extends AbstractOperationServicePlugIn imp | |||
|                     userName); | ||||
|             //驳回时,对清账明细单修改人发送邮件通知,OA待办 业务员可修改后,再次提交。 | ||||
|             JhzjUtils.sendEmail(userinfo.getString("email"),"请登录资金系统操作清账明细单", | ||||
|                     prinfo.getString("billno")+"\n 详情页面"+JhzjUtils.getBillPCURL(prinfo),"清账明细单新增"); | ||||
|                     prinfo.getString("billno")+"\n 详情页面 <a href='"+JhzjUtils.getBillPCURL(prinfo)+"' target='_blank'>请点击此次</a>","清账明细单新增"); | ||||
|             JhzjUtils.handleOA(prinfo,"0", "0"); | ||||
|             //处理完成提示 | ||||
|             this.operationResult.addSuccessPkId(prinfo.getPkValue()); | ||||
|  |  | |||
|  | @ -61,9 +61,10 @@ public class PayinfoChangeOperation extends AbstractOperationServicePlugIn imple | |||
|                 List<Long> receivers = new ArrayList<>(1); | ||||
|                 receivers.add(userField.getLong("id")); | ||||
|                 String title = "支付信息变更单号"+prinfo.getString("billno"); | ||||
|                 String content = "请登录资金系统处理付款单"+sourcebillno+"的变更,原因如下:\n"+changeCause; | ||||
|                 JhzjUtils.sendEmail(title,content+"\n 变更详情页面:"+JhzjUtils.getBillPCURL(prinfo),receivers); | ||||
|                 JhzjUtils.sendWEIXINQY(title,content,receivers); | ||||
|                 String content = "请登录资金系统处理付款单"+sourcebillno+"的变更,原因如下:<br>"+changeCause; | ||||
|                 String pcurl = JhzjUtils.getBillPCURL(prinfo); | ||||
|                 JhzjUtils.sendEmail(title,content+"<br> 变更详情页面:<a href='"+pcurl+"' target='_blank'>"+pcurl+"</a>",receivers,prinfo); | ||||
|                 JhzjUtils.sendWEIXINQY(title,content,receivers,prinfo); | ||||
|             } | ||||
|         } | ||||
|     } | ||||
|  |  | |||
|  | @ -76,8 +76,8 @@ public class NotCreditedNoticeTask extends AbstractTask implements Plugin { | |||
|                 } | ||||
|                 title = pzbinfo.getDynamicObject("shjh_org").getString("number")+"公司未入账的付款流水"; | ||||
|                 content = "请登录资金系统处理 "+title+" 共"+entry.getValue()+"笔"; | ||||
|                 JhzjUtils.sendEmail(title,content,receivers); | ||||
|                 JhzjUtils.sendWEIXINQY(title,content,receivers); | ||||
|                 JhzjUtils.sendEmail(title,content,receivers,pzbinfo); | ||||
|                 JhzjUtils.sendWEIXINQY(title,content,receivers,pzbinfo); | ||||
|             }else{ | ||||
|                 logger.info("付款未查找到对应人员"+qFilter.toArray()); | ||||
|             } | ||||
|  | @ -109,8 +109,8 @@ public class NotCreditedNoticeTask extends AbstractTask implements Plugin { | |||
|                 } | ||||
|                 title = pzbinfo.getDynamicObject("shjh_org").getString("number")+"公司未入账的收款流水"; | ||||
|                 content = "请登录资金系统处理 "+title+" 共"+entry.getValue()+"笔"; | ||||
|                 JhzjUtils.sendEmail(title,content,receivers); | ||||
|                 JhzjUtils.sendWEIXINQY(title,content,receivers); | ||||
|                 JhzjUtils.sendEmail(title,content,receivers,pzbinfo); | ||||
|                 JhzjUtils.sendWEIXINQY(title,content,receivers,pzbinfo); | ||||
|             }else{ | ||||
|                 logger.info("收款未查找到对应人员"+qFilter.toArray()); | ||||
|             } | ||||
|  |  | |||
|  | @ -76,12 +76,14 @@ public class UnclaimedNoticeTask extends AbstractTask implements Plugin { | |||
|         for (Map.Entry<String, List<DynamicObject>> entry : userBills.entrySet()) { | ||||
|             userid = entry.getKey(); | ||||
|             billlist = entry.getValue(); | ||||
|             receivers.clear(); | ||||
|             receivers.add(Long.parseLong(userid)); | ||||
|             title = "业务认领通知"; | ||||
|             content = "请登录资金系统处理认领公告 共"+billlist.size()+"笔\n"; | ||||
|             JhzjUtils.sendEmail(title,content+JhzjUtils.getTableHtml(billlist),receivers); | ||||
|             JhzjUtils.sendWEIXINQY(title,content,receivers); | ||||
|             if(!billlist.isEmpty()){ | ||||
|                 receivers.clear(); | ||||
|                 receivers.add(Long.parseLong(userid)); | ||||
|                 title = "业务认领通知"; | ||||
|                 content = "请登录资金系统处理认领公告 共"+billlist.size()+"笔"; | ||||
|                 JhzjUtils.sendEmail(title,content+JhzjUtils.getTableHtml(billlist),receivers,billlist.get(0)); | ||||
|                 JhzjUtils.sendWEIXINQY(title,content,receivers,billlist.get(0)); | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|  |  | |||
|  | @ -40,7 +40,7 @@ public class JhzjUtils { | |||
| 
 | ||||
|     private static final ILocaleString msgtag = new LocaleString("消息提醒"); | ||||
| 
 | ||||
|     private static final String groupId = "default_netctrl";//单据网络互斥默认分组 | ||||
|     private static final String netctrlgroupId = "default_netctrl";//单据网络互斥默认分组 | ||||
| 
 | ||||
|     private static final Log logger = LogFactory.getLog(JhzjUtils.class); | ||||
| 
 | ||||
|  | @ -114,7 +114,7 @@ public class JhzjUtils { | |||
|     public static String getTableHtml(List<DynamicObject> billlist){ | ||||
| 
 | ||||
|         StringBuilder tabstr = new StringBuilder(); | ||||
|         tabstr.append("<table border='1'> "); | ||||
|         tabstr.append("<br> <table border='1'> "); | ||||
|         //设置表头-10列 | ||||
|         tabstr.append("<thead> <tr> <th>认领通知单</th> <th>银行账号</th> <th>对方账号</th> <th>对方户名</th> <th>币种</th> <th>收款金额</th> "); | ||||
|         tabstr.append("<th>交易日期</th> <th>摘要</th> <th>票据号/明细编号</th> <th>承兑人名称/明细流水号</th></tr></thead> "); | ||||
|  | @ -185,7 +185,7 @@ public class JhzjUtils { | |||
|         receivers.add(email);//增加接收人 | ||||
|         emailInfo.setReceiver(receivers); | ||||
|         Map<String, Object> sendResult = EmailHandler.sendEmail(emailInfo); | ||||
|         //保存邮件发送日志 | ||||
|         //以邮箱地址发送,手动保存邮件发送日志,系统不保存至消息日志中 | ||||
|         saveLog(email,"邮件",content,(String)sendResult.get("description"),(Boolean)sendResult.get("result"),operation); | ||||
|     } | ||||
| 
 | ||||
|  | @ -194,8 +194,9 @@ public class JhzjUtils { | |||
|      * @param title 邮件主题 | ||||
|      * @param content 邮件内容 | ||||
|      * @param receivers 上游操作触发 | ||||
|      * @param billinfo 源业务单据对象 | ||||
|      */ | ||||
|     public static void sendEmail(String title, String content, List<Long> receivers){ | ||||
|     public static void sendEmail(String title, String content, List<Long> receivers, DynamicObject billinfo){ | ||||
|         //构建消息体发送 | ||||
|         MessageInfo message = new MessageInfo(); | ||||
|         //信息 title | ||||
|  | @ -211,8 +212,14 @@ public class JhzjUtils { | |||
|         message.setSenderId(RequestContext.get().getCurrUserId()); | ||||
|         message.setType("notice_email");//消息类型的编号 | ||||
|         message.setNotifyType(MessageChannels.EMAIL.getNumber());//消息渠道的编号 | ||||
| //        MessageCenterServiceHelper.sendMessage(message); | ||||
|         //如下四个参数必须有,否则消息发送校验不通过 | ||||
|         message.setEntityNumber(billinfo.getDataEntityType().getName());//实体标识 | ||||
|         message.setSource("funding");//来源资金系统 | ||||
|         message.setBizDataId((Long) billinfo.getPkValue());//业务单据id | ||||
|         message.setNestBillId((Long) billinfo.getPkValue());//源单据id | ||||
| //        MessageCenterServiceHelper.sendMessage(message);//该方法已弃用,换成如下消息发送 | ||||
|         List<MessageInfo> msgs = new ArrayList<>(1); | ||||
|         msgs.add(message); | ||||
|         MessageCenterServiceHelper.batchSendMessages(msgs); | ||||
|     } | ||||
| 
 | ||||
|  | @ -221,8 +228,9 @@ public class JhzjUtils { | |||
|      * @param title 消息主题 | ||||
|      * @param content 消息内容 | ||||
|      * @param receivers 信息接收人 | ||||
|      * @param billinfo 源业务单据对象 | ||||
|      */ | ||||
|     public static void sendWEIXINQY(String title, String content, List<Long> receivers){ | ||||
|     public static void sendWEIXINQY(String title, String content, List<Long> receivers, DynamicObject billinfo){ | ||||
|         //构建消息体发送 | ||||
|         MessageInfo message = new MessageInfo(); | ||||
|         //信息 title | ||||
|  | @ -241,8 +249,14 @@ public class JhzjUtils { | |||
| //        notifyType.append(MessageChannels.EMAIL.getNumber()).append(","); | ||||
| //        notifyType.append(MessageChannels.WEIXINQY.getNumber()); | ||||
|         message.setNotifyType(MessageChannels.WEIXINQY.getNumber());//消息渠道的编号 | ||||
| //        MessageCenterServiceHelper.sendMessage(message); | ||||
|         //如下四个参数必须有,否则消息发送校验不通过 | ||||
|         message.setEntityNumber(billinfo.getDataEntityType().getName());//实体标识 | ||||
|         message.setSource("funding");//来源资金系统 | ||||
|         message.setBizDataId((Long) billinfo.getPkValue());//业务单据id | ||||
|         message.setNestBillId((Long) billinfo.getPkValue());//源单据id | ||||
| //        MessageCenterServiceHelper.sendMessage(message);//该方法已弃用,换成如下消息发送 | ||||
|         List<MessageInfo> msgs = new ArrayList<>(1); | ||||
|         msgs.add(message); | ||||
|         MessageCenterServiceHelper.batchSendMessages(msgs); | ||||
|     } | ||||
| 
 | ||||
|  | @ -332,7 +346,7 @@ public class JhzjUtils { | |||
|             List mutexRequireList = new ArrayList(1); | ||||
|             Map requireParam = new HashMap(); | ||||
|             requireParam.put(DataMutex.PARAMNAME_DATAOBJID, prinfo.getString("id"));//数据id | ||||
|             requireParam.put(DataMutex.PARAMNAME_GROUPID, groupId); | ||||
|             requireParam.put(DataMutex.PARAMNAME_GROUPID, netctrlgroupId); | ||||
|             requireParam.put(DataMutex.PARAMNAME_ENTITYKEY, entityKey); | ||||
|             requireParam.put(DataMutex.PARAMNAME_OPERATIONKEY, "modify"); | ||||
|             requireParam.put(DataMutex.PARAMNAME_ISSTRICT, true); | ||||
|  | @ -371,7 +385,7 @@ public class JhzjUtils { | |||
|             List mutexRequireList = new ArrayList(1); | ||||
|             Map requireParam = new HashMap(); | ||||
|             requireParam.put(DataMutex.PARAMNAME_DATAOBJID, prinfo.getString("id")); | ||||
|             requireParam.put(DataMutex.PARAMNAME_GROUPID, groupId); | ||||
|             requireParam.put(DataMutex.PARAMNAME_GROUPID, netctrlgroupId); | ||||
|             requireParam.put(DataMutex.PARAMNAME_ENTITYKEY, prinfo.getDataEntityType().getName()); | ||||
|             requireParam.put(DataMutex.PARAMNAME_OPERATIONKEY, "modify"); | ||||
|             mutexRequireList.add(requireParam); | ||||
|  |  | |||
|  | @ -119,7 +119,9 @@ public class PayreceiptQueryControler { | |||
|                                         realUploadUrl = ReceiptPrintHelper.getFilePreviewUrl(realUploadUrl); | ||||
|                                         entryBean.setReceipturl(realUploadUrl); | ||||
|                                         logger.info("电子回单预览URL: "+realUploadUrl); | ||||
| //                                        new ViewReceiptService().getElecByReceiptno();//可获得电子回单的查看URL kd.tmc.bei.business.opservice.elec | ||||
|                                         //如下两句代码方法也可以获得回单的url | ||||
| //                                        List<String> resultlist = new ViewReceiptService().getElecByReceiptno("109020222",new Object[]{receiptNo});//可获得电子回单的查看URL kd.tmc.bei.business.opservice.elec | ||||
| //                                        entryBean.setVoucherYear(resultlist.get(0)); | ||||
| //                                        byte[] stream = BeiHelper.getPdfPutStream(realUploadUrl);//电子回单字节数组 | ||||
| //                                        if (stream.length <= 1) { | ||||
| //                                            logger.warn(receiptNo + "下载回单文件流为空,请检查回单文件路径值。"); | ||||
|  | @ -133,11 +135,11 @@ public class PayreceiptQueryControler { | |||
| //                                        } | ||||
|                                     } catch (Exception var11) { | ||||
|                                         logger.error("电子回单获取文件路径异常: " + var11.getMessage()); | ||||
|                                         return handleErrorAndReturn("查询失败:电子回单获取文件路径异常", eReceiptid+"", jsonBodyString,apiResultExt); | ||||
|                                         return handleErrorAndReturn("查询失败:电子回单获取文件路径异常", receiptNo, jsonBodyString,apiResultExt); | ||||
|                                     } | ||||
|                                 } else { | ||||
|                                     logger.warn(receiptNo + "回单为非文件类回单"); | ||||
|                                     return handleErrorAndReturn("查询失败:回单为非文件类回单", eReceiptid+"", jsonBodyString,apiResultExt); | ||||
|                                     return handleErrorAndReturn("查询失败:回单为非文件类回单", receiptNo, jsonBodyString,apiResultExt); | ||||
|                                 } | ||||
|                             }else{ | ||||
|                                 return handleErrorAndReturn("查询失败:电子回单不存在", eReceiptid+"", jsonBodyString,apiResultExt); | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue