资金计划科目定时任务优化
This commit is contained in:
parent
d95588fda4
commit
903b495259
|
|
@ -20,8 +20,10 @@ import kd.bos.servicehelper.QueryServiceHelper;
|
|||
import kd.bos.servicehelper.coderule.CodeRuleServiceHelper;
|
||||
import kd.bos.servicehelper.operation.SaveServiceHelper;
|
||||
import kd.sdk.plugin.Plugin;
|
||||
import shjh.jhzj7.fi.fi.utils.ApiUtils;
|
||||
import shjh.jhzj7.fi.fi.utils.JhzjUtils;
|
||||
import shjh.jhzj7.fi.fi.utils.SapUtils;
|
||||
import shjh.jhzj7.fi.fi.utils.domin.ResponseData;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.text.SimpleDateFormat;
|
||||
|
|
@ -49,7 +51,7 @@ public class ClearAccountBillOperation extends AbstractOperationServicePlugIn im
|
|||
|
||||
private static final String entityName = "shjh_clear_acctdetail";//清账明细单
|
||||
private static final String userName = "bos_user";//用户
|
||||
private static final String recbillName = "cas_recbill";//收款单
|
||||
private static final String recbillName = "cas_recbill";//收款单 T_CAS_ReceivingBill
|
||||
private static final String pzbName = "shjh_jgqzcust";//结构性清账客户映射表
|
||||
private static final String voucherName = "gl_voucher";//凭证
|
||||
|
||||
|
|
@ -140,6 +142,9 @@ public class ClearAccountBillOperation extends AbstractOperationServicePlugIn im
|
|||
case "notice":
|
||||
handleNotice(e);//清账实时通知
|
||||
break;
|
||||
case "updatestatus_check":
|
||||
handleAudit(e);//模拟调用推送sap
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -520,11 +525,7 @@ public class ClearAccountBillOperation extends AbstractOperationServicePlugIn im
|
|||
IS_HEADER.put("USNAM",oauser);//用户名
|
||||
//----------------处理详细入参(清账不需要items参数)----------------------
|
||||
String customerCode = customerinfo.getString("number");
|
||||
// JSONObject item = new JSONObject();
|
||||
// item.put("KUNNR",customerCode);//客户编号
|
||||
// item.put("HKONT","");//总账科目
|
||||
// item.put("DMBTR",prinfo.getString("shjh_receamount"));//金额-传清账单收款金额
|
||||
// IT_ITEM.add(item);
|
||||
customerCode = "1005004";//上海禾诗家化妆品有限公司 -- 仅测试
|
||||
//----------------处理清账数据入参----------------------
|
||||
DynamicObjectCollection docolls = prinfo.getDynamicObjectCollection("shjh_details");
|
||||
DynamicObject entryinfo;
|
||||
|
|
@ -538,49 +539,49 @@ public class ClearAccountBillOperation extends AbstractOperationServicePlugIn im
|
|||
clear.put("BUZEI",entryinfo.getString("shjh_e_pzhh"));//行编号
|
||||
clear.put("KUNNR",customerCode);//客户编号
|
||||
clear.put("HKONT",entryinfo.getString("shjh_e_account"));//总账科目
|
||||
clear.put("DMBTR1",entryinfo.getString("shjh_e_cursettle"));//清账金额
|
||||
clear.put("DMBTR1",entryinfo.getBigDecimal("shjh_e_cursettle").abs());//清账金额--sap接收的正数金额
|
||||
IT_CLEAR.add(clear);
|
||||
}
|
||||
//从收款单cas_recbill获取实收的凭证数据
|
||||
//先根据关系表找到收款单id和收款分录id,再将收款单对象查出来
|
||||
Map<Long,Long> entrybillids = DB.query(DBRoute.of("fi"),queryRealtion,new Object[]{prinfo.getPkValue()},(rs) -> {
|
||||
Map<Long,Long> entryidList = new HashMap<>();
|
||||
while(rs.next()) {
|
||||
entryidList.put(rs.getLong(1),rs.getLong(2));
|
||||
}
|
||||
return entryidList;
|
||||
});
|
||||
// Map<Long,Long> entrybillids = DB.query(DBRoute.of("fi"),queryRealtion,new Object[]{prinfo.getPkValue()},(rs) -> {
|
||||
// Map<Long,Long> entryidList = new HashMap<>();
|
||||
// while(rs.next()) {
|
||||
// entryidList.put(rs.getLong(1),rs.getLong(2));
|
||||
// }
|
||||
// return entryidList;
|
||||
// });
|
||||
//遍历map,还原收款单对象
|
||||
DynamicObject recebill;//收款单
|
||||
for (Map.Entry<Long,Long> entry : entrybillids.entrySet()) {
|
||||
//收款单分录ID entry.getKey();
|
||||
//收款单ID entry.getValue();
|
||||
recebill = BusinessDataServiceHelper.loadSingleFromCache(entry.getValue(), recbillName);
|
||||
docolls = recebill.getDynamicObjectCollection("entry");//收款明细分录
|
||||
for(DynamicObject receentry : docolls){
|
||||
if(receentry.getLong("id") == entry.getKey()){
|
||||
clear = new JSONObject();
|
||||
clear.put("BUKRS",companyCode);//公司代码
|
||||
clear.put("KUNNR",customerCode);//客户编号
|
||||
clear.put("BELNR",recebill.getString("shjh_vouchernum"));//收款sap凭证编号
|
||||
clear.put("GJAHR",recebill.getString("shjh_sapfiscalyear"));//收款sap会计年度
|
||||
clear.put("BUZEI",recebill.getString("shjh_sapline"));//收款sap凭证行号
|
||||
clear.put("HKONT",getAccountNumber(entry.getValue()));//总账科目-从对应收款单的凭证上取值
|
||||
clear.put("DMBTR1",receentry.getString("e_actamt"));//清账金额-收款单分录的实收金额
|
||||
IT_CLEAR.add(clear);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
// DynamicObject recebill;//收款单
|
||||
// for (Map.Entry<Long,Long> entry : entrybillids.entrySet()) {
|
||||
// //收款单分录ID entry.getKey();
|
||||
// //收款单ID entry.getValue();
|
||||
// recebill = BusinessDataServiceHelper.loadSingleFromCache(entry.getValue(), recbillName);
|
||||
// docolls = recebill.getDynamicObjectCollection("entry");//收款明细分录
|
||||
// for(DynamicObject receentry : docolls){
|
||||
// if(receentry.getLong("id") == entry.getKey()){
|
||||
// clear = new JSONObject();
|
||||
// clear.put("BUKRS",companyCode);//公司代码
|
||||
// clear.put("KUNNR",customerCode);//客户编号
|
||||
// clear.put("BELNR",recebill.getString("shjh_vouchernum"));//收款sap凭证编号
|
||||
// clear.put("GJAHR",recebill.getString("shjh_sapfiscalyear"));//收款sap会计年度
|
||||
// clear.put("BUZEI",recebill.getString("shjh_sapline"));//收款sap凭证行号
|
||||
// clear.put("HKONT",getAccountNumber(entry.getValue()));//总账科目-从对应收款单的凭证上取值
|
||||
// clear.put("DMBTR1",receentry.getString("e_actamt"));//清账金额-收款单分录的实收金额
|
||||
// IT_CLEAR.add(clear);
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
JSONObject sapReturnData = SapUtils.sapTransactionAPI(IS_HEADER,IT_ITEM,IT_CLEAR,prinfo.getString("billno"));
|
||||
//sap返回的结果不为空且正确
|
||||
if(sapReturnData != null && "0".equals(sapReturnData.getString("code"))){
|
||||
JSONObject data = sapReturnData.getJSONObject("data");
|
||||
// JSONObject data = sapReturnData.getJSONObject("data");
|
||||
//"OBJ_TYPE":"参考交易"
|
||||
//"OBJ_KEY":"字段参考关键"
|
||||
//"OBJ_SYS":"源凭证的逻辑系统"
|
||||
return data;
|
||||
return sapReturnData;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
|
@ -618,16 +619,23 @@ public class ClearAccountBillOperation extends AbstractOperationServicePlugIn im
|
|||
String billstatus;
|
||||
JSONObject resultData;
|
||||
List<DynamicObject> detailList = new ArrayList<>();
|
||||
ResponseData respdata;
|
||||
for (int i = 0; i < dos.length; i++) {
|
||||
prinfo = BusinessDataServiceHelper.loadSingle(dos[i].getPkValue(), dos[i].getDataEntityType().getName());
|
||||
//TODO 调用SAP清账接口,生成清账凭证。
|
||||
//调用SAP清账接口,生成清账凭证,反写凭证号和会计年度至清账单中
|
||||
resultData = sapTransactionVoucher(prinfo);
|
||||
if(resultData == null){
|
||||
addErrorInfo(prinfo,"调用SAP清账接口失败,详见接口日志");
|
||||
continue;
|
||||
}else{
|
||||
//解析sap凭证接口返回值
|
||||
respdata = ApiUtils.getResponseData(resultData);
|
||||
if(respdata == null){
|
||||
addErrorInfo(prinfo,"SAP清账接口返回值为空,详见接口日志");
|
||||
continue;
|
||||
}
|
||||
//反写清账状态、清账凭证号、会计年度字段至清账单中
|
||||
DB.update(DBRoute.of("fi"), updateSap, new Object[]{resultData.getString(""),resultData.getString(""),prinfo.getPkValue()});
|
||||
DB.update(DBRoute.of("fi"), updateSap, new Object[]{respdata.getNumber(),respdata.getYear(),prinfo.getPkValue()});
|
||||
//反写收款单分录清账状态
|
||||
reWriteCeceBill(prinfo,"C");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,50 @@
|
|||
package shjh.jhzj7.fi.fi.plugin.operate;
|
||||
|
||||
import kd.bos.dataentity.entity.DynamicObject;
|
||||
import kd.bos.db.DB;
|
||||
import kd.bos.db.DBRoute;
|
||||
import kd.bos.entity.plugin.AbstractOperationServicePlugIn;
|
||||
import kd.bos.entity.plugin.args.AfterOperationArgs;
|
||||
import kd.bos.logging.Log;
|
||||
import kd.bos.logging.LogFactory;
|
||||
import kd.sdk.plugin.Plugin;
|
||||
|
||||
public class ExecuteplanBillOperation extends AbstractOperationServicePlugIn implements Plugin {
|
||||
|
||||
// private static final String entityName = "fpm_executeplan";//计划执行记录 t_fpm_executeplan
|
||||
private static final String recbillName = "cas_recbill";//收款单
|
||||
private static final String updateRece = "update T_CAS_ReceivingBill set fk_shjh_city='二开更新' where fbillno=?;";
|
||||
private static final String paybillName = "cas_paybill";//付款单
|
||||
private static final String updatePay = "update T_CAS_PaymentBill set fk_shjh_textfield1='二开更新' where fbillno=?;";
|
||||
|
||||
private static final Log logger = LogFactory.getLog(ExecuteplanBillOperation.class);
|
||||
|
||||
@Override
|
||||
public void afterExecuteOperationTransaction(AfterOperationArgs e) {
|
||||
super.afterExecuteOperationTransaction(e);
|
||||
String eok = e.getOperationKey();
|
||||
if("save".equals(eok)){
|
||||
DynamicObject[] dos = e.getDataEntities();
|
||||
DynamicObject prinfo;//计划执行记录
|
||||
DynamicObject billbizinfo;
|
||||
for (int i = 0; i < dos.length; i++) {
|
||||
prinfo = dos[i];
|
||||
billbizinfo = prinfo.getDynamicObject("billbizetype");//业务单据类型
|
||||
if(billbizinfo != null){
|
||||
// prinfo.getString("bizbillcode");//业务单据编号
|
||||
if(recbillName.equals(billbizinfo.getString("number"))){
|
||||
//处理收款单
|
||||
DB.update(DBRoute.of("fi"), updateRece, new Object[]{prinfo.getString("bizbillcode")});
|
||||
}else if(paybillName.equals(billbizinfo.getString("number"))){
|
||||
//处理付款单
|
||||
DB.update(DBRoute.of("fi"), updatePay, new Object[]{prinfo.getString("bizbillcode")});
|
||||
}
|
||||
logger.info("ExecuteplanBillOperation 业务单据类型"+billbizinfo.getString("number"));
|
||||
logger.info("ExecuteplanBillOperation 业务单据编号"+prinfo.getString("bizbillcode"));
|
||||
}else{
|
||||
logger.info("ExecuteplanBillOperation 未获取到业务单据类型"+prinfo.getString("billno"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -6,6 +6,8 @@ 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.db.DB;
|
||||
import kd.bos.db.DBRoute;
|
||||
import kd.bos.entity.operate.result.OperateErrorInfo;
|
||||
import kd.bos.entity.plugin.AbstractOperationServicePlugIn;
|
||||
import kd.bos.entity.plugin.args.AfterOperationArgs;
|
||||
|
|
@ -14,8 +16,10 @@ import kd.bos.orm.query.QCP;
|
|||
import kd.bos.orm.query.QFilter;
|
||||
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
||||
import kd.sdk.plugin.Plugin;
|
||||
import shjh.jhzj7.fi.fi.utils.ApiUtils;
|
||||
import shjh.jhzj7.fi.fi.utils.JhzjUtils;
|
||||
import shjh.jhzj7.fi.fi.utils.SapUtils;
|
||||
import shjh.jhzj7.fi.fi.utils.domin.ResponseData;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.text.SimpleDateFormat;
|
||||
|
|
@ -61,14 +65,21 @@ public class RevenueBillOperation extends AbstractOperationServicePlugIn impleme
|
|||
DynamicObject[] dos = e.getDataEntities();
|
||||
DynamicObject prinfo;//预提记账处理单
|
||||
JSONObject sapReturnData;
|
||||
ResponseData respdata;
|
||||
for (int i = 0; i < dos.length; i++) {
|
||||
prinfo = BusinessDataServiceHelper.loadSingle(dos[i].getPkValue(), dos[i].getDataEntityType().getName());
|
||||
if(prinfo.getBoolean("shjh_needvoucher") && !prinfo.getBoolean("shjh_sendsap")){
|
||||
//如果预提记账处理单需要生成凭证且未推送sap的才推送sap
|
||||
sapReturnData = sendVoucher(prinfo);
|
||||
if(sapReturnData != null && "0".equals(sapReturnData.getString("code"))){
|
||||
//TODO 推送sap成功后,反写已推送标记
|
||||
// DB.update(DBRoute.of("fi"), updateVoucherFlag, new Object[]{sapReturnData.getString(""),prinfo.getPkValue()});
|
||||
//解析sap凭证接口返回值
|
||||
respdata = ApiUtils.getResponseData(sapReturnData);
|
||||
if(respdata == null){
|
||||
addErrorInfo(prinfo,"SAP凭证接口返回值为空,详见接口日志");
|
||||
continue;
|
||||
}
|
||||
//推送sap成功后,反写已推送标记和sap凭证号至预提单中
|
||||
DB.update(DBRoute.of("fi"), updateVoucherFlag, new Object[]{respdata.getNumber(),prinfo.getPkValue()});
|
||||
this.operationResult.addSuccessPkId(prinfo.getPkValue());
|
||||
}else if(sapReturnData != null){
|
||||
addErrorInfo(prinfo,"推送SAP接口失败:"+sapReturnData.getString("msg"));
|
||||
|
|
|
|||
|
|
@ -37,6 +37,8 @@ public class FundPlanCollectionTask extends AbstractTask implements Plugin {
|
|||
private static final String payReceName = "shjh_pay_account";//收付款资金计划科目配置表
|
||||
private static final String ppsybName = "shjh_pp_syb";//品牌和事业部对应关系 tk_shjh_pp_syb
|
||||
|
||||
private static final String custName = "bd_customer";//系统库 表名 T_BD_Customer
|
||||
|
||||
private static final Log logger = LogFactory.getLog(FundPlanCollectionTask.class);
|
||||
private Gson gson = new Gson();//用于将json格式化为对象
|
||||
|
||||
|
|
@ -49,7 +51,7 @@ public class FundPlanCollectionTask extends AbstractTask implements Plugin {
|
|||
qFilter.and("reportplantype", QCP.equals, "reportplan");//报表类型-计划编制
|
||||
DynamicObject[] collection = BusinessDataServiceHelper.load(entityName, "id", qFilter.toArray());
|
||||
if(collection.length > 0){
|
||||
//调用SAP应收已清接口,按照公司、月份、计划科目汇总金额
|
||||
//调用SAP应收已清接口,按照事业部、月份、计划科目汇总金额
|
||||
Map<String, BigDecimal> acctamountMap = getSapARClearedData();
|
||||
if(acctamountMap == null || acctamountMap.isEmpty()){
|
||||
return;
|
||||
|
|
@ -247,8 +249,14 @@ public class FundPlanCollectionTask extends AbstractTask implements Plugin {
|
|||
if (accounts.length > 1) {
|
||||
//多个条件时根据优先级排序,拿到优先级最高的
|
||||
String kmbh = sapresult.getString("HKONT");//科目编号
|
||||
String custfive = sapresult.getString("SPART");//客户组5
|
||||
// String custfive = sapresult.getString("SPART");//客户组5
|
||||
String cust = sapresult.getString("KUNNR");//客户编号
|
||||
//根据客户编号查出对应的客户组5集合
|
||||
DynamicObjectCollection custinfofives = null;
|
||||
DynamicObject customerinfo = BusinessDataServiceHelper.loadSingle(custName,new QFilter[]{new QFilter("number", QCP.equals, cust)});
|
||||
if(customerinfo != null){
|
||||
custinfofives = customerinfo.getDynamicObjectCollection("shjh_entry_five");
|
||||
}
|
||||
DynamicObjectCollection kmcolls;//科目集合
|
||||
DynamicObjectCollection custfivecolls;//客户组5集合
|
||||
DynamicObjectCollection custcolls;//包含客户的集合
|
||||
|
|
@ -280,10 +288,22 @@ public class FundPlanCollectionTask extends AbstractTask implements Plugin {
|
|||
//当前配置表没有配置客户组5,即任何客户组5都可以匹配
|
||||
custfiveFlag = true;
|
||||
}else{
|
||||
for (DynamicObject custfiveinfo : custfivecolls) {
|
||||
if(custfiveinfo.getDynamicObject("fbasedataid").getString("number").equals(custfive)){
|
||||
custfiveFlag = true;
|
||||
break;
|
||||
//sap数据中的客户没有客户组5,此时不匹配;否则进行两边客户组5的比较
|
||||
if(custinfofives != null){
|
||||
for (DynamicObject custinfofive : custinfofives) {
|
||||
if(!custinfofive.getBoolean("shjh_status")){
|
||||
//客户里面的客户组5被禁用了,则不进行判断
|
||||
continue;
|
||||
}
|
||||
for (DynamicObject custfiveinfo : custfivecolls) {
|
||||
if(custfiveinfo.getDynamicObject("fbasedataid").getString("number").equals(custinfofive.getString("shjh_entryfive_number"))){
|
||||
custfiveFlag = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(custfiveFlag){
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -302,7 +322,6 @@ public class FundPlanCollectionTask extends AbstractTask implements Plugin {
|
|||
}
|
||||
}
|
||||
|
||||
nocustFlag = false;
|
||||
nocustcolls = account.getDynamicObjectCollection("shjh_bbhkh");//不包含客户
|
||||
if(nocustcolls.isEmpty()){
|
||||
//当前配置表没有配置客户,即任何客户都可以匹配
|
||||
|
|
|
|||
|
|
@ -18,11 +18,13 @@ import kd.sdk.plugin.Plugin;
|
|||
import kd.tmc.fpm.business.dataproc.save.ReportDataSDKService;
|
||||
import kd.tmc.fpm.business.dataproc.save.domain.FpmResponse;
|
||||
import kd.tmc.fpm.business.dataproc.save.domain.ReportDataBatchSaveParam;
|
||||
import shjh.jhzj7.fi.fi.utils.JhzjUtils;
|
||||
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;
|
||||
|
||||
|
|
@ -34,6 +36,8 @@ import java.util.Map;
|
|||
public class FundPlanPaymentTask extends AbstractTask implements Plugin {
|
||||
|
||||
private static final String entityName = "fpm_report";//资金计划编制 t_fpm_report
|
||||
private static final String payReceName = "shjh_request_account";//付款申请单_资金计划科目配置表
|
||||
private static final String ppsybName = "shjh_ejbm_syb";//二级部门和事业部对应关系 tk_shjh_pg
|
||||
|
||||
private static final Log logger = LogFactory.getLog(FundPlanPaymentTask.class);
|
||||
|
||||
|
|
@ -41,18 +45,18 @@ public class FundPlanPaymentTask extends AbstractTask implements Plugin {
|
|||
|
||||
@Override
|
||||
public void execute(RequestContext requestContext, Map<String, Object> map) throws KDException {
|
||||
//TODO 查询当月暂存付款类资金计划(付款区分公司,当月应只有一个)
|
||||
//查询当月暂存付款类资金计划(付款不区分公司,当月应只有一个)
|
||||
QFilter qFilter = new QFilter("billstatus", QCP.equals, "A");//单据状态
|
||||
qFilter.and("name", QCP.equals, " 编制表");//报表名称
|
||||
qFilter.and("enable", QCP.equals, "1");//是否可用
|
||||
qFilter.and("reportplantype", QCP.equals, "reportplan");//报表类型-计划编制
|
||||
DynamicObject[] collection = BusinessDataServiceHelper.load(entityName, "id", qFilter.toArray());
|
||||
if(collection.length > 0){
|
||||
JSONObject sapresult = getSapAR();
|
||||
if(sapresult == null){
|
||||
//调用SAP应付未清接口,按照事业部、月份、计划科目汇总金额
|
||||
Map<String, BigDecimal> acctamountMap = getSapAR();
|
||||
if(acctamountMap == null){
|
||||
return;
|
||||
}
|
||||
//调用SAP应付接口,按照公司、月份、计划科目汇总金额
|
||||
ReportDataSDKService reportService = new ReportDataSDKService();//报表服务,用于写入或者查询报表数据
|
||||
ReportDataBatchSaveParam pdsp;//报表批量保存的参数
|
||||
JSONObject json_obj;//入参主对象
|
||||
|
|
@ -60,6 +64,9 @@ public class FundPlanPaymentTask extends AbstractTask implements Plugin {
|
|||
String reportPeriodCode;//编报期间的编号
|
||||
DynamicObject reportOrg;//编报主体对象
|
||||
DynamicObject accountInfo;//资金计划科目
|
||||
String sybnum;//事业部编号-编报主体的编号
|
||||
String months;//月份-科目编制分录中的期间编号
|
||||
String accountnum;//资金计划科目编号
|
||||
DynamicObjectCollection maindimentrys;
|
||||
String billno;//资金计划编制单号
|
||||
String result;//反写结果
|
||||
|
|
@ -79,25 +86,27 @@ public class FundPlanPaymentTask extends AbstractTask implements Plugin {
|
|||
reportPeriodCode = doinfo.getDynamicObject("reportperiod").getString("number");
|
||||
json_obj.put("reportPeriodCode",reportPeriodCode);//编报期间 code
|
||||
reportOrg = doinfo.getDynamicObject("reportorg");
|
||||
json_obj.put("reportOrgCode",reportOrg.getString("number"));//编报主体 code
|
||||
sybnum = reportOrg.getString("number");
|
||||
json_obj.put("reportOrgCode",sybnum);//编报主体 code
|
||||
//组装计划科目
|
||||
items = new JSONArray(maindimentrys.size());
|
||||
int i = 1;
|
||||
for(DynamicObject entryinfo : maindimentrys){
|
||||
accountInfo = entryinfo.getDynamicObject("subjectmem");
|
||||
if(!accountInfo.getBoolean("isleaf")){
|
||||
continue;
|
||||
}
|
||||
accountnum = accountInfo.getString("number");
|
||||
JSONObject itemInfo = new JSONObject();
|
||||
itemInfo.put("currencyCode",entryinfo.getDynamicObject("currencymem").getString("number"));//币别 code
|
||||
itemInfo.put("subjectCode",accountInfo.getString("number"));//计划科目 code
|
||||
itemInfo.put("entryPeriodCode",entryinfo.getDynamicObject("periodmem").getString("number"));//主维度数据分录期间 code
|
||||
itemInfo.put("subjectCode",accountnum);//计划科目 code
|
||||
months = entryinfo.getDynamicObject("periodmem").getString("number");
|
||||
itemInfo.put("entryPeriodCode",months);//主维度数据分录期间 code
|
||||
//组装度量值
|
||||
JSONArray mms = new JSONArray(1);//科目的度量值明细,目前只写入计划参考数
|
||||
JSONObject mmInfo = new JSONObject();
|
||||
//PLANREFERENCEAMT 计划参考值 ACTMAT 已执行额度
|
||||
mmInfo.put("templateMetricType","PLANREFERENCEAMT");//度量值预置类型
|
||||
mmInfo.put("amount",i++);//TODO 写入金额-从SAP接口中获取
|
||||
mmInfo.put("amount",acctamountMap.get(sybnum+months+accountnum));//写入金额-从SAP接口中获取
|
||||
mmInfo.put("amountUnit","one");//金额单位 one元 thousand千元 ten_thousand 万元
|
||||
mms.add(mmInfo);
|
||||
itemInfo.put("metricMembers",mms);//度量值列表
|
||||
|
|
@ -114,7 +123,7 @@ public class FundPlanPaymentTask extends AbstractTask implements Plugin {
|
|||
}
|
||||
}
|
||||
|
||||
private JSONObject getSapAR(){
|
||||
private Map<String, BigDecimal> getSapAR(){
|
||||
//获取当前日期
|
||||
Calendar cal = Calendar.getInstance();
|
||||
//设置日期为本月1号
|
||||
|
|
@ -136,21 +145,67 @@ public class FundPlanPaymentTask extends AbstractTask implements Plugin {
|
|||
JSONArray items = data.getJSONArray("IT_ITEM");
|
||||
Map<String, BigDecimal> acctamountMap = new HashMap<>();
|
||||
BigDecimal amount;//根据事业部编号+月份+资金计划科目编号汇总的金额
|
||||
String productnum;//品牌
|
||||
String deptnum;//部门编号
|
||||
String sybnum;//事业部编号
|
||||
String months;//月份
|
||||
String accountnum;//资金计划科目编号
|
||||
String mapkey;//事业部编号+月份+资金计划科目编号
|
||||
DynamicObject ppsybinfo;//二级部门和事业部关系对象
|
||||
for (int i = 0; i < items.size(); i++) {
|
||||
sapresult = items.getJSONObject(i);
|
||||
sapresult.getString("BUKRS");//公司编号
|
||||
sapresult.getString("FAEDT");//到期日
|
||||
sapresult.getString("WRBTR");//未清金额
|
||||
sapresult.getString("ZREQ_DEPT");//二级部门,需求部门
|
||||
months = sapresult.getString("FAEDT");//到期日
|
||||
amount = sapresult.getBigDecimal("WRBTR");//未清金额
|
||||
deptnum = sapresult.getString("ZREQ_DEPT");//二级部门,需求部门
|
||||
if(JhzjUtils.isEmpty(months)){
|
||||
continue;
|
||||
}
|
||||
accountnum = xdMembersubjectNumber(sapresult);
|
||||
if(JhzjUtils.isEmpty(accountnum)){
|
||||
continue;
|
||||
}
|
||||
months = JhzjUtils.getFundPeriodBySAPDate(months);
|
||||
//根据二级部门和事业部关系,将该笔金额归属到事业部上
|
||||
ppsybinfo = BusinessDataServiceHelper.loadSingleFromCache(ppsybName,new QFilter[]{new QFilter("shjh_orgdept", QCP.equals, deptnum)});
|
||||
if(ppsybinfo != null){
|
||||
sybnum = ppsybinfo.getDynamicObject("shjh_division").getString("number");
|
||||
mapkey = sybnum+months+accountnum;
|
||||
if(acctamountMap.containsKey(mapkey)){
|
||||
acctamountMap.put(mapkey, JhzjUtils.addTwoAmount(amount,acctamountMap.get(mapkey)));
|
||||
}else{
|
||||
acctamountMap.put(mapkey,amount);
|
||||
}
|
||||
}else{
|
||||
//TODO 如果二级部门没有对应的事业部时,数据放哪里?
|
||||
}
|
||||
}
|
||||
return acctamountMap;
|
||||
}
|
||||
}
|
||||
return sapresult;
|
||||
return null;
|
||||
}
|
||||
|
||||
//根据sap的应付未清数据获取对应的资金计划科目编号
|
||||
private String xdMembersubjectNumber(JSONObject sapresult){
|
||||
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");//科目编号
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public void addFilterCondition(JSONArray IT_LIST, String field, String low, String high) {
|
||||
|
|
|
|||
|
|
@ -33,6 +33,13 @@ public class EsbUtils {
|
|||
return value == null || value.trim().length() <= 0;
|
||||
}
|
||||
|
||||
public static boolean getStatusForBoolean(String value){
|
||||
if("1".equals(value)){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static String getApiFailStr(){
|
||||
|
||||
return null;
|
||||
|
|
|
|||
|
|
@ -194,7 +194,7 @@ public class CustomerControler {
|
|||
fiveinfo.set("shjh_salecompanynum",json_body.getString("salecompanynum"));//公司编号
|
||||
fiveinfo.set("shjh_entryfive_number",json_body.getString("customerfivecode"));//编号
|
||||
fiveinfo.set("shjh_entryfive_name",json_body.getString("customerfivename"));//名称
|
||||
fiveinfo.set("shjh_status",json_body.getString("customerfivestatus"));//状态
|
||||
fiveinfo.set("shjh_status",EsbUtils.getStatusForBoolean(json_body.getString("customerfivestatus")));//状态
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue