天眼查供应商变更优化

This commit is contained in:
weiyunlong 2024-11-24 17:49:22 +08:00
parent 7e7d1107d5
commit a9e3555979
2 changed files with 279 additions and 3 deletions

View File

@ -1,14 +1,25 @@
package shkd.repc.resm.formplugin;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.dataentity.entity.DynamicObjectCollection;
import kd.bos.form.events.AfterDoOperationEventArgs;
import kd.bos.form.plugin.AbstractFormPlugin;
import kd.bos.orm.query.QCP;
import kd.bos.orm.query.QFilter;
import kd.bos.servicehelper.BusinessDataServiceHelper;
import kd.bos.servicehelper.operation.SaveServiceHelper;
import shkd.utils.DobeDWUtils;
import shkd.utils.TycUtils;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.EventObject;
import static shkd.utils.TycUtils.*;
/**
* 供应商变更
* qeug_resm_change_supp_ext
@ -57,6 +68,235 @@ public class SupplierChangeFormPlugin extends AbstractFormPlugin {
this.getView().updateView("qeug_infocheckentry");
}
/**
* 基本信息
*/
getModel().setValue("qeug_legalpersonn",supplier.getString("qeug_legalpersonn"));
getModel().setValue("qeug_regnumber",supplier.getString("qeug_regnumber"));
getModel().setValue("qeug_orgnumber",supplier.getString("qeug_orgnumber"));
getModel().setValue("qeug_businessduration",supplier.getString("qeug_businessduration"));
getModel().setValue("qeug_reglocation",supplier.getString("qeug_reglocation"));
getModel().setValue("qeug_reginstitute",supplier.getString("qeug_reginstitute"));
getModel().setValue("qeug_regstatus",supplier.getString("qeug_regstatus"));
getModel().setValue("qeug_websitelist",supplier.getString("qeug_websitelist"));
getModel().setValue("qeug_photodate",supplier.getDate("qeug_photodate"));
getModel().setValue("qeug_creditcode",supplier.getString("qeug_creditcode"));
getModel().setValue("qeug_industry",supplier.getString("qeug_industry"));
getModel().setValue("qeug_bases",supplier.getString("qeug_bases"));
getModel().setValue("qeug_regcapital",supplier.getString("qeug_regcapital"));
getModel().setValue("qeug_companyorgtype",supplier.getString("qeug_companyorgtype"));
getModel().setValue("qeug_estiblishtime",supplier.getDate("qeug_estiblishtime"));
getModel().setValue("qeug_canceldate",supplier.getString("qeug_canceldate"));
getModel().setValue("qeug_city",supplier.getString("qeug_city"));
getModel().setValue("qeug_phonenumber",supplier.getString("qeug_phonenumber"));
getModel().setValue("qeug_headoffice",supplier.getString("qeug_headoffice"));
getModel().setValue("qeug_historynames",supplier.getString("qeug_historynames"));
getModel().setValue("qeug_socialstaffnum",supplier.getString("qeug_socialstaffnum"));
getModel().setValue("qeug_controllingperson",supplier.getString("qeug_controllingperson"));
getModel().setValue("qeug_businessscopes",supplier.getString("qeug_businessscopes"));
// getModel().setValue("qeug_verify",supplier.getString("qeug_verify"));//企业三要素验证
this.getView().updateView("qeug_legalpersonn");
this.getView().updateView("qeug_regnumber");
this.getView().updateView("qeug_orgnumber");
this.getView().updateView("qeug_businessduration");
this.getView().updateView("qeug_reglocation");
this.getView().updateView("qeug_reginstitute");
this.getView().updateView("qeug_regstatus");
this.getView().updateView("qeug_websitelist");
this.getView().updateView("qeug_photodate");
this.getView().updateView("qeug_creditcode");
this.getView().updateView("qeug_industry");
this.getView().updateView("qeug_bases");
this.getView().updateView("qeug_regcapital");
this.getView().updateView("qeug_companyorgtype");
this.getView().updateView("qeug_estiblishtime");
this.getView().updateView("qeug_canceldate");
this.getView().updateView("qeug_city");
this.getView().updateView("qeug_phonenumber");
this.getView().updateView("qeug_headoffice");
this.getView().updateView("qeug_historynames");
this.getView().updateView("qeug_socialstaffnum");
this.getView().updateView("qeug_controllingperson");
this.getView().updateView("qeug_businessscopes");
// this.getView().updateView("qeug_verify");
}
}
@Override
public void afterDoOperation(AfterDoOperationEventArgs afterDoOperationEventArgs) {
super.afterDoOperation(afterDoOperationEventArgs);
String operateKey = afterDoOperationEventArgs.getOperateKey();
if ("query_tyc".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_change_supplier = BusinessDataServiceHelper.loadSingle(pkValue, "resm_change_supplier");
if (null != resm_change_supplier) {
queryTyc(resm_change_supplier, 2);
showPreaudits(resm_change_supplier);
this.getView().invokeOperation("refresh");
}
}
}
/**
* 天眼查查询
* @param supplier 供应商实体
* @param type 0:潜在/1:正式/2:变更
*/
private void queryTyc(DynamicObject supplier, Integer type) {
String tyc_Test_keyword = supplier.getString("name");//供应商名称
try {
/**
* 1.企业基本信息含主要人员_819 ?keyword=中航重机股份有限公司
*/
String tyc_Baseinfo = TycUtils.executeGet(TycUtils.tyc_Token, TycUtils.tyc_Baseinfo
+ "?keyword=" + tyc_Test_keyword, tyc_Test_keyword, "企业基本信息含主要人员_819",type);
JSONObject tyc_Baseinfo_results = JSONObject.parseObject(tyc_Baseinfo);
if (null != tyc_Baseinfo_results) {
JSONObject tyc_Baseinfo_result = (JSONObject) tyc_Baseinfo_results.get("result");
if (null != tyc_Baseinfo_result) {
//法人
String legalPersonName = (String) tyc_Baseinfo_result.get("legalPersonName");
//注册号
String regNumber = (String) tyc_Baseinfo_result.get("regNumber");
//组织机构代码
String orgNumber = (String) tyc_Baseinfo_result.get("orgNumber");
//营业期限(逻辑待定)--经营开始时间-经营结束时间
String businessduration = "";
Long fromTime = (Long) tyc_Baseinfo_result.get("fromTime");//开始时间
Long toTime = (Long) tyc_Baseinfo_result.get("toTime");//结束时间
if (null != fromTime && null != toTime) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
businessduration = sdf.format(new Date(fromTime)) + "" + sdf.format(new Date(toTime));//营业期限
}
//注册地址
String regLocation = (String) tyc_Baseinfo_result.get("regLocation");
//登记机关
String regInstitute = (String) tyc_Baseinfo_result.get("regInstitute");
//经营范围(2000 文本)
String businessScope = (String) tyc_Baseinfo_result.get("businessScope");
//企业状态经营状态
String regStatus = (String) tyc_Baseinfo_result.get("regStatus");
//网址
String websiteList = (String) tyc_Baseinfo_result.get("websiteList");
//todo 发照日期
//统一社会信用代码
String creditCode = (String) tyc_Baseinfo_result.get("creditCode");
//行业
String industry = (String) tyc_Baseinfo_result.get("industry");
//省份简称
String base = (String) tyc_Baseinfo_result.get("base");
String provinceName = getProvinceName(base);
//注册资本
String regCapital = (String) tyc_Baseinfo_result.get("regCapital");
//企业联系电话
//企业联系方式
String phoneNumber = (String) tyc_Baseinfo_result.get("phoneNumber");
//企业类型
String companyOrgType = (String) tyc_Baseinfo_result.get("companyOrgType");
//成立日期
String estiblishtime = "";
Long estiblishTime = (Long) tyc_Baseinfo_result.get("estiblishTime");
if (null != estiblishTime) {
estiblishtime = convertTimestampToDate(estiblishTime);
}
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
//注销日期
String canceldate = "";
Long cancelDate = (Long) tyc_Baseinfo_result.get("cancelDate");
if (null != cancelDate) {
canceldate = convertTimestampToDate(cancelDate);
}
//
String city = (String) tyc_Baseinfo_result.get("city");
//曾用名
String historyNames = (String) tyc_Baseinfo_result.get("historyNames");
//参保人数
Integer socialStaffNum = (Integer) tyc_Baseinfo_result.get("socialStaffNum");
//主要人员列表
DynamicObjectCollection qeugEntryentity = supplier.getDynamicObjectCollection("qeug_entryentity");
qeugEntryentity.clear();
JSONObject staffListS = tyc_Baseinfo_result.getJSONObject("staffList");
if (null != staffListS) {
JSONArray staffLists = staffListS.getJSONArray("result");
if (null != staffLists) {
for (int i = 0; i < staffLists.size(); i++) {
DynamicObject add = qeugEntryentity.addNew();
JSONObject staffList = (JSONObject) staffLists.get(i);
String name = staffList.getString("name");//主要人员姓名
String typeJoin = "";//主要人员职位
JSONArray typeJoins = staffList.getJSONArray("typeJoin");
if (null != typeJoins) {
StringBuilder sb = new StringBuilder();
for (int j = 0; j < typeJoins.size(); j++) {
sb.append((String) typeJoins.get(j));
if (j < typeJoins.size() - 1) {
sb.append(",");
}
}
typeJoin = sb.toString();
}
add.set("seq", i);
add.set("qeug_personnelname", name);//主要人员姓名
add.set("qeug_position", typeJoin);//主要人员职位
}
}
}
//设置到供应商中
supplier.set("qeug_legalpersonn", legalPersonName);//法人代表
supplier.set("qeug_regnumber", regNumber);//企业注册号
supplier.set("qeug_orgnumber", orgNumber);//组织机构代码
supplier.set("qeug_businessduration", businessduration);//营业期限
supplier.set("qeug_reglocation", regLocation);//公司地址
supplier.set("qeug_reginstitute", regInstitute);//登记机关
supplier.set("qeug_regstatus", regStatus);//经营状态
supplier.set("qeug_websitelist", websiteList);//企业网站
try {
Date parse = sdf.parse(estiblishtime);
supplier.set("qeug_photodate", parse);//发照日期
supplier.set("qeug_estiblishtime", parse);//成立日期
} catch (ParseException ex) {
throw new RuntimeException(ex);
}
supplier.set("qeug_creditcode", creditCode);//统一社会信用代码
supplier.set("qeug_industry", industry);//所属行业
supplier.set("qeug_bases", provinceName);//
supplier.set("qeug_regcapital", regCapital);//注册资本
supplier.set("qeug_companyorgtype", companyOrgType);//企业类型
supplier.set("qeug_canceldate", canceldate);//注销日期
supplier.set("qeug_city", city);//城市
supplier.set("qeug_phonenumber", phoneNumber);//联系电话
supplier.set("qeug_historynames", historyNames);//曾用名
supplier.set("qeug_socialstaffnum", socialStaffNum);//参保人数
supplier.set("qeug_businessscopes", businessScope);//经营范围
SaveServiceHelper.save(new DynamicObject[]{supplier});
}
}
// if (type == 1) {
// supplier.set("qeug_istyccheck",true);//是否查询天眼查(正式供应商)
// SaveServiceHelper.save(new DynamicObject[]{supplier});
// }
} catch (Exception ex) {
DobeDWUtils.saveLog(tyc_Test_keyword + "_变更",
"天眼查", tyc_Test_keyword, ex.getMessage() + "\n" +
ex.getStackTrace()[0].getClassName() + "\n" +
ex.getStackTrace()[0].getMethodName() + "\n" +
ex.getStackTrace()[0].getLineNumber(),
false, "query_tyc");
}
}
}

View File

@ -100,6 +100,7 @@ public class TycUtils {
* @param token token
* @param supname 供应商name
* @param apiname 接口name
* @param type 0:潜在/1:正式/2:变更
* @return 返回接口数据
*/
public static String executeGet(String token,String url,String supname,String apiname,Integer type) {
@ -120,20 +121,55 @@ public class TycUtils {
resultData = response.body().string();
JSONObject resultData1 = JSONObject.parseObject(resultData);
if (null != resultData1) {
JSONObject result = (JSONObject)resultData1.get("result");
String logType = (type == 0) ? "潜在" : "正式";
JSONObject result = (JSONObject) resultData1.get("result");
String logType = "";
// 根据type的值设置logType
switch (type) {
case 0:
logType = "潜在";
break;
case 1:
logType = "正式";
break;
case 2:
logType = "变更";
break;
default:
logType = "未定义"; // 可选的默认值
break;
}
DobeDWUtils.saveLog(supname + "_" + logType,
"天眼查", apiname + "\n" + request.toString(), resultData.toString(),
null != result, "query_tyc");
}
} catch (Exception e) {
String logType = (type == 0) ? "潜在" : "正式";
String logType = "";
// 根据type的值设置logType
switch (type) {
case 0:
logType = "潜在";
break;
case 1:
logType = "正式";
break;
case 2:
logType = "变更";
break;
default:
logType = "未定义"; // 可选的默认值
break;
}
DobeDWUtils.saveLog(supname + "_" + logType,
"天眼查", apiname + "\n" + request.toString(), e.getMessage(),
false, "query_tyc");
}
return resultData;
}
/**