2024-11-04 15:32:41 +00:00
|
|
|
|
package shkd.repc.resm.opplugin;
|
|
|
|
|
|
|
|
|
|
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.entity.operate.result.OperateErrorInfo;
|
|
|
|
|
import kd.bos.entity.plugin.AbstractOperationServicePlugIn;
|
|
|
|
|
import kd.bos.entity.plugin.args.AfterOperationArgs;
|
|
|
|
|
import kd.bos.entity.validate.ErrorLevel;
|
|
|
|
|
import kd.bos.logging.Log;
|
|
|
|
|
import kd.bos.logging.LogFactory;
|
|
|
|
|
import kd.bos.orm.query.QCP;
|
|
|
|
|
import kd.bos.orm.query.QFilter;
|
|
|
|
|
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
|
|
|
|
import kd.bos.util.HttpClientUtils;
|
|
|
|
|
import kd.bos.util.StringUtils;
|
|
|
|
|
import shkd.repc.recon.opplugin.TestOPPlugin;
|
|
|
|
|
import shkd.utils.OAUtils;
|
|
|
|
|
|
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
|
import java.util.Date;
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
2024-11-12 04:09:33 +00:00
|
|
|
|
import static shkd.utils.OAUtils.pushOASupplier;
|
|
|
|
|
|
2024-11-04 15:32:41 +00:00
|
|
|
|
/**
|
|
|
|
|
* 推送OA供应商
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
public class PushOASupplierOPPlugin extends AbstractOperationServicePlugIn {
|
|
|
|
|
|
|
|
|
|
private static final Log logger = LogFactory.getLog(PushOASupplierOPPlugin.class);
|
|
|
|
|
|
2024-11-13 10:35:26 +00:00
|
|
|
|
public static final String RESM_OFFICIAL_SUPPLIER = "resm_official_supplier";//正式供应商
|
2024-11-04 15:32:41 +00:00
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void afterExecuteOperationTransaction(AfterOperationArgs e){
|
|
|
|
|
|
|
|
|
|
super.afterExecuteOperationTransaction(e);
|
|
|
|
|
//todo:定时任务推送所有供应商 变更审核操作之后推送供应商
|
|
|
|
|
String operationKey = e.getOperationKey();
|
|
|
|
|
if ("audit".equals(operationKey)) {
|
|
|
|
|
|
|
|
|
|
for (DynamicObject dataEntity : e.getDataEntities()) {
|
2024-11-13 10:35:26 +00:00
|
|
|
|
String name = dataEntity.getDynamicObjectType().getName();
|
|
|
|
|
String supplierName = "";
|
|
|
|
|
DynamicObject supplier = null;
|
|
|
|
|
if ("resm_change_supplier".equals(name)) {
|
|
|
|
|
supplierName = dataEntity.getDynamicObject("supplier").getString("name");
|
|
|
|
|
supplier = dataEntity.getDynamicObject("supplier");
|
|
|
|
|
}else {
|
|
|
|
|
supplierName = dataEntity.getString("name");
|
|
|
|
|
supplier = dataEntity;
|
|
|
|
|
}
|
2024-11-04 15:32:41 +00:00
|
|
|
|
//获取token
|
2024-11-13 10:35:26 +00:00
|
|
|
|
String oaToken = OAUtils.getOaToken(supplierName);
|
2024-11-04 15:32:41 +00:00
|
|
|
|
|
2024-11-13 10:35:26 +00:00
|
|
|
|
if (StringUtils.isNotEmpty(oaToken) && null != supplier) {
|
|
|
|
|
pushOASupplier(oaToken,supplier);
|
2024-11-04 15:32:41 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 组装供应商入参
|
|
|
|
|
*/
|
2024-11-12 04:09:33 +00:00
|
|
|
|
public static JSONObject assembleBody(long supplierID){
|
2024-11-04 15:32:41 +00:00
|
|
|
|
JSONObject customerBody = null;
|
|
|
|
|
//获取正式供应商
|
|
|
|
|
QFilter q = new QFilter("id", QCP.equals, supplierID);
|
|
|
|
|
// QFilter q = new QFilter("number", QCP.equals, "111");//成都筑垒建筑工程有限公司
|
|
|
|
|
DynamicObject official_supplier = BusinessDataServiceHelper.loadSingle(RESM_OFFICIAL_SUPPLIER, new QFilter[]{q});
|
|
|
|
|
if (null != official_supplier) {
|
|
|
|
|
|
2024-11-13 10:35:26 +00:00
|
|
|
|
String code = official_supplier.getString("qeug_oacode");
|
2024-11-04 15:32:41 +00:00
|
|
|
|
String name = official_supplier.getString("name");
|
|
|
|
|
String taxpayerid = official_supplier.getString("tx_register_no");
|
|
|
|
|
String shortname = official_supplier.getString("simplename");
|
|
|
|
|
String legalbody = official_supplier.getString("artificialperson");
|
|
|
|
|
Date createTime = official_supplier.getDate("createtime");
|
|
|
|
|
Date updateTime = official_supplier.getDate("modifytime");
|
|
|
|
|
Object createtime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(createTime);
|
|
|
|
|
Object updatetime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(updateTime);
|
|
|
|
|
|
|
|
|
|
//接口请求体
|
|
|
|
|
customerBody = new JSONObject();
|
|
|
|
|
customerBody.put("code", code);//"客户编码:传递OA回执的code,如果没有则为空,OA判断新增后返回code",
|
|
|
|
|
customerBody.put("name", name);//"客户名称",
|
|
|
|
|
customerBody.put("taxpayerid", taxpayerid);//"纳税人登记号/身份证号 唯一值不可变",
|
|
|
|
|
customerBody.put("shortname", shortname);//"客户简称",
|
|
|
|
|
customerBody.put("custprop", "0");//"客户类型:默认0",
|
|
|
|
|
customerBody.put("enablestate", "2");//"客户状态:默认2",
|
|
|
|
|
customerBody.put("pk_custclass", "02");//"客户基本分类:默认02",
|
|
|
|
|
customerBody.put("legalbody", legalbody);// "法人",
|
|
|
|
|
customerBody.put("createTime", createtime);// "创建时间:例如2024-06-02 17:27:10",
|
|
|
|
|
customerBody.put("updateTime", updatetime);//"更新时间:例如2024-06-02 17:27:10",
|
|
|
|
|
customerBody.put("def1", "租赁客户");//"客商类别:默认租赁客户",
|
|
|
|
|
JSONArray custBankaccMapBody = new JSONArray();
|
|
|
|
|
|
|
|
|
|
//银行信息
|
|
|
|
|
DynamicObjectCollection entry_banks = official_supplier.getDynamicObjectCollection("entry_bank");
|
|
|
|
|
for (DynamicObject entry_bank : entry_banks) {
|
|
|
|
|
|
|
|
|
|
JSONObject custBankaccBody = new JSONObject();
|
|
|
|
|
custBankaccBody.put("accnum", entry_bank.getString("bankaccount"));//"银行账号",
|
|
|
|
|
DynamicObject bank = entry_bank.getDynamicObject("bank");
|
|
|
|
|
if (null != bank) {
|
|
|
|
|
// "开户行名称:例如招商银行股份有限公司上海分行外高桥支行龙江支行"
|
|
|
|
|
custBankaccBody.put("pk_bankdoc", bank.getString("name"));
|
|
|
|
|
DynamicObject city = bank.getDynamicObject("city");
|
|
|
|
|
if (null != city) {
|
|
|
|
|
//"城市"
|
|
|
|
|
custBankaccBody.put("city", city.getString("name"));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
custBankaccBody.put("accname", entry_bank.getString("accountname"));//"银行账号名称",
|
|
|
|
|
custBankaccBody.put("pk_banktype", "");//todo:"银行类别:例如招商银行",
|
|
|
|
|
String persontype = entry_bank.getString("persontype");//法人类型
|
|
|
|
|
//法人企业 LEGALENTERPRISE
|
|
|
|
|
//非法人企业 UNINCORPORATED
|
|
|
|
|
//非企业单位 NONENTERPRISE
|
|
|
|
|
//个人 PERSONAL
|
|
|
|
|
if (!"PERSONAL".equals(persontype)) {
|
|
|
|
|
custBankaccBody.put("psnOrCompany", "3397730183813155472");// "个人或公司:公司:3397730183813155472/个人:-7676950454987503991"
|
|
|
|
|
}else {
|
|
|
|
|
custBankaccBody.put("psnOrCompany", "-7676950454987503991");
|
|
|
|
|
}
|
|
|
|
|
custBankaccMapBody.add(custBankaccBody);
|
|
|
|
|
}
|
|
|
|
|
//无银行信息
|
|
|
|
|
if (entry_banks.isEmpty()) {
|
|
|
|
|
JSONObject custBankaccBody = new JSONObject();
|
|
|
|
|
custBankaccBody.put("accnum","");//"银行账号",
|
|
|
|
|
custBankaccBody.put("pk_bankdoc", "");// "开户行名称:例如招商银行股份有限公司上海分行外高桥支行龙江支行"
|
|
|
|
|
custBankaccBody.put("city","");//"城市"
|
|
|
|
|
custBankaccBody.put("accname","");//"银行账号名称",
|
|
|
|
|
custBankaccBody.put("pk_banktype", "");//todo:"银行类别:例如招商银行",
|
|
|
|
|
custBankaccBody.put("psnOrCompany", "3397730183813155472");// "个人或公司:公司:3397730183813155472/个人:-7676950454987503991"
|
|
|
|
|
custBankaccMapBody.add(custBankaccBody);
|
|
|
|
|
}
|
|
|
|
|
customerBody.put("bankacc", custBankaccMapBody);
|
|
|
|
|
}
|
|
|
|
|
return customerBody;
|
|
|
|
|
}
|
|
|
|
|
}
|