0514问题处理
This commit is contained in:
		
							parent
							
								
									772e962d0e
								
							
						
					
					
						commit
						46ff16e41d
					
				|  | @ -17,6 +17,7 @@ import kd.bos.orm.query.QFilter; | |||
| import kd.bos.servicehelper.BusinessDataServiceHelper; | ||||
| import kd.sdk.plugin.Plugin; | ||||
| import shjh.jhzj7.fi.fi.plugin.form.info.ClaimFieldsInfo; | ||||
| import shjh.jhzj7.fi.fi.utils.EsbUtils; | ||||
| 
 | ||||
| import java.util.EventObject; | ||||
| import java.util.HashMap; | ||||
|  | @ -174,6 +175,9 @@ public class ClaimBillButtonAssPlugin extends AbstractFormPlugin implements Plug | |||
|         this.getModel().setValue(ClaimFieldsInfo.PAYMENT_AMOUNT, returnData.get(i).getBigDecimal(ClaimFieldsInfo.PAYMENT_AMOUNT), i); | ||||
|         //单据可退还金额 | ||||
|         this.getModel().setValue(ClaimFieldsInfo.DOCUMENT_AMOUNT, returnData.get(i).getBigDecimal(ClaimFieldsInfo.DOCUMENT_AMOUNT), i); | ||||
|         //标品的应收金额字段和二开的本次退还本位币金额,默认设置为可用金额 | ||||
|         this.getModel().setValue(ClaimFieldsInfo.REFUNDED_AMOUNT, returnData.get(i).getBigDecimal(ClaimFieldsInfo.DOCUMENT_AMOUNT), i); | ||||
| //        this.getModel().setValue("amountfield3", returnData.get(i).getBigDecimal(ClaimFieldsInfo.DOCUMENT_AMOUNT), i); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|  | @ -188,6 +192,10 @@ public class ClaimBillButtonAssPlugin extends AbstractFormPlugin implements Plug | |||
|         this.getModel().setValue(ClaimFieldsInfo.LOAN_AMOUNT, returnData.get(i).getBigDecimal(ClaimFieldsInfo.LOAN_AMOUNT), i); | ||||
|         //借款余额 | ||||
|         this.getModel().setValue(ClaimFieldsInfo.LOAN_BALANCE, returnData.get(i).getBigDecimal(ClaimFieldsInfo.LOAN_BALANCE), i); | ||||
| 
 | ||||
|         //标品的实收金额和二开的本次还款金额,默认设置为借款余额 | ||||
|         this.getModel().setValue(ClaimFieldsInfo.REPAYMENT_AMOUNT, returnData.get(i).getBigDecimal(ClaimFieldsInfo.LOAN_BALANCE), i); | ||||
| //        this.getModel().setValue("amountfield3", returnData.get(i).getBigDecimal(ClaimFieldsInfo.LOAN_BALANCE), i); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|  | @ -211,16 +219,20 @@ public class ClaimBillButtonAssPlugin extends AbstractFormPlugin implements Plug | |||
| 
 | ||||
|         //过账日期 | ||||
|         this.getModel().setValue("shjh_postingdate", returnData.get(i).getDate("shjh_postingdate"), i); | ||||
|         //科目 | ||||
|         //会计科目-得到当前公司的科目 | ||||
|         String accountCode = returnData.get(i).getString("shjh_coaitemcode"); | ||||
|         DynamicObject account = BusinessDataServiceHelper.loadSingle("bd_accountview", (new QFilter("number", QCP.equals, accountCode)).toArray()); | ||||
|         if (null!=account){ | ||||
|             this.getModel().setValue("shjh_coaitemcode", account, i); | ||||
|         DynamicObject orginfo = (DynamicObject) this.getModel().getValue("org");//当前公司ID | ||||
|         QFilter qFilter = new QFilter("number", QCP.equals, accountCode);//科目编号 | ||||
|         qFilter.and("createorg.id", QCP.equals, orginfo.getPkValue());//当前公司ID | ||||
|         qFilter.and("accounttable.id", QCP.equals, EsbUtils.ACCTABLE);//科目表 | ||||
|         DynamicObject accountinfo = BusinessDataServiceHelper.loadSingle("bd_accountview", qFilter.toArray()); | ||||
|         if (null != accountinfo){ | ||||
|             this.getModel().setValue("shjh_coaitemcode", accountinfo, i); | ||||
|         } | ||||
|         //原因码 | ||||
|         String code = returnData.get(i).getString("shjh_reasoncode"); | ||||
|         DynamicObject reason = BusinessDataServiceHelper.loadSingle("gl_cashflowitem", (new QFilter("number", QCP.equals, code)).toArray()); | ||||
|         if (null!=reason){ | ||||
|         if (null != reason){ | ||||
|             this.getModel().setValue("shjh_reasoncode", reason, i); | ||||
|         } | ||||
|     } | ||||
|  |  | |||
|  | @ -78,16 +78,18 @@ public class FeeControlApiPlugin extends AbstractFormPlugin implements Plugin { | |||
|             //【关联员工借款单】按钮进来,隐藏【供应商】 | ||||
|             this.getView().setVisible(false, "shjh_supplier"); | ||||
|         } | ||||
|         // 设置为三个月前 | ||||
|         Date date = new Date(); | ||||
|         date.setMonth(date.getMonth() - 12); | ||||
|         this.getView().getModel().setValue("shjh_startdate",date); | ||||
|         //设置查询开始日期为一年前 | ||||
|         //获取当前日期 | ||||
|         Calendar cal = Calendar.getInstance(); | ||||
|         //将日期减去一年 | ||||
|         cal.add(Calendar.YEAR, -1); | ||||
|         this.getModel().setValue("shjh_startdate",cal.getTime()); | ||||
|         this.getView().updateView("shjh_startdate"); | ||||
|         String paymenttype = ""+this.getView().getParentView().getModel().getValue("paymenttype"); | ||||
|         String paymenttype = (String) this.getView().getParentView().getModel().getValue("paymenttype"); | ||||
|         if ("bd_supplier".equals(paymenttype)) { | ||||
|             this.getView().getModel().setValue("shjh_supplier",this.getView().getParentView().getModel().getValue("recbasepayer")); | ||||
|             this.getModel().setValue("shjh_supplier",this.getView().getParentView().getModel().getValue("recbasepayer")); | ||||
|             this.getView().updateView("shjh_supplier"); | ||||
|         } | ||||
|         this.getView().updateView("shjh_supplier"); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|  | @ -226,7 +228,7 @@ public class FeeControlApiPlugin extends AbstractFormPlugin implements Plugin { | |||
|      */ | ||||
|     private void handlePaymentApiResponse(String response) { | ||||
|         try { | ||||
|             hideLoanFields(); | ||||
| //            hideLoanFields(); | ||||
|             JSONObject root = JSONObject.parseObject(response); | ||||
|             JSONObject data = root.getJSONObject("data"); | ||||
|             JSONObject data2 = data.getJSONObject("data"); | ||||
|  | @ -256,7 +258,7 @@ public class FeeControlApiPlugin extends AbstractFormPlugin implements Plugin { | |||
|      */ | ||||
|     private void handleLoanApiResponse(String response) { | ||||
|         try { | ||||
|             hidePaymentFields(); | ||||
| //            hidePaymentFields(); | ||||
|             JSONObject root = JSONObject.parseObject(response); | ||||
|             JSONObject data = root.getJSONObject("data"); | ||||
|             JSONObject data2 = data.getJSONObject("data"); | ||||
|  | @ -283,14 +285,17 @@ public class FeeControlApiPlugin extends AbstractFormPlugin implements Plugin { | |||
|      */ | ||||
|     private void setPaymentApiValues(JSONObject top, JSONObject detail, int i, JSONArray voucherItems) { | ||||
|         try { | ||||
|             this.getModel().setValue("shjh_prepaymentnum", detail.getString("RequestCode"), i); | ||||
|             this.getModel().setValue("shjh_purchasenum", detail.getString("PoOrderNo"), i); | ||||
|             this.getModel().setValue("shjh_purchaselinenum", detail.getString("PoOrderColNo"), i); | ||||
|             this.getModel().setValue("shjh_billsubject", detail.getString("RequestName"), i); | ||||
|             this.getModel().setValue("shjh_prepaymentdate", top.getString("RequestDate"), i); | ||||
|             this.getModel().setValue("shjh_paymentamount", detail.getBigDecimal("RequestAmt"), i); | ||||
|             this.getModel().setValue("shjh_documentamount", detail.getBigDecimal("AvailableAmt"), i); | ||||
|             this.getModel().setValue("shjh_prepaymentnum", detail.getString("RequestCode"), i);//预付款单号 | ||||
|             this.getModel().setValue("shjh_purchasenum", detail.getString("PoOrderNo"), i);//采购订单号 | ||||
|             this.getModel().setValue("shjh_purchaselinenum", detail.getString("PoOrderColNo"), i);//采购订单行号 | ||||
|             this.getModel().setValue("shjh_billsubject", detail.getString("RequestName"), i);//单据主题 | ||||
|             this.getModel().setValue("shjh_prepaymentdate", top.getString("RequestDate"), i);//预付款日期 | ||||
|             this.getModel().setValue("shjh_paymentamount", detail.getBigDecimal("RequestAmt"), i);//提单金额 | ||||
|             this.getModel().setValue("shjh_documentamount", detail.getBigDecimal("AvailableAmt"), i);//可用金额 | ||||
|             this.getModel().setValue("shjh_detailid", detail.getString("DetailID"), i); | ||||
|             //预付款明细带出 事项描述 字段 | ||||
|             this.getModel().setValue("shjh_description", detail.getString("RequestRemark"), i); | ||||
| 
 | ||||
|             setPublicValues(top, i, voucherItems); | ||||
|         } catch (Exception e) { | ||||
|             logger.error("预付单赋值异常: " + e.getMessage(), e); | ||||
|  | @ -307,7 +312,7 @@ public class FeeControlApiPlugin extends AbstractFormPlugin implements Plugin { | |||
|         try { | ||||
|             this.getModel().setValue("shjh_loannum", top.getString("RequestCode"), i); | ||||
|             this.getModel().setValue("shjh_loanamount", top.getBigDecimal("RequestAmt"), i); | ||||
|             this.getModel().setValue("shjh_loanbalance", top.getBigDecimal("AvailableAmt"), i); | ||||
|             this.getModel().setValue("shjh_loanbalance", top.getBigDecimal("AvailableAmt"), i);//可用金额 | ||||
|             setPublicValues(top, i, voucherItems); | ||||
|         } catch (Exception e) { | ||||
|             logger.error("借款单赋值异常: " + e.getMessage(), e); | ||||
|  | @ -317,13 +322,15 @@ public class FeeControlApiPlugin extends AbstractFormPlugin implements Plugin { | |||
|     private void setPublicValues(JSONObject top, int i, JSONArray voucherItems) { | ||||
|         try { | ||||
|             this.getModel().setValue("shjh_billno", top.getString("CompanyCode"), i);//公司编号 | ||||
|             this.getModel().setValue("shjh_verificationnum", top.getString("StrColumn20"), i);//核销单凭证号 | ||||
|             this.getModel().setValue("shjh_verificationnum", top.getString("StrColumn20"), i);//预付款凭证号 | ||||
|             this.getModel().setValue("shjh_fiscalyear", top.getString("GLDate").substring(0, 4), i);//会计年度 | ||||
|             this.getModel().setValue("shjh_billheaderid", top.getString("ID"), i); | ||||
|             this.getModel().setValue("shjh_usercode", top.getString("RequestUserCode"), i);//员工工号 | ||||
|             this.getModel().setValue("shjh_deptcode", top.getString("RequestDeptCode"), i);//部门编码 | ||||
|             this.getModel().setValue("shjh_postingdate", top.getString("GLDate"), i);//过账日期 | ||||
|             if (voucherItems != null && voucherItems.size() != 0) { | ||||
|             //借款单带出 事项描述 字段 | ||||
|             this.getModel().setValue("shjh_description", top.getString("RequestRemark"), i); | ||||
|             if (voucherItems != null && !voucherItems.isEmpty()) { | ||||
|                 String id = top.getString("ID"); | ||||
|                 for (int i1 = 0; i1 < voucherItems.size(); i1++) { | ||||
|                     JSONObject voucherItem = (JSONObject) voucherItems.get(i1); | ||||
|  |  | |||
|  | @ -117,12 +117,13 @@ public class RecBillChangeListExtendPlugin extends AbstractListPlugin implements | |||
|                         break; | ||||
|                     } | ||||
|                 } | ||||
|             } else { | ||||
|                 //未关联下游业务时 | ||||
|                 this.getView().showTipNotification("所选单据不满足变更条件,下游未关联清账单。"); | ||||
|                 evt.setCancel(true); | ||||
|                 return; | ||||
|             } | ||||
| //            else { | ||||
|                 //未关联下游业务时 | ||||
| //                this.getView().showTipNotification("所选单据不满足变更条件,下游未关联清账单。"); | ||||
| //                evt.setCancel(true); | ||||
| //                return; | ||||
| //            } | ||||
|         } | ||||
| 
 | ||||
|         if (!(isAutoCleared || (isToBeCleared && isClearBillCancelled))) { | ||||
|  |  | |||
|  | @ -0,0 +1,247 @@ | |||
| package shjh.jhzj7.fi.fi.plugin.operate; | ||||
| 
 | ||||
| import com.alibaba.fastjson.JSONArray; | ||||
| import com.alibaba.fastjson.JSONException; | ||||
| 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.dataentity.entity.DynamicObjectCollection; | ||||
| import kd.bos.entity.operate.result.OperateErrorInfo; | ||||
| import kd.bos.entity.plugin.AbstractOperationServicePlugIn; | ||||
| import kd.bos.entity.plugin.args.AfterOperationArgs; | ||||
| import kd.bos.id.ID; | ||||
| import kd.bos.logging.Log; | ||||
| import kd.bos.logging.LogFactory; | ||||
| import kd.bos.orm.query.QFilter; | ||||
| import kd.bos.servicehelper.BusinessDataServiceHelper; | ||||
| import kd.bos.servicehelper.operation.SaveServiceHelper; | ||||
| import kd.sdk.plugin.Plugin; | ||||
| import shjh.jhzj7.fi.fi.utils.EsbUtils; | ||||
| import shjh.jhzj7.fi.fi.utils.JhzjUtils; | ||||
| 
 | ||||
| import java.util.Date; | ||||
| import java.util.HashMap; | ||||
| import java.util.Map; | ||||
| 
 | ||||
| public class CustomerInitOperation extends AbstractOperationServicePlugIn implements Plugin { | ||||
| 
 | ||||
|     private static final String entityName = "bd_customer";//系统库 表名 T_BD_Customer | ||||
| 
 | ||||
|     private static final String cusTypeName = "bd_customergroup";//系统库 表名 t_bd_customergroup | ||||
|     private static final String gdName = "bd_customergroupdetail";//系统库 客户分组 表名 t_bd_customergroupdetail | ||||
|     private static final String bebankName = "bd_bebank";//系统库 行名行号 表名 t_bd_bebank | ||||
|     private static final Log log = LogFactory.getLog(CustomerInitOperation.class); | ||||
| 
 | ||||
| 
 | ||||
|     @Override | ||||
|     public void afterExecuteOperationTransaction(AfterOperationArgs e) { | ||||
|         super.afterExecuteOperationTransaction(e); | ||||
|         String eok = e.getOperationKey(); | ||||
|         if("customerinit".equals(eok)){ | ||||
|             DynamicObject[] dos =  e.getDataEntities(); | ||||
|             DynamicObject pzinfo = BusinessDataServiceHelper.loadSingle(dos[0].getPkValue(), dos[0].getDataEntityType().getName()); | ||||
|             JSONObject json_obj; | ||||
|             try{ | ||||
|                 //解析入参,如果格式不正确,日志记录,并反馈esb | ||||
|                 json_obj = JSONObject.parseObject(pzinfo.getString("shjh_inputs_tag")); | ||||
|             }catch (JSONException e1) { | ||||
|                 String jsonResult = String.format("客户接口入参异常:%s", e1.getMessage()); | ||||
|                 log.error(jsonResult); | ||||
|                 addErrorInfo(pzinfo,"接口入参异常"+jsonResult); | ||||
|                 return; | ||||
|             } | ||||
|             JSONArray itemsJson = new JSONArray();//返回值明细集合 | ||||
|             JSONObject itemInfo;//返回值明细对象 | ||||
|             JSONArray detailsJson = json_obj.getJSONArray("items");//客户基本信息 | ||||
|             if(detailsJson == null){ | ||||
|                 addErrorInfo(pzinfo,"未识别到items参数"); | ||||
|                 return; | ||||
|             } | ||||
|             JSONArray banksJson = json_obj.getJSONArray("banks");//客户银行 | ||||
|             JSONArray companysJson = json_obj.getJSONArray("companys");//客户所属公司 | ||||
|             JSONArray customerfivesJson = json_obj.getJSONArray("customerfives");//客户组5 | ||||
|             String cusnumber; | ||||
|             String cusname; | ||||
|             String taxno; | ||||
|             String type; | ||||
|             DynamicObject currentCus; | ||||
|             DynamicObject custype; | ||||
|             JSONObject json_body; | ||||
|             Long currentSupId; | ||||
|             DynamicObject custgroupdetail; | ||||
|             Map<String, Long> cusids = new HashMap<>();//客户编号和ID对应关系 | ||||
| 
 | ||||
|             for (int i = 0; i < detailsJson.size(); i++) { | ||||
|                 json_body = detailsJson.getJSONObject(i); | ||||
|                 cusnumber = json_body.getString("code"); | ||||
|                 cusname = json_body.getString("name"); | ||||
|                 taxno = json_body.getString("taxno"); | ||||
|                 type = json_body.getString("type"); | ||||
| 
 | ||||
|                 if(EsbUtils.isEmpty(cusnumber) || EsbUtils.isEmpty(cusname) || EsbUtils.isEmpty(type)){ | ||||
|                     log.error(String.format("客户接口入参为空异常:%s", json_body.toJSONString())); | ||||
|                     itemInfo = new JSONObject(); | ||||
|                     itemInfo.put("code",cusnumber); | ||||
|                     itemInfo.put("error","code name type入参值为空"); | ||||
|                     itemsJson.add(itemInfo); | ||||
|                     continue; | ||||
|                 } | ||||
|                 currentCus = BusinessDataServiceHelper.loadSingle(entityName,new QFilter[]{new QFilter("number","=",cusnumber)}); | ||||
|                 if(currentCus == null){ | ||||
|                     //判断客户分类 | ||||
|                     custype = BusinessDataServiceHelper.loadSingleFromCache(cusTypeName,"id,number",new QFilter[]{new QFilter("number","=",type)}); | ||||
|                     if(custype == null){ | ||||
|                         log.error(String.format("客户分类未匹配:%s", json_body.toJSONString())); | ||||
|                         itemInfo = new JSONObject(); | ||||
|                         itemInfo.put("code",cusnumber); | ||||
|                         itemInfo.put("error","客户分类未匹配"); | ||||
|                         itemsJson.add(itemInfo); | ||||
|                         continue; | ||||
|                     } | ||||
|                     //根据编号找不到客户,则新增 | ||||
|                     currentCus = BusinessDataServiceHelper.newDynamicObject(entityName); | ||||
|                     currentCus.set("number",cusnumber); | ||||
|                     currentCus.set("status","C");//数据状态 | ||||
|                     currentCus.set("creator", RequestContext.get().getCurrUserId());//创建人 | ||||
|                     currentCus.set("approverid", RequestContext.get().getCurrUserId());//审核人 | ||||
|                     currentCus.set("approvedate", new Date());//审核时间 | ||||
|                     currentCus.set("enable",1);//默认可用 | ||||
|                     currentCus.set("type","1");//伙伴类型 默认法人企业 | ||||
|                     currentCus.set("bizfunction",",1,2,3,4,");//业务职能 默认全选 | ||||
|                     currentCus.set("createorg", JhzjUtils.GROUPID);//创建组织 默认为集团 | ||||
|                     currentCus.set("org", JhzjUtils.GROUPID);//管理组织 默认为集团 | ||||
|                     currentCus.set("ctrlstrategy","1");//控制策略 默认逐级分配1 自由分配2 | ||||
|                     currentCus.set("group",custype.getLong("id"));//客户分组 | ||||
|                     currentCus.set("bitindex",1);//位图 | ||||
|                     currentCus.set("customerstatus",EsbUtils.CUSTOMERSTATUS);//客户状态 | ||||
|                     currentCus.set("name",cusname);//客户名称 | ||||
|                     currentCus.set("tx_register_no",taxno);//税务登记号 | ||||
|                     currentCus.set("societycreditcode",taxno);//统一社会信用代码 | ||||
|                     currentCus.set("linkman",json_body.getString("contacts"));//联系人 | ||||
|                     currentCus.set("bizpartner_phone",json_body.getString("telnum"));//联系电话 | ||||
|                     //设置id和masterid 不然不能进行分配动作 | ||||
|                     currentSupId = ID.genLongId(); | ||||
|                     currentCus.set("id", currentSupId); | ||||
|                     currentCus.set("masterid",currentSupId); | ||||
|                     //处理银行-新增-员工类客户不需要处理 | ||||
|                     if(!"M400".equals(type)){ | ||||
|                         handleBank(banksJson,currentCus.getDynamicObjectCollection("entry_bank"),cusnumber,cusname); | ||||
|                     }else{ | ||||
|                         //如果是个人,则伙伴类型字段为个人 | ||||
|                         currentCus.set("type","4");//伙伴类型 | ||||
|                     } | ||||
|                     //处理 客户组5 | ||||
|                     handleFive(customerfivesJson,currentCus.getDynamicObjectCollection("shjh_entry_five"),cusnumber); | ||||
| 
 | ||||
|                     SaveServiceHelper.save(new DynamicObject[]{currentCus}); | ||||
|                     //处理分类 | ||||
|                     custgroupdetail = BusinessDataServiceHelper.newDynamicObject(gdName); | ||||
|                     custgroupdetail.set("createorg",JhzjUtils.GROUPID);//创建组织 | ||||
|                     custgroupdetail.set("standard",EsbUtils.CUSTOMERSTAND);//客户分类标准 | ||||
|                     custgroupdetail.set("group",custype.getLong("id"));//具体分类 | ||||
|                     custgroupdetail.set("customer",currentSupId);//客户 | ||||
|                     SaveServiceHelper.save(new DynamicObject[]{custgroupdetail}); | ||||
|                 }else{ | ||||
|                     //修改客户 名称 税务登记号 联系人 联系电话 银行信息 客户组5 | ||||
|                     currentSupId = currentCus.getLong("id"); | ||||
|                     currentCus.set("name",cusname);//客户名称 | ||||
|                     currentCus.set("tx_register_no",taxno);//税务登记号 | ||||
|                     currentCus.set("societycreditcode",taxno);//统一社会信用代码 | ||||
|                     currentCus.set("linkman",json_body.getString("contacts"));//联系人 | ||||
|                     currentCus.set("bizpartner_phone",json_body.getString("telnum"));//联系电话 | ||||
|                     //处理 客户组5 | ||||
|                     handleFive(customerfivesJson,currentCus.getDynamicObjectCollection("shjh_entry_five"),cusnumber); | ||||
|                     //处理银行-新增-员工类客户不需要处理 | ||||
|                     if(!"M400".equals(type)){ | ||||
|                         handleBank(banksJson,currentCus.getDynamicObjectCollection("entry_bank"),cusnumber,cusname); | ||||
|                     } | ||||
|                     SaveServiceHelper.save(new DynamicObject[]{currentCus}); | ||||
|                 } | ||||
|                 cusids.put(cusnumber,currentSupId); | ||||
|             } | ||||
|             //处理客户分配 | ||||
|             EsbUtils.handleAssignNew(companysJson, cusids, entityName); | ||||
|             //处理客户取消分配--初始化时不需要用 | ||||
| //            EsbUtils.handleUnAssign(companysJson, cusids, entityName); | ||||
| 
 | ||||
|             if(itemsJson.isEmpty()){ | ||||
|                 this.operationResult.addSuccessPkId(pzinfo.getPkValue()); | ||||
|             }else{ | ||||
|                 addErrorInfo(pzinfo,"接口处理异常"+itemsJson.toJSONString()); | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     private void handleFive(JSONArray customerfivesJson, DynamicObjectCollection doc_five, String cusnumber){ | ||||
|         if(customerfivesJson == null){ | ||||
|             return; | ||||
|         } | ||||
|         doc_five.clear(); | ||||
|         JSONObject json_body; | ||||
|         DynamicObject fiveinfo; | ||||
|         String channelnum; | ||||
|         String companynum; | ||||
|         String fivecode; | ||||
|         for (int i = 0; i < customerfivesJson.size(); i++) { | ||||
|             json_body = customerfivesJson.getJSONObject(i); | ||||
|             if(cusnumber.equals(json_body.getString("code"))){ | ||||
|                 channelnum = json_body.getString("channelnum"); | ||||
|                 companynum = json_body.getString("salecompanynum"); | ||||
|                 fivecode = json_body.getString("customerfivecode"); | ||||
|                 if(EsbUtils.isEmpty(channelnum) || EsbUtils.isEmpty(companynum) || EsbUtils.isEmpty(fivecode)){ | ||||
|                     //任意一个为空,则不处理 | ||||
|                     log.error(String.format("客户组5入参值为空:%s", json_body.toJSONString())); | ||||
|                     continue; | ||||
|                 } | ||||
|                 fiveinfo = doc_five.addNew(); | ||||
|                 fiveinfo.set("shjh_channelnum",channelnum);//渠道编号 | ||||
|                 fiveinfo.set("shjh_channelname",json_body.getString("channelname"));//渠道名称 | ||||
|                 fiveinfo.set("shjh_salecompanynum",companynum);//公司编号 | ||||
|                 fiveinfo.set("shjh_entryfive_number",fivecode);//编号 | ||||
|                 fiveinfo.set("shjh_entryfive_name",json_body.getString("customerfivename"));//名称 | ||||
|                 fiveinfo.set("shjh_status",EsbUtils.getStatusForBoolean(json_body.getString("customerfivestatus")));//状态 | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     private void handleBank(JSONArray banksJson,DynamicObjectCollection doc_bank,String cusnumber,String cusname){ | ||||
|         if(banksJson == null){ | ||||
|             return; | ||||
|         } | ||||
|         doc_bank.clear(); | ||||
|         JSONObject json_body; | ||||
|         DynamicObject bankinfo; | ||||
|         DynamicObject bebankinfo; | ||||
|         for (int i = 0; i < banksJson.size(); i++) { | ||||
|             json_body = banksJson.getJSONObject(i); | ||||
|             if(cusnumber.equals(json_body.getString("code"))){ | ||||
|                 bankinfo = doc_bank.addNew(); | ||||
|                 bankinfo.set("bankaccount",json_body.getString("banknumber"));//银行账号 | ||||
|                 if(EsbUtils.isEmpty(json_body.getString("acctname"))){ | ||||
|                     //如果入参中没有账户名称,则使用当前名称 | ||||
|                     bankinfo.set("accountname",cusname);//账户名称 | ||||
|                 }else{ | ||||
|                     bankinfo.set("accountname",json_body.getString("acctname"));//账户名称 | ||||
|                 } | ||||
|                 //根据详细分机银行 查找对应的行名行号 | ||||
|                 bebankinfo = BusinessDataServiceHelper.loadSingleFromCache(bebankName,"id,name",new QFilter[]{new QFilter("name","=",json_body.getString("bankname"))}); | ||||
|                 if(bebankinfo != null){ | ||||
|                     bankinfo.set("bank",bebankinfo.getLong("id"));//开户银行-行名行号 根据入参查找 | ||||
|                 } | ||||
|                 bankinfo.set("currency", JhzjUtils.CNY);//币别 默认人民币 | ||||
|             } | ||||
|         } | ||||
|         if(!doc_bank.isEmpty()){ | ||||
|             doc_bank.get(0).set("isdefault_bank",true); | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     private void addErrorInfo(DynamicObject bill, String errorMsg) { | ||||
|         OperateErrorInfo operateErrorInfo = new OperateErrorInfo(); | ||||
|         operateErrorInfo.setMessage(errorMsg); | ||||
|         operateErrorInfo.setErrorLevel(ErrorLevel.Error.name()); | ||||
|         operateErrorInfo.setPkValue(bill.getPkValue()); | ||||
|         this.operationResult.addErrorInfo(operateErrorInfo); | ||||
|     } | ||||
| } | ||||
|  | @ -30,7 +30,7 @@ import java.util.List; | |||
| import java.util.concurrent.atomic.AtomicReference; | ||||
| import java.util.stream.Collectors; | ||||
| 
 | ||||
| import static shjh.jhzj7.fi.fi.utils.SapUtils.*; | ||||
| import static shjh.jhzj7.fi.fi.utils.SapUtils.sap_accounVoucher; | ||||
| 
 | ||||
| /** | ||||
|  * 付款单推送SAP凭证操作插件 | ||||
|  | @ -129,15 +129,41 @@ public class PaybillPushSapOperation extends AbstractOperationServicePlugIn impl | |||
|                 JSONObject jsonObject = sap_accounVoucher(data, bill.getString("billno")); | ||||
|                 if (jsonObject.getIntValue("code") == 0) { | ||||
|                     ResponseData responseData = ApiUtils.getResponseData(jsonObject); | ||||
|                     if (responseData!=null){ | ||||
|                     if (responseData != null){ | ||||
|                         bill.set("shjh_credentialnum",responseData.getNumber()); | ||||
|                         bill.set("shjh_sapfiscalyear",responseData.getYear()); | ||||
|                         bill.set("shjh_ispushsap", true); | ||||
|                         SaveServiceHelper.save(new DynamicObject[]{bill}); | ||||
|                         //处理sap主动付款时,更新日记账的sap凭证号 | ||||
|                         //处理被动付款时,更新流水和日记账的sap凭证号 | ||||
|                         DynamicObject bankjournal = BusinessDataServiceHelper.loadSingle("cas_bankjournal", new QFilter("billno", | ||||
|                                 QCP.equals, bill.getString("billno")).toArray()); | ||||
|                         //同步更新银行日记账单(cas_bankjournal)的SAP付款凭证号,若没有下游单据,付款操作后执行携带(PaybillPayOperation) | ||||
|                         if (null != bankjournal) { | ||||
|                             bankjournal.set("shjh_credentialnum",responseData.getNumber()); | ||||
|                             SaveServiceHelper.save(new DynamicObject[]{bankjournal}); | ||||
|                         } | ||||
|                         //同步更新交易明细查询(bei_transdetail)__被动 主动参考操作代码 BeiIntelpayBillTask | ||||
|                         DynamicObjectCollection bankcheckentity = bill.getDynamicObjectCollection("bankcheckentity"); | ||||
|                         for (DynamicObject dynamicObject : bankcheckentity) { | ||||
|                             String detailbillno = dynamicObject.getString("edetailbillno");//交易明细编号 | ||||
|                             DynamicObject beiIntelpay = BusinessDataServiceHelper.loadSingle("bei_transdetail", new QFilter( | ||||
|                                     "billno", QCP.equals, detailbillno).toArray()); | ||||
|                             if (null != beiIntelpay) { | ||||
|                                 beiIntelpay.set("shjh_credentialnums",responseData.getNumber()); | ||||
|                                 SaveServiceHelper.save(new DynamicObject[]{beiIntelpay}); | ||||
|                             } | ||||
|                         } | ||||
|                     }else{ | ||||
|                         OperateErrorInfo operateErrorInfo = new OperateErrorInfo(); | ||||
|                         operateErrorInfo.setMessage("SAP凭证接口返回值解析失败,请查看接口日志"); | ||||
|                         operateErrorInfo.setErrorLevel(ErrorLevel.Error.name()); | ||||
|                         operateErrorInfo.setPkValue(bill.getPkValue()); | ||||
|                         this.operationResult.addErrorInfo(operateErrorInfo); | ||||
|                     } | ||||
|                     bill.set("shjh_ispushsap", true); | ||||
|                     SaveServiceHelper.save(new DynamicObject[]{bill}); | ||||
|                 }else { | ||||
|                     OperateErrorInfo operateErrorInfo = new OperateErrorInfo(); | ||||
|                     operateErrorInfo.setMessage("推送SAP凭证接口失败,原因:"+String.valueOf(jsonObject.get("msg"))); | ||||
|                     operateErrorInfo.setMessage("推送SAP凭证接口失败,原因:"+jsonObject.get("msg")); | ||||
|                     operateErrorInfo.setErrorLevel(ErrorLevel.Error.name()); | ||||
|                     operateErrorInfo.setPkValue(bill.getPkValue()); | ||||
|                     this.operationResult.addErrorInfo(operateErrorInfo); | ||||
|  | @ -161,11 +187,11 @@ public class PaybillPushSapOperation extends AbstractOperationServicePlugIn impl | |||
|             bizdate1 = format.format(bizdate); | ||||
|         } | ||||
|         IS_HEADER.put("BLDAT", bizdate1);//凭证日期_业务日期(付款单bizdate) | ||||
|         Date acttradedate = bill.getDate("acttradedate"); | ||||
|         String acttradedate1 = ""; | ||||
|         if (null != acttradedate) { | ||||
|             acttradedate1 = format.format(acttradedate); | ||||
|         } | ||||
| //        Date acttradedate = bill.getDate("acttradedate"); | ||||
| //        String acttradedate1 = ""; | ||||
| //        if (null != acttradedate) { | ||||
| //            acttradedate1 = format.format(acttradedate); | ||||
| //        } | ||||
| //        IS_HEADER.put("BUDAT", acttradedate1);//todo:过账日期_实际交易日期(付款单acttradedate) | ||||
|         IS_HEADER.put("BUDAT", bizdate1);//过账日期_业务日期(付款单bizdate) | ||||
|         String isoCode = bill.getDynamicObject("currency").getString("number"); | ||||
|  | @ -180,8 +206,8 @@ public class PaybillPushSapOperation extends AbstractOperationServicePlugIn impl | |||
|     private JSONArray getIT_ITEM(DynamicObject bill , JSONObject IS_HEADER) { | ||||
|         String shjhSourcesystem = bill.getString("shjh_sourcesystem");//来源系统 | ||||
|         //客户(bd_customer)||供应商(bd_supplier)  收款人id:payee | ||||
|         String payeetype = bill.getString("payeetype");//收款人类型 | ||||
|         String customerOrsupnum = getCustomerOrSupplierNumber(payeetype, bill,"payee"); | ||||
| //        String payeetype = bill.getString("payeetype");//收款人类型 | ||||
| //        String customerOrsupnum = getCustomerOrSupplierNumber(payeetype, bill,"payee"); | ||||
| 
 | ||||
|         //原因码(付款明细) | ||||
|         String RSTGR; | ||||
|  | @ -240,6 +266,7 @@ public class PaybillPushSapOperation extends AbstractOperationServicePlugIn impl | |||
|                             continue;//非银行科目 | ||||
|                         } | ||||
|                         IT_ITEMS.put("HKONT", account.getString("number")); // 总账科目_科目(凭证分录account) | ||||
|                         IT_ITEMS.put("UMSKZ", JhzjUtils.getUMSKZ(account.getString("number")));//特殊总账标识 | ||||
|                     }else { | ||||
|                         continue; | ||||
|                     } | ||||
|  | @ -341,7 +368,7 @@ public class PaybillPushSapOperation extends AbstractOperationServicePlugIn impl | |||
|                 HKONT = shjhSapkjkm.getString("number");//SAP会计科目 | ||||
|             } | ||||
|             jsonObject.put("HKONT", HKONT);//总账科目 | ||||
|             jsonObject.put("UMSKZ", "");//todo:特殊总账标识 | ||||
|             jsonObject.put("UMSKZ", JhzjUtils.getUMSKZ(HKONT));//特殊总账标识 | ||||
|             jsonObject.put("DMBTR1", entry.getBigDecimal("e_actamt"));//清账金额_实付金额 | ||||
|             IT_CLEAR.add(jsonObject); | ||||
|         }); | ||||
|  | @ -389,8 +416,8 @@ public class PaybillPushSapOperation extends AbstractOperationServicePlugIn impl | |||
|                             if (shjhSapkjkm != null) { | ||||
|                                 HKONT = shjhSapkjkm.getString("number"); | ||||
|                             } | ||||
|                             jsonObject.put("HKONT", HKONT); | ||||
|                             jsonObject.put("UMSKZ", ""); | ||||
|                             jsonObject.put("HKONT", HKONT);//科目编号 | ||||
|                             jsonObject.put("UMSKZ", JhzjUtils.getUMSKZ(HKONT));//特殊总账标识 | ||||
|                             jsonObject.put("DMBTR", entr.getBigDecimal("e_actamt")); | ||||
|                             IT_CLEAR.add(jsonObject); | ||||
|                         }); | ||||
|  |  | |||
|  | @ -395,6 +395,7 @@ public class RecPushVoucherOperation extends AbstractOperationServicePlugIn impl | |||
|                     DynamicObject account = entry.getDynamicObject("account"); | ||||
|                     if (account != null) { | ||||
|                         IT_ITEMS.put("HKONT", account.getString("number")); | ||||
|                         IT_ITEMS.put("UMSKZ", JhzjUtils.getUMSKZ(account.getString("number")));//特殊总账标识 | ||||
|                         //查找核算维度 | ||||
| //                        DynamicObjectCollection checkItems = account.getDynamicObjectCollection("checkitementry"); | ||||
| //                        if (!customersplit && checkItems!=null && checkItems.size()!=0){ | ||||
|  | @ -624,7 +625,7 @@ public class RecPushVoucherOperation extends AbstractOperationServicePlugIn impl | |||
|         item.put("LIFNR", supplierNum); | ||||
| 
 | ||||
|         // 金额相关字段 | ||||
| //        item.put("UMSKZ", "");                                         // 特殊总帐标识 | ||||
|         item.put("UMSKZ", JhzjUtils.getUMSKZ(entry.getString("shjh_accountsap.number")));// 特殊总帐标识 | ||||
| //        item.put("DMBTR", "");                                         // 未清金额 | ||||
|         item.put("DMBTR1", clearAmount != null ? clearAmount.toString() : "0"); // 清账金额 | ||||
| //        item.put("DMBTR2", "");                                        // 剩余金额 | ||||
|  |  | |||
|  | @ -146,6 +146,7 @@ public class RevenueBillOperation extends AbstractOperationServicePlugIn impleme | |||
|                 account = entry.getDynamicObject("account");//科目 | ||||
|                 if (null != account) { | ||||
|                     item.put("HKONT", account.getString("number")); //总账科目_科目(凭证分录account) | ||||
|                     item.put("UMSKZ", JhzjUtils.getUMSKZ(account.getString("number")));//特殊总账标识 | ||||
|                 } | ||||
|                 //获取贷方金额 | ||||
|                 creditlocal = entry.getBigDecimal("creditlocal");//贷方 | ||||
|  |  | |||
|  | @ -55,7 +55,7 @@ public class SupplierInitOperation extends AbstractOperationServicePlugIn implem | |||
|             JSONArray detailsJson = json_obj.getJSONArray("items"); | ||||
|             if(detailsJson == null){ | ||||
|                 addErrorInfo(pzinfo,"未识别到items参数"); | ||||
|                 return ; | ||||
|                 return; | ||||
|             } | ||||
|             JSONArray banksJson = json_obj.getJSONArray("banks");//供应商银行 | ||||
|             JSONArray companysJson = json_obj.getJSONArray("companys");//供应商所属公司 | ||||
|  | @ -191,7 +191,7 @@ public class SupplierInitOperation extends AbstractOperationServicePlugIn implem | |||
| 
 | ||||
|             //处理供应商分配 | ||||
|             EsbUtils.handleAssignNew(companysJson, cusids, entityName); | ||||
|             //处理供应商取消分配 | ||||
|             //处理供应商取消分配--初始化时不需要用 | ||||
| //            EsbUtils.handleUnAssign(companysJson, cusids, entityName); | ||||
| 
 | ||||
|             if(itemsJson.isEmpty()){ | ||||
|  |  | |||
|  | @ -16,7 +16,7 @@ import java.math.BigDecimal; | |||
| import java.util.Map; | ||||
| 
 | ||||
| /** | ||||
|  * 被动付款入账_定时从付款单携带SAP应付凭证单号 | ||||
|  * 定时从付款单携带SAP付凭证单号至被动付款入账中心(主要处理sap主动付款场景) | ||||
|  */ | ||||
| public class BeiIntelpayBillTask extends AbstractTask implements Plugin { | ||||
| 
 | ||||
|  |  | |||
|  | @ -448,6 +448,21 @@ public class JhzjUtils { | |||
|         } | ||||
|     } | ||||
| 
 | ||||
|     /* | ||||
|      * 根据科目编号返回特殊总账标识 | ||||
|      *  "1123900000", "2203900000", "2204900000", "1123070000", "1123080000" }; 传A | ||||
|      * { "1121010100", "1121020100", "1121010501" }; 传W | ||||
|      * */ | ||||
|     public static String getUMSKZ(String accountNum){ | ||||
|         if("1123900000".equals(accountNum) || "2203900000".equals(accountNum) || "2204900000".equals(accountNum) || | ||||
|                 "1123070000".equals(accountNum) || "1123080000".equals(accountNum)){ | ||||
|             return "A"; | ||||
|         }else if("1121010100".equals(accountNum) || "1121020100".equals(accountNum) || "1121010501".equals(accountNum)){ | ||||
|             return "W"; | ||||
|         } | ||||
|         return ""; | ||||
|     } | ||||
| 
 | ||||
|     /* | ||||
|      * 判断收款单编号是否由多个组成,如果是多个,其中每个中间以逗号分隔的 | ||||
|      * */ | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue