资金计划优化日志输出
This commit is contained in:
		
							parent
							
								
									9e88a03b69
								
							
						
					
					
						commit
						63608afa17
					
				|  | @ -54,7 +54,7 @@ public class FundPlanCollectionTask extends AbstractTask implements Plugin { | ||||||
|             //调用SAP应收已清接口,按照事业部、月份、计划科目汇总金额 |             //调用SAP应收已清接口,按照事业部、月份、计划科目汇总金额 | ||||||
|             Map<String, BigDecimal> acctamountMap = getSapARClearedData(); |             Map<String, BigDecimal> acctamountMap = getSapARClearedData(); | ||||||
|             if(acctamountMap == null || acctamountMap.isEmpty()){ |             if(acctamountMap == null || acctamountMap.isEmpty()){ | ||||||
|                 logger.info("未获取到月份、计划科目汇总金额"); |                 logger.info("SAP未获取到月份、计划科目汇总金额"); | ||||||
|                 return; |                 return; | ||||||
|             } |             } | ||||||
|             ReportDataSDKService reportService = new ReportDataSDKService();//报表服务,用于写入或者查询报表数据 |             ReportDataSDKService reportService = new ReportDataSDKService();//报表服务,用于写入或者查询报表数据 | ||||||
|  | @ -75,10 +75,10 @@ public class FundPlanCollectionTask extends AbstractTask implements Plugin { | ||||||
|             for(DynamicObject doinfo : collection){ |             for(DynamicObject doinfo : collection){ | ||||||
|                 doinfo = BusinessDataServiceHelper.loadSingle(doinfo.getPkValue(),entityName); |                 doinfo = BusinessDataServiceHelper.loadSingle(doinfo.getPkValue(),entityName); | ||||||
|                 billno = doinfo.getString("billno"); |                 billno = doinfo.getString("billno"); | ||||||
|                 logger.info("资金计划编制单号"+billno); |                 logger.info("SAP资金计划编制单号"+billno); | ||||||
|                 maindimentrys = doinfo.getDynamicObjectCollection("maindimentry");//主维度分录 |                 maindimentrys = doinfo.getDynamicObjectCollection("maindimentry");//主维度分录 | ||||||
|                 if(maindimentrys.isEmpty()){ |                 if(maindimentrys.isEmpty()){ | ||||||
|                     logger.info("资金计划编制单主维度分录为空,不继续反写"+billno); |                     logger.info("SAP资金计划编制单主维度分录为空,不继续反写"+billno); | ||||||
|                     continue; |                     continue; | ||||||
|                 } |                 } | ||||||
|                 json_obj = new JSONObject(); |                 json_obj = new JSONObject(); | ||||||
|  | @ -114,9 +114,9 @@ public class FundPlanCollectionTask extends AbstractTask implements Plugin { | ||||||
|                     //PLANREFERENCEAMT 计划参考值 ACTMAT 已执行额度 |                     //PLANREFERENCEAMT 计划参考值 ACTMAT 已执行额度 | ||||||
|                     mmInfo.put("templateMetricType","ACTMAT");//度量值预置类型 |                     mmInfo.put("templateMetricType","ACTMAT");//度量值预置类型 | ||||||
|                     mmInfo.put("amount",acctamountMap.get(months+accountnum));//写入金额-从SAP接口中汇总 |                     mmInfo.put("amount",acctamountMap.get(months+accountnum));//写入金额-从SAP接口中汇总 | ||||||
|                     logger.info(billno+"收款计划实际数入参 months "+months); |                     logger.info(billno+"SAP收款计划实际数入参 months "+months); | ||||||
|                     logger.info(billno+"收款计划实际数入参 accountnum "+accountnum); |                     logger.info(billno+"SAP收款计划实际数入参 accountnum "+accountnum); | ||||||
|                     logger.info(billno+"收款计划实际数"+acctamountMap.get(months+accountnum)); |                     logger.info(billno+"SAP收款计划实际数"+acctamountMap.get(months+accountnum)); | ||||||
|                     mmInfo.put("amountUnit","one");//金额单位 one元 thousand千元 ten_thousand 万元 |                     mmInfo.put("amountUnit","one");//金额单位 one元 thousand千元 ten_thousand 万元 | ||||||
|                     mms.add(mmInfo); |                     mms.add(mmInfo); | ||||||
|                     itemInfo.put("metricMembers",mms);//度量值列表 |                     itemInfo.put("metricMembers",mms);//度量值列表 | ||||||
|  | @ -124,11 +124,11 @@ public class FundPlanCollectionTask extends AbstractTask implements Plugin { | ||||||
|                 } |                 } | ||||||
| 
 | 
 | ||||||
|                 json_obj.put("batchSaveData",items);//报表批量写入数据 |                 json_obj.put("batchSaveData",items);//报表批量写入数据 | ||||||
|                 logger.info(billno+"收款计划实际数入参"+json_obj.toJSONString()); |                 logger.info(billno+"SAP收款计划实际数入参"+json_obj.toJSONString()); | ||||||
|                 pdsp = gson.fromJson(json_obj.toJSONString(), ReportDataBatchSaveParam.class); |                 pdsp = gson.fromJson(json_obj.toJSONString(), ReportDataBatchSaveParam.class); | ||||||
|                 result = reportService.batchSaveReportData(SerializationUtils.serializeToBase64(pdsp)); |                 result = reportService.batchSaveReportData(SerializationUtils.serializeToBase64(pdsp)); | ||||||
|                 frv = SerializationUtils.deSerializeFromBase64(result); |                 frv = SerializationUtils.deSerializeFromBase64(result); | ||||||
|                 logger.info(billno+"收款计划实际数反写结果"+frv.getCode()+frv.getMessage()); |                 logger.info(billno+"SAP收款计划实际数反写结果"+frv.getCode()+frv.getMessage()); | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  | @ -184,6 +184,8 @@ public class FundPlanCollectionTask extends AbstractTask implements Plugin { | ||||||
|                         acctamountMap.put(mapkey,amount); |                         acctamountMap.put(mapkey,amount); | ||||||
|                     } |                     } | ||||||
|                     logger.info("SAP应收已清对应资金科目"+mapkey); |                     logger.info("SAP应收已清对应资金科目"+mapkey); | ||||||
|  |                     logger.info("SAP应收已清会计科目"+sapresult.getString("HKONT")); | ||||||
|  |                     logger.info("SAP应收已清金额"+amount); | ||||||
|                     //根据品牌和事业部关系,将该笔金额归属到事业部上 |                     //根据品牌和事业部关系,将该笔金额归属到事业部上 | ||||||
| //                    ppsybinfo = BusinessDataServiceHelper.loadSingleFromCache(ppsybName,new QFilter[]{new QFilter("shjh_productgroup.number", QCP.equals, productnum)}); | //                    ppsybinfo = BusinessDataServiceHelper.loadSingleFromCache(ppsybName,new QFilter[]{new QFilter("shjh_productgroup.number", QCP.equals, productnum)}); | ||||||
| //                    if(ppsybinfo != null){ | //                    if(ppsybinfo != null){ | ||||||
|  |  | ||||||
|  | @ -7,6 +7,8 @@ import kd.bos.context.RequestContext; | ||||||
| import kd.bos.dataentity.OperateOption; | import kd.bos.dataentity.OperateOption; | ||||||
| import kd.bos.dataentity.entity.DynamicObject; | import kd.bos.dataentity.entity.DynamicObject; | ||||||
| import kd.bos.dataentity.entity.DynamicObjectCollection; | import kd.bos.dataentity.entity.DynamicObjectCollection; | ||||||
|  | import kd.bos.db.DB; | ||||||
|  | import kd.bos.db.DBRoute; | ||||||
| import kd.bos.entity.operate.OperateOptionConst; | import kd.bos.entity.operate.OperateOptionConst; | ||||||
| import kd.bos.exception.KDException; | import kd.bos.exception.KDException; | ||||||
| import kd.bos.logging.Log; | import kd.bos.logging.Log; | ||||||
|  | @ -32,6 +34,7 @@ import java.util.*; | ||||||
| 
 | 
 | ||||||
| /** | /** | ||||||
|  * 定时任务更新付款资金计划的计划参考数 |  * 定时任务更新付款资金计划的计划参考数 | ||||||
|  |  * 目前仅有从sap获取应付未清数据,还需要增加已经在资金系统内的付款申请单数据 | ||||||
|  * @author yuxueliang |  * @author yuxueliang | ||||||
|  */ |  */ | ||||||
| public class FundPlanPaymentTask extends AbstractTask implements Plugin { | public class FundPlanPaymentTask extends AbstractTask implements Plugin { | ||||||
|  | @ -40,6 +43,9 @@ public class FundPlanPaymentTask extends AbstractTask implements Plugin { | ||||||
|     private static final String payReceName = "shjh_request_account";//付款申请单_资金计划科目配置表 |     private static final String payReceName = "shjh_request_account";//付款申请单_资金计划科目配置表 | ||||||
| //    private static final String ppsybName = "shjh_ejbm_syb";//二级部门和事业部对应关系 tk_shjh_pg | //    private static final String ppsybName = "shjh_ejbm_syb";//二级部门和事业部对应关系 tk_shjh_pg | ||||||
| 
 | 
 | ||||||
|  |     //非关闭付款申请单表头到期日范围内的金额合计,按照资金科目编号+到期日年月进行分组 | ||||||
|  |     private static final String paysql = "select tfm.fnumber,to_char(apbl.fk_shjh_duedate,'yyyy-MM'),sum(apbl.fapplyamount) from t_ap_applypaybill apbl left join t_fpm_member tfm on tfm.fid=apbl.fk_shjh_membersubject where apbl.fk_shjh_membersubject>0 and apbl.fbillstatus<>'D' and to_char(apbl.fk_shjh_duedate,'yyyyMMDD')>=? and to_char(apbl.fk_shjh_duedate,'yyyyMMDD')<=? GROUP by tfm.fnumber,to_char(apbl.fk_shjh_duedate,'yyyy-MM')"; | ||||||
|  | 
 | ||||||
|     private static final Log logger = LogFactory.getLog(FundPlanPaymentTask.class); |     private static final Log logger = LogFactory.getLog(FundPlanPaymentTask.class); | ||||||
| 
 | 
 | ||||||
|     private Gson gson = new Gson();//用于将json格式化为对象 |     private Gson gson = new Gson();//用于将json格式化为对象 | ||||||
|  | @ -56,7 +62,7 @@ public class FundPlanPaymentTask extends AbstractTask implements Plugin { | ||||||
|             //调用SAP应付未清接口,按照事业部、月份、计划科目汇总金额 |             //调用SAP应付未清接口,按照事业部、月份、计划科目汇总金额 | ||||||
|             Map<String, BigDecimal> acctamountMap = getSapAR(); |             Map<String, BigDecimal> acctamountMap = getSapAR(); | ||||||
|             if(acctamountMap == null || acctamountMap.isEmpty()){ |             if(acctamountMap == null || acctamountMap.isEmpty()){ | ||||||
|                 logger.info("未获取到月份、计划科目汇总金额"); |                 logger.info("SAP未获取到月份、计划科目汇总金额"); | ||||||
|                 return; |                 return; | ||||||
|             } |             } | ||||||
|             ReportDataSDKService reportService = new ReportDataSDKService();//报表服务,用于写入或者查询报表数据 |             ReportDataSDKService reportService = new ReportDataSDKService();//报表服务,用于写入或者查询报表数据 | ||||||
|  | @ -90,7 +96,7 @@ public class FundPlanPaymentTask extends AbstractTask implements Plugin { | ||||||
|                     doinfo = BusinessDataServiceHelper.loadSingle(doinfo.getPkValue(),entityName); |                     doinfo = BusinessDataServiceHelper.loadSingle(doinfo.getPkValue(),entityName); | ||||||
|                     maindimentrys = doinfo.getDynamicObjectCollection("maindimentry");//主维度分录 |                     maindimentrys = doinfo.getDynamicObjectCollection("maindimentry");//主维度分录 | ||||||
|                     if(maindimentrys.isEmpty()){ |                     if(maindimentrys.isEmpty()){ | ||||||
|                         logger.info("资金计划编制主维度分录为空"+doinfo.getString("billno")); |                         logger.info("SAP资金计划编制主维度分录为空"+doinfo.getString("billno")); | ||||||
|                         continue; |                         continue; | ||||||
|                     } |                     } | ||||||
|                 }else{ |                 }else{ | ||||||
|  | @ -98,7 +104,7 @@ public class FundPlanPaymentTask extends AbstractTask implements Plugin { | ||||||
|                     maindimentrys = doinfo.getDynamicObjectCollection("maindimentry");//主维度分录 |                     maindimentrys = doinfo.getDynamicObjectCollection("maindimentry");//主维度分录 | ||||||
|                 } |                 } | ||||||
|                 billno = doinfo.getString("billno"); |                 billno = doinfo.getString("billno"); | ||||||
|                 logger.info("资金计划编制单号"+billno); |                 logger.info("SAP资金计划编制单号"+billno); | ||||||
|                 json_obj = new JSONObject(); |                 json_obj = new JSONObject(); | ||||||
|                 //体系编号 非必填时,系统通过【编报主体 code】确定,需保证一个编报主体只关联一个体系 |                 //体系编号 非必填时,系统通过【编报主体 code】确定,需保证一个编报主体只关联一个体系 | ||||||
|                 json_obj.put("systemCode",doinfo.getDynamicObject("bodysys").getString("number")); |                 json_obj.put("systemCode",doinfo.getDynamicObject("bodysys").getString("number")); | ||||||
|  | @ -132,9 +138,9 @@ public class FundPlanPaymentTask extends AbstractTask implements Plugin { | ||||||
|                     //PLANREFERENCEAMT 计划参考值 ACTMAT 已执行额度 |                     //PLANREFERENCEAMT 计划参考值 ACTMAT 已执行额度 | ||||||
|                     mmInfo.put("templateMetricType","PLANREFERENCEAMT");//度量值预置类型 |                     mmInfo.put("templateMetricType","PLANREFERENCEAMT");//度量值预置类型 | ||||||
|                     mmInfo.put("amount",acctamountMap.get(months+accountnum));//写入金额-从SAP接口中获取 |                     mmInfo.put("amount",acctamountMap.get(months+accountnum));//写入金额-从SAP接口中获取 | ||||||
|                     logger.info(billno+"付款计划参考数入参 months "+months); |                     logger.info(billno+"SAP付款计划参考数入参 months "+months); | ||||||
|                     logger.info(billno+"付款计划参考数入参 accountnum "+accountnum); |                     logger.info(billno+"SAP付款计划参考数入参 accountnum "+accountnum); | ||||||
|                     logger.info(billno+"付款计划参考数"+acctamountMap.get(months+accountnum)); |                     logger.info(billno+"SAP付款计划参考数"+acctamountMap.get(months+accountnum)); | ||||||
|                     mmInfo.put("amountUnit","one");//金额单位 one元 thousand千元 ten_thousand 万元 |                     mmInfo.put("amountUnit","one");//金额单位 one元 thousand千元 ten_thousand 万元 | ||||||
|                     mms.add(mmInfo); |                     mms.add(mmInfo); | ||||||
|                     itemInfo.put("metricMembers",mms);//度量值列表 |                     itemInfo.put("metricMembers",mms);//度量值列表 | ||||||
|  | @ -142,11 +148,11 @@ public class FundPlanPaymentTask extends AbstractTask implements Plugin { | ||||||
|                 } |                 } | ||||||
| 
 | 
 | ||||||
|                 json_obj.put("batchSaveData",items);//报表批量写入数据 |                 json_obj.put("batchSaveData",items);//报表批量写入数据 | ||||||
|                 logger.info(billno+"付款计划参考数入参"+json_obj.toJSONString()); |                 logger.info(billno+"SAP付款计划参考数入参"+json_obj.toJSONString()); | ||||||
|                 pdsp = gson.fromJson(json_obj.toJSONString(), ReportDataBatchSaveParam.class); |                 pdsp = gson.fromJson(json_obj.toJSONString(), ReportDataBatchSaveParam.class); | ||||||
|                 result = reportService.batchSaveReportData(SerializationUtils.serializeToBase64(pdsp)); |                 result = reportService.batchSaveReportData(SerializationUtils.serializeToBase64(pdsp)); | ||||||
|                 frv = SerializationUtils.deSerializeFromBase64(result); |                 frv = SerializationUtils.deSerializeFromBase64(result); | ||||||
|                 logger.info(billno+"付款计划参考数反写结果"+frv.getCode()+frv.getMessage()); |                 logger.info(billno+"SAP付款计划参考数反写结果"+frv.getCode()+frv.getMessage()); | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  | @ -176,7 +182,7 @@ public class FundPlanPaymentTask extends AbstractTask implements Plugin { | ||||||
|                 List<DynamicObject> pzblist = getPzb(); |                 List<DynamicObject> pzblist = getPzb(); | ||||||
|                 if(pzblist.isEmpty()){ |                 if(pzblist.isEmpty()){ | ||||||
|                     //配置表没有对应规则,返回null |                     //配置表没有对应规则,返回null | ||||||
|                     logger.info("付款申请单配置表没有对应规则"); |                     logger.info("SAP付款申请单配置表没有对应规则"); | ||||||
|                     return null; |                     return null; | ||||||
|                 } |                 } | ||||||
|                 JSONArray items = data.getJSONArray("IT_ITEM"); |                 JSONArray items = data.getJSONArray("IT_ITEM"); | ||||||
|  | @ -210,6 +216,8 @@ public class FundPlanPaymentTask extends AbstractTask implements Plugin { | ||||||
|                         acctamountMap.put(mapkey,amount); |                         acctamountMap.put(mapkey,amount); | ||||||
|                     } |                     } | ||||||
|                     logger.info("SAP应付凭证对应资金科目"+mapkey); |                     logger.info("SAP应付凭证对应资金科目"+mapkey); | ||||||
|  |                     logger.info("SAP应付凭证会计科目"+sapresult.getString("HKONT")); | ||||||
|  |                     logger.info("SAP应付未清金额"+amount); | ||||||
|                     //根据二级部门和事业部关系,将该笔金额归属到事业部上 |                     //根据二级部门和事业部关系,将该笔金额归属到事业部上 | ||||||
| //                    ppsybinfo = BusinessDataServiceHelper.loadSingleFromCache(ppsybName,new QFilter[]{new QFilter("shjh_orgdept.number", QCP.equals, deptnum)}); | //                    ppsybinfo = BusinessDataServiceHelper.loadSingleFromCache(ppsybName,new QFilter[]{new QFilter("shjh_orgdept.number", QCP.equals, deptnum)}); | ||||||
| //                    if(ppsybinfo != null){ | //                    if(ppsybinfo != null){ | ||||||
|  | @ -225,6 +233,56 @@ public class FundPlanPaymentTask extends AbstractTask implements Plugin { | ||||||
| //                        logger.info("根据SAP的二级部门编号未找到对应的二级部门和事业部关系"+deptnum); | //                        logger.info("根据SAP的二级部门编号未找到对应的二级部门和事业部关系"+deptnum); | ||||||
| //                    } | //                    } | ||||||
|                 } |                 } | ||||||
|  |                 //追加付款申请单金额计算逻辑 | ||||||
|  |                 logger.info("SAP追加付款申请单金额之前大小"+acctamountMap.size()); | ||||||
|  |                 DB.query(DBRoute.of("fi"),paysql,new Object[]{duedate_starts,duedate_ends},(rs) -> { | ||||||
|  |                     String sql_months;//月份 | ||||||
|  |                     String sql_mapkey; | ||||||
|  |                     BigDecimal sql_amount; | ||||||
|  |                     int rows = 0; | ||||||
|  |                     while(rs.next()) { | ||||||
|  |                         sql_months = JhzjUtils.getFundPeriodBySAPDate(rs.getString(2)); | ||||||
|  |                         sql_mapkey = sql_months+rs.getString(1); | ||||||
|  |                         sql_amount = rs.getBigDecimal(3);//付款申请单合计金额 | ||||||
|  |                         if(acctamountMap.containsKey(sql_mapkey)){ | ||||||
|  |                             acctamountMap.put(sql_mapkey, JhzjUtils.addTwoAmount(sql_amount,acctamountMap.get(sql_mapkey))); | ||||||
|  |                         }else{ | ||||||
|  |                             acctamountMap.put(sql_mapkey,sql_amount); | ||||||
|  |                         } | ||||||
|  |                         rows++; | ||||||
|  |                     } | ||||||
|  |                     logger.info("SAP付款申请单金额查询结果集大小"+rows); | ||||||
|  |                     return acctamountMap; | ||||||
|  |                 }); | ||||||
|  |                 logger.info("SAP追加付款申请单金额之后大小"+acctamountMap.size()); | ||||||
|  | //                Map<String, BigDecimal> payreqamouts = DB.query(DBRoute.of("fi"),paysql,new Object[]{duedate_starts,duedate_ends},(rs) -> { | ||||||
|  | //                    Map<String, BigDecimal> reqamouts = new HashMap<>(); | ||||||
|  | //                    String sql_months;//月份 | ||||||
|  | //                    String sql_mapkey; | ||||||
|  | //                    BigDecimal sql_amount; | ||||||
|  | //                    while(rs.next()) { | ||||||
|  | //                        sql_months = JhzjUtils.getFundPeriodBySAPDate(rs.getString(2)); | ||||||
|  | //                        sql_mapkey = sql_months+rs.getString(1); | ||||||
|  | //                        sql_amount = rs.getBigDecimal(3);//付款申请单合计金额 | ||||||
|  | //                        if(reqamouts.containsKey(sql_mapkey)){ | ||||||
|  | //                            reqamouts.put(sql_mapkey, JhzjUtils.addTwoAmount(sql_amount,reqamouts.get(sql_mapkey))); | ||||||
|  | //                        }else{ | ||||||
|  | //                            reqamouts.put(sql_mapkey,sql_amount); | ||||||
|  | //                        } | ||||||
|  | //                    } | ||||||
|  | //                    return reqamouts; | ||||||
|  | //                }); | ||||||
|  | //                logger.info("付款申请单资金计划金额集合大小"+payreqamouts.size()); | ||||||
|  | //                //遍历付款申请单的金额map 以追加到acctamountMap | ||||||
|  | //                for (Map.Entry<String, BigDecimal> entry : payreqamouts.entrySet()) { | ||||||
|  | //                    if(acctamountMap.containsKey(entry.getKey())){ | ||||||
|  | //                        //sap解析的数据中包含付款申请单,则两个map金额相加 | ||||||
|  | //                        acctamountMap.put(entry.getKey(), JhzjUtils.addTwoAmount(entry.getValue(),acctamountMap.get(entry.getKey()))); | ||||||
|  | //                    }else{ | ||||||
|  | //                        //sap解析的数据中不包含付款申请单,则直接put进acctamountMap | ||||||
|  | //                        acctamountMap.put(entry.getKey(), entry.getValue()); | ||||||
|  | //                    } | ||||||
|  | //                } | ||||||
|                 return acctamountMap; |                 return acctamountMap; | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue