清账单和明细单操作插件代码完善
This commit is contained in:
		
							parent
							
								
									ee1f69f9e4
								
							
						
					
					
						commit
						8d55cf498b
					
				|  | @ -1,21 +1,28 @@ | |||
| package shjh.jhzj7.fi.fi.plugin.operate; | ||||
| 
 | ||||
| import kd.bos.dataentity.entity.DynamicObject; | ||||
| import kd.bos.dataentity.entity.DynamicObjectCollection; | ||||
| import kd.bos.db.DB; | ||||
| import kd.bos.db.DBRoute; | ||||
| import kd.bos.entity.plugin.AbstractOperationServicePlugIn; | ||||
| import kd.bos.entity.plugin.args.AfterOperationArgs; | ||||
| import kd.bos.entity.plugin.args.BeforeOperationArgs; | ||||
| import kd.bos.servicehelper.BusinessDataServiceHelper; | ||||
| import kd.bos.servicehelper.operation.SaveServiceHelper; | ||||
| import kd.sdk.plugin.Plugin; | ||||
| import shjh.jhzj7.fi.fi.utils.JhzjUtils; | ||||
| 
 | ||||
| import java.math.BigDecimal; | ||||
| 
 | ||||
| /** | ||||
|  * 清账明细单据操作插件 | ||||
|  */ | ||||
| public class ClearDetailBillOperation extends AbstractOperationServicePlugIn implements Plugin { | ||||
| 
 | ||||
|     private static final String updateDetailByID = "update tk_shjh_clear_acctdetail set fbillstatus='A' where fid=?;"; | ||||
|     private static final String updateDetailSave = "update tk_shjh_clear_acctdetail set fbillstatus='A' where fid=?;"; | ||||
|     private static final String updateDetailReject = "update tk_shjh_clear_acctdetail set fbillstatus='E' where fid=?;"; | ||||
|     private static final String updateClearBillSave = "update tk_shjh_clear_account set fbillstatus='A' where fbillstatus='B' and fid=?;"; | ||||
|     private static final String clearBillName = "shjh_clear_account";//清账单 | ||||
| 
 | ||||
|     /** | ||||
|      * 操作校验通过之后,开启事务之前,触发此事件; | ||||
|  | @ -28,7 +35,8 @@ public class ClearDetailBillOperation extends AbstractOperationServicePlugIn imp | |||
|         String eok = e.getOperationKey(); | ||||
|         if("submit".equals(eok) || "revoke".equals(eok) || "reject".equals(eok)){ | ||||
|             DynamicObject[] dos =  e.getDataEntities(); | ||||
|             DynamicObject prinfo; | ||||
|             DynamicObject prinfo;//清账明细单 | ||||
|             DynamicObject clearBillInfo;//清账单 | ||||
|             String billno; | ||||
|             for (int i = 0; i < dos.length; i++) { | ||||
|                 //反审核操作之前系统未把info对象所有属性加载出来,尤其是二开的字段,需要在此处重新load一下 | ||||
|  | @ -36,7 +44,7 @@ public class ClearDetailBillOperation extends AbstractOperationServicePlugIn imp | |||
|                 billno = prinfo.getString("billno"); | ||||
|                 if("submit".equals(eok)){ | ||||
|                     if("B".equals(prinfo.getString("billstatus"))){ | ||||
|                         e.setCancelMessage(prinfo.getString("billno")+"单据已提交,不允许重复提交"); | ||||
|                         e.setCancelMessage(billno+"单据已提交,不允许重复提交"); | ||||
|                         e.setCancel(true); | ||||
|                     } | ||||
|                     //清账明细单【未清金额】+【账扣金额】+【尾差金额】≥【本次核销金额合计】 | ||||
|  | @ -44,24 +52,56 @@ public class ClearDetailBillOperation extends AbstractOperationServicePlugIn imp | |||
|                         e.setCancelMessage(billno+"【未清金额】+【账扣金额】+【尾差金额】≥【本次核销金额合计】,才允许提交"); | ||||
|                         e.setCancel(true); | ||||
|                     } | ||||
|                     //判断对应的清账单是否已提交,如果是,则不允许提交此明细单 | ||||
|                     clearBillInfo = BusinessDataServiceHelper.loadSingle(prinfo.getString("shjh_clearbillid"),clearBillName,"id,billno,billstatus"); | ||||
|                     if("B".equals(clearBillInfo.getString("billstatus"))){ | ||||
|                         e.setCancelMessage(clearBillInfo.getString("billno")+"清账单已提交,此明细单无需提交"); | ||||
|                         e.setCancel(true); | ||||
|                     } | ||||
|                 }else if("revoke".equals(eok) && !"B".equals(prinfo.getString("billstatus"))){ | ||||
|                     //清账明细单【单据状态】=已提交,才允许撤销 | ||||
|                     e.setCancelMessage(billno+"【单据状态】=已提交,才允许撤销"); | ||||
|                     e.setCancel(true); | ||||
|                     //若对应的清账单【单据状态】=已提交,则不允许清账明细单撤销,可联系财务驳回 | ||||
|                 }else if("reject".equals(eok) && !"B".equals(prinfo.getString("billstatus"))){ | ||||
|                     //清账明细单【单据状态】=已提交,才允许点击驳回按钮 | ||||
|                     e.setCancelMessage(billno+"【单据状态】=已提交,才允许驳回"); | ||||
|                     e.setCancel(true); | ||||
|                 }else if("reject".equals(eok)){ | ||||
|                     if(!"B".equals(prinfo.getString("billstatus"))){ | ||||
|                         //清账明细单【单据状态】=已提交,才允许点击驳回按钮 | ||||
|                         e.setCancelMessage(billno+"【单据状态】=已提交,才允许驳回"); | ||||
|                         e.setCancel(true); | ||||
|                     } | ||||
|                     //判断对应的清账单是否已审核,如果是,则不允许驳回此明细单 | ||||
|                     clearBillInfo = BusinessDataServiceHelper.loadSingle(prinfo.getString("shjh_clearbillid"),clearBillName,"id,billno,billstatus"); | ||||
|                     if("C".equals(clearBillInfo.getString("billstatus"))){ | ||||
|                         e.setCancelMessage(clearBillInfo.getString("billno")+"清账单已审核,此明细单无需驳回"); | ||||
|                         e.setCancel(true); | ||||
|                     } | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     private boolean checkAmount(DynamicObject prinfo){ | ||||
| 
 | ||||
|         //校验通过返回true | ||||
|         return true; | ||||
|         //TODO【未清金额】+【账扣金额】+【尾差金额】≥【本次核销金额合计】 | ||||
|         BigDecimal billtotal = BigDecimal.ZERO; | ||||
|         BigDecimal a1 = prinfo.getBigDecimal(""); | ||||
|         BigDecimal a2 = prinfo.getBigDecimal(""); | ||||
|         BigDecimal a3 = prinfo.getBigDecimal(""); | ||||
|         if(a1 != null){ | ||||
|             billtotal = billtotal.add(a1); | ||||
|         } | ||||
|         //获取分录本次核销金额合计 | ||||
|         BigDecimal entrytotal = BigDecimal.ZERO; | ||||
|         DynamicObjectCollection doc = prinfo.getDynamicObjectCollection("");//获取分录 | ||||
|         for (int i = 0; i < doc.size(); i++) { | ||||
|             if(doc.get(i).getBigDecimal("") != null){ | ||||
|                 entrytotal = entrytotal.add(doc.get(i).getBigDecimal(""));//累计分录本次核销金额 | ||||
|             } | ||||
|         } | ||||
|         if(billtotal.compareTo(entrytotal) >= 0){ | ||||
|             //校验通过返回true | ||||
|             return true; | ||||
|         } | ||||
|         return false; | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|  | @ -83,12 +123,85 @@ public class ClearDetailBillOperation extends AbstractOperationServicePlugIn imp | |||
|         //提交具体实现 | ||||
|         DynamicObject[] dos =  e.getDataEntities(); | ||||
|         DynamicObject prinfo; | ||||
|         String result; | ||||
|         for (int i = 0; i < dos.length; i++) { | ||||
|             prinfo = dos[i]; | ||||
|             //TODO 将清账明细分录反写至清账单分录,清账单【收款金额】+【账扣】+【尾差】≥【本次核销金额合计】 | ||||
|             result = reWriteClearBill(prinfo); | ||||
|             if(!"success".equals(result)){ | ||||
|                 this.operationResult.setSuccess(false); | ||||
|                 this.operationResult.setMessage("反写清账单失败,原因是:"+result);//前端界面提示内容 | ||||
|                 this.operationResult.setShowMessage(true);//前端界面 是否显示提示消息 | ||||
|                 continue; | ||||
|             } | ||||
|             //清账明细单的OA待办转成已办 | ||||
|             JhzjUtils.handleOA(prinfo,"2", "0"); | ||||
|         } | ||||
|         //将清账明细反写清账单,清账单【收款金额】+【账扣】+【尾差】≥【本次核销金额合计】 | ||||
|     } | ||||
| 
 | ||||
|     private String reWriteClearBill(DynamicObject detailBillInfo){ | ||||
|         //根据清账明细单反写清账单 | ||||
|         String clearBillid = detailBillInfo.getString("shjh_clearbillid"); | ||||
|         DynamicObject clearBillInfo = BusinessDataServiceHelper.loadSingle(clearBillid,clearBillName); | ||||
|         if(clearBillInfo == null){ | ||||
|             return detailBillInfo.getString("shjh_clearbillno")+"清账单未找到"; | ||||
|         } | ||||
|         //给清账单增加互斥锁,如果失败反馈用户 | ||||
|         String lockresult = JhzjUtils.lockBill(clearBillInfo); | ||||
|         if(!"success".equals(lockresult)){ | ||||
|             return clearBillInfo.getString("billno")+lockresult; | ||||
|         } | ||||
|         //清账明细单分录 | ||||
|         DynamicObjectCollection detaildoc = detailBillInfo.getDynamicObjectCollection(""); | ||||
|         //清账单分录 | ||||
|         DynamicObjectCollection cleardoc = clearBillInfo.getDynamicObjectCollection(""); | ||||
|         DynamicObject detailEntryInfo; | ||||
|         DynamicObject clearEntryInfo; | ||||
|         for (int i = 0; i < detaildoc.size(); i++) { | ||||
|             detailEntryInfo = detaildoc.get(i); | ||||
|             clearEntryInfo = cleardoc.addNew(); | ||||
|             clearEntryInfo.set("",detailEntryInfo.getString(""));//凭证号 | ||||
|             clearEntryInfo.set("",detailEntryInfo.getString(""));//凭证类型 | ||||
|             clearEntryInfo.set("",detailEntryInfo.getString(""));//凭证行项目号 | ||||
|             clearEntryInfo.set("",detailEntryInfo.getString(""));//发票号 | ||||
|             clearEntryInfo.set("",detailEntryInfo.getDate(""));//发票日期 | ||||
|             clearEntryInfo.set("",detailEntryInfo.getString(""));// 总账科目 | ||||
|             clearEntryInfo.set("",detailEntryInfo.getString(""));// 分配 | ||||
|             clearEntryInfo.set("",detailEntryInfo.getString(""));// 参照 | ||||
|             clearEntryInfo.set("",detailEntryInfo.getString(""));//参考代码1 | ||||
|             clearEntryInfo.set("",detailEntryInfo.getString(""));// 参考代码2 | ||||
|             clearEntryInfo.set("",detailEntryInfo.getString(""));// 文本 | ||||
|             clearEntryInfo.set("",detailEntryInfo.getDate(""));// 过账日期 | ||||
|             clearEntryInfo.set("",detailEntryInfo.getBigDecimal(""));//未核销金额 | ||||
|             clearEntryInfo.set("",detailEntryInfo.getBigDecimal(""));//本次核销金额 | ||||
|             clearEntryInfo.set("",detailEntryInfo.getString(""));//会计年度 | ||||
|             clearEntryInfo.set("",detailEntryInfo.getString(""));// 清账凭证文本 | ||||
|         } | ||||
|         //处理清账单账扣 | ||||
|         BigDecimal q1 = JhzjUtils.addTwoAmount(clearBillInfo.getBigDecimal(""), | ||||
|                 detailBillInfo.getBigDecimal("")); | ||||
|         clearBillInfo.set("",q1); | ||||
|         //处理清账单尾差 | ||||
|         BigDecimal q2 = JhzjUtils.addTwoAmount(clearBillInfo.getBigDecimal(""), | ||||
|                 detailBillInfo.getBigDecimal("")); | ||||
|         clearBillInfo.set("",q2); | ||||
|         //获取清账单收款金额 | ||||
|         BigDecimal q3 =clearBillInfo.getBigDecimal(""); | ||||
|         //获取清账单的本次核销金额合计 | ||||
|         BigDecimal entrytotal = BigDecimal.ZERO; | ||||
|         for (int i = 0; i < cleardoc.size(); i++) { | ||||
|             clearEntryInfo = cleardoc.get(i); | ||||
|             entrytotal = entrytotal.add(clearEntryInfo.getBigDecimal("")); | ||||
|         } | ||||
|         //清账单的收款金额+账扣+尾差=本次核销金额合计,即可提交 | ||||
|         if(entrytotal.compareTo(q1.add(q2).add(q3)) == 0){ | ||||
|             clearBillInfo.set("billstatus","B"); | ||||
|         } | ||||
|         SaveServiceHelper.save(new DynamicObject[]{clearBillInfo}); | ||||
|         //解除清账单互斥锁 | ||||
|         JhzjUtils.unLockBill(clearBillInfo); | ||||
| 
 | ||||
|         return "success"; | ||||
|     } | ||||
| 
 | ||||
|     private void handleRevoke(AfterOperationArgs e){ | ||||
|  | @ -98,15 +211,25 @@ public class ClearDetailBillOperation extends AbstractOperationServicePlugIn imp | |||
|         DynamicObject prinfo; | ||||
|         for (int i = 0; i < dos.length; i++) { | ||||
|             prinfo = dos[i]; | ||||
|             DB.update(DBRoute.of("fi"), updateDetailByID, new Object[]{prinfo.getLong("id")}); | ||||
|             DB.update(DBRoute.of("fi"), updateDetailSave, new Object[]{prinfo.getLong("id")}); | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     private void handleReject(AfterOperationArgs e){ | ||||
|         //驳回具体实现 | ||||
|         //清账明细单【单据状态】=驳回 | ||||
|         //若清账单【单据状态】=提交,则需调用清账单撤销,清账单【单据状态】=暂存。 | ||||
|         //业务员可修改后,再次提交。驳回时,对清账明细单创建人发送邮件通知,OA待办 | ||||
|         DynamicObject[] dos =  e.getDataEntities(); | ||||
|         DynamicObject prinfo; | ||||
|         for (int i = 0; i < dos.length; i++) { | ||||
|             prinfo = BusinessDataServiceHelper.loadSingle(dos[i].getPkValue(),dos[i].getDataEntityType().getName()); | ||||
|             //若清账单【单据状态】=已提交,则更新清账单【单据状态】=暂存。 | ||||
|             DB.update(DBRoute.of("fi"), updateClearBillSave, new Object[]{prinfo.getString("shjh_clearbillid")}); | ||||
|             //清账明细单【单据状态】=驳回 | ||||
|             DB.update(DBRoute.of("fi"), updateDetailReject, new Object[]{prinfo.getLong("id")}); | ||||
|             //驳回时,对清账明细单修改人发送邮件通知,OA待办 业务员可修改后,再次提交。 | ||||
|             JhzjUtils.sendEmail(prinfo.getDynamicObject("modifier").getString("email"),"请登录资金系统操作清账明细单", | ||||
|                     prinfo.getString("billno")+"\n 详情页面"+JhzjUtils.getBillPCURL(prinfo),"清账明细单新增"); | ||||
|             JhzjUtils.handleOA(prinfo,"0", "0"); | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
| } | ||||
|  | @ -0,0 +1,35 @@ | |||
| package shjh.jhzj7.fi.fi.plugin.task; | ||||
| 
 | ||||
| import kd.bos.context.RequestContext; | ||||
| import kd.bos.dataentity.entity.DynamicObject; | ||||
| import kd.bos.exception.KDException; | ||||
| import kd.bos.logging.Log; | ||||
| import kd.bos.logging.LogFactory; | ||||
| import kd.bos.orm.query.QCP; | ||||
| import kd.bos.orm.query.QFilter; | ||||
| import kd.bos.schedule.executor.AbstractTask; | ||||
| import kd.bos.servicehelper.BusinessDataServiceHelper; | ||||
| import kd.sdk.plugin.Plugin; | ||||
| 
 | ||||
| import java.math.BigDecimal; | ||||
| import java.util.Map; | ||||
| 
 | ||||
| /** | ||||
|  * 定时任务更新资金计划收款实际数 | ||||
|  */ | ||||
| public class FundPlanCollectionTask extends AbstractTask implements Plugin { | ||||
|     private static final String entityName = "bd_accountview"; | ||||
| 
 | ||||
| 
 | ||||
|     private static final Log logger = LogFactory.getLog(FundPlanCollectionTask.class); | ||||
| 
 | ||||
|     @Override | ||||
|     public void execute(RequestContext requestContext, Map<String, Object> map) throws KDException { | ||||
|         //查询当月已审核收款类资金计划(收款不区分公司,当月应只有一个) | ||||
|         QFilter qFilter = new QFilter("receredtype", QCP.equals, "0"); | ||||
|         qFilter.and("creditamount", QCP.not_equals, BigDecimal.ZERO); | ||||
|         qFilter.and("claimnoticebillno", QCP.equals, ""); | ||||
|         qFilter.and("billno", QCP.equals, "20250211-0000000094"); | ||||
|         DynamicObject[] collection = BusinessDataServiceHelper.load(entityName, "id", qFilter.toArray()); | ||||
|     } | ||||
| } | ||||
|  | @ -0,0 +1,39 @@ | |||
| package shjh.jhzj7.fi.fi.plugin.task; | ||||
| 
 | ||||
| import kd.bos.context.RequestContext; | ||||
| import kd.bos.dataentity.entity.DynamicObject; | ||||
| import kd.bos.entity.operate.result.OperationResult; | ||||
| import kd.bos.exception.KDException; | ||||
| import kd.bos.logging.Log; | ||||
| import kd.bos.logging.LogFactory; | ||||
| import kd.bos.orm.query.QCP; | ||||
| import kd.bos.orm.query.QFilter; | ||||
| import kd.bos.schedule.executor.AbstractTask; | ||||
| import kd.bos.servicehelper.BusinessDataServiceHelper; | ||||
| import kd.sdk.plugin.Plugin; | ||||
| import shjh.jhzj7.fi.fi.utils.JhzjUtils; | ||||
| 
 | ||||
| import java.math.BigDecimal; | ||||
| import java.util.Map; | ||||
| 
 | ||||
| /** | ||||
|  * 定时任务收款单自动下推生成清账单 | ||||
|  */ | ||||
| public class ReceBillToClearBillTask extends AbstractTask implements Plugin { | ||||
|     private static final String srcEntityName = "cas_recbill";//源单 收款单 | ||||
|     private static final String destEntityName = "shjh_clear_account";//目标单 清账单 | ||||
| 
 | ||||
|     private static final Log logger = LogFactory.getLog(FundPlanCollectionTask.class); | ||||
| 
 | ||||
|     @Override | ||||
|     public void execute(RequestContext requestContext, Map<String, Object> map) throws KDException { | ||||
|         //设置定时任务,按时下推清账单,T+1日下推T及T之前收款单,生成清账单 | ||||
|         QFilter qFilter = new QFilter("receredtype", QCP.equals, "0"); | ||||
|         qFilter.and("creditamount", QCP.not_equals, BigDecimal.ZERO); | ||||
|         qFilter.and("claimnoticebillno", QCP.equals, ""); | ||||
|         qFilter.and("billno", QCP.equals, "20250211-0000000094"); | ||||
|         DynamicObject[] collection = BusinessDataServiceHelper.load(srcEntityName, "id", qFilter.toArray()); | ||||
| 
 | ||||
|         OperationResult operationResult3 = JhzjUtils.push(srcEntityName, destEntityName, null); | ||||
|     } | ||||
| } | ||||
|  | @ -2,15 +2,20 @@ package shjh.jhzj7.fi.fi.utils; | |||
| 
 | ||||
| import kd.bos.context.RequestContext; | ||||
| import kd.bos.dataentity.entity.DynamicObject; | ||||
| import kd.bos.dataentity.entity.ILocaleString; | ||||
| import kd.bos.dataentity.entity.LocaleString; | ||||
| import kd.bos.logging.Log; | ||||
| import kd.bos.logging.LogFactory; | ||||
| import kd.bos.message.api.EmailInfo; | ||||
| import kd.bos.message.api.MessageChannels; | ||||
| import kd.bos.message.service.handler.EmailHandler; | ||||
| import kd.bos.mutex.DataMutex; | ||||
| import kd.bos.servicehelper.BusinessDataServiceHelper; | ||||
| import kd.bos.servicehelper.operation.SaveServiceHelper; | ||||
| 
 | ||||
| import java.math.BigDecimal; | ||||
| import java.text.SimpleDateFormat; | ||||
| import java.util.Date; | ||||
| import java.util.HashMap; | ||||
| import java.util.Map; | ||||
| import java.util.*; | ||||
| 
 | ||||
| import kd.bos.data.BusinessDataReader; | ||||
| import kd.bos.dataentity.OperateOption; | ||||
|  | @ -27,8 +32,8 @@ import kd.bos.entity.operate.result.IOperateInfo; | |||
| import kd.bos.entity.operate.result.OperationResult; | ||||
| import kd.bos.exception.KDBizException; | ||||
| import kd.bos.servicehelper.botp.ConvertServiceHelper; | ||||
| import java.util.ArrayList; | ||||
| import java.util.List; | ||||
| import kd.bos.servicehelper.workflow.MessageCenterServiceHelper; | ||||
| import kd.bos.workflow.engine.msg.info.MessageInfo; | ||||
| 
 | ||||
| 
 | ||||
| public class JhzjUtils { | ||||
|  | @ -36,10 +41,23 @@ public class JhzjUtils { | |||
|     public static final Long GROUPID = 100000l;//组织根节点ID | ||||
|     public static final Long CNY = 1l;//人民币-币别ID | ||||
| 
 | ||||
|     private static final String groupId = "default_netctrl";//单据网络互斥默认分组 | ||||
| 
 | ||||
|     private static final Log logger = LogFactory.getLog(JhzjUtils.class); | ||||
| 
 | ||||
|     public static boolean isEmpty(String value) { | ||||
|         return value == null || value.trim().length() <= 0; | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * 保存接口调用过程中的日志 | ||||
|      * @param billno   单据编号 | ||||
|      * @param jkname 接口名称 | ||||
|      * @param inputs 接口入参 | ||||
|      * @param outputs 接口出参 | ||||
|      * @param isSuccess 接口是否调用成功 | ||||
|      * @param operation 上游操作触发 | ||||
|      */ | ||||
|     public static void saveLog(String billno,String jkname,String inputs,String outputs,boolean isSuccess,String operation){ | ||||
|         //保存星瀚与第三方接口调用之间的日志记录 | ||||
|         //参数说明:单据编号、接口名称、接口入参、接口返回值、接口执行结果是否成功、操作名称(audit、unaudit等) | ||||
|  | @ -74,6 +92,40 @@ public class JhzjUtils { | |||
|         saveLog(email,"邮件",content,(String)sendResult.get("description"),(Boolean)sendResult.get("result"),operation); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * 组装入参,给指定人员发企微消息 | ||||
|      * @param email   邮箱地址 | ||||
|      * @param title1 邮件主题 | ||||
|      * @param content1 邮件内容 | ||||
|      * @param operation 上游操作触发 | ||||
|      */ | ||||
|     public static void sendWEIXINQY(String email, String title1, String content1,String operation){ | ||||
|         //构建消息体发送 | ||||
|         MessageInfo message = new MessageInfo(); | ||||
|         //信息title | ||||
|         ILocaleString title = new LocaleString("测试消息主题"); | ||||
|         message.setMessageTitle(title); | ||||
|         //信息主体 | ||||
|         ILocaleString content = new LocaleString("消息主体内容,请登录资金系统处理业务"); | ||||
|         message.setMessageContent(content); | ||||
|         //信息接收人 | ||||
|         ArrayList<Long> receivers = new ArrayList<>(); | ||||
|         receivers.add(RequestContext.get().getCurrUserId()); | ||||
|         message.setUserIds(receivers); | ||||
|         //信息标签 | ||||
|         ILocaleString tag = new LocaleString("消息提醒"); | ||||
|         message.setTag(tag.getLocaleValue_zh_CN()); | ||||
|         message.setMessageTag(tag); | ||||
|         //信息发送人 | ||||
|         message.setSenderId(RequestContext.get().getCurrUserId()); | ||||
|         message.setType(MessageInfo.TYPE_MESSAGE); | ||||
|         StringBuilder notifyType = new StringBuilder(); | ||||
|         notifyType.append(MessageChannels.WEIXINQY).append(","); | ||||
|         notifyType.append(MessageChannels.EMAIL); | ||||
|         message.setNotifyType(notifyType.toString()); | ||||
|         MessageCenterServiceHelper.sendMessage(message); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * 组装入参,处理OA接口调用 | ||||
|      * @param prinfo   清账明细单 | ||||
|  | @ -111,6 +163,100 @@ public class JhzjUtils { | |||
|         OAUtils.thirdParty(thirdPartyMap); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * 根据指定的对象增加网络互斥,让其他人不可修改 | ||||
|      * @param prinfo 具体对象,可以是收付款单、清账单和明细单 | ||||
|      **/ | ||||
|     public static String lockBill(DynamicObject prinfo){ | ||||
|         try (DataMutex dataMutex = DataMutex.create()) { | ||||
|             //如果需要和标准操作(如保存、提交、审核)互斥,则可使用default_netctrl(默认分组),不需要和标准操作互斥则需要用自定义的groupId | ||||
|             String entityKey = prinfo.getDataEntityType().getName(); | ||||
|             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_ENTITYKEY, entityKey); | ||||
|             requireParam.put(DataMutex.PARAMNAME_OPERATIONKEY, "modify"); | ||||
|             requireParam.put(DataMutex.PARAMNAME_ISSTRICT, true); | ||||
|             //建议设置自定义标识,用于后续区分标准操作和自定义申请的网控 | ||||
|             requireParam.put(DataMutex.PARAMNAME_DATA_CALL_SOURCE, "reWriteClearBill"); | ||||
|             mutexRequireList.add(requireParam); | ||||
|             Map mutexResult = dataMutex.batchrequire(mutexRequireList); | ||||
|             Iterator it = mutexResult.entrySet().iterator(); | ||||
|             if(it.hasNext()){ | ||||
|                 Map.Entry next = (Map.Entry) it.next(); | ||||
| //                String key = (String) next.getKey(); | ||||
|                 if ((Boolean) next.getValue()) { | ||||
|                     //申请互斥成功的 | ||||
|                     return "success"; | ||||
|                 } else { | ||||
|                     return "清账单锁定失败,已被其他人占用"; | ||||
| //                    Map lockInfo = dataMutex.getLockInfo(key, groupId, entityKey); | ||||
| //                    if (lockInfo != null) { | ||||
| //                        //申请锁失败,提示已经存在的锁信息 | ||||
| //                    } | ||||
|                 } | ||||
|             } | ||||
|             return "清账单锁定异常,请稍后再试"; | ||||
|         } catch (Exception e) { | ||||
|             logger.error(e); | ||||
|             return "清账单锁定异常,请稍后再试"; | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * 根据指定的对象清除网络互斥,让其他人可修改 | ||||
|      * @param prinfo 具体对象,可以是收付款单、清账单和明细单 | ||||
|      **/ | ||||
|     public static void unLockBill(DynamicObject prinfo){ | ||||
|         try (DataMutex dataMutex = DataMutex.create()) { | ||||
|             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_ENTITYKEY, prinfo.getDataEntityType().getName()); | ||||
|             requireParam.put(DataMutex.PARAMNAME_OPERATIONKEY, "modify"); | ||||
|             mutexRequireList.add(requireParam); | ||||
|             dataMutex.batchRelease(mutexRequireList); | ||||
| //            Set set = mutexResult.entrySet(); | ||||
| //            Iterator it = set.iterator(); | ||||
| //            while(it.hasNext()){ | ||||
| //                Map.Entry next = (Map.Entry) it.next(); | ||||
| //                String key = (String) next.getKey(); | ||||
| //                Boolean value = (Boolean) next.getValue(); | ||||
| //                if (value) { | ||||
| //                    //申请互斥成功的 | ||||
| //                } else { | ||||
| //                    Map lockInfo = dataMutex.getLockInfo(key, groupId, entityKey); | ||||
| //                    if (lockInfo != null) { | ||||
| //                        //申请锁失败,提示已经存在的锁信息 | ||||
| //                    } | ||||
| //                } | ||||
| //            } | ||||
|         } catch (Exception e) { | ||||
|             logger.error(e); | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     /* | ||||
|     * 两个金额字段相加,如果两个都为null,返回0 | ||||
|     * 两个有一个为null,返回其中一个值;两个都不为null,则相加 | ||||
|     * */ | ||||
|     public static BigDecimal addTwoAmount(BigDecimal a1, BigDecimal a2){ | ||||
|         if(a1 == null && a2 != null){ | ||||
|             return a2; | ||||
|         }else if(a2 == null && a1 != null){ | ||||
|             return a1; | ||||
|         }else if(a1 != null && a2 != null){ | ||||
|             return a1.add(a2); | ||||
|         } | ||||
|         return BigDecimal.ZERO; | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * 根据指定的对象获取其详情界面的url | ||||
|      * @param prinfo 具体对象,可以是收付款单、清账单和明细单 | ||||
|      **/ | ||||
|     public static String getBillPCURL(DynamicObject prinfo){ | ||||
|         //获得单据的pc详情url | ||||
|         //https://ip:port/ierp/index.html?formId=er_tripreqbill&pkId=721810009540800512 | ||||
|  | @ -121,6 +267,8 @@ public class JhzjUtils { | |||
| 
 | ||||
|     /** | ||||
|      * 收款单下推清账单-默认下推 | ||||
|      * @param oribill 源单标识-收款单 | ||||
|      * @param tobill 目标单标识-清账单 | ||||
|      **/ | ||||
|     public static OperationResult push(String oribill, String tobill, String oribillid) { | ||||
|         // 生成下推参数PushArgs | ||||
|  |  | |||
|  | @ -214,6 +214,8 @@ public class PersonControler implements Serializable { | |||
| //                    itemInfo.put("message",""); | ||||
|                     //更新人员对应客户的银行信息 | ||||
|                     handlePersonForCustomer(result); | ||||
|                     //TODO 处理人员金蝶id和企微id的对应关系 | ||||
|                     handlePersonImmapping(result); | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|  | @ -250,6 +252,18 @@ public class PersonControler implements Serializable { | |||
|         } | ||||
|     } | ||||
| 
 | ||||
|     private void handlePersonImmapping(UserParam ups){ | ||||
|         /* | ||||
|         * 这里可以使用企业微信同步用户,也可以直接在系统库中t_bas_immapping表插入数据,需要苍穹中用户的主键和微信中用户的openId,可以在苍穹的系统库使用sql: | ||||
|         insert into t_bas_immapping (fid, FIMTYPEID, FOPENID) value (主键, 类型(暂时随便给值也可以), '微信公众号用户的openId'); | ||||
|         update t_bas_immapping SET FUSERID = (select fid from t_sec_user where fphone = '用户手机号') where fid = '用户手机号'; | ||||
|         如果没有同步用户,即t_bas_immapping表中查不到数据,则会跳转到苍穹登陆界面;用户输入信息之后苍穹会自动在t_bas_immapping中获取openid并存储; | ||||
|         * ( 此逻辑在kd.bos.login.thirdauth.app.tencent.WxgzhLoginAfter中,目前标准代码存在bug,多系统对接对于同一个fuserid会替换openid, | ||||
|         * 导致单点登录到别的系统失败,多系统对接需要修改总部标准代码或者联系总部出私包解决 ) | ||||
|         * */ | ||||
| 
 | ||||
|     } | ||||
| 
 | ||||
|     private void handlePersonForCustomer(UserParam ups){ | ||||
|         String cusnumber = (String) ups.getDataMap().get("number");//客户编号-即是 人员的编号 | ||||
|         DynamicObject currentCus = BusinessDataServiceHelper.loadSingle(cusEntityName,new QFilter[]{new QFilter("number","=",cusnumber)}); | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue