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.plugin.AbstractOperationServicePlugIn;
|
|
|
|
|
import kd.bos.entity.plugin.args.AfterOperationArgs;
|
|
|
|
|
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;
|
2024-11-20 07:20:20 +00:00
|
|
|
|
import kd.bos.servicehelper.operation.SaveServiceHelper;
|
2024-11-04 15:32:41 +00:00
|
|
|
|
import kd.bos.util.StringUtils;
|
|
|
|
|
import shkd.utils.OAUtils;
|
|
|
|
|
|
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
|
import java.util.Date;
|
|
|
|
|
|
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-20 07:20:20 +00:00
|
|
|
|
|
|
|
|
|
//处理联系人分录中的开通账号的人员名称更新到主表字段上面 yxl 20241120
|
2024-11-22 10:12:45 +00:00
|
|
|
|
//文本字段的人员工作流中配置人员时选不到,得改成用户字段让经办人自己选择,如下代码注释
|
|
|
|
|
// handleContactPerson(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");
|
2024-11-20 05:43:15 +00:00
|
|
|
|
String taxpayerid = official_supplier.getString("tx_register_no");//纳税人识别号
|
|
|
|
|
String societycreditcode = official_supplier.getString("societycreditcode");//统一社会信用代码
|
|
|
|
|
String artificialpersoncard = official_supplier.getString("artificialpersoncard");//法人代表身份证号码
|
|
|
|
|
String persontype = official_supplier.getString("persontype");//法人类型
|
2024-11-04 15:32:41 +00:00
|
|
|
|
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);//"客户名称",
|
2024-11-20 05:43:15 +00:00
|
|
|
|
//PERSONAL 个人
|
|
|
|
|
if ("PERSONAL".equals(persontype)) {
|
|
|
|
|
customerBody.put("taxpayerid", artificialpersoncard);//"纳税人登记号/身份证号 唯一值不可变",
|
|
|
|
|
}else {
|
|
|
|
|
customerBody.put("taxpayerid", societycreditcode);//"纳税人登记号/身份证号 唯一值不可变",
|
|
|
|
|
|
|
|
|
|
}
|
2024-11-04 15:32:41 +00:00
|
|
|
|
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:"银行类别:例如招商银行",
|
2024-11-20 05:43:15 +00:00
|
|
|
|
// String persontype = entry_bank.getString("persontype");//法人类型
|
2024-11-04 15:32:41 +00:00
|
|
|
|
//法人企业 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;
|
|
|
|
|
}
|
2024-11-20 07:20:20 +00:00
|
|
|
|
|
|
|
|
|
private void handleContactPerson(DynamicObject supplier){
|
|
|
|
|
// 获取正式供应商
|
|
|
|
|
QFilter q = new QFilter("id", QCP.equals, supplier.getPkValue());
|
|
|
|
|
DynamicObject officialSupplier = BusinessDataServiceHelper.loadSingle(RESM_OFFICIAL_SUPPLIER, new QFilter[]{q});
|
|
|
|
|
DynamicObjectCollection lxrcoll = officialSupplier.getDynamicObjectCollection("entry_linkman");
|
|
|
|
|
DynamicObject lxrinfo = null;
|
|
|
|
|
String lxrmc = null;
|
|
|
|
|
for (int i = 0; i < lxrcoll.size(); i++) {
|
|
|
|
|
lxrinfo = lxrcoll.get(i);
|
|
|
|
|
if(lxrinfo.getBoolean("isopenaccount")){
|
|
|
|
|
lxrmc = lxrinfo.getString("contactperson");
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(lxrmc != null){
|
|
|
|
|
officialSupplier.set("qeug_supplierperson", lxrmc);//开通账号人员
|
|
|
|
|
SaveServiceHelper.save(new DynamicObject[]{officialSupplier});
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-11-04 15:32:41 +00:00
|
|
|
|
}
|