sap凭证接口
This commit is contained in:
		
							parent
							
								
									13fc0b0ebb
								
							
						
					
					
						commit
						ba6dffb339
					
				|  | @ -16,7 +16,6 @@ import kd.bos.form.events.BeforeClosedEvent; | |||
| import kd.bos.form.plugin.AbstractFormPlugin; | ||||
| import kd.bos.logging.Log; | ||||
| import kd.bos.logging.LogFactory; | ||||
| import kd.sdk.plugin.Plugin; | ||||
| import shjh.jhzj7.fi.fi.utils.SapUtils; | ||||
| 
 | ||||
| import java.text.SimpleDateFormat; | ||||
|  | @ -27,7 +26,7 @@ import java.util.EventObject; | |||
|  * 动态表单插件-【SAP应收未清】 shjh_sapyswq | ||||
|  * @author yuxueliang | ||||
|  */ | ||||
| public class ASParbillFormPlugin extends AbstractFormPlugin implements Plugin { | ||||
| public class ASParbillFormPlugin extends AbstractFormPlugin { | ||||
| 
 | ||||
|     private final static Log logger = LogFactory.getLog(ASParbillFormPlugin.class); | ||||
|     private final static String entryID = "shjh_entryentity";//分录标识 | ||||
|  | @ -79,6 +78,7 @@ public class ASParbillFormPlugin extends AbstractFormPlugin implements Plugin { | |||
|             IDataModel model = parentView.getModel();//获取父表单模型 | ||||
|             this.getModel().setValue("shjh_org",model.getDataEntity().get("org"));//公司从父页面带过来 | ||||
|             this.getModel().setValue("shjh_customer",model.getDataEntity().get("shjh_customer"));//客户从父页面带过来 | ||||
|             this.getModel().setValue("shjh_currency",model.getDataEntity().get("shjh_currency"));//币别从父页面带过来 | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|  | @ -195,12 +195,13 @@ public class ASParbillFormPlugin extends AbstractFormPlugin implements Plugin { | |||
|                 JSONArray rows = data.getJSONArray("IT_ITEM"); | ||||
|                 DynamicObjectCollection entry = this.getModel().getEntryEntity(entryID); | ||||
|                 entry.clear(); | ||||
|                 JSONObject detail; | ||||
|                 this.getModel().deleteEntryData(entryID); | ||||
|                 JSONObject detailJson; | ||||
|                 for (int i = 0; i < rows.size(); i++) { | ||||
|                     detail = (JSONObject) rows.get(i); | ||||
|                     detailJson = (JSONObject) rows.get(i); | ||||
|                     entry.addNew(); | ||||
|                     setEntityRowValues(detail, i); | ||||
|                     this.getModel().setValue("shjh_e_pzh","001", i); | ||||
|                     this.getModel().createNewEntryRow(entryID); | ||||
|                     setEntityRowValues(detailJson, i); | ||||
|                 } | ||||
|                 this.getView().updateView(entryID); | ||||
|             } | ||||
|  |  | |||
|  | @ -1,5 +1,6 @@ | |||
| package shjh.jhzj7.fi.fi.plugin.form; | ||||
| 
 | ||||
| import kd.bos.bill.AbstractBillPlugIn; | ||||
| import kd.bos.bill.BillShowParameter; | ||||
| import kd.bos.bill.OperationStatus; | ||||
| import kd.bos.dataentity.entity.DynamicObject; | ||||
|  | @ -8,7 +9,6 @@ import kd.bos.form.ShowType; | |||
| import kd.bos.form.control.EntryGrid; | ||||
| import kd.bos.form.control.Toolbar; | ||||
| import kd.bos.form.control.events.ItemClickEvent; | ||||
| import kd.bos.form.plugin.AbstractFormPlugin; | ||||
| import kd.bos.logging.Log; | ||||
| import kd.bos.logging.LogFactory; | ||||
| import kd.sdk.plugin.Plugin; | ||||
|  | @ -21,7 +21,7 @@ import java.util.HashMap; | |||
|  * 表单插件-清账单-处理sap应收未清、查看清账明细按钮 | ||||
|  * @author yuxueliang | ||||
|  */ | ||||
| public class ClearBillFormPlugin extends AbstractFormPlugin implements Plugin { | ||||
| public class ClearBillFormPlugin extends AbstractBillPlugIn implements Plugin { | ||||
|     private final static Log logger = LogFactory.getLog(ClearBillFormPlugin.class); | ||||
|     private final static String SAPFormID = "shjh_sapyswq";//sap动态表单标识 | ||||
|     private final static String DetailFormID = "shjh_clear_acctdetail";//清账明细单标识 | ||||
|  | @ -31,8 +31,8 @@ public class ClearBillFormPlugin extends AbstractFormPlugin implements Plugin { | |||
|     public void registerListener(EventObject e) { | ||||
|         super.registerListener(e); | ||||
|         //监听整个工具栏 | ||||
|         Toolbar toolbar = getControl("tbmain"); | ||||
|         toolbar.addItemClickListener(this); | ||||
| //        Toolbar toolbar = getControl("tbmain"); | ||||
| //        toolbar.addItemClickListener(this); | ||||
|     } | ||||
| 
 | ||||
|     @Override | ||||
|  |  | |||
|  | @ -1,5 +1,6 @@ | |||
| package shjh.jhzj7.fi.fi.plugin.form; | ||||
| 
 | ||||
| import kd.bos.bill.AbstractBillPlugIn; | ||||
| import kd.bos.dataentity.entity.DynamicObject; | ||||
| import kd.bos.dataentity.entity.DynamicObjectCollection; | ||||
| import kd.bos.form.CloseCallBack; | ||||
|  | @ -8,7 +9,6 @@ import kd.bos.form.ShowType; | |||
| import kd.bos.form.control.Toolbar; | ||||
| import kd.bos.form.control.events.ItemClickEvent; | ||||
| import kd.bos.form.events.ClosedCallBackEvent; | ||||
| import kd.bos.form.plugin.AbstractFormPlugin; | ||||
| import kd.bos.logging.Log; | ||||
| import kd.bos.logging.LogFactory; | ||||
| import kd.sdk.plugin.Plugin; | ||||
|  | @ -19,7 +19,7 @@ import java.util.EventObject; | |||
|  * 表单插件-清账明细单-处理sap应收未清按钮 | ||||
|  * @author yuxueliang | ||||
|  */ | ||||
| public class ClearDetailFormPlugin extends AbstractFormPlugin implements Plugin { | ||||
| public class ClearDetailFormPlugin extends AbstractBillPlugIn implements Plugin { | ||||
|     private final static Log logger = LogFactory.getLog(ClearDetailFormPlugin.class); | ||||
|     private final static String destFormID = "shjh_sapyswq";//目标表单标识 | ||||
|     private final static String entryID = "shjh_details";//分录标识 | ||||
|  | @ -29,8 +29,8 @@ public class ClearDetailFormPlugin extends AbstractFormPlugin implements Plugin | |||
|     public void registerListener(EventObject e) { | ||||
|         super.registerListener(e); | ||||
|         //监听整个工具栏 | ||||
|         Toolbar toolbar = getControl("tbmain"); | ||||
|         toolbar.addItemClickListener(this); | ||||
| //        Toolbar toolbar = getControl("tbmain"); | ||||
| //        toolbar.addItemClickListener(this); | ||||
|     } | ||||
| 
 | ||||
|     @Override | ||||
|  | @ -136,9 +136,9 @@ public class ClearDetailFormPlugin extends AbstractFormPlugin implements Plugin | |||
|                     currentRow = this.getModel().createNewEntryRow(entryID); | ||||
|                     //设置当前行需要填充的字段 | ||||
|                     setCurrentRows(returnInfo,currentRow); | ||||
|                     //更新分录页面显示 | ||||
|                     this.getView().updateView(entryID); | ||||
|                 } | ||||
|                 //更新分录页面显示 | ||||
|                 this.getView().updateView(entryID); | ||||
|             } | ||||
|         } | ||||
|     } | ||||
|  | @ -159,7 +159,7 @@ public class ClearDetailFormPlugin extends AbstractFormPlugin implements Plugin | |||
|         this.getModel().setValue("shjh_e_unsettle",returnInfo.getBigDecimal("shjh_e_unsettle"), i);//未核销金额 | ||||
| //        this.getModel().setValue("shjh_e_cursettle",returnInfo.getBigDecimal("shjh_e_cursettle"), i);//本次核销金额 | ||||
|         this.getModel().setValue("shjh_e_year",returnInfo.getString("shjh_e_year"), i);//会计年度 | ||||
|         this.getModel().setValue("shjh_e_qzpztext",returnInfo.getString("shjh_e_qzpztext"), i);// 清账凭证文本 | ||||
| //        this.getModel().setValue("shjh_e_qzpztext",returnInfo.getString("shjh_e_qzpztext"), i);// 清账凭证文本 | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|  |  | |||
|  | @ -1,9 +1,9 @@ | |||
| package shjh.jhzj7.fi.fi.plugin.form; | ||||
| 
 | ||||
| import kd.bos.bill.AbstractBillPlugIn; | ||||
| 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; | ||||
| 
 | ||||
| 
 | ||||
|  | @ -12,7 +12,7 @@ import kd.sdk.plugin.Plugin; | |||
|  * 分录增加金额字段【现值】,由资金老师手动录入;录入后系统计算预提差额 | ||||
|  * @author yuxueliang | ||||
|  */ | ||||
| public class IntBillBatchFormPlugin extends AbstractFormPlugin implements Plugin { | ||||
| public class IntBillBatchFormPlugin extends AbstractBillPlugIn implements Plugin { | ||||
| 
 | ||||
|     private final static String entryID = "entry";//分录标识 | ||||
| 
 | ||||
|  |  | |||
|  | @ -34,13 +34,14 @@ import java.util.*; | |||
| public class ClearAccountBillOperation extends AbstractOperationServicePlugIn implements Plugin { | ||||
| 
 | ||||
|     private static final String updateClearStatus = "update tk_shjh_clear_account set fbillstatus='D' where fid=?;"; | ||||
|     private static final String updateSap = "update tk_shjh_clear_account set fk_shjh_clearstatus='A',fk_shjh_pzh=?,fk_shjh_year=? where fid=?;"; | ||||
|     private static final String updateSrcClear = "update tk_shjh_clear_account set fk_shjh_iscopy=1 where fid=?;"; | ||||
|     private static final String updateUnClearStatus = "update tk_shjh_clear_account set fbillstatus='D',fk_shjh_clearstatus='C',fk_shjh_unpzh=? where fid=?;"; | ||||
|     private static final String updateDetailStatusByBill = "update tk_shjh_clear_acctdetail set fbillstatus='D' where fk_shjh_clearbillid=?;"; | ||||
|     private static final String updateDetailStatusByID = "update tk_shjh_clear_acctdetail set fbillstatus='D' where fid=?;"; | ||||
|     private static final String updateDetailClearStatus = "update tk_shjh_clear_acctdetail set fbillstatus='D',fk_shjh_clearstatus='C' where fk_shjh_clearbillid=?;"; | ||||
| 
 | ||||
|     private static final String queryRealtion = "select fsid from tk_shjh_clear_account_tc where ftbillid=?;";//查看清账单与收款单的关联关系表 | ||||
|     private static final String queryRealtion = "select fsid,fsbillid from tk_shjh_clear_account_tc where ftbillid=?;";//查看清账单与收款单的关联关系表 | ||||
| 
 | ||||
|     private static final String entityName = "shjh_clear_acctdetail";//清账明细单 | ||||
|     private static final String userName = "bos_user";//用户 | ||||
|  | @ -138,7 +139,7 @@ public class ClearAccountBillOperation extends AbstractOperationServicePlugIn im | |||
|     } | ||||
| 
 | ||||
|     private boolean reWriteCeceBill(DynamicObject prinfo, String closingstatus){ | ||||
|         //反写收款单分录行 | ||||
|         //TODO 反写收款单分录行 表头清账状态如何标记? | ||||
|         //根据清账单id查找上游收款单分录行 | ||||
|         List<Long> entryids = DB.query(DBRoute.of("fi"),queryRealtion,new Object[]{prinfo.getPkValue()},(rs) -> { | ||||
|             List<Long> entryidList = new ArrayList<>(); | ||||
|  | @ -366,7 +367,7 @@ public class ClearAccountBillOperation extends AbstractOperationServicePlugIn im | |||
|             DB.update(DBRoute.of("fi"), updateUnClearStatus, new Object[]{fqzpzh, prinfo.getLong("id")}); | ||||
|             //更新下游清账明细单【单据状态】=作废;【清账状态】=反清账。 | ||||
|             DB.update(DBRoute.of("fi"), updateDetailClearStatus, new Object[]{prinfo.getString("id")}); | ||||
|             //TODO 更新上游收款单分录行【清账状态】=反清账 D,表头清账状态如何标记? | ||||
|             //更新上游收款单分录行【清账状态】=反清账 D | ||||
|             reWriteCeceBill(prinfo,"D"); | ||||
|             //若选择的反清后处理方式=重新清账,则复制原清账单,在新清账单上重新清账 | ||||
|             if ("A".equals(prinfo.getString("shjh_unclearway"))) { | ||||
|  | @ -457,7 +458,7 @@ public class ClearAccountBillOperation extends AbstractOperationServicePlugIn im | |||
|             IT_CLEAR.add(clear); | ||||
|         } | ||||
|         //从收款单cas_recbill获取实收的凭证数据 | ||||
|         //先根据关系表找到收款单id和分录id,再将收款单对象查出来 | ||||
|         //先根据关系表找到收款单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()) { | ||||
|  | @ -466,10 +467,10 @@ public class ClearAccountBillOperation extends AbstractOperationServicePlugIn im | |||
|             return entryidList; | ||||
|         }); | ||||
|         //遍历map | ||||
|         DynamicObject recebill; | ||||
|         DynamicObject recebill;//收款单 | ||||
|         for (Map.Entry<Long,Long> entry : entrybillids.entrySet()) { | ||||
|             entry.getKey();//收款单分录ID | ||||
|             entry.getValue();//收款单ID | ||||
|             //收款单分录ID entry.getKey(); | ||||
|             //收款单ID entry.getValue(); | ||||
|             recebill = BusinessDataServiceHelper.loadSingleFromCache(entry.getValue(), recbillName); | ||||
|             docolls = recebill.getDynamicObjectCollection("entry");//收款明细分录 | ||||
|             for(DynamicObject receentry : docolls){ | ||||
|  | @ -477,9 +478,11 @@ public class ClearAccountBillOperation extends AbstractOperationServicePlugIn im | |||
|                     clear = new JSONObject(); | ||||
|                     clear.put("BUKRS",companyCode);//公司代码 | ||||
|                     clear.put("KUNNR",customerCode);//客户编号 | ||||
|                     //shjh_vouchernum 收款sap凭证号 | ||||
|                     //shjh_sapfiscalyear 收款sap会计年度 | ||||
|                     //shjh_sapline 收款sap凭证行号 | ||||
|                     clear.put("BELNR",recebill.getString("shjh_vouchernum"));//收款sap凭证编号 | ||||
|                     clear.put("GJAHR",recebill.getString("shjh_sapfiscalyear"));//收款sap会计年度 | ||||
|                     clear.put("BUZEI",recebill.getString("shjh_sapline"));//收款sap凭证行号 | ||||
| //                    clear.put("HKONT",receentry.getString(""));//TODO 总账科目-如何取值? | ||||
|                     clear.put("DMBTR1",receentry.getString("e_actamt"));//清账金额-收款单分录的实收金额 | ||||
|                     IT_CLEAR.add(clear); | ||||
|                     break; | ||||
|                 } | ||||
|  | @ -511,6 +514,15 @@ public class ClearAccountBillOperation extends AbstractOperationServicePlugIn im | |||
|             prinfo = BusinessDataServiceHelper.loadSingle(dos[i].getPkValue(), dos[i].getDataEntityType().getName()); | ||||
|             //TODO 调用SAP清账接口,生成清账凭证。 | ||||
|             resultData = sapTransactionVoucher(prinfo); | ||||
|             if(resultData == null){ | ||||
|                 addErrorInfo(prinfo,"调用SAP清账接口失败,详见接口日志"); | ||||
|                 continue; | ||||
|             }else{ | ||||
|                 //反写清账状态、清账凭证号、会计年度字段至清账单中 | ||||
|                 DB.update(DBRoute.of("fi"), updateSap, new Object[]{resultData.getString(""),resultData.getString(""),prinfo.getPkValue()}); | ||||
|                 //反写收款单分录清账状态 | ||||
|                 reWriteCeceBill(prinfo,"C"); | ||||
|             } | ||||
|             //若存在(暂存、驳回)的清账明细单,则系统自动处理:清账明细单【单据状态】全标记为作废,并消除被作废明细单的OA待办。 | ||||
|             ddos = BusinessDataServiceHelper.load(entityName, "id,billno,billstatus,shjh_clearbillid,shjh_clearbillno,createtime,creator,modifier", | ||||
|                     new QFilter[]{new QFilter("shjh_clearbillid", QCP.equals, prinfo.getString("id"))}); | ||||
|  |  | |||
|  | @ -1,7 +1,9 @@ | |||
| package shjh.jhzj7.fi.fi.plugin.operate; | ||||
| 
 | ||||
| import com.alibaba.fastjson.JSONArray; | ||||
| import com.alibaba.fastjson.JSONObject; | ||||
| import com.sap.db.jdbc.packet.ErrorLevel; | ||||
| import kd.bos.context.RequestContext; | ||||
| import kd.bos.dataentity.entity.DynamicObject; | ||||
| import kd.bos.db.DB; | ||||
| import kd.bos.db.DBRoute; | ||||
|  | @ -10,8 +12,12 @@ import kd.bos.entity.plugin.AbstractOperationServicePlugIn; | |||
| import kd.bos.entity.plugin.args.AfterOperationArgs; | ||||
| import kd.bos.servicehelper.BusinessDataServiceHelper; | ||||
| import kd.sdk.plugin.Plugin; | ||||
| import shjh.jhzj7.fi.fi.utils.JhzjUtils; | ||||
| import shjh.jhzj7.fi.fi.utils.SapUtils; | ||||
| 
 | ||||
| import java.text.SimpleDateFormat; | ||||
| import java.util.Date; | ||||
| 
 | ||||
| /** | ||||
|  * 预提记账处理-单据操作插件 | ||||
|  * @author yuxueliang | ||||
|  | @ -19,6 +25,7 @@ import shjh.jhzj7.fi.fi.utils.SapUtils; | |||
| public class RevenueBillOperation extends AbstractOperationServicePlugIn implements Plugin { | ||||
| 
 | ||||
|     private static final String updateVoucherFlag = "update t_cim_revenue set fk_shjh_sendsap=1 where fid=?;"; | ||||
|     private static final String userName = "bos_user";//用户 | ||||
| 
 | ||||
|     @Override | ||||
|     public void afterExecuteOperationTransaction(AfterOperationArgs e) { | ||||
|  | @ -32,15 +39,17 @@ public class RevenueBillOperation extends AbstractOperationServicePlugIn impleme | |||
|             for (int i = 0; i < dos.length; i++) { | ||||
|                 prinfo = BusinessDataServiceHelper.loadSingle(dos[i].getPkValue(), dos[i].getDataEntityType().getName()); | ||||
|                 if(prinfo.getBoolean("shjh_needvoucher") && !prinfo.getBoolean("shjh_sendsap")){ | ||||
|                     //TODO 如果预提记账处理单需要生成凭证且未推送sap的才推送sap | ||||
|                     //如果预提记账处理单需要生成凭证且未推送sap的才推送sap | ||||
|                     sapReturnData = sendVoucher(prinfo); | ||||
| 
 | ||||
|                     if(sapReturnData != null && "0".equals(sapReturnData.getString("code"))){ | ||||
|                         //推送sap成功后,反写已推送标记 | ||||
|                         DB.update(DBRoute.of("fi"), updateVoucherFlag, new Object[]{prinfo.getPkValue()}); | ||||
|                         this.operationResult.addSuccessPkId(prinfo.getPkValue()); | ||||
|                     }else{ | ||||
|                     }else if(sapReturnData != null){ | ||||
|                         addErrorInfo(prinfo,"推送SAP接口失败:"+sapReturnData.getString("msg")); | ||||
|                     }else{ | ||||
|                         addErrorInfo(prinfo,"推送SAP接口失败,SAP返回值为空"); | ||||
|                     } | ||||
|                 } | ||||
|             } | ||||
|  | @ -48,8 +57,31 @@ public class RevenueBillOperation extends AbstractOperationServicePlugIn impleme | |||
|     } | ||||
| 
 | ||||
|     private JSONObject sendVoucher(DynamicObject prinfo){ | ||||
|         //组装参数调用推送sap接口 | ||||
|         return null; | ||||
|         //SAP预提收益凭证接口入参组装和调用 | ||||
|         JSONObject IS_HEADER = new JSONObject();//抬头 | ||||
|         JSONArray IT_ITEM = new JSONArray();//详细 | ||||
|         SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");//日期格式化工具 | ||||
|         String companyCode = prinfo.getDynamicObject("org").getString("number"); | ||||
|         IS_HEADER.put("BUKRS",companyCode);//公司代码 | ||||
|         IS_HEADER.put("BLART","SA");//凭证类型-总账类凭证 | ||||
|         IS_HEADER.put("BLDAT",sdf.format(prinfo.getDate("bizdate")));//凭证日期-业务日期 | ||||
|         IS_HEADER.put("BUDAT",sdf.format(prinfo.getDate("expiredate")));//过账日期-预提日期 | ||||
|         String isoCode = prinfo.getDynamicObject("currency").getString("number"); | ||||
|         IS_HEADER.put("WAERS", JhzjUtils.getCurrencyCode(isoCode));//币种 | ||||
|         IS_HEADER.put("XBLNR",prinfo.getString("billno"));//参考凭证号-单据编号 固定长度16位 | ||||
|         IS_HEADER.put("BKTXT",prinfo.getString("productname"));//凭证抬头文本 产品名称 | ||||
|         //添加用户名过滤条件-操作审核按钮的用户(OA用户名) | ||||
|         DynamicObject userinfo = BusinessDataServiceHelper.loadSingleFromCache(RequestContext.get().getCurrUserId(), userName); | ||||
|         String oauser = userinfo.getString("shjh_oauser"); | ||||
|         IS_HEADER.put("USNAM",oauser);//用户名 | ||||
|         //----------------处理详细入参--TODO 获取对应凭证-------------------- | ||||
|         JSONObject item = new JSONObject(); | ||||
|         item.put("HKONT","");//总账科目 | ||||
|         item.put("DMBTR",prinfo.getString("shjh_receamount"));//金额-传清账单收款金额 | ||||
|         IT_ITEM.add(item); | ||||
|         //组装参数调用推送sap凭证接口 | ||||
|         JSONObject sapReturnData = SapUtils.sapTransactionAPI(IS_HEADER,IT_ITEM,null,prinfo.getString("billno")); | ||||
|         return sapReturnData; | ||||
|     } | ||||
| 
 | ||||
|     private void addErrorInfo(DynamicObject bill, String errorMsg) { | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue