收款单分录客户清账状态更新;科目接口优化
This commit is contained in:
		
							parent
							
								
									4c4ad1e7e4
								
							
						
					
					
						commit
						67048086ba
					
				|  | @ -105,16 +105,17 @@ public class RecBillSaveOperation extends AbstractOperationServicePlugIn impleme | |||
|                         /* | ||||
|                          * 1.收款入账中心按规则生单,收款单保存时触发 | ||||
|                          * 2.匹配的规则分录行中"取规则得映射表客户"为true,按照收款入账中心的对方户名去映射表过滤客户 | ||||
|                          * 3若没有,取"4000042_不明确客户"为默认值,携带到收款单的收款人名称,id字段, | ||||
|                          * 3若没有,取"1042086_不明确客户"为默认值,携带到收款单的收款人名称,id字段, | ||||
|                          * 4.并且将对方户名携带到收款单备注字段中 | ||||
|                          */ | ||||
|                         long payer = bill.getLong("payer");//付款人id | ||||
|                         if (payer == 0) { | ||||
|                             boolean shjhEGetcustomer = entry.getBoolean("shjh_e_getcustomer"); | ||||
|                             boolean shjhEGetcustomer = entry.getBoolean("shjh_e_getcustomer");//取规则得映射表客户标记 | ||||
|                             if (shjhEGetcustomer) { | ||||
|                                 String oppunit = beiIntelpay.getString("oppunit");//收款入账中心的对方户名 | ||||
|                                 bill.set("shjh_dfhm", oppunit);//收款单备注字段 | ||||
|                                 QFilter qFilter = new QFilter("shjh_dfhm", QCP.equals, oppunit); | ||||
|                                 //对方户名与客户名称映射表 shjh_dfhmcust | ||||
|                                 DynamicObject shjhDfhmcust = BusinessDataServiceHelper.loadSingle("shjh_dfhmcust", qFilter.toArray()); | ||||
|                                 if (null != shjhDfhmcust) { | ||||
|                                     DynamicObject shjhCustomer = shjhDfhmcust.getDynamicObject("shjh_customer"); | ||||
|  | @ -132,32 +133,43 @@ public class RecBillSaveOperation extends AbstractOperationServicePlugIn impleme | |||
|                                 } | ||||
|                             } | ||||
|                         } | ||||
|                         DynamicObject shjhBizbig = (DynamicObject) bill.get("shjh_bizebig"); | ||||
|                         DynamicObject shjhBizbig = (DynamicObject) bill.get("shjh_bizebig");//收款单的业务大类 | ||||
|                         if (null == shjhBizbig) { | ||||
|                             bill.set("shjh_bizebig", entry.getDynamicObject("shjh_e_bizbig")); | ||||
|                         } | ||||
|                         DynamicObject shjhBizsmall = (DynamicObject) bill.get("shjh_bizsmall"); | ||||
|                         DynamicObject shjhBizsmall = (DynamicObject) bill.get("shjh_bizsmall");//收款单的业务小类 | ||||
|                         if (null == shjhBizsmall) { | ||||
|                             bill.set("shjh_bizsmall", entry.getDynamicObject("shjh_e_bizsmall")); | ||||
|                             DynamicObject shjhEBizsmall = entry.getDynamicObject("shjh_e_bizsmall");//规则--业务小类 | ||||
|                             bill.set("shjh_bizsmall", shjhEBizsmall); | ||||
| 
 | ||||
|                             DynamicObjectCollection entrys = bill.getDynamicObjectCollection("entry");//收款单分录 | ||||
|                             if (null != entrys) { | ||||
|                                 DynamicObject entryss = entrys.get(0);//首行(被动) | ||||
|                                 DynamicObject shjhYym = entryss.getDynamicObject("shjh_yym");//若原因码为空 | ||||
|                                 if (null == shjhYym) { | ||||
|                                     DynamicObject shjhEBizsmall = entry.getDynamicObject("shjh_e_bizsmall");//规则--业务小类 | ||||
|                                     if (null != shjhEBizsmall) { | ||||
|                                         shjhEBizsmall = BusinessDataServiceHelper.loadSingle(shjhEBizsmall.getPkValue(),"shjh_bizsmalltype"); | ||||
|                                 DynamicObject shjhYym = entryss.getDynamicObject("shjh_yym");//若收款单分录原因码为空,则从业务小类中携带 | ||||
|                                 if (null != shjhEBizsmall) { | ||||
|                                     shjhEBizsmall = BusinessDataServiceHelper.loadSingle(shjhEBizsmall.getPkValue(),"shjh_bizsmalltype"); | ||||
|                                     if (null == shjhYym) { | ||||
|                                         entryss.set("shjh_yym", shjhEBizsmall.getDynamicObject("shjh_yym"));//规则--小类--原因码 | ||||
|                                     } | ||||
|                                     //根据业务小类的清账方式,设置分录和表头的清账方式,以及分录下推清账单标记 | ||||
|                                     if ("qbjdqz".equals(shjhEBizsmall.getString("shjh_qzfs"))) { | ||||
|                                         //【业务小类】清账方式字段=全部金蝶清账 | ||||
|                                         entryss.set("shjh_needpushbill", true);//需要下推清账单 | ||||
|                                         entryss.set("shjh_closingstatus", "B");//待清账 | ||||
|                                         bill.set("shjh_qzzt", "B");//待清账 | ||||
|                                     }else{ | ||||
|                                         entryss.set("shjh_needpushbill", false);//不需要下推清账单 | ||||
|                                         entryss.set("shjh_closingstatus", "A");//无需金蝶清账 | ||||
|                                         bill.set("shjh_qzzt", "A");//无需金蝶清账 | ||||
|                                     } | ||||
|                                 } | ||||
|                             } | ||||
|                         } | ||||
|                         DynamicObject shjhCostcenter = (DynamicObject) bill.get("shjh_costcenter"); | ||||
|                         DynamicObject shjhCostcenter = (DynamicObject) bill.get("shjh_costcenter");//成本中心 | ||||
|                         if (null == shjhCostcenter) { | ||||
|                             bill.set("shjh_costcenter", entry.getDynamicObject("shjh_e_cc")); | ||||
|                         } | ||||
|                         DynamicObject shjhPc = (DynamicObject) bill.get("shjh_profitcenter"); | ||||
|                         DynamicObject shjhPc = (DynamicObject) bill.get("shjh_profitcenter");//利润中心 | ||||
|                         if (null == shjhPc) { | ||||
|                             bill.set("shjh_profitcenter", entry.getDynamicObject("shjh_e_pc")); | ||||
|                         } | ||||
|  |  | |||
|  | @ -1,5 +1,6 @@ | |||
| package shjh.jhzj7.fi.fi.plugin.operate; | ||||
| 
 | ||||
| import com.sap.db.jdbc.packet.ErrorLevel; | ||||
| import kd.bos.dataentity.OperateOption; | ||||
| import kd.bos.dataentity.entity.DynamicObject; | ||||
| import kd.bos.entity.operate.OperateOptionConst; | ||||
|  | @ -50,6 +51,7 @@ public class VoucherAuditOperation extends AbstractOperationServicePlugIn implem | |||
|             operateOption.setVariableValue(OperateOptionConst.MUTEX_ISSTRICT, String.valueOf(true)); | ||||
|             OperationResult operResult;//操作执行结果 | ||||
|             List<OperateErrorInfo> allErrorInfo; | ||||
|             OperateErrorInfo operateErrorInfo; | ||||
|             for (DynamicObject pzinfo : dos) { | ||||
|                 //重新加载凭证对象 | ||||
|                 pzinfo = BusinessDataServiceHelper.loadSingle(pzinfo.getPkValue(), pzinfo.getDataEntityType().getName(), "id,billno,sourcebill,sourcebilltype"); | ||||
|  | @ -63,12 +65,24 @@ public class VoucherAuditOperation extends AbstractOperationServicePlugIn implem | |||
|                         operResult = OperationServiceHelper.executeOperate("pushvoucher", recbillName, new DynamicObject[]{bizbillinfo}, operateOption); | ||||
|                         if (operResult.isSuccess()) { | ||||
|                             logger.info("执行收款单 pushvoucher 成功,单据编号:" + bizbillinfo.getString("billno")); | ||||
|                             bizbillinfo = BusinessDataServiceHelper.loadSingle(sourcebillid,sourcebilltype,"id,shjh_vouchernum"); | ||||
|                             operateErrorInfo = new OperateErrorInfo(); | ||||
|                             operateErrorInfo.setMessage("SAP凭证号:" + bizbillinfo.getString("shjh_vouchernum")); | ||||
|                             operateErrorInfo.setErrorLevel(ErrorLevel.Error.name()); | ||||
|                             operateErrorInfo.setPkValue(bizbillinfo.getPkValue()); | ||||
|                             this.operationResult.addErrorInfo(operateErrorInfo); | ||||
|                         } | ||||
|                     }else{ | ||||
|                         //收款金额为负数 红冲 redpunch | ||||
|                         operResult = OperationServiceHelper.executeOperate("redpunch", recbillName, new DynamicObject[]{bizbillinfo}, operateOption); | ||||
|                         if (operResult.isSuccess()) { | ||||
|                             logger.info("执行收款单 redpunch 成功,单据编号:" + bizbillinfo.getString("billno")); | ||||
|                             bizbillinfo = BusinessDataServiceHelper.loadSingle(sourcebillid,sourcebilltype,"id,shjh_vouchernum"); | ||||
|                             operateErrorInfo = new OperateErrorInfo(); | ||||
|                             operateErrorInfo.setMessage("SAP凭证号:" + bizbillinfo.getString("shjh_vouchernum")); | ||||
|                             operateErrorInfo.setErrorLevel(ErrorLevel.Error.name()); | ||||
|                             operateErrorInfo.setPkValue(bizbillinfo.getPkValue()); | ||||
|                             this.operationResult.addErrorInfo(operateErrorInfo); | ||||
|                         } | ||||
|                     } | ||||
| 
 | ||||
|  | @ -87,6 +101,12 @@ public class VoucherAuditOperation extends AbstractOperationServicePlugIn implem | |||
|                     // 可以根据需要处理 operationResult,例如检查是否成功、获取返回值等 | ||||
|                     if (operResult.isSuccess()) { | ||||
|                         logger.info("执行付款单 pushsap 成功,单据编号:" + bizbillinfo.getString("billno")); | ||||
|                         bizbillinfo = BusinessDataServiceHelper.loadSingle(sourcebillid,sourcebilltype,"id,shjh_credentialnum"); | ||||
|                         operateErrorInfo = new OperateErrorInfo(); | ||||
|                         operateErrorInfo.setMessage("SAP凭证号:" + bizbillinfo.getString("shjh_credentialnum")); | ||||
|                         operateErrorInfo.setErrorLevel(ErrorLevel.Error.name()); | ||||
|                         operateErrorInfo.setPkValue(bizbillinfo.getPkValue()); | ||||
|                         this.operationResult.addErrorInfo(operateErrorInfo); | ||||
|                     } else { | ||||
|                         logger.error(operResult.getMessage()); | ||||
|                         allErrorInfo = operResult.getAllErrorInfo(); | ||||
|  | @ -101,6 +121,12 @@ public class VoucherAuditOperation extends AbstractOperationServicePlugIn implem | |||
|                     // 可以根据需要处理 operationResult,例如检查是否成功、获取返回值等 | ||||
|                     if (operResult.isSuccess()) { | ||||
|                         logger.info("执行理财或定期预提记账处理单 sendvoucher 成功,单据编号:" + bizbillinfo.getString("billno")); | ||||
|                         bizbillinfo = BusinessDataServiceHelper.loadSingle(sourcebillid,sourcebilltype,"id,shjh_sappzh"); | ||||
|                         operateErrorInfo = new OperateErrorInfo(); | ||||
|                         operateErrorInfo.setMessage("SAP凭证号:" + bizbillinfo.getString("shjh_sappzh")); | ||||
|                         operateErrorInfo.setErrorLevel(ErrorLevel.Error.name()); | ||||
|                         operateErrorInfo.setPkValue(bizbillinfo.getPkValue()); | ||||
|                         this.operationResult.addErrorInfo(operateErrorInfo); | ||||
|                     } else { | ||||
|                         logger.error(operResult.getMessage()); | ||||
|                         allErrorInfo = operResult.getAllErrorInfo(); | ||||
|  |  | |||
|  | @ -12,6 +12,7 @@ import kd.bos.context.RequestContext; | |||
| import kd.bos.dataentity.OperateOption; | ||||
| import kd.bos.dataentity.entity.DynamicObject; | ||||
| import kd.bos.dataentity.entity.DynamicObjectCollection; | ||||
| import kd.bos.entity.operate.result.OperationResult; | ||||
| import kd.bos.id.ID; | ||||
| import kd.bos.logging.Log; | ||||
| import kd.bos.logging.LogFactory; | ||||
|  | @ -86,6 +87,7 @@ public class AspAccountControler { | |||
|         DynamicObject parentAcctInfo; | ||||
|         JSONObject json_body; | ||||
|         OperateOption oop = OperateOption.create(); | ||||
|         OperationResult operResult; | ||||
|         Map<String, Long> acctids = new HashMap<>();//科目编号和ID对应关系 | ||||
|         Map<String, DynamicObject> accountMaps = new HashMap<>();//将科目编号与对象关联 | ||||
|         //先根据基础信息在集团层面生成科目,不考虑核算维度,使用逐级分配 | ||||
|  | @ -143,6 +145,13 @@ public class AspAccountControler { | |||
|                 acctInfo.set("name", name); | ||||
|                 //处理父级科目 | ||||
|                 parentAcctInfo = getParentAcct(number,name,acctType,acctTypeInfo); | ||||
|                 if(parentAcctInfo == null){ | ||||
|                     itemInfo = new JSONObject(); | ||||
|                     itemInfo.put("code",number); | ||||
|                     itemInfo.put("error","父级科目在金蝶中找不到"); | ||||
|                     itemsJson.add(itemInfo); | ||||
|                     continue; | ||||
|                 } | ||||
|                 acctInfo.set("longnumber", number); | ||||
|                 acctInfo.set("fullname", name); | ||||
|                 acctInfo.set("parent", parentAcctInfo); | ||||
|  | @ -181,7 +190,14 @@ public class AspAccountControler { | |||
|                 acctInfo.set("masterid", kmId);//主数据内码,系统不会根据id自动生成,需要手动设置 | ||||
|                 //保存数据:直接保存入库,不走操作校验 | ||||
| //                SaveServiceHelper.save(new DynamicObject[]{acctInfo}); | ||||
|                 OperationServiceHelper.executeOperate("save", entityName, new DynamicObject[]{acctInfo}, oop); | ||||
|                 operResult = OperationServiceHelper.executeOperate("save", entityName, new DynamicObject[]{acctInfo}, oop); | ||||
|                 if(!operResult.isSuccess()){ | ||||
|                     log.error(String.format("科目保存失败:%s", json_body.toJSONString())); | ||||
|                     itemInfo = new JSONObject(); | ||||
|                     itemInfo.put("code",number); | ||||
|                     itemInfo.put("error","科目保存失败"+operResult.getMessage()); | ||||
|                     itemsJson.add(itemInfo); | ||||
|                 } | ||||
|                 //处理科目使用范围 | ||||
| //                DB.update(DBRoute.of("fi"), insertSql, new Object[]{kmId,JhzjUtils.GROUPID}); | ||||
|             } | ||||
|  | @ -251,7 +267,14 @@ public class AspAccountControler { | |||
|                 } | ||||
|                 acctInfo.set("isassist", true);//主表的isassist是否包含核算项目为是 | ||||
| //                SaveServiceHelper.save(new DynamicObject[]{acctInfo}); | ||||
|                 OperationServiceHelper.executeOperate("save", entityName, new DynamicObject[]{acctInfo}, oop); | ||||
|                 operResult = OperationServiceHelper.executeOperate("save", entityName, new DynamicObject[]{acctInfo}, oop); | ||||
|                 if(!operResult.isSuccess()){ | ||||
|                     log.error(String.format("科目保存失败:%s", json_body.toJSONString())); | ||||
|                     itemInfo = new JSONObject(); | ||||
|                     itemInfo.put("code",number); | ||||
|                     itemInfo.put("error","科目保存失败"+operResult.getMessage()); | ||||
|                     itemsJson.add(itemInfo); | ||||
|                 } | ||||
|                 companyAcctMaps.put(number+companynum,acctInfo); | ||||
|             } | ||||
|         } | ||||
|  | @ -479,7 +502,11 @@ public class AspAccountControler { | |||
|             acctInfo.set("masterid", kmId);//主数据内码,系统不会根据id自动生成,需要手动设置 | ||||
|             //保存数据:直接保存入库,不走操作校验 | ||||
| //            SaveServiceHelper.save(new DynamicObject[]{acctInfo}); | ||||
|             OperationServiceHelper.executeOperate("save", entityName, new DynamicObject[]{acctInfo}, OperateOption.create()); | ||||
|             OperationResult operResult = OperationServiceHelper.executeOperate("save", entityName, new DynamicObject[]{acctInfo}, OperateOption.create()); | ||||
|             if(!operResult.isSuccess()){ | ||||
|                 log.error(String.format(number+"父级科目保存失败:%s", operResult.getMessage())); | ||||
|                 return null; | ||||
|             } | ||||
|             //处理科目使用范围 | ||||
| //            DB.update(DBRoute.of("fi"), insertSql, new Object[]{kmId,JhzjUtils.GROUPID}); | ||||
|         } | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue