数仓接口地址https+域名,增加人员收款账户同步逻辑

This commit is contained in:
yuxueliang0813 2024-09-18 14:33:25 +08:00
parent d563681bac
commit e1755ed9dd
6 changed files with 167 additions and 76 deletions

View File

@ -50,7 +50,7 @@ public class DobeDWorgTask extends AbstractTask implements Plugin {
try {
response = client.newCall(request).execute();
resultData = response.body().string();
// log.info("组织接口返回结果:\n{}", resultData);
log.info("组织接口返回结果:\n{}", resultData);
} catch (IOException e) {
log.info(String.format("组织接口异常:%s", e.getMessage()));
throw new RuntimeException(e);

View File

@ -51,7 +51,7 @@ public class DobeDWpersonTask extends AbstractTask implements Plugin {
try {
response = client.newCall(request).execute();
resultData = response.body().string();
// log.info("人员接口返回结果:\n{}", resultData);
log.info("人员接口返回结果:\n{}", resultData);
} catch (IOException e) {
log.info(String.format("人员接口异常:%s", e.getMessage()));
throw new RuntimeException(e);
@ -110,6 +110,9 @@ public class DobeDWpersonTask extends AbstractTask implements Plugin {
String email = null;
String deptid = null;
String jobposition = null;
String bank = null;
String bank_branch = null;
String bank_account = null;
List<UserParam> addList = new ArrayList<>();
// List<UserParam> updateList = new ArrayList<>();
@ -126,6 +129,9 @@ public class DobeDWpersonTask extends AbstractTask implements Plugin {
phone = json_body.getString("mobile_phone");
deptid = json_body.getString("department_id");//部门id
jobposition = json_body.getString("jobposition");//职位
bank = json_body.getString("bank");//银行
bank_branch = json_body.getString("bank_branch");//支行
bank_account = json_body.getString("bank_account");//账号
if(DobeDWUtils.isEmpty(number) || DobeDWUtils.isEmpty(name)){
log.info(String.format("人员入参为空异常:%s", json_body.toJSONString()));
continue;
@ -173,13 +179,19 @@ public class DobeDWpersonTask extends AbstractTask implements Plugin {
}
}
//处理新增人员收款银行账户
// personbank = BusinessDataServiceHelper.newDynamicObject(personEntityName);
// personbank.set("number",number);
// personbank.set("name",name);
// personbank.set("qeug_banknumber",name);//银行账户
// personbank.set("qeug_bankname",name);//开户银行
// //保存数据直接保存入库不走操作校验
// SaveServiceHelper.save(new DynamicObject[]{personbank});
if(DobeDWUtils.isEmpty(bank_account)){
continue;
}
personbank = BusinessDataServiceHelper.newDynamicObject(personEntityName);
personbank.set("number",number);
personbank.set("name",name);
personbank.set("qeug_banknumber",bank_account);//银行账户
personbank.set("qeug_bankname",bank_branch);//开户银行(支行)
personbank.set("qeug_bank",bank);//银行
personbank.set("status","C"); //单据状态默认为已审核
personbank.set("enable",1);//默认可用
//保存数据直接保存入库不走操作校验
SaveServiceHelper.save(new DynamicObject[]{personbank});
}
}
if(addList.size() > 0){

View File

@ -94,6 +94,9 @@ public class DobeDWpersonUpdateTask extends AbstractTask implements Plugin {
String email = null;
String deptid = null;
String jobposition = null;
String bank = null;
String bank_branch = null;
String bank_account = null;
List<UserParam> updateList = new ArrayList<>();
UserParam user = null;
@ -110,6 +113,9 @@ public class DobeDWpersonUpdateTask extends AbstractTask implements Plugin {
phone = json_body.getString("mobile_phone");
deptid = json_body.getString("department_id");//部门id
jobposition = json_body.getString("jobposition");//职位
bank = json_body.getString("bank");//银行
bank_branch = json_body.getString("bank_branch");//支行
bank_account = json_body.getString("bank_account");//账号
if(DobeDWUtils.isEmpty(number) || DobeDWUtils.isEmpty(name)){
log.info(String.format("人员入参为空异常:%s", json_body.toJSONString()));
continue;
@ -147,17 +153,33 @@ public class DobeDWpersonUpdateTask extends AbstractTask implements Plugin {
log.info(String.format("数仓的部门在金蝶中未找到对应组织:%s", deptid));
}
}
//处理人员收款银行账户的修改
// personbank = BusinessDataServiceHelper.loadSingle(personEntityName,new QFilter[]{new QFilter("number","=",number)});
// if(personbank != null){
// if(!name.equals(personbank.getString("name"))){
// //姓名银行账户开户银行任意一个不相同则更新
// personbank.set("name",name);
// personbank.set("qeug_banknumber",name);//银行账户
// personbank.set("qeug_bankname",name);//开户银行
// SaveServiceHelper.update(personbank);
// }
// }
//处理人员收款银行账户的修改,银行账户为空时不处理
if(DobeDWUtils.isEmpty(bank_account)){
continue;
}
personbank = BusinessDataServiceHelper.loadSingle(personEntityName,new QFilter[]{new QFilter("number","=",number)});
if(personbank != null){
if(isNeedUpdate(personbank,name,bank,bank_branch,bank_account)){
//姓名银行账户开户银行任意一个不相同则更新
personbank.set("name",name);
personbank.set("qeug_banknumber",bank_account);//银行账户
personbank.set("qeug_bankname",bank_branch);//开户银行(支行)
personbank.set("qeug_bank",bank);//银行
SaveServiceHelper.update(personbank);
}
}else{
//新增
personbank = BusinessDataServiceHelper.newDynamicObject(personEntityName);
personbank.set("number",number);
personbank.set("name",name);
personbank.set("qeug_banknumber",bank_account);//银行账户
personbank.set("qeug_bankname",bank_branch);//开户银行(支行)
personbank.set("qeug_bank",bank);//银行
personbank.set("status","C"); //单据状态默认为已审核
personbank.set("enable",1);//默认可用
//保存数据直接保存入库不走操作校验
SaveServiceHelper.save(new DynamicObject[]{personbank});
}
}
}
if(updateList.size() > 0){
@ -170,4 +192,16 @@ public class DobeDWpersonUpdateTask extends AbstractTask implements Plugin {
}
}
}
private boolean isNeedUpdate(DynamicObject personbank,String name,String bank,String bank_branch,String bank_account){
if(!name.equals(personbank.getString("name"))){
return true;
}else if(!bank_account.equals(personbank.getString("qeug_banknumber"))){
return true;
}else if(DobeDWUtils.isEmpty(bank) || !bank.equals(personbank.getString("qeug_bank"))){
return true;
}else if(DobeDWUtils.isEmpty(bank_branch) || !bank_branch.equals(personbank.getString("qeug_bankname"))){
return true;
}
return false;
}
}

View File

@ -28,9 +28,6 @@ import java.math.BigDecimal;
public class YongyouBIPOperation extends AbstractOperationServicePlugIn implements Plugin {
private static final Log log = LogFactory.getLog(YongyouBIPOperation.class);
//加密等级
// private static final String secret_level = "L0";
/**
* 操作执行加载单据数据包之前触发此事件在单据列表上执行单据操作传入的是单据内码
* 系统需要先根据传入的单据内码加载单据数据包其中只包含操作要用到的字段然后再执行操作
@ -122,18 +119,15 @@ public class YongyouBIPOperation extends AbstractOperationServicePlugIn implemen
return null;
}
private String getAccountingOpinion(DynamicObject payrequestinfo){
//根据单据id查找审批流程中会计部的审批意见多人时合并输出意见
return null;
}
private String[] getCompanyDeptNumber(String bizDept){
//根据用款部门的编号获得对应关系表中的财务公司编号和部门编号
DynamicObject orginfo = BusinessDataServiceHelper.loadSingle("qeug_recon_orgrelation",new QFilter[]{new QFilter("number","=",bizDept)});
String[] result = new String[2];
String[] result = new String[3];
if(orginfo != null){
result[0] = orginfo.getString("qeug_companynumber");//财务公司编号
result[1] = orginfo.getString("qeug_deptnumber");//财务部门编号
// result[2] = orginfo.getString("qeug_deptnumber");//财务公司付款账户
result[2] = "03002635967";
}else{
log.error(String.format("用友付款接口根据用款部门编号转换财务编号失败:%s", bizDept));
}
@ -159,7 +153,6 @@ public class YongyouBIPOperation extends AbstractOperationServicePlugIn implemen
ap_recaccount = payrequestinfo.getString("receiveno");
}
String supplierNum = payrequestinfo.getDynamicObject("receiveunit").getString("number");
// payData.put("supplier",);//供应商编码 非必传
payData.put("customer",supplierNum);//客户编码 即使是供应商也传入到该字段
payData.put("pk_dept",companyDept[1]);//部门编码通过公司主体明细表找部门编码
if(isgrdf){
@ -169,8 +162,8 @@ public class YongyouBIPOperation extends AbstractOperationServicePlugIn implemen
}
payData.put("pk_currtype","CNY");//币种传编码CNY
payData.put("pk_busitype","AP01");//业务流程传编码 AP01(生产可能有变化)
String ap_payaccount = "";//付款银行账号
payData.put("pk_busitype","AP04");//业务流程传编码 AP01(生产可能有变化)
String ap_payaccount = companyDept[2];//付款银行账号
//付款银行账户编码德必传编码例31001562700050031883-上海德必文化创意产业发展集团股份有限公司
payData.put("ap_payaccount",ap_payaccount);//如何取值-从数仓获取的组织对应关系中获取默认付款银行账号
payData.put("ap_recaccount",ap_recaccount);//收款银行账户编码客商传编码例3101040160000098225-上海达洋消防保安工程有限公司
@ -197,20 +190,14 @@ public class YongyouBIPOperation extends AbstractOperationServicePlugIn implemen
payData.put("approvedate",DobeDWUtils.getDateString(payrequestinfo.getDate("auditDate")));//审核日期 YYYY-MM-DD
// payData.put("src_syscode","ISC");//单据来源系统编码 非必传
if(isnotext){
payData.put("def1","无合同");//自定义项1 流程类型有合同 无合同
payData.put("def11","无合同付款");//自定义项1 流程类型有合同 无合同
}else{
payData.put("def1","合同");//自定义项1 流程类型有合同 无合同
payData.put("def11","合同付款");//自定义项1 流程类型有合同 无合同
}
payData.put("def12",payrequestinfo.getString("billno"));//自定义项2 付款申请单的单号全局唯一才行
payData.put("def13","");//备注传合同总金额及付款比例等拼接凭证摘要
payData.put("def2",payrequestinfo.getString("billno"));//自定义项2 付款申请单的单号全局唯一才行
payData.put("def3","");//自定义项3 是否分摊传字符
payData.put("def4",getInvoiceNumber(payrequestinfo, isnotext));//自定义项4 发票号码拼接数据传字符 数电票(增值税专用发票):24512000000077221149
payData.put("def5",null);//自定义项5 付款申请单的备注后续作为的凭证摘要字段长度最大为30
payData.put("def6","");//自定义项6 0A接口预留字段1
payData.put("def7","");//自定义项7 0A接口预留字段2
payData.put("def8","");//自定义项8 0A接口预留字段3
//------以下是表体组装-------------
//------------------以下是表体组装--------------------
JSONArray jas = new JSONArray();
JSONObject items = new JSONObject();
// items.put("contractno",payrequestinfo.getDynamicObject("contractbill"));//合同号
@ -221,7 +208,6 @@ public class YongyouBIPOperation extends AbstractOperationServicePlugIn implemen
}else{
items.put("objtype","0");//往来对象(0-客户 1-供应商 2-部门 3-业务员)
}
// items.put("supplier",);//供应商编码 非必传
items.put("customer",supplierNum);//客户编码 供应商的数据也传入这里
items.put("pk_dept",companyDept[1]);//部门编码通过公司主体明细表找部门编码
if(isgrdf){
@ -259,23 +245,18 @@ public class YongyouBIPOperation extends AbstractOperationServicePlugIn implemen
items.put("ap_payaccount",ap_payaccount);//付款银行账户编码 同表头
items.put("ap_recaccount",ap_recaccount);//收款银行账户编码
items.put("pk_balatype","07");//结算方式编码传编码例07-网银
items.put("def5","");//费用类别传编码 无抵暂支业务先传空
items.put("def6","");//抵暂支状态,传字符现在应该有 0 1 -1 三种状态?
items.put("def7","");//原暂支金额xxxxx.00000000?
items.put("def8","");//抵暂支金额xxxxx.00000000?
if(isnotext){
items.put("def13","");//供应链系统合同号无合同怎么传递
}else{
items.put("def13","");//供应链系统合同号
}
items.put("def14",payrequestinfo.getString("id"));//供应链付款单ID
jas.add(items);
payData.put("items",jas);//表头关联表体
return payData;
}
private void handleForBIP(String eventName, DynamicObject payrequestinfo, boolean isnotext){
// //认证接口得到accesstoken
// Request request = new Request.Builder().url(tokenUrl)
// .post(createAccessTokenBody())
// .header("Content-Type", "application/x-www-form-urlencoded")
// .build();
String accesstoken = null;
APICurUtils apiutil = new APICurUtils();//处理认证接口的工具类用友提供的第三方工具得到accesstoken
apiutil.init(DobeDWUtils.yyip,DobeDWUtils.yyport,DobeDWUtils.bizcenter,DobeDWUtils.clientid,DobeDWUtils.clientsecret,DobeDWUtils.pubKey,DobeDWUtils.clientid,null);
@ -348,7 +329,6 @@ public class YongyouBIPOperation extends AbstractOperationServicePlugIn implemen
}
private RequestBody createAccessTokenBody() {
FormBody.Builder builder = new FormBody.Builder();
//如下写法在接口调用后用友反馈解密失败猜测是没有给RequestBody使用指定的MediaType 以及 没有使用json格式进行RequestBody设置
// try {

View File

@ -59,8 +59,17 @@ public class DobeDWaccountTask extends AbstractTask implements Plugin {
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"))});
boolean isNew = false;
if(billinfo == null){
isNew = true;
billinfo = BusinessDataServiceHelper.newDynamicObject(entityName);
}
QFilter billfilter = new QFilter("fid","=", billinfo.getLong("id"));
JSONArray detailsJson = json_body.getJSONArray("data");
String acctid = null;
String number = null;
@ -86,13 +95,29 @@ public class DobeDWaccountTask extends AbstractTask implements Plugin {
isleaf = json_body.getString("isleaf");//是否叶子节点
level = json_body.getString("level");//科目级次
if(DobeDWUtils.isEmpty(number) || DobeDWUtils.isEmpty(name) || DobeDWUtils.isEmpty(isleaf)
|| DobeDWUtils.isEmpty(level)){
|| DobeDWUtils.isEmpty(level) || DobeDWUtils.isEmpty(acctid)){
//如果组织ID和组织编码 名称是空的则跳过此记录
log.info(String.format("成本科目入参为空异常:%s", json_body.toJSONString()));
continue;
}
//根据科目id查找是否已存在
acctinfo = BusinessDataServiceHelper.loadSingle(accEntity,new QFilter[]{new QFilter("caentry_srcid","=",acctid)});
//整体是修改的情况下根据科目id查找是否已存在
if(isNew){
acctinfo = BusinessDataServiceHelper.newDynamicObject(accEntity);
acctinfo.set("caentry_srcid", acctid);//源ID 用于存储数仓的科目id
acctinfo.set("caentry_number", number);
acctinfo.set("caentry_name", name);
acctinfo.set("caentry_longnumber", longnumber);
acctinfo.set("caentry_ciaccountflag", ciaccountflag);//科目类别 建安 1 非建安 0
acctinfo.set("caentry_apportionway", null);//分摊方式 基础资料
acctinfo.set("caentry_fullname", longname);
acctinfo.set("caentry_taxrate", taxrate);
acctinfo.set("caentry_isleaf", isleaf);
acctinfo.set("caentry_level", level);
acctinfo.set("caentry_project", projectinfo.getLong("id"));//项目
acctinfo.set("caentry_enable", true);//默认 启用
billinfo.getDynamicObjectCollection("costaccountentry").add(acctinfo);
}else{
acctinfo = BusinessDataServiceHelper.loadSingle(accEntity,new QFilter[]{billfilter.and(new QFilter("caentry_srcid","=",acctid))});
if(acctinfo == null){
//不存在做新增 根据实体名称创建动态对象
acctinfo = BusinessDataServiceHelper.newDynamicObject(accEntity);
@ -108,8 +133,9 @@ public class DobeDWaccountTask extends AbstractTask implements Plugin {
acctinfo.set("caentry_level", level);
acctinfo.set("caentry_project", projectinfo.getLong("id"));//项目
acctinfo.set("caentry_enable", true);//默认 启用
acctinfo.set("caentry_isimportaccount", true);//是否导入科目
SaveServiceHelper.save(new DynamicObject[]{acctinfo});
// acctinfo.set("caentry_isimportaccount", true);//是否导入科目
// SaveServiceHelper.save(new DynamicObject[]{acctinfo});
billinfo.getDynamicObjectCollection("costaccountentry").add(acctinfo);
}else{
//已存在做更新 编号名称长编号名称科目类别等
acctinfo.set("caentry_number", number);
@ -119,8 +145,10 @@ public class DobeDWaccountTask extends AbstractTask implements Plugin {
acctinfo.set("caentry_taxrate", taxrate);
acctinfo.set("caentry_isleaf", isleaf);
acctinfo.set("caentry_level", level);
SaveServiceHelper.update(acctinfo);
// SaveServiceHelper.update(acctinfo);
}
}
}
// SaveServiceHelper.save(new DynamicObject[]{billinfo});
}
}

View File

@ -14,7 +14,7 @@ public class DobeDWUtils {
//数仓接口的appCode 可能会更换
public static final String appCode = "AppCode 895894e0-73de-40a9-9b1f-e87fe35a13fd";
//数仓接口地址基本信息
public static final String dwUrl = "http://106.14.120.215:8080/webroot/service/publish/7e9d818c-43c0-47cf-ad4c-40c66b92bb34/";
public static final String dwUrl = "https://wedc.dobechina.com/webroot/service/publish/7e9d818c-43c0-47cf-ad4c-40c66b92bb34/";
public static final MediaType MTJSON = MediaType.get("application/json");
//授权模式客户端模式为client密码模式为password
@ -42,7 +42,7 @@ public class DobeDWUtils {
public static String getDateString(Date billDate){
//创建一个SimpleDateFormat对象定义目标日期格式
SimpleDateFormat targetFormat = new SimpleDateFormat("yyyy-MM-dd");
SimpleDateFormat targetFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
//格式化Date对象为新的字符串格式
if(billDate == null){
return targetFormat.format(new Date());
@ -125,6 +125,43 @@ public class DobeDWUtils {
return json_body.toJSONString();
}
public static String getTestAcct(){
JSONObject json_body = new JSONObject();
json_body.put("totalNum","1");
json_body.put("projectnumber","test0667");
JSONObject json_detail = new JSONObject();
json_detail.put("accid","100003");
json_detail.put("parentid","");
json_detail.put("number","01");
json_detail.put("name","ziji科目1");
json_detail.put("longnumber","01");
json_detail.put("longname","ziji科目1");
json_detail.put("ciaccountflag","1");
json_detail.put("taxrate","6");
json_detail.put("isleaf","1");
json_detail.put("level","2");
JSONArray array = new JSONArray();
array.add(json_detail);
json_detail = new JSONObject();
json_detail.put("accid","100004");
json_detail.put("parentid","100003");
json_detail.put("number","02");
json_detail.put("name","ziji科目2");
json_detail.put("longnumber","02");
json_detail.put("longname","ziji科目2");
json_detail.put("ciaccountflag","1");
json_detail.put("taxrate","3");
json_detail.put("isleaf","1");
json_detail.put("level","2");
array.add(json_detail);
json_body.put("data",array);
return json_body.toJSONString();
}
public static String getTestProject(){
JSONObject json_body = new JSONObject();
json_body.put("totalNum","1");