parent
							
								
									d82ef1f7d0
								
							
						
					
					
						commit
						87aa1f9621
					
				|  | @ -208,7 +208,6 @@ public class PayBillSubmitOperation extends AbstractOperationServicePlugIn imple | |||
|             DMBTR1 = apPayapply.getBigDecimal("applyamount");//申请金额 | ||||
|         } | ||||
|         BigDecimal DMBTR2 = BigDecimal.ZERO;//已清 | ||||
|         BigDecimal DMBTR = DMBTR1.subtract(DMBTR2);//未清 | ||||
|         QFilter q1 = new QFilter("entry.shjh_voucheryear", QCP.equals, dynamicObject.getString("shjh_voucheryear")); | ||||
|         QFilter q2 = new QFilter("entry.shjh_vouchernums", QCP.equals, dynamicObject.getString("shjh_vouchernums")); | ||||
|         QFilter q3 = new QFilter("entry.shjh_voucherentrynum", QCP.equals, dynamicObject.getString("shjh_voucherentrynum")); | ||||
|  | @ -226,6 +225,7 @@ public class PayBillSubmitOperation extends AbstractOperationServicePlugIn imple | |||
|                 DMBTR2 = DMBTR2.add(entr.getBigDecimal("e_actamt")); | ||||
|             } | ||||
|         } | ||||
|         BigDecimal DMBTR = DMBTR1.subtract(DMBTR2);//未清 | ||||
|         IT_ITEM.put("DMBTR1", DMBTR1);//按本位币计的金额 总金额 | ||||
|         IT_ITEM.put("DMBTR2", DMBTR2);//按本位币计的金额 已清 | ||||
|         IT_ITEM.put("DMBTR", DMBTR);//按本位币计的金额   未清 | ||||
|  |  | |||
|  | @ -55,10 +55,12 @@ public class PaybillPushSapOperation extends AbstractOperationServicePlugIn impl | |||
|                         String billstatus = bill.getString("billstatus");//付款单状态 | ||||
|                         if (!"D".equals(billstatus)) { | ||||
|                             this.addErrorMessage(entity, "付款单状态不为已付款,不允许推送SAP凭证"); | ||||
|                             return; | ||||
|                         } | ||||
|                         //已推送,校验 | ||||
|                         if (bill.getBoolean("shjh_ispushsap")) { | ||||
|                             this.addErrorMessage(entity, "已推送SAP凭证,不允许重复推送"); | ||||
|                             return; | ||||
|                         } | ||||
|                         String shjhSourcesystem = bill.getString("shjh_sourcesystem");//来源系统,A_sap,B_fk | ||||
|                         DynamicObject paymentidentify = bill.getDynamicObject("paymentidentify");//付款单标识 | ||||
|  | @ -70,6 +72,7 @@ public class PaybillPushSapOperation extends AbstractOperationServicePlugIn impl | |||
|                             if ("FKBS01".equals(number) && !("214".equals(paymenttypeNumber) || "217".equals(paymenttypeNumber))) { | ||||
|                                 if (!"A".equals(shjhSourcesystem)) { | ||||
|                                     this.addErrorMessage(entity, "付款单为主动付款且来源系统不为SAP,不允许推送SAP凭证"); | ||||
|                                     return; | ||||
|                                 } | ||||
|                             } | ||||
|                         } | ||||
|  | @ -118,8 +121,8 @@ public class PaybillPushSapOperation extends AbstractOperationServicePlugIn impl | |||
|                 } | ||||
|                 JSONArray IT_CLEAR = new JSONArray();//清账数据,参考《IT_CLEAR》,仅清账需要输入 | ||||
|                 JSONArray IT_ITEM = new JSONArray(); | ||||
|                 //解析付款凭证分录行组装成map,票据在贷方(客户编号+金额,行摘要),sap应付在借方(科目编号,行摘要) | ||||
|                 voucherMap; | ||||
|                 //解析付款凭证分录行组装成map,票据在贷方(客户编号+金额,行摘要),sap应付在借方(科目编号+金额,行摘要) | ||||
|                 Map<String, String> voucherMap = getVoucherTypeMap(gl_voucher); | ||||
|                 // 票据信息 | ||||
|                 DynamicObjectCollection casDraftinfos = bill.getDynamicObjectCollection("cas_draftinfo"); | ||||
|                 if (!casDraftinfos.isEmpty()) { | ||||
|  | @ -171,8 +174,8 @@ public class PaybillPushSapOperation extends AbstractOperationServicePlugIn impl | |||
|                             jsonObject.put("HKONT", HKONT);//总账科目 | ||||
|                             jsonObject.put("UMSKZ", JhzjUtils.getUMSKZ(HKONT));//特殊总账标识 | ||||
|                             jsonObject.put("DMBTR1", entry.getBigDecimal("e_actamt"));//清账金额_实付金额 | ||||
|                             //以HKONT作为key,将voucherMap的value放入行项目文本(sap应付行) | ||||
|                             jsonObject.put("SGTXT", voucherMap.get(HKONT)); | ||||
|                             //以HKONT+金额作为key,将voucherMap的value放入行项目文本(sap应付行) | ||||
|                             jsonObject.put("SGTXT", voucherMap.get(HKONT+jsonObject.getString("DMBTR1"))); | ||||
|                             IT_CLEAR.add(jsonObject); | ||||
|                         } | ||||
|                         //2.遍历票 | ||||
|  | @ -257,6 +260,13 @@ public class PaybillPushSapOperation extends AbstractOperationServicePlugIn impl | |||
|                                     jsonObject.put("SGTXT", voucherMap.get(jsonObject.getString("KUNNR")+jsonObject.getString("DMBTR1"))); | ||||
|                                 } | ||||
|                                 IT_CLEAR.add(jsonObject); | ||||
|                             }else { | ||||
|                                 OperateErrorInfo operateErrorInfo = new OperateErrorInfo(); | ||||
|                                 operateErrorInfo.setMessage("未查询"+draftbillinfo.getString("billno") +"的收票凭证,请检查。"); | ||||
|                                 operateErrorInfo.setErrorLevel(ErrorLevel.Error.name()); | ||||
|                                 operateErrorInfo.setPkValue(bill.getPkValue()); | ||||
|                                 this.operationResult.addErrorInfo(operateErrorInfo); | ||||
|                                 return; | ||||
|                             } | ||||
|                         } | ||||
|                     } | ||||
|  | @ -382,6 +392,7 @@ public class PaybillPushSapOperation extends AbstractOperationServicePlugIn impl | |||
|                             QFilter qFilter = new QFilter("cas_draftinfo.draftbillinfo.id", QCP.equals, draftbillinfo.getLong("id")); | ||||
|                             //根据票据号过滤收款单 | ||||
|                             DynamicObject casRecbill = BusinessDataServiceHelper.loadSingle("cas_recbill", qFilter.toArray()); | ||||
| 
 | ||||
|                             if (null != casRecbill) { | ||||
|                                 JSONObject jsonObject = new JSONObject(); | ||||
|                                 String BUKRS  = ""; | ||||
|  | @ -432,13 +443,40 @@ public class PaybillPushSapOperation extends AbstractOperationServicePlugIn impl | |||
|                                                 } | ||||
|                                                 jsonObject.put("HKONT", account.getString("number")); // 总账科目_科目(凭证分录account) | ||||
|                                                 jsonObject.put("UMSKZ", JhzjUtils.getUMSKZ(account.getString("number")));//特殊总账标识 | ||||
|                                                 DynamicObject assgrpinfo = entry.getDynamicObject("assgrp");//核算维度(弹性域) | ||||
|                                                 if(assgrpinfo != null){ | ||||
|                                                     DynamicObjectCollection gl_assist_bd = QueryServiceHelper.query("gl_assist_bd", "asstype,assval", | ||||
|                                                             new QFilter[]{new QFilter("hg.id", QCP.equals, assgrpinfo.getPkValue())}); | ||||
|                                                     String asstype; | ||||
|                                                     DynamicObject glassistbd; | ||||
|                                                     DynamicObject hsxminfo; | ||||
|                                                     for (int j = 0; j < gl_assist_bd.size(); j++) { | ||||
|                                                         glassistbd = gl_assist_bd.get(j); | ||||
|                                                         asstype = glassistbd.getString("asstype");//核算项目类型-对应核算维度的字段名 | ||||
|                                                         if("f000057".equals(asstype) || "f0001".equals(asstype)){ | ||||
|                                                             //t_bas_flex_property 表中获取对应编号 客户-获利段 f0001 客户编码 f000057 | ||||
|                                                             hsxminfo = QueryServiceHelper.queryOne("bd_customer", "id,name,number", | ||||
|                                                                     new QFilter[]{new QFilter("id", QCP.equals, glassistbd.getLong("assval"))});//维度值 | ||||
|                                                             jsonObject.put("KUNNR", hsxminfo.getString("number"));//客户 | ||||
|                                                         } | ||||
|                                                     } | ||||
|                                                 } | ||||
|                                             } | ||||
|                                         } | ||||
|                                     } | ||||
|                                 } | ||||
|                                 //清张金额取票据(转让金额) | ||||
|                                 jsonObject.put("DMBTR1",casDraftinfo.getBigDecimal("transamount"));//清账金额 | ||||
|                                 //以收款单凭证行的客户编号+清账金额作为key,将voucherMap的value放入行项目文本(票据行) | ||||
|                                 jsonObject.put("SGTXT", voucherMap.get(jsonObject.getString("KUNNR")+jsonObject.getString("DMBTR1"))); | ||||
|                                 IT_CLEAR.add(jsonObject); | ||||
|                             }else { | ||||
|                                 OperateErrorInfo operateErrorInfo = new OperateErrorInfo(); | ||||
|                                 operateErrorInfo.setMessage("未查询"+draftbillinfo.getString("billno") +"的收票凭证,请检查。"); | ||||
|                                 operateErrorInfo.setErrorLevel(ErrorLevel.Error.name()); | ||||
|                                 operateErrorInfo.setPkValue(bill.getPkValue()); | ||||
|                                 this.operationResult.addErrorInfo(operateErrorInfo); | ||||
|                                 return; | ||||
|                             } | ||||
|                         } | ||||
|                     } | ||||
|  | @ -605,6 +643,8 @@ public class PaybillPushSapOperation extends AbstractOperationServicePlugIn impl | |||
|                             jsonObject.put("HKONT", HKONT);//总账科目 | ||||
|                             jsonObject.put("UMSKZ", JhzjUtils.getUMSKZ(HKONT));//特殊总账标识 | ||||
|                             jsonObject.put("DMBTR1", entry.getBigDecimal("e_actamt"));//清账金额_实付金额 | ||||
|                             //以HKONT+金额作为key,将voucherMap的value放入行项目文本(sap应付行) | ||||
|                             jsonObject.put("SGTXT", voucherMap.get(HKONT+jsonObject.getString("DMBTR1"))); | ||||
|                             IT_CLEAR.add(jsonObject); | ||||
|                         } | ||||
|                     }else { | ||||
|  |  | |||
|  | @ -3,6 +3,7 @@ package shjh.jhzj7.fi.fi.utils; | |||
| import com.alibaba.fastjson.JSONArray; | ||||
| import com.alibaba.fastjson.JSONObject; | ||||
| 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.logging.Log; | ||||
|  | @ -10,6 +11,7 @@ import kd.bos.logging.LogFactory; | |||
| import kd.bos.orm.query.QCP; | ||||
| import kd.bos.orm.query.QFilter; | ||||
| import kd.bos.servicehelper.BusinessDataServiceHelper; | ||||
| import kd.bos.servicehelper.QueryServiceHelper; | ||||
| import org.apache.http.HttpEntity; | ||||
| import org.apache.http.HttpResponse; | ||||
| import org.apache.http.client.HttpClient; | ||||
|  | @ -20,6 +22,7 @@ import org.apache.http.impl.client.HttpClients; | |||
| import org.apache.http.util.EntityUtils; | ||||
| 
 | ||||
| import java.io.IOException; | ||||
| import java.math.BigDecimal; | ||||
| import java.time.LocalDateTime; | ||||
| import java.time.format.DateTimeFormatter; | ||||
| import java.util.*; | ||||
|  | @ -704,4 +707,55 @@ public class SapUtils { | |||
|         }); | ||||
|         return fseq; | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * 解析付款凭证分录行组装成map,票据在贷方(客户编号+金额,行摘要),sap应付在借方(科目编号+金额,行摘要) | ||||
|      * @param voucher 凭证 | ||||
|      */ | ||||
|     public static Map<String,String> getVoucherTypeMap(DynamicObject voucher){ | ||||
|         //组装map | ||||
|         Map<String, String> sapMap = new HashMap<>(); | ||||
|         DynamicObjectCollection entries = voucher.getDynamicObjectCollection("entries"); | ||||
|         for (int i = 0; i < entries.size(); i++) { | ||||
|             DynamicObject entry = entries.get(i); | ||||
|             DynamicObject account = entry.getDynamicObject("account");//科目 | ||||
|             String accountNumber = ""; | ||||
|             if (null != account) { | ||||
|                 accountNumber = account.getString("number");//科目编号 | ||||
|             } | ||||
|             // 获取借方金额 | ||||
|             BigDecimal debitlocal = (BigDecimal) entry.get("debitlocal");//借方 | ||||
|             // 获取贷方金额 | ||||
|             BigDecimal creditlocal = (BigDecimal) entry.get("creditlocal");//贷方 | ||||
|             String entrydc = (String) entry.get("entrydc");//分录方向(1.借方,-1.贷方) | ||||
|             //贷方(客户编号+金额,行摘要) | ||||
|             if ("-1".equals(entrydc)) { | ||||
|                 //核算维度(弹性域)_客户 | ||||
|                 DynamicObject assgrpinfo = entry.getDynamicObject("assgrp");//核算维度(弹性域) | ||||
|                 if(assgrpinfo != null) { | ||||
|                     DynamicObjectCollection gl_assist_bd = QueryServiceHelper.query("gl_assist_bd", "asstype,assval", | ||||
|                             new QFilter[]{new QFilter("hg.id", QCP.equals, assgrpinfo.getPkValue())}); | ||||
|                     String asstype; | ||||
|                     DynamicObject glassistbd; | ||||
|                     DynamicObject hsxminfo; | ||||
|                     for (int j = 0; j < gl_assist_bd.size(); j++) { | ||||
|                         glassistbd = gl_assist_bd.get(j); | ||||
|                         asstype = glassistbd.getString("asstype");//核算项目类型-对应核算维度的字段名 | ||||
|                         if ("f000057".equals(asstype) || "f0001".equals(asstype)) { | ||||
|                             //t_bas_flex_property 表中获取对应编号 客户-获利段 f0001 客户编码 f000057 | ||||
|                             hsxminfo = QueryServiceHelper.queryOne("bd_customer", "id,name,number", | ||||
|                                     new QFilter[]{new QFilter("id", QCP.equals, glassistbd.getLong("assval"))});//维度值 | ||||
|                             sapMap.put(hsxminfo.getString("number")+ creditlocal, entry.getString("edescription")); | ||||
|                         } | ||||
|                     } | ||||
|                 } | ||||
|             } | ||||
|             //借方(科目编号+金额,行摘要) | ||||
|             if ("1".equals(entrydc)) { | ||||
|                 sapMap.put(accountNumber+ debitlocal, entry.getString("edescription")); | ||||
|             } | ||||
|         } | ||||
| 
 | ||||
|         return sapMap; | ||||
|     } | ||||
| } | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue