清账接口
This commit is contained in:
		
							parent
							
								
									fa7d486e14
								
							
						
					
					
						commit
						02d9b1c94b
					
				|  | @ -200,6 +200,7 @@ public class ASParbillFormPlugin extends AbstractFormPlugin implements Plugin { | |||
|                     detail = (JSONObject) rows.get(i); | ||||
|                     entry.addNew(); | ||||
|                     setEntityRowValues(detail, i); | ||||
|                     this.getModel().setValue("shjh_e_pzh","001", i); | ||||
|                 } | ||||
|                 this.getView().updateView(entryID); | ||||
|             } | ||||
|  |  | |||
|  | @ -0,0 +1,36 @@ | |||
| package shjh.jhzj7.fi.fi.plugin.form; | ||||
| 
 | ||||
| import kd.bos.dataentity.entity.DynamicObjectCollection; | ||||
| import kd.bos.dataentity.utils.StringUtils; | ||||
| import kd.bos.entity.datamodel.events.PropertyChangedArgs; | ||||
| import kd.bos.form.plugin.AbstractFormPlugin; | ||||
| import kd.sdk.plugin.Plugin; | ||||
| 
 | ||||
| 
 | ||||
| /** | ||||
|  * 表单插件-理财收益批量预提 shjh_cim_intbill_batc_ext | ||||
|  * 分录增加金额字段【现值】,由资金老师手动录入;录入后系统计算预提差额 | ||||
|  * @author yuxueliang | ||||
|  */ | ||||
| public class IntBillBatchFormPlugin extends AbstractFormPlugin implements Plugin { | ||||
| 
 | ||||
|     private final static String entryID = "entry";//分录标识 | ||||
| 
 | ||||
|     @Override | ||||
|     public void propertyChanged(PropertyChangedArgs e) { | ||||
|         super.propertyChanged(e); | ||||
|         String fieldKey = e.getProperty().getName(); | ||||
|         if (StringUtils.equals(fieldKey, "shjh_nowamount")){ | ||||
|             //分录现值字段的值改变事件 | ||||
|             DynamicObjectCollection docolls = this.getModel().getEntryEntity(entryID); | ||||
|             if (null != docolls && !docolls.isEmpty()) { | ||||
|                 calcAmount(docolls); | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     private void calcAmount(DynamicObjectCollection docolls){ | ||||
| 
 | ||||
|     } | ||||
| 
 | ||||
| } | ||||
|  | @ -44,6 +44,7 @@ public class ClearAccountBillOperation extends AbstractOperationServicePlugIn im | |||
| 
 | ||||
|     private static final String entityName = "shjh_clear_acctdetail";//清账明细单 | ||||
|     private static final String userName = "bos_user";//用户 | ||||
|     private static final String recbillName = "cas_recbill";//收款单 | ||||
|     private static final String pzbName = "shjh_jgqzcust";//结构性清账客户映射表 | ||||
| 
 | ||||
|     /** | ||||
|  | @ -223,29 +224,17 @@ public class ClearAccountBillOperation extends AbstractOperationServicePlugIn im | |||
|         QFilter qFilter; | ||||
|         DynamicObject[] pzbs; | ||||
|         DynamicObject pzbinfo;//配置表 | ||||
|         DynamicObject userinfo;//用户 | ||||
|         DynamicObject userinfo;//被通知用户 | ||||
|         DynamicObjectCollection users;//配置表中的被通知人集合 | ||||
|         for (int i = 0; i < dos.length; i++) { | ||||
|             prinfo = BusinessDataServiceHelper.loadSingle(dos[i].getPkValue(), dos[i].getDataEntityType().getName()); | ||||
| //            billno = prinfo.getString("billno"); | ||||
|             //根据客户、公司、是否可用找到对应的被通知人员(可能多个) | ||||
|             qFilter = new QFilter("enable", QCP.equals, "1"); | ||||
|             qFilter.and("shjh_customer", QCP.equals, prinfo.getDynamicObject("shjh_customer").getLong("id")); | ||||
|             qFilter.and("shjh_org", QCP.equals, prinfo.getDynamicObject("org").getLong("id")); | ||||
|             pzbs = BusinessDataServiceHelper.load(pzbName, "id", qFilter.toArray(), "modifytime desc"); | ||||
|             if (pzbs.length == 0) { | ||||
|                 addErrorInfo(prinfo,"根据结构性清账客户映射表未找到对应通知人,无法下推清账明细单"); | ||||
|                 continue; | ||||
|             } | ||||
|             pzbinfo = BusinessDataServiceHelper.loadSingle(pzbs[0].getLong("id"), pzbName); | ||||
|             users = pzbinfo.getDynamicObjectCollection("shjh_users"); | ||||
|             for (DynamicObject user : users) { | ||||
|                 userinfo = user.getDynamicObject("fbasedataid");//fbasedataid | ||||
|             //判断当前清账单是否由收款单补推,如果是,则根据清账单上的被通知人进行通知;否则根据配置表 | ||||
|             userinfo = prinfo.getDynamicObject("shjh_noticeuser"); | ||||
|             if(userinfo != null){ | ||||
|                 //根据清账单id和创建人id判断清账明细单是否已生成 | ||||
|                 qFilter = new QFilter("shjh_clearbillid", QCP.equals, prinfo.getString("id")); | ||||
|                 qFilter.and("creator", QCP.equals, userinfo.getLong("id")); | ||||
|                 if (!QueryServiceHelper.exists(entityName, qFilter.toArray())) { | ||||
| //                    userinfo = BusinessDataServiceHelper.loadSingleFromCache(user.getDynamicObject("fbasedataid"), userName); | ||||
|                     //新增一个清账明细单 | ||||
|                     detailinfo = newDetailBill(prinfo, userinfo); | ||||
|                     //发送清账明细单的OA待办 | ||||
|  | @ -253,7 +242,34 @@ public class ClearAccountBillOperation extends AbstractOperationServicePlugIn im | |||
|                     JhzjUtils.sendEmail(userinfo.getString("email"), "请登录资金系统操作清账明细单", | ||||
|                             detailinfo.getString("billno") + "\n 详情页面" + JhzjUtils.getBillPCURL(detailinfo), "清账明细单新增"); | ||||
|                 } | ||||
|             }else{ | ||||
|                 //根据客户、公司、是否可用找到对应的被通知人员(可能多个) | ||||
|                 qFilter = new QFilter("enable", QCP.equals, "1"); | ||||
|                 qFilter.and("shjh_customer", QCP.equals, prinfo.getDynamicObject("shjh_customer").getLong("id")); | ||||
|                 qFilter.and("shjh_org", QCP.equals, prinfo.getDynamicObject("org").getLong("id")); | ||||
|                 pzbs = BusinessDataServiceHelper.load(pzbName, "id", qFilter.toArray(), "modifytime desc"); | ||||
|                 if (pzbs.length == 0) { | ||||
|                     addErrorInfo(prinfo,"根据结构性清账客户映射表未找到对应通知人,无法下推清账明细单"); | ||||
|                     continue; | ||||
|                 } | ||||
|                 pzbinfo = BusinessDataServiceHelper.loadSingle(pzbs[0].getLong("id"), pzbName); | ||||
|                 users = pzbinfo.getDynamicObjectCollection("shjh_users"); | ||||
|                 for (DynamicObject user : users) { | ||||
|                     userinfo = user.getDynamicObject("fbasedataid");//fbasedataid | ||||
|                     //根据清账单id和创建人id判断清账明细单是否已生成 | ||||
|                     qFilter = new QFilter("shjh_clearbillid", QCP.equals, prinfo.getString("id")); | ||||
|                     qFilter.and("creator", QCP.equals, userinfo.getLong("id")); | ||||
|                     if (!QueryServiceHelper.exists(entityName, qFilter.toArray())) { | ||||
|                         //新增一个清账明细单 | ||||
|                         detailinfo = newDetailBill(prinfo, userinfo); | ||||
|                         //发送清账明细单的OA待办 | ||||
|                         JhzjUtils.handleOA(detailinfo, "0", "0"); | ||||
|                         JhzjUtils.sendEmail(userinfo.getString("email"), "请登录资金系统操作清账明细单", | ||||
|                                 detailinfo.getString("billno") + "\n 详情页面" + JhzjUtils.getBillPCURL(detailinfo), "清账明细单新增"); | ||||
|                     } | ||||
|                 } | ||||
|             } | ||||
| 
 | ||||
|             //处理完成提示 | ||||
|             this.operationResult.addSuccessPkId(prinfo.getPkValue()); | ||||
|         } | ||||
|  | @ -402,40 +418,73 @@ public class ClearAccountBillOperation extends AbstractOperationServicePlugIn im | |||
|         JSONObject IS_HEADER = new JSONObject();//抬头 | ||||
|         JSONArray IT_ITEM = new JSONArray();//详细 | ||||
|         JSONArray IT_CLEAR = new JSONArray();//清账数据 | ||||
|         SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");//日期格式化工具 | ||||
|         String companyCode = prinfo.getDynamicObject("org").getString("number"); | ||||
|         DynamicObject customerinfo = prinfo.getDynamicObject("shjh_customer");//客户对象 | ||||
|         IS_HEADER.put("BUKRS",companyCode);//公司代码 | ||||
|         IS_HEADER.put("BLART","KA");//TODO 凭证类型 | ||||
|         IS_HEADER.put("BUDAT","2025.03.01");//TODO 过账日期 | ||||
|         IS_HEADER.put("BLART","AB");//凭证类型-清账凭证 | ||||
|         IS_HEADER.put("BLDAT",sdf.format(prinfo.getDate("shjh_bizdate")));//凭证日期-业务日期 | ||||
|         IS_HEADER.put("BUDAT",sdf.format(new Date()));//过账日期-当前日期 | ||||
|         String isoCode = prinfo.getDynamicObject("shjh_currency").getString("number"); | ||||
|         IS_HEADER.put("WAERS",JhzjUtils.getCurrencyCode(isoCode));//币种 | ||||
|         IS_HEADER.put("XBLNR","KA");//TODO 参考凭证号 | ||||
|         IS_HEADER.put("BKTXT","KA");//TODO 凭证抬头文本 | ||||
|         //添加用户名过滤条件-操作反清账按钮的用户(OA用户名) | ||||
|         IS_HEADER.put("XBLNR",prinfo.getString("billno"));//参考凭证号-单据编号 固定长度16位 | ||||
|         IS_HEADER.put("BKTXT",customerinfo.getString("name"));//凭证抬头文本 习惯传 供应商||客户名称 | ||||
|         //添加用户名过滤条件-操作审核按钮的用户(OA用户名) | ||||
|         DynamicObject userinfo = BusinessDataServiceHelper.loadSingleFromCache(RequestContext.get().getCurrUserId(), userName); | ||||
|         String oauser = userinfo.getString("shjh_oauser"); | ||||
|         IS_HEADER.put("USNAM",oauser);//用户名 | ||||
|         //----------------处理详细入参---------------------- | ||||
|         String customerCode = customerinfo.getString("number"); | ||||
|         JSONObject item = new JSONObject(); | ||||
| 
 | ||||
|         item.put("KUNNR",customerCode);//客户编号 | ||||
|         item.put("HKONT","");//TODO 总账科目 | ||||
|         item.put("DMBTR",prinfo.getString("shjh_receamount"));//金额-传清账单收款金额 | ||||
|         IT_ITEM.add(item); | ||||
|         //----------------处理清账数据入参---------------------- | ||||
|         String customerCode = prinfo.getDynamicObject("shjh_customer").getString("number"); | ||||
|         DynamicObjectCollection docolls = prinfo.getDynamicObjectCollection("shjh_details"); | ||||
|         DynamicObject entryinfo; | ||||
|         JSONObject clear; | ||||
|         JSONObject clear;//从清账单分录获取应收的凭证数据 | ||||
|         for (int i = 0; i < docolls.size(); i++) { | ||||
|             entryinfo = docolls.get(i); | ||||
|             clear = new JSONObject(); | ||||
|             clear.put("BUKRS",companyCode);//公司代码 | ||||
|             clear.put("BELNR",entryinfo.getString("shjh_e_pzh"));//应收会计凭证编号 | ||||
|             clear.put("GJAHR",entryinfo.getString("shjh_e_pzh"));//会计年度 | ||||
|             clear.put("GJAHR",entryinfo.getString("shjh_e_year"));//会计年度 | ||||
|             clear.put("BUZEI",entryinfo.getString("shjh_e_pzhh"));//行编号 | ||||
|             clear.put("KUNNR",customerCode);//客户编号 | ||||
| //            clear.put("LIFNR",);//供应商编号 | ||||
|             //TODO 特殊总帐标识 未清金额 剩余金额 | ||||
|             clear.put("HKONT",entryinfo.getString("shjh_e_account"));//总账科目 | ||||
|             clear.put("DMBTR1",entryinfo.getString("shjh_e_cursettle"));//清账金额 | ||||
|             IT_CLEAR.add(clear); | ||||
|         } | ||||
|         //从收款单cas_recbill获取实收的凭证数据 | ||||
|         //先根据关系表找到收款单id和分录id,再将收款单对象查出来 | ||||
|         Map<Long,Long> entrybillids = DB.query(DBRoute.of("fi"),queryRealtion,new Object[]{prinfo.getPkValue()},(rs) -> { | ||||
|             Map<Long,Long> entryidList = new HashMap<>(); | ||||
|             while(rs.next()) { | ||||
|                 entryidList.put(rs.getLong(1),rs.getLong(2)); | ||||
|             } | ||||
|             return entryidList; | ||||
|         }); | ||||
|         //遍历map | ||||
|         DynamicObject recebill; | ||||
|         for (Map.Entry<Long,Long> entry : entrybillids.entrySet()) { | ||||
|             entry.getKey();//收款单分录ID | ||||
|             entry.getValue();//收款单ID | ||||
|             recebill = BusinessDataServiceHelper.loadSingleFromCache(entry.getValue(), recbillName); | ||||
|             docolls = recebill.getDynamicObjectCollection("entry");//收款明细分录 | ||||
|             for(DynamicObject receentry : docolls){ | ||||
|                 if(receentry.getLong("id") == entry.getKey()){ | ||||
|                     clear = new JSONObject(); | ||||
|                     clear.put("BUKRS",companyCode);//公司代码 | ||||
|                     clear.put("KUNNR",customerCode);//客户编号 | ||||
|                     //shjh_vouchernum 收款sap凭证号 | ||||
|                     //shjh_sapfiscalyear 收款sap会计年度 | ||||
|                     //shjh_sapline 收款sap凭证行号 | ||||
|                     IT_CLEAR.add(clear); | ||||
|                     break; | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
| 
 | ||||
|         JSONObject sapReturnData = SapUtils.sapTransactionAPI(IS_HEADER,IT_ITEM,IT_CLEAR,prinfo.getString("billno")); | ||||
|         //sap返回的结果不为空且正确 | ||||
|  |  | |||
|  | @ -218,6 +218,7 @@ public class ClearDetailBillOperation extends AbstractOperationServicePlugIn imp | |||
|             clearEntryInfo.set("shjh_e_qzpztext",detailEntryInfo.getString("shjh_e_qzpztext"));// 清账凭证文本 | ||||
|             clearEntryInfo.set("shjh_e_detailentryid",detailEntryInfo.getString("id"));// 明细单分录ID | ||||
|             clearEntryInfo.set("shjh_e_detailbillid",detailBillInfo.getString("id"));// 明细单ID | ||||
|             clearEntryInfo.set("shjh_e_detailbillno",detailBillInfo.getString("billno"));// 明细单编号 | ||||
|         } | ||||
|         //处理清账单账扣 | ||||
|         BigDecimal q1 = JhzjUtils.addTwoAmount(clearBillInfo.getBigDecimal("shjh_deductionamount"), | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue