科目数仓对接、用友实付款查询各按对应接口文档调整
This commit is contained in:
parent
7842e9faa6
commit
b8d9311ba4
|
@ -30,10 +30,10 @@ import java.util.Map;
|
|||
public class DobeDWaccountTask extends AbstractTask implements Plugin {
|
||||
|
||||
private static Log log = LogFactory.getLog(DobeDWaccountTask.class);
|
||||
private static final String entityName = "recos_projcostaccount";//项目成本科目实体 供应链库 表名 t_recos_pcostaccount
|
||||
private static final String accEntity = "costaccountentry";//科目分录实体 供应链库 表名 t_recos_costaccount
|
||||
private static final String projectEntity = "repmd_projectbill";//项目实体 表名 t_repmd_projectbill
|
||||
private static final String dw_menthod = "";
|
||||
private static final String entityName = "recos_stdcostaccount";//标准成本科目实体 供应链库 表名 t_recos_scostaccount
|
||||
// private static final String accEntity = "costaccountentry";//科目分录实体 供应链库 表名 t_recos_costaccount
|
||||
// private static final String projectEntity = "repmd_projectbill";//项目实体 表名 t_repmd_projectbill
|
||||
private static final String dw_menthod = "mdm_costsubject";
|
||||
|
||||
@Override
|
||||
public void execute(RequestContext requestContext, Map<String, Object> map) throws KDException {
|
||||
|
@ -58,26 +58,28 @@ public class DobeDWaccountTask extends AbstractTask implements Plugin {
|
|||
//接口返回的数据进行了分页
|
||||
int totalNum = json_body.getIntValue("totalNum");//分页-SQL查询总数据量
|
||||
//解析接口返回值,与系统数据比较
|
||||
String projectnumber = json_body.getString("projectnumber");
|
||||
DynamicObject projectinfo = QueryServiceHelper.queryOne(projectEntity,"id,billno",new QFilter[]{new QFilter("billno","=",projectnumber)});
|
||||
if(projectinfo == null){
|
||||
log.info(String.format("成本科目接口异常未根据项目编号找到对应项目:%s", projectnumber));
|
||||
return;
|
||||
}
|
||||
//根据项目查找成本科目的表头信息
|
||||
DynamicObject billinfo = BusinessDataServiceHelper.loadSingle(entityName,new QFilter[]{new QFilter("project","=",projectinfo.getLong("id"))});
|
||||
if(billinfo == null){
|
||||
billinfo = BusinessDataServiceHelper.newDynamicObject(entityName);
|
||||
billinfo.set("project",projectinfo.getLong("id"));
|
||||
}
|
||||
// String projectnumber = json_body.getString("projectnumber");
|
||||
// DynamicObject projectinfo = QueryServiceHelper.queryOne(projectEntity,"id,billno",new QFilter[]{new QFilter("billno","=",projectnumber)});
|
||||
// if(projectinfo == null){
|
||||
// log.info(String.format("成本科目接口异常未根据项目编号找到对应项目:%s", projectnumber));
|
||||
// return;
|
||||
// }
|
||||
//根据id查找标准成本科目的表头信息
|
||||
long bzkmid = 2012525353133704192l;//测试id
|
||||
// long bzkmid = 2012525353133704192l;//正式id
|
||||
DynamicObject billinfo = BusinessDataServiceHelper.loadSingle(entityName,new QFilter[]{new QFilter("id","=",bzkmid)});
|
||||
// if(billinfo == null){
|
||||
// billinfo = BusinessDataServiceHelper.newDynamicObject(entityName);
|
||||
// billinfo.set("project",projectinfo.getLong("id"));
|
||||
// }
|
||||
String acctid = null;
|
||||
String number = null;
|
||||
String name = null;
|
||||
String longnumber = null;
|
||||
String longname = null;
|
||||
// String longnumber = null;
|
||||
// String longname = null;
|
||||
String ciaccountflag = null;
|
||||
String apportionway = null;
|
||||
String taxrate = null;
|
||||
// String apportionway = null;
|
||||
// String taxrate = null;
|
||||
String isleaf = null;
|
||||
String level = null;
|
||||
String parentid = null;
|
||||
|
@ -92,33 +94,36 @@ public class DobeDWaccountTask extends AbstractTask implements Plugin {
|
|||
//循环入参,判断哪些科目该修改,哪些该新增
|
||||
for (int i = 0; i < detailsJson.size(); i++) {
|
||||
json_body = detailsJson.getJSONObject(i);
|
||||
acctid = json_body.getString("accid");//科目id
|
||||
number = json_body.getString("number");//科目编号
|
||||
name = json_body.getString("name");//科目名称
|
||||
longnumber = json_body.getString("longnumber");//科目长编号
|
||||
longname = json_body.getString("longname");//科目长名称
|
||||
acctid = json_body.getString("costsubject_id");//科目id
|
||||
number = json_body.getString("costsubject_code");//科目编号
|
||||
name = json_body.getString("costsubject_name");//科目名称
|
||||
// longnumber = json_body.getString("longnumber");//科目长编号
|
||||
// longname = json_body.getString("longname");//科目长名称
|
||||
ciaccountflag = json_body.getString("ciaccountflag");//科目类别 非建安科目and建安科目
|
||||
apportionway = json_body.getString("apportionway");//分摊方式
|
||||
taxrate = json_body.getString("taxrate");//税率
|
||||
// apportionway = json_body.getString("apportionway");//分摊方式
|
||||
// taxrate = json_body.getString("taxrate");//税率
|
||||
isleaf = json_body.getString("isleaf");//是否叶子节点
|
||||
level = json_body.getString("level");//科目级次
|
||||
parentid = json_body.getString("parentid");//科目级次
|
||||
// level = json_body.getString("level");//科目级次
|
||||
parentid = json_body.getString("costsubject_pid");//科目父级id
|
||||
if(DobeDWUtils.isEmpty(number) || DobeDWUtils.isEmpty(name) || DobeDWUtils.isEmpty(isleaf)
|
||||
|| DobeDWUtils.isEmpty(level) || DobeDWUtils.isEmpty(acctid)){
|
||||
|| DobeDWUtils.isEmpty(acctid)){
|
||||
//如果组织ID和组织编码 名称是空的,则跳过此记录
|
||||
log.info(String.format("成本科目入参为空异常:%s", json_body.toJSONString()));
|
||||
continue;
|
||||
}else if(Integer.parseInt(level) >= 2 && DobeDWUtils.isEmpty(parentid)){
|
||||
log.info(String.format("成本科目级次大于等于2但是无对应的父级科目ID:%s", json_body.toJSONString()));
|
||||
continue;
|
||||
}
|
||||
// else if(Integer.parseInt(level) >= 2 && DobeDWUtils.isEmpty(parentid)){
|
||||
// log.info(String.format("成本科目级次大于等于2但是无对应的父级科目ID:%s", json_body.toJSONString()));
|
||||
// continue;
|
||||
// }
|
||||
//先从现有科目集合中获取,未获取到则新增
|
||||
acctinfo = parentAccts.get(acctid);
|
||||
if(acctinfo == null){
|
||||
acctinfo = doDetails.addNew();
|
||||
acctinfo.set("caentry_srcid", acctid);//源ID 用于存储数仓的科目id
|
||||
acctinfo.set("caentry_project", projectinfo.getLong("id"));//项目
|
||||
// acctinfo.set("caentry_project", projectinfo.getLong("id"));//项目
|
||||
acctinfo.set("caentry_enable", true);//默认 启用
|
||||
acctinfo.set("caentry_isstdaccount", true);//是否标准科目
|
||||
acctinfo.set("caentry_standlibflag", true);//是否标准科目库
|
||||
//将此次新增的科目放到现有科目集合中,方便后续科目能获取到父级科目
|
||||
parentAccts.put(acctid,acctinfo);
|
||||
}
|
||||
|
@ -126,12 +131,11 @@ public class DobeDWaccountTask extends AbstractTask implements Plugin {
|
|||
acctinfo.set("caentry_number", number);
|
||||
acctinfo.set("caentry_name", name);
|
||||
acctinfo.set("caentry_ciaccountflag", ciaccountflag);//科目类别 建安 1 非建安 0
|
||||
acctinfo.set("caentry_apportionway", null);//分摊方式 基础资料
|
||||
acctinfo.set("caentry_longnumber", longnumber);
|
||||
acctinfo.set("caentry_fullname", longname);
|
||||
acctinfo.set("caentry_taxrate", taxrate);
|
||||
// acctinfo.set("caentry_apportionway", null);//分摊方式 基础资料
|
||||
// acctinfo.set("caentry_taxrate", taxrate);//税率
|
||||
acctinfo.set("caentry_longnumber", number);//科目长编号
|
||||
acctinfo.set("caentry_fullname", name);//科目长名称
|
||||
acctinfo.set("caentry_isleaf", isleaf);
|
||||
acctinfo.set("caentry_level", level);
|
||||
//创建组织 caentry_createorg
|
||||
//组织 caentry_org
|
||||
//业务组织 caentry_useorg
|
||||
|
@ -141,6 +145,11 @@ public class DobeDWaccountTask extends AbstractTask implements Plugin {
|
|||
//如果数仓不指定长编码和长名称,则需要在此处手动处理
|
||||
acctinfo.set("caentry_longnumber", parentAccts.get(parentid).getString("caentry_longnumber")+"."+number);
|
||||
acctinfo.set("caentry_fullname", parentAccts.get(parentid).getString("caentry_fullname")+"_"+name);
|
||||
//科目级次=父级科目级次+1
|
||||
acctinfo.set("caentry_level", parentAccts.get(parentid).getInt("caentry_level")+1);
|
||||
}else{
|
||||
//没有父节点的是根节点,级次是1
|
||||
acctinfo.set("caentry_level", 1);
|
||||
}
|
||||
}
|
||||
SaveServiceHelper.save(new DynamicObject[]{billinfo});
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package shkd.repc.task;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import kd.bos.context.RequestContext;
|
||||
import kd.bos.dataentity.OperateOption;
|
||||
|
@ -23,6 +24,7 @@ import okhttp3.RequestBody;
|
|||
import okhttp3.Response;
|
||||
import shkd.utils.DobeDWUtils;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
|
@ -32,10 +34,10 @@ public class YongyouBIPTask extends AbstractTask implements Plugin {
|
|||
private static Log log = LogFactory.getLog(YongyouBIPTask.class);
|
||||
|
||||
//合同付款申请单的实体名称
|
||||
private static final String payrequestEntity = "recon_payreqbill";
|
||||
// private static final String payrequestEntity = "recon_payreqbill";
|
||||
//费用登记的实体名称
|
||||
private static final String notextEntity = "recon_connotextbill";
|
||||
private static final String payregisterEntity = "recon_payregister";//供应链库 t_recon_payregister
|
||||
// private static final String notextEntity = "recon_connotextbill";
|
||||
private static final String payregisterEntity = "recon_payregister";//付款登记标识 供应链库 t_recon_payregister
|
||||
|
||||
@Override
|
||||
public void execute(RequestContext requestContext, Map<String, Object> map) throws KDException {
|
||||
|
@ -54,6 +56,36 @@ public class YongyouBIPTask extends AbstractTask implements Plugin {
|
|||
if(prs.length == 0){
|
||||
return;
|
||||
}
|
||||
//将满足本次查询条件的单子存入map中
|
||||
DynamicObject prinfo = null;
|
||||
DynamicObject requestinfo = null;
|
||||
String yynum = null;
|
||||
JSONObject idjson = null;
|
||||
JSONArray idarray = new JSONArray();
|
||||
Map<String,DynamicObject> billMap = new HashMap();
|
||||
for (int i = 0; i < prs.length; i++) {
|
||||
prinfo = BusinessDataServiceHelper.loadSingle(prs[i].getPkValue(),payregisterEntity);
|
||||
//费用登记
|
||||
requestinfo = prinfo.getDynamicObject("connotextbill");
|
||||
if(requestinfo == null){
|
||||
//付款申请
|
||||
requestinfo = prinfo.getDynamicObject("payreqbill");
|
||||
}
|
||||
requestinfo = BusinessDataServiceHelper.loadSingle(requestinfo.getPkValue(),requestinfo.getDataEntityType().getName());
|
||||
//看用友的实付款查询接口是一个个查询,还是集中查询;这个字段直接从F7实体对象中获取不到,需要扩展F7实体
|
||||
yynum = requestinfo.getString("qeug_yynum");
|
||||
//获取到的yynum为空,则不进行实付查询
|
||||
if(DobeDWUtils.isEmpty(yynum)){
|
||||
continue;
|
||||
}
|
||||
billMap.put(yynum,prinfo);
|
||||
idjson = new JSONObject();
|
||||
idjson.put("id",yynum);
|
||||
idarray.add(idjson);
|
||||
}
|
||||
if(billMap.isEmpty()){
|
||||
return;
|
||||
}
|
||||
//bip接口认证
|
||||
String accesstoken = null;
|
||||
APICurUtils apiutil = new APICurUtils();//处理认证接口的工具类(用友提供的第三方工具),得到accesstoken
|
||||
|
@ -78,69 +110,64 @@ public class YongyouBIPTask extends AbstractTask implements Plugin {
|
|||
log.error("用友认证接口返回的accessToken为空");
|
||||
return;
|
||||
}
|
||||
Request request = null;
|
||||
JSONObject resultData = null;
|
||||
DynamicObject prinfo = null;
|
||||
DynamicObject requestinfo = null;
|
||||
String yynum = null;
|
||||
String[] companyDept = null;
|
||||
JSONObject queryParams = new JSONObject();
|
||||
OkHttpClient client = new OkHttpClient();
|
||||
Response response = null;
|
||||
for (int i = 0; i < prs.length; i++) {
|
||||
prinfo = BusinessDataServiceHelper.loadSingle(prs[i].getPkValue(),payregisterEntity);
|
||||
//费用登记
|
||||
requestinfo = prinfo.getDynamicObject("connotextbill");
|
||||
if(requestinfo == null){
|
||||
//付款申请
|
||||
requestinfo = prinfo.getDynamicObject("payreqbill");
|
||||
queryParams.put("bipData",idarray);
|
||||
Request request = new Request.Builder().url(DobeDWUtils.payQueryUrl)
|
||||
.post(createFormRequestBody(queryParams))
|
||||
.header("Content-Type", "application/json;charset=utf-8")
|
||||
.header("access_token", accesstoken)
|
||||
.header("repeat_check", "Y")
|
||||
.header("ucg_flag", "Y")
|
||||
.header("client_id", DobeDWUtils.clientid)
|
||||
.build();
|
||||
try {
|
||||
OkHttpClient client = new OkHttpClient();
|
||||
Response response = client.newCall(request).execute();
|
||||
JSONObject resultData = JSON.parseObject(response.body().string());
|
||||
if(!"200".equals(resultData.getString("code"))){
|
||||
//增加日志记录
|
||||
DobeDWUtils.saveLog("noQueryResult","用友实付查询",queryParams.toString(),resultData.toString(),false,"定时任务");
|
||||
return;
|
||||
}
|
||||
requestinfo = BusinessDataServiceHelper.loadSingle(requestinfo.getPkValue(),requestinfo.getDataEntityType().getName());
|
||||
//看用友的实付款查询接口是一个个查询,还是集中查询;这个字段直接从F7实体对象中获取不到,需要扩展F7实体
|
||||
yynum = requestinfo.getString("qeug_yynum");
|
||||
//获取到的yynum为空,则不进行实付查询
|
||||
if(DobeDWUtils.isEmpty(yynum)){
|
||||
continue;
|
||||
}
|
||||
//根据付款申请单的用款部门找到对应财务组织编号
|
||||
companyDept = DobeDWUtils.getCompanyDeptNumber(requestinfo.getDynamicObject("usedepart").getString("number"));
|
||||
if(companyDept[0] == null){
|
||||
DobeDWUtils.saveLog(requestinfo.getString("number"),"用友实付查询",requestinfo.getDynamicObject("usedepart").getString("number"),"根据用款部门编号转换财务编号失败",false,"定时任务");
|
||||
continue;
|
||||
}
|
||||
queryParams.put("pk_org",companyDept[0]);
|
||||
queryParams.put("bill_no",yynum);
|
||||
request = new Request.Builder().url(DobeDWUtils.payQueryUrl)
|
||||
.post(createFormRequestBody(queryParams))
|
||||
.header("Content-Type", "application/json;charset=utf-8")
|
||||
.header("access_token", accesstoken)
|
||||
.header("repeat_check", "Y")
|
||||
.header("ucg_flag", "Y")
|
||||
.header("client_id", DobeDWUtils.clientid)
|
||||
.build();
|
||||
try {
|
||||
response = client.newCall(request).execute();
|
||||
resultData = JSON.parseObject(response.body().string());
|
||||
if(!"true".equals(resultData.getString("success"))){
|
||||
//增加日志记录
|
||||
DobeDWUtils.saveLog(requestinfo.getString("number"),"用友实付查询",queryParams.toString(),resultData.toString(),false,"定时任务");
|
||||
continue;
|
||||
JSONArray dataArray = resultData.getJSONArray("data");
|
||||
for (int i = 0; i < dataArray.size(); i++) {
|
||||
idjson = dataArray.getJSONObject(i);
|
||||
yynum = idjson.getJSONObject("parentVO").getString("pk_settle");
|
||||
prinfo = billMap.get(yynum);
|
||||
if(prinfo != null){
|
||||
prinfo.set("bizdate",idjson.getJSONObject("parentVO").getDate("settleDate"));
|
||||
prinfo.set("billno",yynum);
|
||||
prinfo.set("billstatus","B"); //单据状态改为已提交
|
||||
SaveServiceHelper.update(prinfo);//保存上述设置内容
|
||||
//调用付款登记单的审核方法
|
||||
OperationServiceHelper.executeOperate("audit",payregisterEntity,new DynamicObject[]{prinfo}, OperateOption.create());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
DobeDWUtils.saveLog(requestinfo.getString("number"),"用友实付查询",queryParams.toString(),e.getMessage(),false,"定时任务");
|
||||
continue;
|
||||
}
|
||||
//根据查询结果设置付款登记对象
|
||||
prinfo.set("bizdate",resultData.getJSONObject("data").getDate("billdate"));
|
||||
prinfo.set("billno",yynum);
|
||||
prinfo.set("billstatus","B"); //单据状态改为已提交
|
||||
SaveServiceHelper.update(prinfo);//保存上述设置内容
|
||||
//调用提交方法
|
||||
// OperationServiceHelper.executeOperate("submit",payregisterEntity,new DynamicObject[]{prinfo}, OperateOption.create());
|
||||
//调用付款登记单的审核方法
|
||||
OperationServiceHelper.executeOperate("audit",payregisterEntity,new DynamicObject[]{prinfo}, OperateOption.create());
|
||||
DobeDWUtils.saveLog(requestinfo.getString("number"),"用友实付查询",queryParams.toString(),resultData.toString(),true,"定时任务");
|
||||
DobeDWUtils.saveLog("querySuccess","用友实付查询",queryParams.toString(),resultData.toString(),true,"定时任务");
|
||||
} catch (Exception e) {
|
||||
DobeDWUtils.saveLog("queryException","用友实付查询",queryParams.toString(),e.getMessage(),false,"定时任务");
|
||||
}
|
||||
|
||||
// String[] companyDept = null;
|
||||
// for (int i = 0; i < prs.length; i++) {
|
||||
// //根据付款申请单的用款部门找到对应财务组织编号
|
||||
// companyDept = DobeDWUtils.getCompanyDeptNumber(requestinfo.getDynamicObject("usedepart").getString("number"));
|
||||
// if(companyDept[0] == null){
|
||||
// DobeDWUtils.saveLog(requestinfo.getString("number"),"用友实付查询",requestinfo.getDynamicObject("usedepart").getString("number"),"根据用款部门编号转换财务编号失败",false,"定时任务");
|
||||
// continue;
|
||||
// }
|
||||
// queryParams.put("pk_org",companyDept[0]);
|
||||
// //根据查询结果设置付款登记对象
|
||||
// prinfo.set("bizdate",resultData.getJSONObject("data").getDate("billdate"));
|
||||
// prinfo.set("billno",yynum);
|
||||
// prinfo.set("billstatus","B"); //单据状态改为已提交
|
||||
// SaveServiceHelper.update(prinfo);//保存上述设置内容
|
||||
// //调用提交方法
|
||||
//// OperationServiceHelper.executeOperate("submit",payregisterEntity,new DynamicObject[]{prinfo}, OperateOption.create());
|
||||
// //调用付款登记单的审核方法
|
||||
// OperationServiceHelper.executeOperate("audit",payregisterEntity,new DynamicObject[]{prinfo}, OperateOption.create());
|
||||
// DobeDWUtils.saveLog(requestinfo.getString("number"),"用友实付查询",queryParams.toString(),resultData.toString(),true,"定时任务");
|
||||
// }
|
||||
}
|
||||
|
||||
private RequestBody createFormRequestBody(JSONObject json_body) {
|
||||
|
|
Loading…
Reference in New Issue