资金计划科目定时任务优化-付款申请
This commit is contained in:
parent
6a9affb483
commit
ef1c996c60
|
|
@ -230,7 +230,8 @@ public class InitAccountFormPlugin extends AbstractFormPlugin {
|
|||
if(companyAcctMaps == null){
|
||||
companyAcctMaps = new HashMap<>();
|
||||
//本次只导入核算维度数据 companyAcctMaps 手动获取一次各个分公司的科目数据
|
||||
DynamicObject[] accts = BusinessDataServiceHelper.load(entityName,"id",new QFilter[]{new QFilter("accounttable.id","=",EsbUtils.ACCTABLE),
|
||||
DynamicObject[] accts = BusinessDataServiceHelper.load(entityName,"id",new QFilter[]{
|
||||
new QFilter("accounttable.id","=",EsbUtils.ACCTABLE),
|
||||
new QFilter("createorg.id","<>", JhzjUtils.GROUPID),
|
||||
new QFilter("level","=", 2)});
|
||||
for (DynamicObject acct : accts){
|
||||
|
|
|
|||
|
|
@ -23,10 +23,7 @@ import shjh.jhzj7.fi.fi.utils.SapUtils;
|
|||
|
||||
import java.math.BigDecimal;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
|
||||
|
||||
/**
|
||||
|
|
@ -142,6 +139,13 @@ public class FundPlanPaymentTask extends AbstractTask implements Plugin {
|
|||
if(sapresult != null){
|
||||
JSONObject data = sapresult.getJSONObject("data");
|
||||
if(data != null){
|
||||
//获取付款申请单配置表集合
|
||||
List<DynamicObject> pzblist = getPzb();
|
||||
if(pzblist.isEmpty()){
|
||||
//配置表没有对应规则,返回null
|
||||
logger.info("配置表没有对应规则");
|
||||
return null;
|
||||
}
|
||||
JSONArray items = data.getJSONArray("IT_ITEM");
|
||||
Map<String, BigDecimal> acctamountMap = new HashMap<>();
|
||||
BigDecimal amount;//根据事业部编号+月份+资金计划科目编号汇总的金额
|
||||
|
|
@ -160,7 +164,7 @@ public class FundPlanPaymentTask extends AbstractTask implements Plugin {
|
|||
if(JhzjUtils.isEmpty(months)){
|
||||
continue;
|
||||
}
|
||||
accountnum = xdMembersubjectNumber(sapresult);
|
||||
accountnum = xdMembersubjectNumber(pzblist, sapresult);
|
||||
if(JhzjUtils.isEmpty(accountnum)){
|
||||
continue;
|
||||
}
|
||||
|
|
@ -185,24 +189,115 @@ public class FundPlanPaymentTask extends AbstractTask implements Plugin {
|
|||
return null;
|
||||
}
|
||||
|
||||
//根据sap的应付未清数据获取对应的资金计划科目编号
|
||||
private String xdMembersubjectNumber(JSONObject sapresult){
|
||||
private List<DynamicObject> getPzb(){
|
||||
QFilter qFilter = new QFilter("enable", QCP.equals,"1");//可用状态
|
||||
//原因码
|
||||
String yym = sapresult.getString("RSTGR");
|
||||
QFilter q5 = new QFilter("shjh_yym.fbasedataid.number", QCP.equals, yym);
|
||||
qFilter = qFilter.and(q5);//可用状态
|
||||
|
||||
//再根据生效日期,失效日期区间,判断当前时间满足的数据
|
||||
Date currentDate = new Date();
|
||||
QFilter startDateFilter = new QFilter("shjh_begindate", QCP.less_equals, currentDate);
|
||||
QFilter endDateFilter = new QFilter("shjh_enddate", QCP.large_equals, currentDate);
|
||||
QFilter newFilter = qFilter.and(startDateFilter).and(endDateFilter);
|
||||
|
||||
DynamicObject[] accounts = BusinessDataServiceHelper.load(payReceName, "id,shjh_priority", newFilter.toArray(),"shjh_priority");
|
||||
if (accounts.length > 1) {
|
||||
//多个条件时根据优先级排序,拿到优先级最高的
|
||||
String kmbh = sapresult.getString("HKONT");//科目编号
|
||||
List<DynamicObject> pzblist = new ArrayList<>(accounts.length);
|
||||
DynamicObject account;
|
||||
for (int i = 0; i < accounts.length; i++) {
|
||||
account = BusinessDataServiceHelper.loadSingle(accounts[i].getPkValue(), payReceName);
|
||||
pzblist.add(account);
|
||||
}
|
||||
return pzblist;
|
||||
}
|
||||
|
||||
//获取基础资料包含情况下的标记
|
||||
private boolean getDOInFlag(DynamicObject pzbinfo, String property, String sapvalue){
|
||||
DynamicObjectCollection kmcolls = pzbinfo.getDynamicObjectCollection(property);//具体的属性可能是科目、原因码、客户、供应商
|
||||
if(kmcolls.isEmpty()){
|
||||
//当前配置表没有配置property,即任何property都可以匹配
|
||||
return true;
|
||||
}else{
|
||||
//配置有参数,需要判断与当前数据是否匹配
|
||||
for (DynamicObject kminfo : kmcolls) {
|
||||
if(kminfo.getDynamicObject("fbasedataid").getString("number").equals(sapvalue)){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//获取基础资料不包含情况下的标记
|
||||
private boolean getDOOutFlag(DynamicObject pzbinfo, String property, String sapvalue){
|
||||
DynamicObjectCollection kmcolls = pzbinfo.getDynamicObjectCollection(property);//具体的属性可能是科目、原因码、客户、供应商
|
||||
if(kmcolls.isEmpty()){
|
||||
//当前配置表没有配置property,即任何property都可以匹配
|
||||
return true;
|
||||
}else{
|
||||
//配置有参数,需要判断与当前参数是否匹配,已匹配表示在排除范围内
|
||||
for (DynamicObject kminfo : kmcolls) {
|
||||
if(kminfo.getDynamicObject("fbasedataid").getString("number").equals(sapvalue)){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
//获取布尔类字段匹配的标记
|
||||
private boolean getBooleanFlag(DynamicObject pzbinfo, String property, String sapvalue){
|
||||
if(pzbinfo.getBoolean(property) && "1".equals(sapvalue)){
|
||||
//配置表中为true,代表真实数据必须为true
|
||||
return true;
|
||||
}else if(!pzbinfo.getBoolean(property) && JhzjUtils.isEmpty(sapvalue)){
|
||||
//配置表中为false,代表真实数据为null或者为false
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//获取文本类字段包含的情况下的标记
|
||||
private boolean getInTextFlag(DynamicObject pzbinfo, String property, String sapvalue){
|
||||
//配置为空时,代表所有情况适配
|
||||
if(JhzjUtils.isEmpty(pzbinfo.getString(property))){
|
||||
return true;
|
||||
}else if(sapvalue != null && pzbinfo.getString(property).contains(sapvalue)){
|
||||
//配置表不为空,且包含真实数据
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//获取文本类字段不包含的情况下的标记
|
||||
private boolean getOutTextFlag(DynamicObject pzbinfo, String property, String sapvalue){
|
||||
//配置为空时,代表所有情况适配
|
||||
if(JhzjUtils.isEmpty(pzbinfo.getString(property))){
|
||||
return true;
|
||||
}else if(sapvalue != null && pzbinfo.getString(property).contains(sapvalue)){
|
||||
//配置表不为空,且包含真实数据,说明要剔除
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
//根据sap的应付未清数据获取对应的资金计划科目编号
|
||||
private String xdMembersubjectNumber(List<DynamicObject> pzblist, JSONObject sapresult){
|
||||
DynamicObject pzbinfo;
|
||||
boolean yymFlag;
|
||||
boolean kmbhFlag;
|
||||
boolean orgFlag;
|
||||
boolean bizbigFlag;
|
||||
boolean bizsmallFlag;
|
||||
boolean notorgFlag;
|
||||
boolean suppFlag;
|
||||
boolean notsuppFlag;
|
||||
for (int i = 0; i < pzblist.size(); i++) {
|
||||
pzbinfo = pzblist.get(i);
|
||||
yymFlag = getDOInFlag(pzbinfo,"shjh_yym",sapresult.getString(""));//原因码
|
||||
kmbhFlag = getDOInFlag(pzbinfo,"shjh_kjkm",sapresult.getString(""));//会计科目
|
||||
orgFlag = getDOInFlag(pzbinfo,"shjh_companys",sapresult.getString(""));//公司范围
|
||||
suppFlag = getDOInFlag(pzbinfo,"shjh_supplier",sapresult.getString(""));//包含供应商
|
||||
bizbigFlag = getDOInFlag(pzbinfo,"shjh_bizbig",sapresult.getString(""));//业务大类
|
||||
bizsmallFlag = getDOInFlag(pzbinfo,"shjh_bizsmall",sapresult.getString(""));//业务小类
|
||||
|
||||
notsuppFlag = getDOOutFlag(pzbinfo,"shjh_bbhgys",sapresult.getString(""));//不包含供应商
|
||||
notorgFlag = getDOOutFlag(pzbinfo,"shjh_bbhzz",sapresult.getString(""));//不包含公司
|
||||
}
|
||||
|
||||
return null;
|
||||
|
|
|
|||
Loading…
Reference in New Issue