外网供应商注册携带到潜在供应商,供应商画像动态加载正式供应商信息,优化所有关于天眼查逻辑(比对字段)

This commit is contained in:
weiyunlong 2024-11-15 17:36:04 +08:00
parent 6625d3699a
commit f0c3740510
6 changed files with 428 additions and 1045 deletions

View File

@ -17,32 +17,32 @@ public class RegisteredFormPlugin extends AbstractFormPlugin {
public void afterDoOperation(AfterDoOperationEventArgs args) { public void afterDoOperation(AfterDoOperationEventArgs args) {
super.afterDoOperation(args); super.afterDoOperation(args);
String operateKey = args.getOperateKey(); String operateKey = args.getOperateKey();
switch (operateKey) { // switch (operateKey) {
// 注册完成时将信息携带到潜在供应商 // // 注册完成时将信息携带到潜在供应商
case "finishregistered": // case "finishregistered":
DynamicObject dataEntity = this.getModel().getDataEntity(); // DynamicObject dataEntity = this.getModel().getDataEntity();
//注册供应商 // //注册供应商
DynamicObject resp_registered = BusinessDataServiceHelper.loadSingle(dataEntity.getPkValue(), "resp_registered"); // DynamicObject resp_registered = BusinessDataServiceHelper.loadSingle(dataEntity.getPkValue(), "resp_registered");
if (null != resp_registered) { // if (null != resp_registered) {
DynamicObject regSupplier = resp_registered.getDynamicObject("regsuppplier"); // DynamicObject regSupplier = resp_registered.getDynamicObject("regsuppplier");
//潜在供应商 // //潜在供应商
if (regSupplier != null) { // if (regSupplier != null) {
regSupplier = BusinessDataServiceHelper.loadSingle(regSupplier.getPkValue(), "resm_regsupplier"); // regSupplier = BusinessDataServiceHelper.loadSingle(regSupplier.getPkValue(), "resm_regsupplier");
regSupplier.set("qeug_controllingperses",resp_registered.getString("qeug_controllingperses"));//公司实际控制人/股份公司 // regSupplier.set("qeug_controllingperses",resp_registered.getString("qeug_controllingperses"));//公司实际控制人/股份公司
regSupplier.set("qeug_regnumberes",resp_registered.getString("qeug_regnumberes"));//企业注册号 // regSupplier.set("qeug_regnumberes",resp_registered.getString("qeug_regnumberes"));//企业注册号
regSupplier.set("qeug_orgnumberes",resp_registered.getString("qeug_orgnumberes"));//组织机构代码 // regSupplier.set("qeug_orgnumberes",resp_registered.getString("qeug_orgnumberes"));//组织机构代码
regSupplier.set("qeug_regstatuses",resp_registered.getString("qeug_regstatuses"));//经营状态 // regSupplier.set("qeug_regstatuses",resp_registered.getString("qeug_regstatuses"));//经营状态
regSupplier.set("qeug_linkman",resp_registered.getString("qeug_linkman"));//外部联系人 // regSupplier.set("qeug_linkman",resp_registered.getString("qeug_linkman"));//外部联系人
regSupplier.set("recommender",resp_registered.getDynamicObject("recommender"));//外部联系人 // regSupplier.set("recommender",resp_registered.getDynamicObject("recommender"));//外部联系人
SaveServiceHelper.save(new DynamicObject[]{regSupplier}); // SaveServiceHelper.save(new DynamicObject[]{regSupplier});
DobeDWUtils.saveLog("注册供应商", // DobeDWUtils.saveLog("注册供应商",
"注册供应商",null, null, // "注册供应商",null, null,
true,"注册供应商成功带入潜在供应商"); // true,"注册供应商成功带入潜在供应商");
} // }
} // }
break; // break;
default: // default:
break; // break;
} // }
} }
} }

View File

@ -5,6 +5,7 @@ import kd.bos.bill.OperationStatus;
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.dataentity.entity.OrmLocaleValue;
import kd.bos.dataentity.resource.ResManager; import kd.bos.dataentity.resource.ResManager;
import kd.bos.dataentity.utils.StringUtils; import kd.bos.dataentity.utils.StringUtils;
import kd.bos.entity.EntityMetadataCache; import kd.bos.entity.EntityMetadataCache;
@ -20,6 +21,7 @@ import kd.bos.orm.query.QFilter;
import kd.bos.orm.util.CollectionUtils; import kd.bos.orm.util.CollectionUtils;
import kd.bos.servicehelper.BusinessDataServiceHelper; import kd.bos.servicehelper.BusinessDataServiceHelper;
import kd.bos.servicehelper.operation.OperationServiceHelper; import kd.bos.servicehelper.operation.OperationServiceHelper;
import kd.bos.servicehelper.operation.SaveServiceHelper;
import kd.repc.common.enums.PersontypeEnum; import kd.repc.common.enums.PersontypeEnum;
import kd.repc.common.enums.resm.RegSupplierStatusEnum; import kd.repc.common.enums.resm.RegSupplierStatusEnum;
import kd.repc.common.util.PermissionUtils; import kd.repc.common.util.PermissionUtils;
@ -28,6 +30,7 @@ import kd.repc.common.util.resm.SupplierStrategyUtil;
//import kd.repc.common.util.resm.SupplierStrategyUtil; //import kd.repc.common.util.resm.SupplierStrategyUtil;
//import kd.repc.common.util.MultiLangEnumBridge; //import kd.repc.common.util.MultiLangEnumBridge;
import java.text.SimpleDateFormat;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -84,10 +87,98 @@ public class TycQzSupplierFormPlugin extends AbstractFormPlugin {
this.showPreaudit(args); this.showPreaudit(args);
} }
} }
// if ("query_tyc".equals(operateKey)) {
// this.getView().invokeOperation("save");
// }
} }
@Override
public void afterDoOperation(AfterDoOperationEventArgs afterDoOperationEventArgs) {
super.afterDoOperation(afterDoOperationEventArgs);
String operateKey = afterDoOperationEventArgs.getOperateKey();
if ("query_tyc".equals(operateKey) || "preaudit".equals(operateKey)) {
Object pkValue = this.getModel().getDataEntity().getPkValue();
if (pkValue instanceof Number) {
long pkLongValue = ((Number) pkValue).longValue(); // 转换为 long
if (pkLongValue == 0) {
this.getView().showMessage("请先保存单据");
return;
}
}
DynamicObject resm_regsupplier = BusinessDataServiceHelper.loadSingle(pkValue, "resm_regsupplier");
if ("preaudit".equals(operateKey) && resm_regsupplier != null) {
DynamicObjectCollection qeug_infocheckentry = resm_regsupplier.getDynamicObjectCollection("qeug_infocheckentry");
if (qeug_infocheckentry.size() > 0) {
return; // 如果存在核对项直接返回
}
}
showPreaudit();
this.getView().invokeOperation("refresh");
}
}
private void showPreaudit() {
Object pkValue = this.getModel().getDataEntity().getPkValue();
DynamicObject resm_regsupplier = BusinessDataServiceHelper.loadSingle(pkValue, "resm_regsupplier");
if (resm_regsupplier != null) {
DynamicObjectCollection qeug_infocheckentry = resm_regsupplier.getDynamicObjectCollection("qeug_infocheckentry");
qeug_infocheckentry.clear();
DynamicObject[] qeugTycInfochecks = BusinessDataServiceHelper.load("qeug_tyc_infocheck", "number,name,qeug_apifields", null);
SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd");
for (int i = 0; i < qeugTycInfochecks.length; i++) {
DynamicObject qeugTycInfocheck = qeugTycInfochecks[i];
DynamicObject add = qeug_infocheckentry.addNew();
add.set("seq", i);
add.set("qeug_bsfield", qeugTycInfocheck.getString("number")); // 核对字段标识
add.set("qeug_bsfieldname", qeugTycInfocheck.getString("name")); // 核对项目名称
add.set("qeug_bsinput", getBsInput(resm_regsupplier, qeugTycInfocheck.getString("number"), sd)); // 录入内容
String qeugApifields = qeugTycInfocheck.getString("qeug_apifields"); // 接口字段标识
add.set("qeug_apifield", qeugApifields); // 接口字段标识
add.set("qeug_queryresult", getQueryResult(resm_regsupplier, qeugApifields, sd)); // 接口查询结果
// 判断是否匹配
String bsinput = add.getString("qeug_bsinput");
String queryresult = add.getString("qeug_queryresult");
add.set("qeug_issame", bsinput.equals(queryresult) ? "1" : "0"); // 0: 不匹配 1: 匹配
}
SaveServiceHelper.save(new DynamicObject[]{resm_regsupplier});
}
}
// 获取录入内容
private String getBsInput(DynamicObject resm_regsupplier, String number, SimpleDateFormat sd) {
Object obj = resm_regsupplier.get(number);
return formatFieldValue(obj, sd);
}
// 获取查询结果
private String getQueryResult(DynamicObject resm_regsupplier, String qeugApifields, SimpleDateFormat sd) {
Object obj = resm_regsupplier.get(qeugApifields);
return formatFieldValue(obj, sd);
}
// 格式化字段值
private String formatFieldValue(Object obj, SimpleDateFormat sd) {
if (obj instanceof Date) {
return sd.format((Date) obj);
} else if (obj instanceof String) {
return (String) obj;
} else if (obj instanceof Long) {
return sd.format(new Date((Long) obj));
}else if(obj instanceof OrmLocaleValue) {
OrmLocaleValue o = (OrmLocaleValue) obj;
return (String)o.get("zh_CN");
}
return ""; // 返回空字符串表示无效值
}
protected boolean checkIsCanDo(BeforeDoOperationEventArgs args) { protected boolean checkIsCanDo(BeforeDoOperationEventArgs args) {
if (!SupplierStrategyUtil.isPreTrial()) { if (!SupplierStrategyUtil.isPreTrial()) {
return true; return true;

View File

@ -2,12 +2,16 @@ package shkd.repc.resm.formplugin;
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.dataentity.entity.OrmLocaleValue;
import kd.bos.form.events.AfterDoOperationEventArgs;
import kd.bos.form.plugin.AbstractFormPlugin; import kd.bos.form.plugin.AbstractFormPlugin;
import kd.bos.orm.query.QCP; import kd.bos.orm.query.QCP;
import kd.bos.orm.query.QFilter; import kd.bos.orm.query.QFilter;
import kd.bos.servicehelper.BusinessDataServiceHelper; import kd.bos.servicehelper.BusinessDataServiceHelper;
import kd.bos.servicehelper.operation.SaveServiceHelper; import kd.bos.servicehelper.operation.SaveServiceHelper;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.EventObject; import java.util.EventObject;
/** /**
@ -390,4 +394,69 @@ public class TycSupplieFormPlugin extends AbstractFormPlugin {
} }
// } // }
} }
@Override
public void afterDoOperation(AfterDoOperationEventArgs afterDoOperationEventArgs) {
super.afterDoOperation(afterDoOperationEventArgs);
String operateKey = afterDoOperationEventArgs.getOperateKey();
if ("query_tyc".equals(operateKey)) {
DynamicObject dynamicObject = this.getModel().getDataEntity();
Long supplierid = dynamicObject.getLong("supplierid");
QFilter q1 = new QFilter("id", QCP.equals, supplierid);
DynamicObject supplier_t = BusinessDataServiceHelper.loadSingle("resm_official_supplier", new QFilter[]{q1});
if (null != supplier_t) {
/**
* -------------------------------------------基本信息核对------------------------------------------
*/
DynamicObjectCollection qeug_infocheckentry = supplier_t.getDynamicObjectCollection("qeug_infocheckentry");
qeug_infocheckentry.clear();
DynamicObject[] qeugTycInfochecks = BusinessDataServiceHelper.load("qeug_tyc_infocheck",
"number,name,qeug_apifields", null);
for (int i = 0; i < qeugTycInfochecks.length; i++) {
DynamicObject qeugTycInfocheck = qeugTycInfochecks[i];
DynamicObject add = qeug_infocheckentry.addNew();
add.set("seq",i);
String number = qeugTycInfocheck.getString("number");
add.set("qeug_bsfield",number);//核对字段标识
add.set("qeug_bsfieldname",qeugTycInfocheck.getString("name"));//核对项目名称
String bsinput = "";//录入内容
Object obj = supplier_t.get(number);
SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd");
if (obj instanceof Date) {
Date date = (Date) obj;
bsinput = sd.format(date);
} else if(obj instanceof String) {
bsinput =(String) obj;
}else if(obj instanceof OrmLocaleValue) {
OrmLocaleValue o = (OrmLocaleValue) obj;
bsinput = o.get("zh_CN");
}
add.set("qeug_bsinput",bsinput);
String qeugApifields = qeugTycInfocheck.getString("qeug_apifields");//接口字段标识
add.set("qeug_apifield",qeugApifields);//接口字段标识
String queryresult = "";//接口查询结果
Object obj1 = dynamicObject.get(qeugApifields);
if (obj1 instanceof Date) {
Date date = (Date) obj1;
queryresult = sd.format(date);
} else if(obj1 instanceof String) {
queryresult =(String) obj1;
} else if(obj1 instanceof Long) {
Date date = new Date((Long) obj1);
queryresult = sd.format(date);
}
add.set("qeug_queryresult",queryresult);
if (bsinput.equals(queryresult)) {
add.set("qeug_issame","1");//0:不匹配 1:匹配
}else {
add.set("qeug_issame","0");
}
}
SaveServiceHelper.save(new DynamicObject[]{supplier_t});
}
this.getView().invokeOperation("refresh");
}
}
} }

View File

@ -0,0 +1,47 @@
package shkd.repc.resm.opplugin;
import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.entity.plugin.AbstractOperationServicePlugIn;
import kd.bos.entity.plugin.args.AfterOperationArgs;
import kd.bos.servicehelper.BusinessDataServiceHelper;
import kd.bos.servicehelper.operation.SaveServiceHelper;
import shkd.utils.DobeDWUtils;
/**
* 注册完成时将信息携带到潜在供应商
* qeug_resp_registered_ext
*/
public class RegisteredFinishregOPPlugin extends AbstractOperationServicePlugIn {
@Override
public void afterExecuteOperationTransaction(AfterOperationArgs e) {
super.afterExecuteOperationTransaction(e);
String operationKey = e.getOperationKey();
if ("finishregistered".equals(operationKey)) {
// DynamicObject dataEntity = this.getModel().getDataEntity();
DynamicObject[] dataEntities1 = e.getDataEntities();
DynamicObject dataEntity = dataEntities1[0];
//注册供应商
DynamicObject resp_registered = BusinessDataServiceHelper.loadSingle(dataEntity.getPkValue(), "resp_registered");
if (null != resp_registered) {
DynamicObject regSupplier = resp_registered.getDynamicObject("regsuppplier");
//潜在供应商
if (regSupplier != null) {
regSupplier = BusinessDataServiceHelper.loadSingle(regSupplier.getPkValue(), "resm_regsupplier");
regSupplier.set("qeug_controllingperses",resp_registered.getString("qeug_controllingperses"));//公司实际控制人/股份公司
regSupplier.set("qeug_regnumberes",resp_registered.getString("qeug_regnumberes"));//企业注册号
regSupplier.set("qeug_orgnumberes",resp_registered.getString("qeug_orgnumberes"));//组织机构代码
regSupplier.set("qeug_regstatuses",resp_registered.getString("qeug_regstatuses"));//经营状态
regSupplier.set("qeug_linkman",resp_registered.getString("qeug_linkman"));//外部联系人
regSupplier.set("recommender",resp_registered.getDynamicObject("recommender"));//外部联系人
SaveServiceHelper.save(new DynamicObject[]{regSupplier});
DobeDWUtils.saveLog("注册供应商",
"注册供应商",null, null,
true,"注册供应商成功带入潜在供应商");
}
}
}
}
}

View File

@ -57,7 +57,6 @@ public class TycSupplierSearchOPPlugin extends AbstractOperationServicePlugIn {
if (null != supplier_t) { if (null != supplier_t) {
queryTyc(supplier_t); queryTyc(supplier_t);
} }
} }
//todo 测试定时任务代码 //todo 测试定时任务代码
//正式供应商列表批量查询 //正式供应商列表批量查询
@ -74,12 +73,67 @@ public class TycSupplierSearchOPPlugin extends AbstractOperationServicePlugIn {
DynamicObject supplier = BusinessDataServiceHelper.loadSingle("resm_official_supplier", new QFilter[]{q1}); DynamicObject supplier = BusinessDataServiceHelper.loadSingle("resm_official_supplier", new QFilter[]{q1});
if (null != supplier) { if (null != supplier) {
logger.info(name+"3333333正式供应商列表批量查询"); logger.info(name+"3333333正式供应商列表批量查询");
queryTyc(supplier); queryTyc(supplier);
dbTYC(supplier);//比对天眼查数据
} }
} }
} }
} }
public void dbTYC(DynamicObject supplier_zs){
/**
* -------------------------------------------基本信息核对------------------------------------------
*/
DynamicObjectCollection qeug_infocheckentry = supplier_zs.getDynamicObjectCollection("qeug_infocheckentry");
qeug_infocheckentry.clear();
DynamicObject[] qeugTycInfochecks = BusinessDataServiceHelper.load("qeug_tyc_infocheck",
"number,name,qeug_apifields", null);
for (int i = 0; i < qeugTycInfochecks.length; i++) {
DynamicObject qeugTycInfocheck = qeugTycInfochecks[i];
DynamicObject add = qeug_infocheckentry.addNew();
add.set("seq",i);
String number = qeugTycInfocheck.getString("number");
add.set("qeug_bsfield",number);//核对字段标识
add.set("qeug_bsfieldname",qeugTycInfocheck.getString("name"));//核对项目名称
String bsinput = "";//录入内容
Object obj = supplier_zs.get(number);
SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd");
if (obj instanceof Date) {
Date date = (Date) obj;
bsinput = sd.format(date);
} else if(obj instanceof String) {
bsinput =(String) obj;
}else if(obj instanceof OrmLocaleValue) {
OrmLocaleValue o = (OrmLocaleValue) obj;
bsinput = o.get("zh_CN");
}
add.set("qeug_bsinput",bsinput);
String qeugApifields = qeugTycInfocheck.getString("qeug_apifields");//接口字段标识
add.set("qeug_apifield",qeugApifields);//接口字段标识
String queryresult = "";//接口查询结果
Object obj1 = supplier_zs.get(qeugApifields);
if (obj1 instanceof Date) {
Date date = (Date) obj1;
queryresult = sd.format(date);
} else if(obj1 instanceof String) {
queryresult =(String) obj1;
} else if(obj1 instanceof Long) {
Date date = new Date((Long) obj1);
queryresult = sd.format(date);
}
add.set("qeug_queryresult",queryresult);
if (bsinput.equals(queryresult)) {
add.set("qeug_issame","1");//0:不匹配 1:匹配
}else {
add.set("qeug_issame","0");
}
}
SaveServiceHelper.save(new DynamicObject[]{supplier_zs});
}
public static void queryTyc(DynamicObject supplier_zs) { public static void queryTyc(DynamicObject supplier_zs) {
DynamicObject dynamicObject = supplier_zs;//正式供应商 DynamicObject dynamicObject = supplier_zs;//正式供应商
// DynamicObject supplier_t = supplier_zs;//正式供应商 // DynamicObject supplier_t = supplier_zs;//正式供应商
@ -211,70 +265,7 @@ public class TycSupplierSearchOPPlugin extends AbstractOperationServicePlugIn {
dynamicObject.set("qeug_businessscopes",businessScope);//经营范围 dynamicObject.set("qeug_businessscopes",businessScope);//经营范围
SaveServiceHelper.save(new DynamicObject[]{dynamicObject}); SaveServiceHelper.save(new DynamicObject[]{dynamicObject});
/**
* -------------------------------------------基本信息核对------------------------------------------
*/
DynamicObjectCollection qeug_infocheckentry = dynamicObject.getDynamicObjectCollection("qeug_infocheckentry");
qeug_infocheckentry.clear();
DynamicObject[] qeugTycInfochecks = BusinessDataServiceHelper.load("qeug_tyc_infocheck",
"number,name,qeug_apifields", null);
for (int i = 0; i < qeugTycInfochecks.length; i++) {
DynamicObject qeugTycInfocheck = qeugTycInfochecks[i];
DynamicObject add = qeug_infocheckentry.addNew();
add.set("seq",i);
String number = qeugTycInfocheck.getString("number");
add.set("qeug_bsfield",number);//核对字段标识
add.set("qeug_bsfieldname",qeugTycInfocheck.getString("name"));//核对项目名称
String bsinput = "";//录入内容
Object obj = dynamicObject.get(number);
SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd");
if (obj instanceof Date) {
Date date = (Date) obj;
bsinput = sd.format(date);
} else if(obj instanceof String) {
bsinput =(String) obj;
}else if(obj instanceof OrmLocaleValue) {
OrmLocaleValue o = (OrmLocaleValue) obj;
bsinput = o.get("zh_CN");
}
add.set("qeug_bsinput",bsinput);
String qeugApifields = qeugTycInfocheck.getString("qeug_apifields");//接口字段标识
add.set("qeug_apifield",qeugApifields);//接口字段标识
String queryresult = "";//接口查询结果
Object obj1 = tyc_Baseinfo_result.get(qeugApifields);
if (obj1 instanceof Date) {
Date date = (Date) obj1;
queryresult = sd.format(date);
} else if(obj1 instanceof String) {
queryresult =(String) obj1;
} else if(obj1 instanceof Long) {
Date date = new Date((Long) obj1);
queryresult = sd.format(date);
}
add.set("qeug_queryresult",queryresult);
if (bsinput.equals(queryresult)) {
add.set("qeug_issame","1");//0:不匹配 1:匹配
}else {
add.set("qeug_issame","0");
}
}
SaveServiceHelper.save(new DynamicObject[]{dynamicObject});
} }
// else {
// //接口调用失败
// Integer error_code = (Integer)tyc_Baseinfo_results.get("error_code");//状态码
// if (error_code.equals(300003)) {
// String reason = (String)tyc_Baseinfo_results.get("reason");//错误信息
// OperateErrorInfo operateErrorInfo = new OperateErrorInfo();
// operateErrorInfo.setMessage(reason + ",请联系管理员");
// operateErrorInfo.setErrorLevel(ErrorLevel.Error.name());
// operateErrorInfo.setPkValue(dynamicObject.getPkValue());
// this.operationResult.addErrorInfo(operateErrorInfo);
// logger.error("天眼查接口调用失败,错误码:" + error_code + ",原因:" + reason);
// }
// }
} }